On Aug 10, 2007, at 3:43 PM, David Chelimsky wrote:
> On 8/7/07, Scott Taylor <[EMAIL PROTECTED]> wrote:
>>
>> I have the following code, which yields instance eval's the block
>> given:
>>
>> class Foo
>>
>> def bar(&blk)
>> instance_eval &blk
>> end
>>
>> def baz
>> yield
>> end
>>
>> end
>>
>> The effect of this is that self is reassigned:
>>
>> Foo.new.bar do
>> # here, self is the instance of Foo
>> # created by new
>> end
>
> Why not just do this, which is already a language construct?
>
> Foo.new.instance_eval { ... }
Maybe a better example would be in place. Consider the following
from the Autotest plugin:
Autotest.add_discovery do
"rspec" if File.exist?('spec')
end
How would you go about testing this?
It's easy enough to test that Autotest receives the method
add_discovery. But how would you deal with the block?
Scott
_______________________________________________
rspec-users mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/rspec-users