On Apr 29, 2013, at 1:10 PM, Adam G <[email protected]> wrote: > Thanks for the feedback. Yea, thats an obvious solution. I'll have to > namespace my examples so they don't conflict with some other similarly named > tests. Will play with it a bit more. Would be neat if there was a context > group what was intelligent enough not to redeclare everything.
Please file a feature request at http://github.com/rspec/rspec-core/issues > > On Monday, April 29, 2013 1:16:38 AM UTC-4, [email protected] wrote: >> >> On Sun, Apr 28, 2013 at 8:33 PM, Adam Gotterer <[email protected]> wrote: >>> 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! >> >> It's very difficult to discuss these ideas without a concrete example, but >> from what you've described, what I would do is: >> >> shared_examples_for 'group_a' do >> ... >> end >> >> shared_examples_for 'group_a' do >> ... >> end >> >> shared_context 'some_context' do >> let(:some_var) { ... } >> matcher :some_matches { ... { >> end >> >> describe "something" do >> include_context "some context" >> >> it_behaves_like "group_a" >> it_behaves_like "group_b" >> end >> >> This gives you the outcome you're looking for (I think) without nesting the >> shared examples within the shared context, but resulting in applying the >> shared context to each of the shared examples. Make sense? >> >> HTH, >> David >> >>> >>> >>> 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]> 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]. >>>>> 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/-/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. > -- > 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/-/gcvEGgFs0_oJ. > 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]. For more options, visit https://groups.google.com/groups/opt_out.
