RSpec shared examples must not be shared RSpec shared examples must not be shared ruby-on-rails ruby-on-rails

RSpec shared examples must not be shared


As of rspec 2.6, shared examples are global. You can declare them in an example group, but they are not scoped to that group.


There are some tips in the official documentation on how best to handle this:

https://www.relishapp.com/rspec/rspec-core/docs/example-groups/shared-examples

TL;DR

Yes, shared examples are global. Best practice for Ruby On Rails: Place shared examples in spec/support/foo_bar_shared_examples.rb and just start writing shared_example straight, without wrapping in any describe block or otherwise.