Problem as described in pastie:
http://pastie.org/385069
I have made a unit test that describes this problem which can be
found below.
I have played around with the code but been unable to get this
passing. Will continue working on it but it may be quicker if
anyone here knows a solution.
From what I have gathered, two expectations with the same method
name are added to the mock. This seems to lead to an error not
being raised or something like that.
def test_should_fail_fast_if_method_is_never_expected_but_is_called_once_even_after_it_has_been_stubbed
test_result = run_as_test do
o = Object.new
o.stubs(:method)
o.expects(:method).never
1.times { o.method }
end
assert_failed(test_result)
assert_equal ["unexpected invocation: #<Mock:stub>.method()\nsatisfied expectations:\n- expected never, not yet invoked: #<Mock:stub>.method(any_parameters)\n"], test_result.failure_messages
end
Will update this ticket if I mange to fix it