[mocha-developer] Expecting calls with two different parameters

James Mead jamesmead44 at gmail.com
Sat Oct 7 05:35:01 EDT 2006


On 10/6/06, Bryan Helmkamp <bhelmkamp at gmail.com> wrote:
> How would I setup a mock that expects that a method will be called
> once with no paramaters, and a second time with a parameter?  I'd be
> tempted to shortcut and just do something like
> foo.expects(:bar).times(2), but the value used as the parameter when
> calling it the second time is very important.

You shoud be able to do the following...

  def test_me
    object = mock()
    object.expects(:expected_method).with(:important_value)
    object.expects(:expected_method)

    object.expected_method(:important_value)
    object.expected_method(:another_value)
  end

Is that what you mean? Calling expects() without a call to with() matches a
call to the method with any parameters.
-- 
James.
http://blog.floehopper.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rubyforge.org/pipermail/mocha-developer/attachments/20061007/175f1f8b/attachment.html 


More information about the mocha-developer mailing list