[mocha-developer] Scoping expectations and more ...
gabriel.birke at gmail.com
Sat Dec 2 12:49:57 EST 2006
I didn't know you can "stack" expectations this easily - it makes may
example somewhat moot.
I assumed that each "expect" would override the previous one. Btw,
does that mean that each "expect" call adds 1 to the expected number
of times the mocked method is called?
2006/12/2, James Mead <jamesmead44 at gmail.com>:
> Thanks for your interest in Mocha. It's quite likely that some
> behaviour is not properly documented. I might be missing something,
> but I don't see why you wouldn't write the two tests like this...
> def test_m_call
> b = B.new
> assert_equal 10, b.m(9)
> assert_equal 6, b.m(5)
> def test_twocall
> b = B.new
> assert_equal 15, b.calltwice(5)
> I don't think the begin...end combinations in your first test buy you
> anything, does it?
> While your second test is an example of how to use a block with the
> with() method and a Proc with the returns() method, I don't see why
> you wouldn't just use two expectations as shown above.
> mocha-developer mailing list
> mocha-developer at rubyforge.org
CEO describe europe Ltd.
More information about the mocha-developer