1
require File.join(File.dirname(__FILE__), "..", "test_helper")
5
class MockedMethodDispatchAcceptanceTest < Test::Unit::TestCase
9
def test_should_find_latest_matching_expectation
10
test_result = run_test do
12
mock.stubs(:method).returns(1)
13
mock.stubs(:method).returns(2)
14
assert_equal 2, mock.method
15
assert_equal 2, mock.method
16
assert_equal 2, mock.method
18
assert_passed(test_result)
21
def test_should_find_latest_expectation_which_has_not_stopped_matching
22
test_result = run_test do
24
mock.stubs(:method).returns(1)
25
mock.stubs(:method).once.returns(2)
26
assert_equal 2, mock.method
27
assert_equal 1, mock.method
28
assert_equal 1, mock.method
30
assert_passed(test_result)
33
def test_should_keep_finding_later_stub_and_so_never_satisfy_earlier_expectation
34
test_result = run_test do
36
mock.expects(:method).returns(1)
37
mock.stubs(:method).returns(2)
38
assert_equal 2, mock.method
39
assert_equal 2, mock.method
40
assert_equal 2, mock.method
42
assert_failed(test_result)
45
def test_should_find_later_expectation_until_it_stops_matching_then_find_earlier_stub
46
test_result = run_test do
48
mock.stubs(:method).returns(1)
49
mock.expects(:method).returns(2)
50
assert_equal 2, mock.method
51
assert_equal 1, mock.method
52
assert_equal 1, mock.method
54
assert_passed(test_result)
57
def test_should_find_latest_expectation_with_range_of_expected_invocation_count_which_has_not_stopped_matching
58
test_result = run_test do
60
mock.stubs(:method).returns(1)
61
mock.stubs(:method).times(2..3).returns(2)
62
assert_equal 2, mock.method
63
assert_equal 2, mock.method
64
assert_equal 2, mock.method
65
assert_equal 1, mock.method
66
assert_equal 1, mock.method
68
assert_passed(test_result)
b'\\ No newline at end of file'