[rspec-users] Evaluating shared example customisation block before shared block
Myron Marston
myron.marston at gmail.com
Sun Aug 1 18:39:02 EDT 2010
> Seems like your mental model is that of a customization block being a subclass or re-opening of the shared block. What you say makes sense in that model, but that's not the same model I have.
My mental model is indeed that the customization block is like a
subclass. I'm not sure where I got it--it's just the intuitive way I
understood shared_examples_for and it_should_behave_like. But if no
one else shares this mental model, then there's not much point in
making rspec work this way. I'm happy going with whatever the general
consensus is. Although, I do think that my mental model makes for
some interesting possibilities :).
> Assuming that can work. I've taken a closer look and getting that to work would take some serious re-architecting that I'm not sure is a good idea.
Maybe I misunderstood you here, but I took this to refer to the
passing of parameters to the shared example group, as you
suggested...and it turns out this isn't very hard at all:
http://github.com/myronmarston/rspec-core/commit/c353badcb8154ab98a7dc46eb19c8a9fc702ec73
The one issue with this is that it uses #module_exec, which is not
available in ruby 1.8.6--so we'd have to find a way to implement it,
similar to how cucumber implements #instance_exec when it's not
available:
http://github.com/aslakhellesoy/cucumber/blob/30d43767a7cffd1675e990115ac86c139e4ea3e0/lib/cucumber/core_ext/instance_exec.rb#L16-31
Myron
More information about the rspec-users
mailing list