#38 new
Dinesh Majrekar

Issue with stubs and never

Reported by Dinesh Majrekar | February 11th, 2009 @ 05:13 PM

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

Comments and changes to this ticket

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

A mocking & stubbing library for Ruby.

* <a href="http://github.com/floehopper/mocha">GitHub repository</a>
* <a href="http://mocha.rubyforge.org">Documentation</a>
* <a href="http://groups.google.com/group/mocha-developer">Mailing List</a>

People watching this ticket

Tags

Pages