The example would be pretty specific to my app. But here's a shot at a simplification... I have an app with multiple modules. This particular module is responsible for parsing different types of input data. Each parser has it own data types, but there are some that are common. There's a separate spec for each parser. The goal was to essentially namespace a group of shared examples that I could then be referenced with a behaves like.
It seems like the "proper" way would be to put all the shared examples, customer matchers, shared methods and variables on the global level. The downside is that I'll have to namespace all the examples, method and variable names (other modules make references to similar names). Including them in tests will be cumbersome since you will need to explicitly include each example individually instead of including the whole group (shared context). While what I came up with may not be perfect. It actually works well minus the annoying warnings. Do you think theres a better approach? Thanks! On Saturday, April 27, 2013 11:57:38 PM UTC-4, [email protected] wrote: > > shared_examples are definitely not intended to be used that way. > > Can you give a more concrete example of what you're trying to accomplish? > > > On Sat, Apr 27, 2013 at 5:59 PM, Adam Gotterer <[email protected]<javascript:> > > wrote: > >> I have a bunch of shared_examples that I've put in a shared context. The >> setup works but running them causes an rspec WARNING: Shared example group >> '...' has been previously defined at:... Which makes me assume there might >> be a better way. Was curious if there is? >> >> Simple example: >> >> shared_context 'some_context' do >> let(:some_var) { ... } >> matcher :some_matches { ... { >> >> shared_examples_for 'group_a' do >> ... >> end >> >> shared_examples_for 'group_b' do >> ... >> end >> end >> >> >> -- >> You received this message because you are subscribed to the Google Groups >> "rspec" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected] <javascript:>. >> To post to this group, send email to [email protected] <javascript:> >> . >> To view this discussion on the web visit >> https://groups.google.com/d/msg/rspec/-/RSW0nfr1apwJ. >> For more options, visit https://groups.google.com/groups/opt_out. >> >> >> > > -- You received this message because you are subscribed to the Google Groups "rspec" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msg/rspec/-/w72JsYQdWSYJ. For more options, visit https://groups.google.com/groups/opt_out.
