Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

Issue with stubs and never

#38

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

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

State: new
Milestone: none
Assigned to: nobody

Activity

  1. Dinesh Majrekar
    Dinesh Majrekar

    I have a solution to this, see:

    http://github.com/DMajrekar/moch...

    for details. It may not be the best solution, but it works at least.

    February 11th, 2009 @ 08:34 PM

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.