a common practice is to define the code for your shared examples in a module and include it via the configuration. that way, you have a clear code separation and reuse.
in spec/support/xyz.rb
module SomeSharedExamples
[...]
end
in your spec_helper.rb
config.include SomeSharedExamples