[rspec-users] Evaluating shared example customisation block before shared block
myron.marston at gmail.com
Wed Aug 4 14:35:43 EDT 2010
> I wouldn't even bother to undef those methods.
If we don't undef the methods, then the semantics of the
#module_eval_with_args (or whatever we call it) will be different on
1.8.6 and other versions. On 1.8.6, a method definition in the block
would define both an instance method _and_ a class method. Someone
could write a spec against 1.8.6, and accidentally call the class
method, not realizing they've done this, and the spec wouldn't work on
1.8.7 and above since the class method won't be there. So I think the
undefs are important, and I don't think it adds too much complexity.
> Something like:
> def module_eval_with_args(*args, &block)
> if respond_to?(:module_exec)
> module_exec(*args, &block)
> # custom solution
> At that point, as long as all the shared group specs are passing, we're good. Make sense?
Makes total sense. I'll work on porting this to RSpec, and open an
github issue with a link to the commits when I'm done.
More information about the rspec-users