This took me by surprise…
Seems that you can’t use the same name for 2 rspec shared example groups anywhere within your project. If you do, then when you run rake spec
(to run all the specs), then rspec complains that a shared example group was declared with a non-unique name.
This happens even when the calls to shared_examples_for
are contained within a describe block (one would presume that should scope the examples).
At first I tried to work around this by changing the names of the example groups (not ideal, but I can live with it).
But this became more of a problem when I wanted to factor out the example group to a separate file so I could share it between multiple spec files.
The specs work okay when run in isolation, but when I run the suite, rspec complains.
`ensure_shared_example_group_name_not_taken': \
Shared example group 'a person' already exists (ArgumentError)
Surely this is a common problem.
Is there something I’m missing here?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With