mocha 0.9.5 → 0.9.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/RELEASE +17 -2
- data/Rakefile +10 -7
- data/examples/misc.rb +0 -1
- data/examples/mocha.rb +0 -1
- data/examples/stubba.rb +0 -1
- data/lib/mocha.rb +1 -47
- data/lib/mocha/any_instance_method.rb +5 -1
- data/lib/mocha/{standalone.rb → api.rb} +8 -1
- data/lib/mocha/class_method.rb +5 -1
- data/lib/mocha/expectation.rb +3 -3
- data/lib/mocha/integration.rb +38 -0
- data/lib/mocha/integration/mini_test.rb +21 -0
- data/lib/mocha/integration/mini_test/assertion_counter.rb +23 -0
- data/lib/mocha/integration/mini_test/version_131_and_above.rb +50 -0
- data/lib/mocha/integration/test_unit.rb +40 -0
- data/lib/mocha/integration/test_unit/assertion_counter.rb +23 -0
- data/lib/mocha/integration/test_unit/gem_version_200.rb +49 -0
- data/lib/mocha/integration/test_unit/gem_version_201_and_above.rb +49 -0
- data/lib/mocha/integration/test_unit/ruby_version_185_and_below.rb +48 -0
- data/lib/mocha/integration/test_unit/ruby_version_186_and_above.rb +50 -0
- data/lib/mocha/parameter_matchers/has_entry.rb +1 -0
- data/lib/mocha_standalone.rb +2 -2
- data/test/acceptance/{standalone_test.rb → api_test.rb} +2 -2
- data/test/acceptance/bug_21465_test.rb +2 -2
- data/test/acceptance/bug_21563_test.rb +1 -1
- data/test/acceptance/expected_invocation_count_test.rb +19 -19
- data/test/acceptance/failure_messages_test.rb +6 -6
- data/test/acceptance/minitest_test.rb +32 -9
- data/test/acceptance/mocha_test_result_test.rb +8 -8
- data/test/acceptance/mock_test.rb +10 -10
- data/test/acceptance/mock_with_initializer_block_test.rb +3 -3
- data/test/acceptance/mocked_methods_dispatch_test.rb +5 -5
- data/test/acceptance/optional_parameters_test.rb +6 -6
- data/test/acceptance/parameter_matcher_test.rb +20 -20
- data/test/acceptance/partial_mocks_test.rb +2 -2
- data/test/acceptance/return_value_test.rb +4 -4
- data/test/acceptance/sequence_test.rb +11 -11
- data/test/acceptance/states_test.rb +4 -4
- data/test/acceptance/stub_any_instance_method_test.rb +12 -12
- data/test/acceptance/stub_class_method_test.rb +12 -12
- data/test/acceptance/stub_everything_test.rb +4 -4
- data/test/acceptance/stub_instance_method_test.rb +13 -13
- data/test/acceptance/stub_module_method_test.rb +12 -12
- data/test/acceptance/stub_test.rb +4 -4
- data/test/acceptance/stubba_test.rb +1 -1
- data/test/acceptance/stubba_test_result_test.rb +6 -6
- data/test/acceptance/stubbing_error_backtrace_test.rb +4 -4
- data/test/acceptance/stubbing_method_unnecessarily_test.rb +5 -5
- data/test/acceptance/stubbing_non_existent_any_instance_method_test.rb +10 -10
- data/test/acceptance/stubbing_non_existent_class_method_test.rb +11 -11
- data/test/acceptance/stubbing_non_existent_instance_method_test.rb +11 -11
- data/test/acceptance/stubbing_non_public_any_instance_method_test.rb +9 -9
- data/test/acceptance/stubbing_non_public_class_method_test.rb +10 -10
- data/test/acceptance/stubbing_non_public_instance_method_test.rb +10 -10
- data/test/acceptance/stubbing_on_non_mock_object_test.rb +5 -5
- data/test/test_helper.rb +4 -0
- data/test/test_runner.rb +1 -1
- data/test/unit/parameter_matchers/has_entry_test.rb +20 -0
- metadata +14 -6
- data/lib/mocha/mini_test_adapter.rb +0 -50
- data/lib/mocha/test_case_adapter.rb +0 -103
@@ -15,7 +15,7 @@ class MochaTestResultTest < Test::Unit::TestCase
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def test_should_include_expectation_verification_in_assertion_count
|
18
|
-
test_result =
|
18
|
+
test_result = run_as_test do
|
19
19
|
object = mock()
|
20
20
|
object.expects(:message)
|
21
21
|
object.message
|
@@ -24,14 +24,14 @@ class MochaTestResultTest < Test::Unit::TestCase
|
|
24
24
|
end
|
25
25
|
|
26
26
|
def test_should_include_assertions_in_assertion_count
|
27
|
-
test_result =
|
27
|
+
test_result = run_as_test do
|
28
28
|
assert true
|
29
29
|
end
|
30
30
|
assert_equal 1, test_result.assertion_count
|
31
31
|
end
|
32
32
|
|
33
33
|
def test_should_not_include_stubbing_expectation_verification_in_assertion_count
|
34
|
-
test_result =
|
34
|
+
test_result = run_as_test do
|
35
35
|
object = mock()
|
36
36
|
object.stubs(:message)
|
37
37
|
object.message
|
@@ -40,7 +40,7 @@ class MochaTestResultTest < Test::Unit::TestCase
|
|
40
40
|
end
|
41
41
|
|
42
42
|
def test_should_include_expectation_verification_failure_in_failure_count
|
43
|
-
test_result =
|
43
|
+
test_result = run_as_test do
|
44
44
|
object = mock()
|
45
45
|
object.expects(:message)
|
46
46
|
end
|
@@ -48,7 +48,7 @@ class MochaTestResultTest < Test::Unit::TestCase
|
|
48
48
|
end
|
49
49
|
|
50
50
|
def test_should_include_unexpected_verification_failure_in_failure_count
|
51
|
-
test_result =
|
51
|
+
test_result = run_as_test do
|
52
52
|
object = mock()
|
53
53
|
object.message
|
54
54
|
end
|
@@ -56,7 +56,7 @@ class MochaTestResultTest < Test::Unit::TestCase
|
|
56
56
|
end
|
57
57
|
|
58
58
|
def test_should_include_assertion_failure_in_failure_count
|
59
|
-
test_result =
|
59
|
+
test_result = run_as_test do
|
60
60
|
flunk
|
61
61
|
end
|
62
62
|
assert_equal 1, test_result.failure_count
|
@@ -64,7 +64,7 @@ class MochaTestResultTest < Test::Unit::TestCase
|
|
64
64
|
|
65
65
|
def test_should_display_backtrace_indicating_line_number_where_unexpected_method_was_called
|
66
66
|
execution_point = nil
|
67
|
-
test_result =
|
67
|
+
test_result = run_as_test do
|
68
68
|
object = mock()
|
69
69
|
execution_point = ExecutionPoint.current; object.message
|
70
70
|
end
|
@@ -74,7 +74,7 @@ class MochaTestResultTest < Test::Unit::TestCase
|
|
74
74
|
|
75
75
|
def test_should_display_backtrace_indicating_line_number_where_failing_assertion_was_called
|
76
76
|
execution_point = nil
|
77
|
-
test_result =
|
77
|
+
test_result = run_as_test do
|
78
78
|
execution_point = ExecutionPoint.current; flunk
|
79
79
|
end
|
80
80
|
assert_equal 1, test_result.failure_count
|
@@ -14,7 +14,7 @@ class MockTest < Test::Unit::TestCase
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def test_should_build_mock_and_explicitly_add_an_expectation_which_is_satisfied
|
17
|
-
test_result =
|
17
|
+
test_result = run_as_test do
|
18
18
|
foo = mock()
|
19
19
|
foo.expects(:bar)
|
20
20
|
foo.bar
|
@@ -23,7 +23,7 @@ class MockTest < Test::Unit::TestCase
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def test_should_build_mock_and_explicitly_add_an_expectation_which_is_not_satisfied
|
26
|
-
test_result =
|
26
|
+
test_result = run_as_test do
|
27
27
|
foo = mock()
|
28
28
|
foo.expects(:bar)
|
29
29
|
end
|
@@ -31,7 +31,7 @@ class MockTest < Test::Unit::TestCase
|
|
31
31
|
end
|
32
32
|
|
33
33
|
def test_should_build_named_mock_and_explicitly_add_an_expectation_which_is_satisfied
|
34
|
-
test_result =
|
34
|
+
test_result = run_as_test do
|
35
35
|
foo = mock('foo')
|
36
36
|
foo.expects(:bar)
|
37
37
|
foo.bar
|
@@ -40,7 +40,7 @@ class MockTest < Test::Unit::TestCase
|
|
40
40
|
end
|
41
41
|
|
42
42
|
def test_should_build_named_mock_and_explicitly_add_an_expectation_which_is_not_satisfied
|
43
|
-
test_result =
|
43
|
+
test_result = run_as_test do
|
44
44
|
foo = mock('foo')
|
45
45
|
foo.expects(:bar)
|
46
46
|
end
|
@@ -48,7 +48,7 @@ class MockTest < Test::Unit::TestCase
|
|
48
48
|
end
|
49
49
|
|
50
50
|
def test_should_build_mock_incorporating_two_expectations_which_are_satisifed
|
51
|
-
test_result =
|
51
|
+
test_result = run_as_test do
|
52
52
|
foo = mock(:bar => 'bar', :baz => 'baz')
|
53
53
|
foo.bar
|
54
54
|
foo.baz
|
@@ -57,7 +57,7 @@ class MockTest < Test::Unit::TestCase
|
|
57
57
|
end
|
58
58
|
|
59
59
|
def test_should_build_mock_incorporating_two_expectations_the_first_of_which_is_not_satisifed
|
60
|
-
test_result =
|
60
|
+
test_result = run_as_test do
|
61
61
|
foo = mock(:bar => 'bar', :baz => 'baz')
|
62
62
|
foo.baz
|
63
63
|
end
|
@@ -65,7 +65,7 @@ class MockTest < Test::Unit::TestCase
|
|
65
65
|
end
|
66
66
|
|
67
67
|
def test_should_build_mock_incorporating_two_expectations_the_second_of_which_is_not_satisifed
|
68
|
-
test_result =
|
68
|
+
test_result = run_as_test do
|
69
69
|
foo = mock(:bar => 'bar', :baz => 'baz')
|
70
70
|
foo.bar
|
71
71
|
end
|
@@ -73,7 +73,7 @@ class MockTest < Test::Unit::TestCase
|
|
73
73
|
end
|
74
74
|
|
75
75
|
def test_should_build_named_mock_incorporating_two_expectations_which_are_satisifed
|
76
|
-
test_result =
|
76
|
+
test_result = run_as_test do
|
77
77
|
foo = mock('foo', :bar => 'bar', :baz => 'baz')
|
78
78
|
foo.bar
|
79
79
|
foo.baz
|
@@ -82,7 +82,7 @@ class MockTest < Test::Unit::TestCase
|
|
82
82
|
end
|
83
83
|
|
84
84
|
def test_should_build_named_mock_incorporating_two_expectations_the_first_of_which_is_not_satisifed
|
85
|
-
test_result =
|
85
|
+
test_result = run_as_test do
|
86
86
|
foo = mock('foo', :bar => 'bar', :baz => 'baz')
|
87
87
|
foo.baz
|
88
88
|
end
|
@@ -90,7 +90,7 @@ class MockTest < Test::Unit::TestCase
|
|
90
90
|
end
|
91
91
|
|
92
92
|
def test_should_build_named_mock_incorporating_two_expectations_the_second_of_which_is_not_satisifed
|
93
|
-
test_result =
|
93
|
+
test_result = run_as_test do
|
94
94
|
foo = mock('foo', :bar => 'bar', :baz => 'baz')
|
95
95
|
foo.bar
|
96
96
|
end
|
@@ -14,7 +14,7 @@ class MockWithInitializerBlockTest < Test::Unit::TestCase
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def test_should_expect_two_method_invocations_and_receive_both_of_them
|
17
|
-
test_result =
|
17
|
+
test_result = run_as_test do
|
18
18
|
mock = mock() do
|
19
19
|
expects(:method_1)
|
20
20
|
expects(:method_2)
|
@@ -26,7 +26,7 @@ class MockWithInitializerBlockTest < Test::Unit::TestCase
|
|
26
26
|
end
|
27
27
|
|
28
28
|
def test_should_expect_two_method_invocations_but_receive_only_one_of_them
|
29
|
-
test_result =
|
29
|
+
test_result = run_as_test do
|
30
30
|
mock = mock() do
|
31
31
|
expects(:method_1)
|
32
32
|
expects(:method_2)
|
@@ -37,7 +37,7 @@ class MockWithInitializerBlockTest < Test::Unit::TestCase
|
|
37
37
|
end
|
38
38
|
|
39
39
|
def test_should_stub_methods
|
40
|
-
test_result =
|
40
|
+
test_result = run_as_test do
|
41
41
|
mock = mock() do
|
42
42
|
stubs(:method_1).returns(1)
|
43
43
|
stubs(:method_2).returns(2)
|
@@ -14,7 +14,7 @@ class MockedMethodDispatchTest < Test::Unit::TestCase
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def test_should_find_latest_matching_expectation
|
17
|
-
test_result =
|
17
|
+
test_result = run_as_test do
|
18
18
|
mock = mock()
|
19
19
|
mock.stubs(:method).returns(1)
|
20
20
|
mock.stubs(:method).returns(2)
|
@@ -26,7 +26,7 @@ class MockedMethodDispatchTest < Test::Unit::TestCase
|
|
26
26
|
end
|
27
27
|
|
28
28
|
def test_should_find_latest_expectation_which_has_not_stopped_matching
|
29
|
-
test_result =
|
29
|
+
test_result = run_as_test do
|
30
30
|
mock = mock()
|
31
31
|
mock.stubs(:method).returns(1)
|
32
32
|
mock.stubs(:method).once.returns(2)
|
@@ -38,7 +38,7 @@ class MockedMethodDispatchTest < Test::Unit::TestCase
|
|
38
38
|
end
|
39
39
|
|
40
40
|
def test_should_keep_finding_later_stub_and_so_never_satisfy_earlier_expectation
|
41
|
-
test_result =
|
41
|
+
test_result = run_as_test do
|
42
42
|
mock = mock()
|
43
43
|
mock.expects(:method).returns(1)
|
44
44
|
mock.stubs(:method).returns(2)
|
@@ -50,7 +50,7 @@ class MockedMethodDispatchTest < Test::Unit::TestCase
|
|
50
50
|
end
|
51
51
|
|
52
52
|
def test_should_find_later_expectation_until_it_stops_matching_then_find_earlier_stub
|
53
|
-
test_result =
|
53
|
+
test_result = run_as_test do
|
54
54
|
mock = mock()
|
55
55
|
mock.stubs(:method).returns(1)
|
56
56
|
mock.expects(:method).returns(2)
|
@@ -62,7 +62,7 @@ class MockedMethodDispatchTest < Test::Unit::TestCase
|
|
62
62
|
end
|
63
63
|
|
64
64
|
def test_should_find_latest_expectation_with_range_of_expected_invocation_count_which_has_not_stopped_matching
|
65
|
-
test_result =
|
65
|
+
test_result = run_as_test do
|
66
66
|
mock = mock()
|
67
67
|
mock.stubs(:method).returns(1)
|
68
68
|
mock.stubs(:method).times(2..3).returns(2)
|
@@ -14,7 +14,7 @@ class OptionalParameterMatcherTest < Test::Unit::TestCase
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def test_should_pass_if_all_required_parameters_match_and_no_optional_parameters_are_supplied
|
17
|
-
test_result =
|
17
|
+
test_result = run_as_test do
|
18
18
|
mock = mock()
|
19
19
|
mock.expects(:method).with(1, 2, optionally(3, 4))
|
20
20
|
mock.method(1, 2)
|
@@ -23,7 +23,7 @@ class OptionalParameterMatcherTest < Test::Unit::TestCase
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def test_should_pass_if_all_required_and_optional_parameters_match_and_some_optional_parameters_are_supplied
|
26
|
-
test_result =
|
26
|
+
test_result = run_as_test do
|
27
27
|
mock = mock()
|
28
28
|
mock.expects(:method).with(1, 2, optionally(3, 4))
|
29
29
|
mock.method(1, 2, 3)
|
@@ -32,7 +32,7 @@ class OptionalParameterMatcherTest < Test::Unit::TestCase
|
|
32
32
|
end
|
33
33
|
|
34
34
|
def test_should_pass_if_all_required_and_optional_parameters_match_and_all_optional_parameters_are_supplied
|
35
|
-
test_result =
|
35
|
+
test_result = run_as_test do
|
36
36
|
mock = mock()
|
37
37
|
mock.expects(:method).with(1, 2, optionally(3, 4))
|
38
38
|
mock.method(1, 2, 3, 4)
|
@@ -41,7 +41,7 @@ class OptionalParameterMatcherTest < Test::Unit::TestCase
|
|
41
41
|
end
|
42
42
|
|
43
43
|
def test_should_fail_if_all_required_and_optional_parameters_match_but_too_many_optional_parameters_are_supplied
|
44
|
-
test_result =
|
44
|
+
test_result = run_as_test do
|
45
45
|
mock = mock()
|
46
46
|
mock.expects(:method).with(1, 2, optionally(3, 4))
|
47
47
|
mock.method(1, 2, 3, 4, 5)
|
@@ -50,7 +50,7 @@ class OptionalParameterMatcherTest < Test::Unit::TestCase
|
|
50
50
|
end
|
51
51
|
|
52
52
|
def test_should_fail_if_all_required_parameters_match_but_some_optional_parameters_do_not_match
|
53
|
-
test_result =
|
53
|
+
test_result = run_as_test do
|
54
54
|
mock = mock()
|
55
55
|
mock.expects(:method).with(1, 2, optionally(3, 4))
|
56
56
|
mock.method(1, 2, 4)
|
@@ -59,7 +59,7 @@ class OptionalParameterMatcherTest < Test::Unit::TestCase
|
|
59
59
|
end
|
60
60
|
|
61
61
|
def test_should_fail_if_all_required_parameters_match_but_no_optional_parameters_match
|
62
|
-
test_result =
|
62
|
+
test_result = run_as_test do
|
63
63
|
mock = mock()
|
64
64
|
mock.expects(:method).with(1, 2, optionally(3, 4))
|
65
65
|
mock.method(1, 2, 4, 5)
|
@@ -14,7 +14,7 @@ class ParameterMatcherTest < Test::Unit::TestCase
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def test_should_match_hash_parameter_with_specified_key
|
17
|
-
test_result =
|
17
|
+
test_result = run_as_test do
|
18
18
|
mock = mock()
|
19
19
|
mock.expects(:method).with(has_key(:key_1))
|
20
20
|
mock.method(:key_1 => 'value_1', :key_2 => 'value_2')
|
@@ -23,7 +23,7 @@ class ParameterMatcherTest < Test::Unit::TestCase
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def test_should_not_match_hash_parameter_with_specified_key
|
26
|
-
test_result =
|
26
|
+
test_result = run_as_test do
|
27
27
|
mock = mock()
|
28
28
|
mock.expects(:method).with(has_key(:key_1))
|
29
29
|
mock.method(:key_2 => 'value_2')
|
@@ -32,7 +32,7 @@ class ParameterMatcherTest < Test::Unit::TestCase
|
|
32
32
|
end
|
33
33
|
|
34
34
|
def test_should_match_hash_parameter_with_specified_value
|
35
|
-
test_result =
|
35
|
+
test_result = run_as_test do
|
36
36
|
mock = mock()
|
37
37
|
mock.expects(:method).with(has_value('value_1'))
|
38
38
|
mock.method(:key_1 => 'value_1', :key_2 => 'value_2')
|
@@ -41,7 +41,7 @@ class ParameterMatcherTest < Test::Unit::TestCase
|
|
41
41
|
end
|
42
42
|
|
43
43
|
def test_should_not_match_hash_parameter_with_specified_value
|
44
|
-
test_result =
|
44
|
+
test_result = run_as_test do
|
45
45
|
mock = mock()
|
46
46
|
mock.expects(:method).with(has_value('value_1'))
|
47
47
|
mock.method(:key_2 => 'value_2')
|
@@ -50,7 +50,7 @@ class ParameterMatcherTest < Test::Unit::TestCase
|
|
50
50
|
end
|
51
51
|
|
52
52
|
def test_should_match_hash_parameter_with_specified_key_value_pair
|
53
|
-
test_result =
|
53
|
+
test_result = run_as_test do
|
54
54
|
mock = mock()
|
55
55
|
mock.expects(:method).with(has_entry(:key_1, 'value_1'))
|
56
56
|
mock.method(:key_1 => 'value_1', :key_2 => 'value_2')
|
@@ -59,7 +59,7 @@ class ParameterMatcherTest < Test::Unit::TestCase
|
|
59
59
|
end
|
60
60
|
|
61
61
|
def test_should_not_match_hash_parameter_with_specified_key_value_pair
|
62
|
-
test_result =
|
62
|
+
test_result = run_as_test do
|
63
63
|
mock = mock()
|
64
64
|
mock.expects(:method).with(has_entry(:key_1, 'value_2'))
|
65
65
|
mock.method(:key_1 => 'value_1', :key_2 => 'value_2')
|
@@ -68,7 +68,7 @@ class ParameterMatcherTest < Test::Unit::TestCase
|
|
68
68
|
end
|
69
69
|
|
70
70
|
def test_should_match_hash_parameter_with_specified_hash_entry
|
71
|
-
test_result =
|
71
|
+
test_result = run_as_test do
|
72
72
|
mock = mock()
|
73
73
|
mock.expects(:method).with(has_entry(:key_1 => 'value_1'))
|
74
74
|
mock.method(:key_1 => 'value_1', :key_2 => 'value_2')
|
@@ -77,7 +77,7 @@ class ParameterMatcherTest < Test::Unit::TestCase
|
|
77
77
|
end
|
78
78
|
|
79
79
|
def test_should_not_match_hash_parameter_with_specified_hash_entry
|
80
|
-
test_result =
|
80
|
+
test_result = run_as_test do
|
81
81
|
mock = mock()
|
82
82
|
mock.expects(:method).with(has_entry(:key_1 => 'value_2'))
|
83
83
|
mock.method(:key_1 => 'value_1', :key_2 => 'value_2')
|
@@ -86,7 +86,7 @@ class ParameterMatcherTest < Test::Unit::TestCase
|
|
86
86
|
end
|
87
87
|
|
88
88
|
def test_should_match_hash_parameter_with_specified_entries
|
89
|
-
test_result =
|
89
|
+
test_result = run_as_test do
|
90
90
|
mock = mock()
|
91
91
|
mock.expects(:method).with(has_entries(:key_1 => 'value_1', :key_2 => 'value_2'))
|
92
92
|
mock.method(:key_1 => 'value_1', :key_2 => 'value_2', :key_3 => 'value_3')
|
@@ -95,7 +95,7 @@ class ParameterMatcherTest < Test::Unit::TestCase
|
|
95
95
|
end
|
96
96
|
|
97
97
|
def test_should_not_match_hash_parameter_with_specified_entries
|
98
|
-
test_result =
|
98
|
+
test_result = run_as_test do
|
99
99
|
mock = mock()
|
100
100
|
mock.expects(:method).with(has_entries(:key_1 => 'value_1', :key_2 => 'value_2'))
|
101
101
|
mock.method(:key_1 => 'value_1', :key_2 => 'value_3')
|
@@ -104,7 +104,7 @@ class ParameterMatcherTest < Test::Unit::TestCase
|
|
104
104
|
end
|
105
105
|
|
106
106
|
def test_should_match_parameter_that_matches_regular_expression
|
107
|
-
test_result =
|
107
|
+
test_result = run_as_test do
|
108
108
|
mock = mock()
|
109
109
|
mock.expects(:method).with(regexp_matches(/meter/))
|
110
110
|
mock.method('this parameter should match')
|
@@ -113,7 +113,7 @@ class ParameterMatcherTest < Test::Unit::TestCase
|
|
113
113
|
end
|
114
114
|
|
115
115
|
def test_should_not_match_parameter_that_does_not_match_regular_expression
|
116
|
-
test_result =
|
116
|
+
test_result = run_as_test do
|
117
117
|
mock = mock()
|
118
118
|
mock.expects(:method).with(regexp_matches(/something different/))
|
119
119
|
mock.method('this parameter should not match')
|
@@ -122,7 +122,7 @@ class ParameterMatcherTest < Test::Unit::TestCase
|
|
122
122
|
end
|
123
123
|
|
124
124
|
def test_should_match_hash_parameter_with_specified_entries_using_nested_matchers
|
125
|
-
test_result =
|
125
|
+
test_result = run_as_test do
|
126
126
|
mock = mock()
|
127
127
|
mock.expects(:method).with(has_entries(:key_1 => regexp_matches(/value_1/), kind_of(Symbol) => 'value_2'))
|
128
128
|
mock.method(:key_1 => 'value_1', :key_2 => 'value_2', :key_3 => 'value_3')
|
@@ -131,7 +131,7 @@ class ParameterMatcherTest < Test::Unit::TestCase
|
|
131
131
|
end
|
132
132
|
|
133
133
|
def test_should_not_match_hash_parameter_with_specified_entries_using_nested_matchers
|
134
|
-
test_result =
|
134
|
+
test_result = run_as_test do
|
135
135
|
mock = mock()
|
136
136
|
mock.expects(:method).with(has_entries(:key_1 => regexp_matches(/value_1/), kind_of(String) => 'value_2'))
|
137
137
|
mock.method(:key_1 => 'value_2', :key_2 => 'value_3')
|
@@ -140,7 +140,7 @@ class ParameterMatcherTest < Test::Unit::TestCase
|
|
140
140
|
end
|
141
141
|
|
142
142
|
def test_should_match_parameter_that_matches_any_value
|
143
|
-
test_result =
|
143
|
+
test_result = run_as_test do
|
144
144
|
mock = mock()
|
145
145
|
mock.expects(:method).with(any_of('value_1', 'value_2')).times(2)
|
146
146
|
mock.method('value_1')
|
@@ -150,7 +150,7 @@ class ParameterMatcherTest < Test::Unit::TestCase
|
|
150
150
|
end
|
151
151
|
|
152
152
|
def test_should_not_match_parameter_that_does_not_match_any_value
|
153
|
-
test_result =
|
153
|
+
test_result = run_as_test do
|
154
154
|
mock = mock()
|
155
155
|
mock.expects(:method).with(any_of('value_1', 'value_2'))
|
156
156
|
mock.method('value_3')
|
@@ -159,7 +159,7 @@ class ParameterMatcherTest < Test::Unit::TestCase
|
|
159
159
|
end
|
160
160
|
|
161
161
|
def test_should_match_parameter_that_matches_all_values
|
162
|
-
test_result =
|
162
|
+
test_result = run_as_test do
|
163
163
|
mock = mock()
|
164
164
|
mock.expects(:method).with(all_of('value_1', 'value_1'))
|
165
165
|
mock.method('value_1')
|
@@ -168,7 +168,7 @@ class ParameterMatcherTest < Test::Unit::TestCase
|
|
168
168
|
end
|
169
169
|
|
170
170
|
def test_should_not_match_parameter_that_does_not_match_all_values
|
171
|
-
test_result =
|
171
|
+
test_result = run_as_test do
|
172
172
|
mock = mock()
|
173
173
|
mock.expects(:method).with(all_of('value_1', 'value_2'))
|
174
174
|
mock.method('value_1')
|
@@ -183,7 +183,7 @@ class ParameterMatcherTest < Test::Unit::TestCase
|
|
183
183
|
end
|
184
184
|
end
|
185
185
|
duck = klass.new
|
186
|
-
test_result =
|
186
|
+
test_result = run_as_test do
|
187
187
|
mock = mock()
|
188
188
|
mock.expects(:method).with(responds_with(:quack, 'quack'))
|
189
189
|
mock.method(duck)
|
@@ -198,7 +198,7 @@ class ParameterMatcherTest < Test::Unit::TestCase
|
|
198
198
|
end
|
199
199
|
end
|
200
200
|
duck = klass.new
|
201
|
-
test_result =
|
201
|
+
test_result = run_as_test do
|
202
202
|
mock = mock()
|
203
203
|
mock.expects(:method).with(responds_with(:quack, 'quack'))
|
204
204
|
mock.method(duck)
|
@@ -14,7 +14,7 @@ class PartialMockTest < Test::Unit::TestCase
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def test_should_pass_if_all_expectations_are_satisfied
|
17
|
-
test_result =
|
17
|
+
test_result = run_as_test do
|
18
18
|
partial_mock_one = "partial_mock_one"
|
19
19
|
partial_mock_two = "partial_mock_two"
|
20
20
|
|
@@ -30,7 +30,7 @@ class PartialMockTest < Test::Unit::TestCase
|
|
30
30
|
end
|
31
31
|
|
32
32
|
def test_should_fail_if_all_expectations_are_not_satisfied
|
33
|
-
test_result =
|
33
|
+
test_result = run_as_test do
|
34
34
|
partial_mock_one = "partial_mock_one"
|
35
35
|
partial_mock_two = "partial_mock_two"
|
36
36
|
|