[rspec-users] Evaluating shared example customisation block before shared block
dchelimsky at gmail.com
Sun Aug 1 19:00:27 EDT 2010
On Aug 1, 2010, at 5:39 PM, Myron Marston wrote:
>> 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:
If we do this, we should use module_exec for both blocks so they both get the same arguments.
> 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
RSpec does that too :). Pretty sure it was Aslak that added that some years back.
Yeah - I'm playing around with an implementation of module_exec, but it doesn't seem to work quite the same way as instance exec does. Not yet, anyhow.
> rspec-users mailing list
> rspec-users at rubyforge.org
More information about the rspec-users