On Sun, Dec 26, 2010 at 12:05 AM, Zhi-Qiang Lei <[email protected]> wrote:
> Hi,
>
> I have a lambda.
>
> Test = lambda { kill(333) }
>
> How should I spec if I want to make sure this Test will send kill message
> with 333? Thanks.
Depends on the scope in which the block will be evaluated. Since kill
is being called with no receiver, its implicit receiver will be the
object in which it is evaluated, so you can mock it on that object,
e.g:
class Foo
def bar
yield
end
end
foo = Foo.new
foo.should_receive(:kill)
foo.bar { kill(333) }
Not sure if that aligns with your situation, but that should give you an idea.
HTH,
David
> Best regards,
> Zhi-Qiang Lei
> [email protected]
>
> _______________________________________________
> rspec-users mailing list
> [email protected]
> http://rubyforge.org/mailman/listinfo/rspec-users
>
_______________________________________________
rspec-users mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/rspec-users