On 10/6/06, Bryan Helmkamp &lt;<a href="mailto:bhelmkamp@gmail.com">bhelmkamp@gmail.com</a>&gt; wrote:<br><div>&gt; How would I setup a mock that expects that a method will be called<br>&gt; once with no paramaters, and a second time with a parameter?&nbsp;&nbsp;I'd be
<br>&gt; tempted to shortcut and just do something like<br>&gt; foo.expects(:bar).times(2), but the value used as the parameter when<br>&gt; 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;">&nbsp; def test_me</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp; object = mock()
</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp; object.expects(:expected_method).with(:important_value)</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
&nbsp;&nbsp;&nbsp; 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;">&nbsp;&nbsp;&nbsp; object.expected_method(:important_value)
</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp; object.expected_method(:another_value)</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
&nbsp; 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>