[rspec-users] Evaluating shared example customisation block before shared block
dchelimsky at gmail.com
Mon Aug 2 08:52:54 EDT 2010
On Aug 1, 2010, at 10:08 PM, Myron Marston wrote:
> OK, I tried to implement #module_exec on ruby 1.8.6, and here's what I
> came up with:
> It works (at least in the sense that it allows the specs and features
> I added in the previous commits in that branch to pass on ruby 1.8.6),
> but I don't think it's correct.
If we're not exposing this as an API, and we're only using it in order to support this feature in RSpec when running Ruby 1.8.6, and it solves our problem, then I think it's correct as it needs to be.
> It just calls #instance_exec, but
> instance_exec and module_exec are not the same (at least as I
> understand them...). However, I based that implementation on rubinius
> Backports (a library that implements features of later versions of
> ruby in 1.8.6) implements it in a similar fashion:
> Unfortunately, rubyspec doesn't provide much help in defining how
> module_exec should work:
> I'd need some concrete examples demonstrating how module_exec should
> work (as compared to instance_exec) to implement it correctly. My
> understanding is that they are identical except in regards to method
> definitions--def's within an instance_exec define methods directly on
> the Module object instance, whereas def's within a module_exec define
> instance methods in the module (i.e. methods that will be added to any
> class that includes the module).
> One side issue I discovered is that instance_exec is implemented in
> rspec-expectations, but not rspec-core (which, incidentally, is why I
> linked to the cucumber implementation; I grepped in rspec-core and
> couldn't find it). instance_exec is already used in rspec-core:
> It needs to be implemented in rspec-core if you want rspec-core to be
> able to be used on 1.8.6 without rspec-expectations.
More information about the rspec-users