Skip to content

Commit

Permalink
make test more robust
Browse files Browse the repository at this point in the history
test_should_keep_finding_later_stub_and_so_never_satisfy_earlier_expectation
would pass even if the earlier expectation was found first, as assert_failed
would succeed for the wrong reason, i.e. due to failure of assert_equal rather
than an unsatisfied expectation
  • Loading branch information
nitishr committed Dec 24, 2019
1 parent d8019ee commit 63a7003
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions test/acceptance/mocked_methods_dispatch_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@ def test_should_find_latest_expectation_which_has_not_stopped_matching
end

def test_should_keep_finding_later_stub_and_so_never_satisfy_earlier_expectation
responses = []
test_result = run_as_test do
mock = mock()
mock.expects(:method).returns(1)
mock.stubs(:method).returns(2)
assert_equal 2, mock.method
assert_equal 2, mock.method
assert_equal 2, mock.method
3.times { responses << mock.method }
end
assert_equal [2, 2, 2], responses
assert_failed(test_result)
end

Expand Down

0 comments on commit 63a7003

Please sign in to comment.