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
@@ -14,7 +14,7 @@ class ReturnValueTest < Test::Unit::TestCase
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def test_should_build_mock_and_explicitly_add_an_expectation_with_a_return_value
|
17
|
-
test_result =
|
17
|
+
test_result = run_as_test do
|
18
18
|
foo = mock('foo')
|
19
19
|
foo.expects(:bar).returns('bar')
|
20
20
|
assert_equal 'bar', foo.bar
|
@@ -23,7 +23,7 @@ class ReturnValueTest < Test::Unit::TestCase
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def test_should_build_mock_incorporating_two_expectations_with_return_values
|
26
|
-
test_result =
|
26
|
+
test_result = run_as_test do
|
27
27
|
foo = mock('foo', :bar => 'bar', :baz => 'baz')
|
28
28
|
assert_equal 'bar', foo.bar
|
29
29
|
assert_equal 'baz', foo.baz
|
@@ -32,7 +32,7 @@ class ReturnValueTest < Test::Unit::TestCase
|
|
32
32
|
end
|
33
33
|
|
34
34
|
def test_should_build_stub_and_explicitly_add_an_expectation_with_a_return_value
|
35
|
-
test_result =
|
35
|
+
test_result = run_as_test do
|
36
36
|
foo = stub('foo')
|
37
37
|
foo.stubs(:bar).returns('bar')
|
38
38
|
assert_equal 'bar', foo.bar
|
@@ -41,7 +41,7 @@ class ReturnValueTest < Test::Unit::TestCase
|
|
41
41
|
end
|
42
42
|
|
43
43
|
def test_should_build_stub_incorporating_two_expectations_with_return_values
|
44
|
-
test_result =
|
44
|
+
test_result = run_as_test do
|
45
45
|
foo = stub('foo', :bar => 'bar', :baz => 'baz')
|
46
46
|
assert_equal 'bar', foo.bar
|
47
47
|
assert_equal 'baz', foo.baz
|
@@ -14,7 +14,7 @@ class SequenceTest < Test::Unit::TestCase
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def test_should_constrain_invocations_to_occur_in_expected_order
|
17
|
-
test_result =
|
17
|
+
test_result = run_as_test do
|
18
18
|
mock = mock()
|
19
19
|
sequence = sequence('one')
|
20
20
|
|
@@ -27,7 +27,7 @@ class SequenceTest < Test::Unit::TestCase
|
|
27
27
|
end
|
28
28
|
|
29
29
|
def test_should_allow_invocations_in_sequence
|
30
|
-
test_result =
|
30
|
+
test_result = run_as_test do
|
31
31
|
mock = mock()
|
32
32
|
sequence = sequence('one')
|
33
33
|
|
@@ -41,7 +41,7 @@ class SequenceTest < Test::Unit::TestCase
|
|
41
41
|
end
|
42
42
|
|
43
43
|
def test_should_constrain_invocations_to_occur_in_expected_order_even_if_expected_on_different_mocks
|
44
|
-
test_result =
|
44
|
+
test_result = run_as_test do
|
45
45
|
mock_one = mock('1')
|
46
46
|
mock_two = mock('2')
|
47
47
|
sequence = sequence('one')
|
@@ -55,7 +55,7 @@ class SequenceTest < Test::Unit::TestCase
|
|
55
55
|
end
|
56
56
|
|
57
57
|
def test_should_allow_invocations_in_sequence_even_if_expected_on_different_mocks
|
58
|
-
test_result =
|
58
|
+
test_result = run_as_test do
|
59
59
|
mock_one = mock('1')
|
60
60
|
mock_two = mock('2')
|
61
61
|
sequence = sequence('one')
|
@@ -70,7 +70,7 @@ class SequenceTest < Test::Unit::TestCase
|
|
70
70
|
end
|
71
71
|
|
72
72
|
def test_should_constrain_invocations_to_occur_in_expected_order_even_if_expected_on_partial_mocks
|
73
|
-
test_result =
|
73
|
+
test_result = run_as_test do
|
74
74
|
partial_mock_one = "1"
|
75
75
|
partial_mock_two = "2"
|
76
76
|
sequence = sequence('one')
|
@@ -84,7 +84,7 @@ class SequenceTest < Test::Unit::TestCase
|
|
84
84
|
end
|
85
85
|
|
86
86
|
def test_should_allow_invocations_in_sequence_even_if_expected_on_partial_mocks
|
87
|
-
test_result =
|
87
|
+
test_result = run_as_test do
|
88
88
|
partial_mock_one = "1"
|
89
89
|
partial_mock_two = "2"
|
90
90
|
sequence = sequence('one')
|
@@ -99,7 +99,7 @@ class SequenceTest < Test::Unit::TestCase
|
|
99
99
|
end
|
100
100
|
|
101
101
|
def test_should_allow_stub_expectations_to_be_skipped_in_sequence
|
102
|
-
test_result =
|
102
|
+
test_result = run_as_test do
|
103
103
|
mock = mock()
|
104
104
|
sequence = sequence('one')
|
105
105
|
|
@@ -114,7 +114,7 @@ class SequenceTest < Test::Unit::TestCase
|
|
114
114
|
end
|
115
115
|
|
116
116
|
def test_should_regard_sequences_as_independent_of_each_other
|
117
|
-
test_result =
|
117
|
+
test_result = run_as_test do
|
118
118
|
mock = mock()
|
119
119
|
sequence_one = sequence('one')
|
120
120
|
sequence_two = sequence('two')
|
@@ -134,7 +134,7 @@ class SequenceTest < Test::Unit::TestCase
|
|
134
134
|
end
|
135
135
|
|
136
136
|
def test_should_include_sequence_in_failure_message
|
137
|
-
test_result =
|
137
|
+
test_result = run_as_test do
|
138
138
|
mock = mock()
|
139
139
|
sequence = sequence('one')
|
140
140
|
|
@@ -148,7 +148,7 @@ class SequenceTest < Test::Unit::TestCase
|
|
148
148
|
end
|
149
149
|
|
150
150
|
def test_should_allow_expectations_to_be_in_more_than_one_sequence
|
151
|
-
test_result =
|
151
|
+
test_result = run_as_test do
|
152
152
|
mock = mock()
|
153
153
|
sequence_one = sequence('one')
|
154
154
|
sequence_two = sequence('two')
|
@@ -166,7 +166,7 @@ class SequenceTest < Test::Unit::TestCase
|
|
166
166
|
end
|
167
167
|
|
168
168
|
def test_should_have_shortcut_for_expectations_to_be_in_more_than_one_sequence
|
169
|
-
test_result =
|
169
|
+
test_result = run_as_test do
|
170
170
|
mock = mock()
|
171
171
|
sequence_one = sequence('one')
|
172
172
|
sequence_two = sequence('two')
|
@@ -14,7 +14,7 @@ class StatesTest < Test::Unit::TestCase
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def test_should_constrain_expectations_to_occur_within_a_given_state
|
17
|
-
test_result =
|
17
|
+
test_result = run_as_test do
|
18
18
|
mock = mock()
|
19
19
|
readiness = states('readiness')
|
20
20
|
|
@@ -27,7 +27,7 @@ class StatesTest < Test::Unit::TestCase
|
|
27
27
|
end
|
28
28
|
|
29
29
|
def test_should_allow_expectations_to_occur_in_correct_state
|
30
|
-
test_result =
|
30
|
+
test_result = run_as_test do
|
31
31
|
mock = mock()
|
32
32
|
readiness = states('readiness')
|
33
33
|
|
@@ -41,7 +41,7 @@ class StatesTest < Test::Unit::TestCase
|
|
41
41
|
end
|
42
42
|
|
43
43
|
def test_should_be_able_to_start_in_a_specific_state
|
44
|
-
test_result =
|
44
|
+
test_result = run_as_test do
|
45
45
|
mock = mock()
|
46
46
|
readiness = states('readiness')
|
47
47
|
|
@@ -54,7 +54,7 @@ class StatesTest < Test::Unit::TestCase
|
|
54
54
|
end
|
55
55
|
|
56
56
|
def test_should_switch_state_when_method_raises_an_exception
|
57
|
-
test_result =
|
57
|
+
test_result = run_as_test do
|
58
58
|
mock = mock()
|
59
59
|
readiness = states('readiness')
|
60
60
|
|
@@ -20,7 +20,7 @@ class StubAnyInstanceMethodTest < Test::Unit::TestCase
|
|
20
20
|
end
|
21
21
|
end
|
22
22
|
instance = klass.new
|
23
|
-
test_result =
|
23
|
+
test_result = run_as_test do
|
24
24
|
klass.any_instance.stubs(:my_instance_method).returns(:new_return_value)
|
25
25
|
assert_equal :new_return_value, instance.my_instance_method
|
26
26
|
end
|
@@ -34,7 +34,7 @@ class StubAnyInstanceMethodTest < Test::Unit::TestCase
|
|
34
34
|
end
|
35
35
|
end
|
36
36
|
instance = klass.new
|
37
|
-
|
37
|
+
run_as_test do
|
38
38
|
klass.any_instance.stubs(:my_instance_method).returns(:new_return_value)
|
39
39
|
end
|
40
40
|
assert instance.public_methods(false).any? { |m| m.to_s == 'my_instance_method' }
|
@@ -49,7 +49,7 @@ class StubAnyInstanceMethodTest < Test::Unit::TestCase
|
|
49
49
|
protected :my_instance_method
|
50
50
|
end
|
51
51
|
instance = klass.new
|
52
|
-
|
52
|
+
run_as_test do
|
53
53
|
klass.any_instance.stubs(:my_instance_method).returns(:new_return_value)
|
54
54
|
end
|
55
55
|
assert instance.protected_methods(false).any? { |m| m.to_s == 'my_instance_method' }
|
@@ -64,7 +64,7 @@ class StubAnyInstanceMethodTest < Test::Unit::TestCase
|
|
64
64
|
private :my_instance_method
|
65
65
|
end
|
66
66
|
instance = klass.new
|
67
|
-
|
67
|
+
run_as_test do
|
68
68
|
klass.any_instance.stubs(:my_instance_method).returns(:new_return_value)
|
69
69
|
end
|
70
70
|
assert instance.private_methods(false).any? { |m| m.to_s == 'my_instance_method' }
|
@@ -78,7 +78,7 @@ class StubAnyInstanceMethodTest < Test::Unit::TestCase
|
|
78
78
|
end
|
79
79
|
end
|
80
80
|
instance = klass.new
|
81
|
-
|
81
|
+
run_as_test do
|
82
82
|
klass.any_instance.stubs(:my_instance_method).returns(:new_return_value)
|
83
83
|
end
|
84
84
|
assert_equal 0, klass.any_instance.mocha.expectations.length
|
@@ -92,7 +92,7 @@ class StubAnyInstanceMethodTest < Test::Unit::TestCase
|
|
92
92
|
end
|
93
93
|
klass = Class.new(superklass)
|
94
94
|
instance = klass.new
|
95
|
-
test_result =
|
95
|
+
test_result = run_as_test do
|
96
96
|
klass.any_instance.stubs(:my_superclass_method).returns(:new_return_value)
|
97
97
|
assert_equal :new_return_value, instance.my_superclass_method
|
98
98
|
end
|
@@ -110,7 +110,7 @@ class StubAnyInstanceMethodTest < Test::Unit::TestCase
|
|
110
110
|
end
|
111
111
|
end
|
112
112
|
end
|
113
|
-
test_result =
|
113
|
+
test_result = run_as_test do
|
114
114
|
ruby18_klass.any_instance.stubs(:my_instance_method).returns(:new_return_value)
|
115
115
|
assert_equal :new_return_value, ruby18_klass.new.my_instance_method
|
116
116
|
end
|
@@ -125,7 +125,7 @@ class StubAnyInstanceMethodTest < Test::Unit::TestCase
|
|
125
125
|
end
|
126
126
|
end
|
127
127
|
end
|
128
|
-
test_result =
|
128
|
+
test_result = run_as_test do
|
129
129
|
ruby19_klass.any_instance.stubs(:my_instance_method).returns(:new_return_value)
|
130
130
|
assert_equal :new_return_value, ruby19_klass.new.my_instance_method
|
131
131
|
end
|
@@ -140,7 +140,7 @@ class StubAnyInstanceMethodTest < Test::Unit::TestCase
|
|
140
140
|
end
|
141
141
|
end
|
142
142
|
end
|
143
|
-
test_result =
|
143
|
+
test_result = run_as_test do
|
144
144
|
ruby18_klass.any_instance.stubs(:my_instance_method).returns(:new_return_value)
|
145
145
|
assert_equal :new_return_value, ruby18_klass.new.my_instance_method
|
146
146
|
end
|
@@ -155,7 +155,7 @@ class StubAnyInstanceMethodTest < Test::Unit::TestCase
|
|
155
155
|
end
|
156
156
|
end
|
157
157
|
end
|
158
|
-
test_result =
|
158
|
+
test_result = run_as_test do
|
159
159
|
ruby19_klass.any_instance.stubs(:my_instance_method).returns(:new_return_value)
|
160
160
|
assert_equal :new_return_value, ruby19_klass.new.my_instance_method
|
161
161
|
end
|
@@ -170,7 +170,7 @@ class StubAnyInstanceMethodTest < Test::Unit::TestCase
|
|
170
170
|
end
|
171
171
|
end
|
172
172
|
end
|
173
|
-
test_result =
|
173
|
+
test_result = run_as_test do
|
174
174
|
ruby18_klass.any_instance.stubs(:my_instance_method).returns(:new_return_value)
|
175
175
|
assert_equal :new_return_value, ruby18_klass.new.my_instance_method
|
176
176
|
end
|
@@ -185,7 +185,7 @@ class StubAnyInstanceMethodTest < Test::Unit::TestCase
|
|
185
185
|
end
|
186
186
|
end
|
187
187
|
end
|
188
|
-
test_result =
|
188
|
+
test_result = run_as_test do
|
189
189
|
ruby19_klass.any_instance.stubs(:my_instance_method).returns(:new_return_value)
|
190
190
|
assert_equal :new_return_value, ruby19_klass.new.my_instance_method
|
191
191
|
end
|
@@ -21,7 +21,7 @@ class StubClassMethodTest < Test::Unit::TestCase
|
|
21
21
|
end
|
22
22
|
end
|
23
23
|
end
|
24
|
-
test_result =
|
24
|
+
test_result = run_as_test do
|
25
25
|
klass.stubs(:my_class_method).returns(:new_return_value)
|
26
26
|
assert_equal :new_return_value, klass.my_class_method
|
27
27
|
end
|
@@ -36,7 +36,7 @@ class StubClassMethodTest < Test::Unit::TestCase
|
|
36
36
|
end
|
37
37
|
end
|
38
38
|
end
|
39
|
-
|
39
|
+
run_as_test do
|
40
40
|
klass.stubs(:my_class_method).returns(:new_return_value)
|
41
41
|
end
|
42
42
|
assert klass.public_methods(false).any? { |m| m.to_s == 'my_class_method' }
|
@@ -52,7 +52,7 @@ class StubClassMethodTest < Test::Unit::TestCase
|
|
52
52
|
protected :my_class_method
|
53
53
|
end
|
54
54
|
end
|
55
|
-
|
55
|
+
run_as_test do
|
56
56
|
klass.stubs(:my_class_method).returns(:new_return_value)
|
57
57
|
end
|
58
58
|
assert klass.protected_methods(false).any? { |m| m.to_s == 'my_class_method' }
|
@@ -68,7 +68,7 @@ class StubClassMethodTest < Test::Unit::TestCase
|
|
68
68
|
private :my_class_method
|
69
69
|
end
|
70
70
|
end
|
71
|
-
|
71
|
+
run_as_test do
|
72
72
|
klass.stubs(:my_class_method).returns(:new_return_value)
|
73
73
|
end
|
74
74
|
assert klass.private_methods(false).any? { |m| m.to_s == 'my_class_method' }
|
@@ -83,7 +83,7 @@ class StubClassMethodTest < Test::Unit::TestCase
|
|
83
83
|
end
|
84
84
|
end
|
85
85
|
end
|
86
|
-
|
86
|
+
run_as_test do
|
87
87
|
klass.stubs(:my_class_method)
|
88
88
|
end
|
89
89
|
assert_equal 0, klass.mocha.expectations.length
|
@@ -98,7 +98,7 @@ class StubClassMethodTest < Test::Unit::TestCase
|
|
98
98
|
end
|
99
99
|
end
|
100
100
|
klass = Class.new(superklass)
|
101
|
-
test_result =
|
101
|
+
test_result = run_as_test do
|
102
102
|
klass.stubs(:my_superclass_method).returns(:new_return_value)
|
103
103
|
assert_equal :new_return_value, klass.my_superclass_method
|
104
104
|
end
|
@@ -118,7 +118,7 @@ class StubClassMethodTest < Test::Unit::TestCase
|
|
118
118
|
end
|
119
119
|
end
|
120
120
|
end
|
121
|
-
test_result =
|
121
|
+
test_result = run_as_test do
|
122
122
|
ruby18_klass.stubs(:my_class_method).returns(:new_return_value)
|
123
123
|
assert_equal :new_return_value, ruby18_klass.my_class_method
|
124
124
|
end
|
@@ -133,7 +133,7 @@ class StubClassMethodTest < Test::Unit::TestCase
|
|
133
133
|
end
|
134
134
|
end
|
135
135
|
end
|
136
|
-
test_result =
|
136
|
+
test_result = run_as_test do
|
137
137
|
ruby19_klass.stubs(:my_class_method).returns(:new_return_value)
|
138
138
|
assert_equal :new_return_value, ruby19_klass.my_class_method
|
139
139
|
end
|
@@ -148,7 +148,7 @@ class StubClassMethodTest < Test::Unit::TestCase
|
|
148
148
|
end
|
149
149
|
end
|
150
150
|
end
|
151
|
-
test_result =
|
151
|
+
test_result = run_as_test do
|
152
152
|
ruby18_klass.stubs(:my_class_method).returns(:new_return_value)
|
153
153
|
assert_equal :new_return_value, ruby18_klass.my_class_method
|
154
154
|
end
|
@@ -163,7 +163,7 @@ class StubClassMethodTest < Test::Unit::TestCase
|
|
163
163
|
end
|
164
164
|
end
|
165
165
|
end
|
166
|
-
test_result =
|
166
|
+
test_result = run_as_test do
|
167
167
|
ruby19_klass.stubs(:my_class_method).returns(:new_return_value)
|
168
168
|
assert_equal :new_return_value, ruby19_klass.my_class_method
|
169
169
|
end
|
@@ -178,7 +178,7 @@ class StubClassMethodTest < Test::Unit::TestCase
|
|
178
178
|
end
|
179
179
|
end
|
180
180
|
end
|
181
|
-
test_result =
|
181
|
+
test_result = run_as_test do
|
182
182
|
ruby18_klass.stubs(:my_class_method).returns(:new_return_value)
|
183
183
|
assert_equal :new_return_value, ruby18_klass.my_class_method
|
184
184
|
end
|
@@ -193,7 +193,7 @@ class StubClassMethodTest < Test::Unit::TestCase
|
|
193
193
|
end
|
194
194
|
end
|
195
195
|
end
|
196
|
-
test_result =
|
196
|
+
test_result = run_as_test do
|
197
197
|
ruby19_klass.stubs(:my_class_method).returns(:new_return_value)
|
198
198
|
assert_equal :new_return_value, ruby19_klass.my_class_method
|
199
199
|
end
|
@@ -14,7 +14,7 @@ class StubEverythingTest < Test::Unit::TestCase
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def test_should_build_stub_and_explicitly_add_an_expectation
|
17
|
-
test_result =
|
17
|
+
test_result = run_as_test do
|
18
18
|
foo = stub_everything()
|
19
19
|
foo.stubs(:bar)
|
20
20
|
foo.bar
|
@@ -24,7 +24,7 @@ class StubEverythingTest < Test::Unit::TestCase
|
|
24
24
|
end
|
25
25
|
|
26
26
|
def test_should_build_named_stub_and_explicitly_add_an_expectation
|
27
|
-
test_result =
|
27
|
+
test_result = run_as_test do
|
28
28
|
foo = stub_everything('foo')
|
29
29
|
foo.stubs(:bar)
|
30
30
|
foo.bar
|
@@ -34,7 +34,7 @@ class StubEverythingTest < Test::Unit::TestCase
|
|
34
34
|
end
|
35
35
|
|
36
36
|
def test_should_build_stub_incorporating_two_expectations
|
37
|
-
test_result =
|
37
|
+
test_result = run_as_test do
|
38
38
|
foo = stub_everything(:bar => 'bar', :baz => 'baz')
|
39
39
|
foo.bar
|
40
40
|
foo.baz
|
@@ -44,7 +44,7 @@ class StubEverythingTest < Test::Unit::TestCase
|
|
44
44
|
end
|
45
45
|
|
46
46
|
def test_should_build_named_stub_incorporating_two_expectations
|
47
|
-
test_result =
|
47
|
+
test_result = run_as_test do
|
48
48
|
foo = stub_everything('foo', :bar => 'bar', :baz => 'baz')
|
49
49
|
foo.bar
|
50
50
|
foo.baz
|
@@ -19,7 +19,7 @@ class StubInstanceMethodTest < Test::Unit::TestCase
|
|
19
19
|
:original_return_value
|
20
20
|
end
|
21
21
|
end.new
|
22
|
-
|
22
|
+
run_as_test do
|
23
23
|
instance.stubs(:my_instance_method).returns(:new_return_value)
|
24
24
|
end
|
25
25
|
assert instance.public_methods(false).any? { |m| m.to_s == 'my_instance_method' }
|
@@ -33,7 +33,7 @@ class StubInstanceMethodTest < Test::Unit::TestCase
|
|
33
33
|
end
|
34
34
|
protected :my_instance_method
|
35
35
|
end.new
|
36
|
-
|
36
|
+
run_as_test do
|
37
37
|
instance.stubs(:my_instance_method).returns(:new_return_value)
|
38
38
|
end
|
39
39
|
assert instance.protected_methods(false).any? { |m| m.to_s == 'my_instance_method' }
|
@@ -47,7 +47,7 @@ class StubInstanceMethodTest < Test::Unit::TestCase
|
|
47
47
|
end
|
48
48
|
private :my_instance_method
|
49
49
|
end.new
|
50
|
-
|
50
|
+
run_as_test do
|
51
51
|
instance.stubs(:my_instance_method).returns(:new_return_value)
|
52
52
|
end
|
53
53
|
assert instance.private_methods(false).any? { |m| m.to_s == 'my_instance_method' }
|
@@ -60,7 +60,7 @@ class StubInstanceMethodTest < Test::Unit::TestCase
|
|
60
60
|
:original_return_value
|
61
61
|
end
|
62
62
|
end.new
|
63
|
-
|
63
|
+
run_as_test do
|
64
64
|
instance.stubs(:my_instance_method).returns(:new_return_value)
|
65
65
|
end
|
66
66
|
assert_equal 0, instance.mocha.expectations.length
|
@@ -74,7 +74,7 @@ class StubInstanceMethodTest < Test::Unit::TestCase
|
|
74
74
|
end
|
75
75
|
klass = Class.new(superklass)
|
76
76
|
instance = klass.new
|
77
|
-
test_result =
|
77
|
+
test_result = run_as_test do
|
78
78
|
instance.stubs(:my_superclass_method).returns(:new_return_value)
|
79
79
|
assert_equal :new_return_value, instance.my_superclass_method
|
80
80
|
end
|
@@ -90,7 +90,7 @@ class StubInstanceMethodTest < Test::Unit::TestCase
|
|
90
90
|
['my_instance_method']
|
91
91
|
end
|
92
92
|
end.new
|
93
|
-
test_result =
|
93
|
+
test_result = run_as_test do
|
94
94
|
ruby18_instance.stubs(:my_instance_method).returns(:new_return_value)
|
95
95
|
assert_equal :new_return_value, ruby18_instance.my_instance_method
|
96
96
|
end
|
@@ -103,7 +103,7 @@ class StubInstanceMethodTest < Test::Unit::TestCase
|
|
103
103
|
[:my_instance_method]
|
104
104
|
end
|
105
105
|
end.new
|
106
|
-
test_result =
|
106
|
+
test_result = run_as_test do
|
107
107
|
ruby19_instance.stubs(:my_instance_method).returns(:new_return_value)
|
108
108
|
assert_equal :new_return_value, ruby19_instance.my_instance_method
|
109
109
|
end
|
@@ -116,7 +116,7 @@ class StubInstanceMethodTest < Test::Unit::TestCase
|
|
116
116
|
['my_instance_method']
|
117
117
|
end
|
118
118
|
end.new
|
119
|
-
test_result =
|
119
|
+
test_result = run_as_test do
|
120
120
|
ruby18_instance.stubs(:my_instance_method).returns(:new_return_value)
|
121
121
|
assert_equal :new_return_value, ruby18_instance.my_instance_method
|
122
122
|
end
|
@@ -129,7 +129,7 @@ class StubInstanceMethodTest < Test::Unit::TestCase
|
|
129
129
|
[:my_instance_method]
|
130
130
|
end
|
131
131
|
end.new
|
132
|
-
test_result =
|
132
|
+
test_result = run_as_test do
|
133
133
|
ruby19_instance.stubs(:my_instance_method).returns(:new_return_value)
|
134
134
|
assert_equal :new_return_value, ruby19_instance.my_instance_method
|
135
135
|
end
|
@@ -142,7 +142,7 @@ class StubInstanceMethodTest < Test::Unit::TestCase
|
|
142
142
|
['my_instance_method']
|
143
143
|
end
|
144
144
|
end.new
|
145
|
-
test_result =
|
145
|
+
test_result = run_as_test do
|
146
146
|
ruby18_instance.stubs(:my_instance_method).returns(:new_return_value)
|
147
147
|
assert_equal :new_return_value, ruby18_instance.my_instance_method
|
148
148
|
end
|
@@ -155,7 +155,7 @@ class StubInstanceMethodTest < Test::Unit::TestCase
|
|
155
155
|
[:my_instance_method]
|
156
156
|
end
|
157
157
|
end.new
|
158
|
-
test_result =
|
158
|
+
test_result = run_as_test do
|
159
159
|
ruby19_instance.stubs(:my_instance_method).returns(:new_return_value)
|
160
160
|
assert_equal :new_return_value, ruby19_instance.my_instance_method
|
161
161
|
end
|
@@ -171,7 +171,7 @@ class StubInstanceMethodTest < Test::Unit::TestCase
|
|
171
171
|
:original_return_value_2
|
172
172
|
end
|
173
173
|
end.new
|
174
|
-
|
174
|
+
run_as_test do
|
175
175
|
instance.expects(
|
176
176
|
:my_instance_method_1 => :new_return_value_1,
|
177
177
|
:my_instance_method_2 => :new_return_value_2
|
@@ -190,7 +190,7 @@ class StubInstanceMethodTest < Test::Unit::TestCase
|
|
190
190
|
:original_return_value_2
|
191
191
|
end
|
192
192
|
end.new
|
193
|
-
|
193
|
+
run_as_test do
|
194
194
|
instance.stubs(
|
195
195
|
:my_instance_method_1 => :new_return_value_1,
|
196
196
|
:my_instance_method_2 => :new_return_value_2
|