On 10/6/06, Bryan Helmkamp <<a href="mailto:bhelmkamp@gmail.com">bhelmkamp@gmail.com</a>> wrote:<br><div>> How would I setup a mock that expects that a method will be called<br>> once with no paramaters, and a second time with a parameter? I'd be
<br>> tempted to shortcut and just do something like<br>> foo.expects(:bar).times(2), but the value used as the parameter when<br>> calling it the second time is very important.<br><br></div>You shoud be able to do the following...
<br><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> def test_me</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> object = mock()
</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> object.expects(:expected_method).with(:important_value)</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
object.expects(:expected_method)</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> object.expected_method(:important_value)
</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> object.expected_method(:another_value)</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
end</span><br style="font-family: courier new,monospace;"><br>Is that what you mean? Calling expects() without a call to with() matches a call to the method with any parameters.<br>-- <br>James.<br><a href="http://blog.floehopper.org">
http://blog.floehopper.org</a>