mocha 0.10.5 → 0.11.0
Sign up to get free protection for your applications and to get access to all the features.
- data/COPYING.rdoc +1 -1
- data/README.rdoc +6 -4
- data/RELEASE.rdoc +12 -0
- data/Rakefile +29 -60
- data/doc/Mocha.html +112 -0
- data/doc/Mocha/API.html +898 -0
- data/doc/Mocha/ClassMethods.html +246 -0
- data/doc/Mocha/Configuration.html +471 -0
- data/doc/Mocha/Expectation.html +2570 -0
- data/doc/Mocha/Mock.html +830 -0
- data/doc/Mocha/ObjectMethods.html +668 -0
- data/doc/Mocha/ParameterMatchers.html +2715 -0
- data/doc/Mocha/ParameterMatchers/AllOf.html +137 -0
- data/doc/Mocha/ParameterMatchers/AnyOf.html +137 -0
- data/doc/Mocha/ParameterMatchers/AnyParameters.html +136 -0
- data/doc/Mocha/ParameterMatchers/Anything.html +136 -0
- data/doc/Mocha/ParameterMatchers/Base.html +419 -0
- data/doc/Mocha/ParameterMatchers/Equals.html +137 -0
- data/doc/Mocha/ParameterMatchers/HasEntries.html +137 -0
- data/doc/Mocha/ParameterMatchers/HasEntry.html +137 -0
- data/doc/Mocha/ParameterMatchers/HasKey.html +137 -0
- data/doc/Mocha/ParameterMatchers/HasValue.html +137 -0
- data/doc/Mocha/ParameterMatchers/Includes.html +137 -0
- data/doc/Mocha/ParameterMatchers/InstanceOf.html +137 -0
- data/doc/Mocha/ParameterMatchers/IsA.html +136 -0
- data/doc/Mocha/ParameterMatchers/KindOf.html +137 -0
- data/doc/Mocha/ParameterMatchers/Not.html +137 -0
- data/doc/Mocha/ParameterMatchers/Optionally.html +136 -0
- data/doc/Mocha/ParameterMatchers/QueryStringMatches.html +136 -0
- data/doc/Mocha/ParameterMatchers/RegexpMatches.html +137 -0
- data/doc/Mocha/ParameterMatchers/RespondsWith.html +137 -0
- data/doc/Mocha/ParameterMatchers/YamlEquivalent.html +137 -0
- data/doc/Mocha/Sequence.html +133 -0
- data/doc/Mocha/StateMachine.html +510 -0
- data/doc/Mocha/StateMachine/State.html +125 -0
- data/doc/Mocha/StateMachine/StatePredicate.html +125 -0
- data/doc/Mocha/StubbingError.html +134 -0
- data/doc/Mocha/UnexpectedInvocation.html +124 -0
- data/doc/_index.html +481 -0
- data/doc/class_list.html +47 -0
- data/doc/css/common.css +1 -0
- data/doc/css/full_list.css +55 -0
- data/doc/css/style.css +322 -0
- data/doc/file.COPYING.html +72 -0
- data/doc/file.MIT-LICENSE.html +86 -0
- data/doc/file.README.html +153 -0
- data/doc/file.RELEASE.html +933 -0
- data/doc/file.misc.html +108 -0
- data/doc/file.mocha.html +90 -0
- data/doc/file.stubba.html +129 -0
- data/doc/file_list.html +67 -0
- data/doc/frames.html +13 -0
- data/doc/index.html +153 -0
- data/doc/js/app.js +205 -0
- data/doc/js/full_list.js +173 -0
- data/doc/js/jquery.js +16 -0
- data/doc/method_list.html +510 -0
- data/doc/top-level-namespace.html +105 -0
- data/lib/mocha/any_instance_method.rb +16 -11
- data/lib/mocha/api.rb +120 -106
- data/lib/mocha/argument_iterator.rb +6 -6
- data/lib/mocha/backtrace_filter.rb +1 -1
- data/lib/mocha/cardinality.rb +21 -21
- data/lib/mocha/central.rb +8 -8
- data/lib/mocha/change_state_side_effect.rb +5 -5
- data/lib/mocha/class_method.rb +14 -19
- data/lib/mocha/configuration.rb +47 -37
- data/lib/mocha/deprecation.rb +8 -8
- data/lib/mocha/exception_raiser.rb +7 -7
- data/lib/mocha/expectation.rb +173 -77
- data/lib/mocha/expectation_error.rb +2 -2
- data/lib/mocha/expectation_list.rb +11 -11
- data/lib/mocha/in_state_ordering_constraint.rb +5 -5
- data/lib/mocha/inspect.rb +8 -8
- data/lib/mocha/instance_method.rb +1 -17
- data/lib/mocha/integration.rb +9 -9
- data/lib/mocha/integration/mini_test/assertion_counter.rb +9 -9
- data/lib/mocha/integration/mini_test/exception_translation.rb +6 -6
- data/lib/mocha/integration/mini_test/version_13.rb +6 -6
- data/lib/mocha/integration/mini_test/version_140.rb +6 -6
- data/lib/mocha/integration/mini_test/version_141.rb +6 -6
- data/lib/mocha/integration/mini_test/version_142_to_172.rb +7 -7
- data/lib/mocha/integration/mini_test/version_200.rb +7 -7
- data/lib/mocha/integration/test_unit/assertion_counter.rb +10 -10
- data/lib/mocha/integration/test_unit/gem_version_200.rb +6 -6
- data/lib/mocha/integration/test_unit/gem_version_201_to_202.rb +6 -6
- data/lib/mocha/integration/test_unit/ruby_version_185_and_below.rb +6 -6
- data/lib/mocha/integration/test_unit/ruby_version_186_and_above.rb +6 -6
- data/lib/mocha/is_a.rb +1 -1
- data/lib/mocha/logger.rb +6 -6
- data/lib/mocha/method_matcher.rb +7 -7
- data/lib/mocha/mock.rb +85 -48
- data/lib/mocha/mockery.rb +47 -33
- data/lib/mocha/module_method.rb +2 -2
- data/lib/mocha/multiple_yields.rb +9 -9
- data/lib/mocha/names.rb +18 -18
- data/lib/mocha/no_yields.rb +7 -7
- data/lib/mocha/object.rb +104 -75
- data/lib/mocha/parameter_matchers.rb +3 -3
- data/lib/mocha/parameter_matchers/all_of.rb +22 -12
- data/lib/mocha/parameter_matchers/any_of.rb +23 -12
- data/lib/mocha/parameter_matchers/any_parameters.rb +15 -8
- data/lib/mocha/parameter_matchers/anything.rb +20 -11
- data/lib/mocha/parameter_matchers/base.rb +35 -27
- data/lib/mocha/parameter_matchers/equals.rb +23 -12
- data/lib/mocha/parameter_matchers/has_entries.rb +22 -12
- data/lib/mocha/parameter_matchers/has_entry.rb +31 -13
- data/lib/mocha/parameter_matchers/has_key.rb +21 -11
- data/lib/mocha/parameter_matchers/has_value.rb +21 -11
- data/lib/mocha/parameter_matchers/includes.rb +15 -5
- data/lib/mocha/parameter_matchers/instance_of.rb +23 -12
- data/lib/mocha/parameter_matchers/is_a.rb +23 -12
- data/lib/mocha/parameter_matchers/kind_of.rb +23 -12
- data/lib/mocha/parameter_matchers/not.rb +22 -12
- data/lib/mocha/parameter_matchers/object.rb +5 -3
- data/lib/mocha/parameter_matchers/optionally.rb +24 -12
- data/lib/mocha/parameter_matchers/query_string.rb +14 -3
- data/lib/mocha/parameter_matchers/regexp_matches.rb +21 -11
- data/lib/mocha/parameter_matchers/responds_with.rb +17 -6
- data/lib/mocha/parameter_matchers/yaml_equivalent.rb +16 -6
- data/lib/mocha/parameters_matcher.rb +8 -8
- data/lib/mocha/pretty_parameters.rb +7 -7
- data/lib/mocha/return_values.rb +11 -11
- data/lib/mocha/sequence.rb +23 -14
- data/lib/mocha/single_return_value.rb +7 -7
- data/lib/mocha/single_yield.rb +9 -9
- data/lib/mocha/standalone.rb +1 -1
- data/lib/mocha/state_machine.rb +61 -46
- data/lib/mocha/stubbing_error.rb +8 -5
- data/lib/mocha/thrower.rb +2 -2
- data/lib/mocha/unexpected_invocation.rb +9 -6
- data/lib/mocha/version.rb +1 -1
- data/lib/mocha/yield_parameters.rb +10 -10
- data/lib/mocha_standalone.rb +1 -1
- data/mocha.gemspec +4 -7
- data/test/acceptance/acceptance_test_helper.rb +10 -10
- data/test/acceptance/api_test.rb +20 -20
- data/test/acceptance/bug_18914_test.rb +12 -12
- data/test/acceptance/bug_21465_test.rb +6 -6
- data/test/acceptance/bug_21563_test.rb +5 -5
- data/test/acceptance/exception_rescue_test.rb +1 -1
- data/test/acceptance/expected_invocation_count_test.rb +17 -17
- data/test/acceptance/failure_messages_test.rb +13 -13
- data/test/acceptance/minitest_test.rb +39 -39
- data/test/acceptance/mocha_example_test.rb +26 -26
- data/test/acceptance/mocha_test_result_test.rb +13 -13
- data/test/acceptance/mock_test.rb +5 -5
- data/test/acceptance/mock_with_initializer_block_test.rb +5 -5
- data/test/acceptance/mocked_methods_dispatch_test.rb +4 -4
- data/test/acceptance/multiple_expectations_failure_message_test.rb +2 -2
- data/test/acceptance/optional_parameters_test.rb +5 -5
- data/test/acceptance/parameter_matcher_test.rb +18 -18
- data/test/acceptance/partial_mocks_test.rb +9 -9
- data/test/acceptance/raise_exception_test.rb +1 -1
- data/test/acceptance/return_value_test.rb +5 -5
- data/test/acceptance/sequence_test.rb +29 -29
- data/test/acceptance/states_test.rb +17 -17
- data/test/acceptance/stub_any_instance_method_test.rb +13 -13
- data/test/acceptance/stub_class_method_defined_on_active_record_association_proxy_test.rb +7 -7
- data/test/acceptance/stub_everything_test.rb +5 -5
- data/test/acceptance/stub_instance_method_defined_on_singleton_class_test.rb +1 -1
- data/test/acceptance/stub_module_method_test.rb +17 -17
- data/test/acceptance/stub_test.rb +5 -5
- data/test/acceptance/stubba_example_test.rb +24 -24
- data/test/acceptance/stubba_test_result_test.rb +11 -11
- data/test/acceptance/stubbing_error_backtrace_test.rb +6 -6
- data/test/acceptance/stubbing_frozen_object_test.rb +88 -0
- data/test/acceptance/stubbing_method_unnecessarily_test.rb +9 -9
- data/test/acceptance/stubbing_nil_test.rb +59 -0
- data/test/acceptance/stubbing_non_existent_any_instance_method_test.rb +13 -13
- data/test/acceptance/stubbing_non_existent_class_method_test.rb +15 -15
- data/test/acceptance/stubbing_non_existent_instance_method_test.rb +14 -14
- data/test/acceptance/stubbing_non_public_any_instance_method_test.rb +13 -13
- data/test/acceptance/stubbing_non_public_class_method_test.rb +12 -12
- data/test/acceptance/stubbing_non_public_instance_method_test.rb +12 -12
- data/test/acceptance/stubbing_on_non_mock_object_test.rb +9 -9
- data/test/acceptance/stubbing_same_class_method_on_parent_and_child_classes_test.rb +35 -0
- data/test/acceptance/throw_test.rb +1 -1
- data/test/deprecation_disabler.rb +1 -1
- data/test/execution_point.rb +7 -7
- data/test/method_definer.rb +1 -1
- data/test/mini_test_result.rb +21 -21
- data/test/simple_counter.rb +5 -5
- data/test/test_helper.rb +1 -1
- data/test/test_runner.rb +22 -24
- data/test/test_unit_result.rb +20 -0
- data/test/unit/any_instance_method_test.rb +28 -32
- data/test/unit/array_inspect_test.rb +3 -3
- data/test/unit/backtrace_filter_test.rb +3 -3
- data/test/unit/cardinality_test.rb +12 -12
- data/test/unit/central_test.rb +18 -18
- data/test/unit/change_state_side_effect_test.rb +12 -12
- data/test/unit/class_method_test.rb +33 -91
- data/test/unit/date_time_inspect_test.rb +4 -4
- data/test/unit/exception_raiser_test.rb +5 -5
- data/test/unit/expectation_list_test.rb +7 -7
- data/test/unit/expectation_test.rb +66 -66
- data/test/unit/hash_inspect_test.rb +4 -4
- data/test/unit/in_state_ordering_constraint_test.rb +13 -13
- data/test/unit/method_matcher_test.rb +3 -3
- data/test/unit/mock_test.rb +40 -40
- data/test/unit/mockery_test.rb +25 -25
- data/test/unit/multiple_yields_test.rb +2 -2
- data/test/unit/no_yields_test.rb +2 -2
- data/test/unit/object_inspect_test.rb +4 -4
- data/test/unit/object_test.rb +15 -15
- data/test/unit/parameter_matchers/all_of_test.rb +6 -6
- data/test/unit/parameter_matchers/any_of_test.rb +6 -6
- data/test/unit/parameter_matchers/anything_test.rb +5 -5
- data/test/unit/parameter_matchers/has_entries_test.rb +10 -10
- data/test/unit/parameter_matchers/has_entry_test.rb +13 -13
- data/test/unit/parameter_matchers/has_key_test.rb +11 -11
- data/test/unit/parameter_matchers/has_value_test.rb +12 -12
- data/test/unit/parameter_matchers/includes_test.rb +4 -4
- data/test/unit/parameter_matchers/not_test.rb +6 -6
- data/test/unit/parameter_matchers/regexp_matches_test.rb +9 -9
- data/test/unit/parameter_matchers/responds_with_test.rb +6 -6
- data/test/unit/parameter_matchers/stub_matcher.rb +4 -4
- data/test/unit/parameter_matchers/yaml_equivalent_test.rb +6 -6
- data/test/unit/parameters_matcher_test.rb +16 -16
- data/test/unit/return_values_test.rb +5 -5
- data/test/unit/sequence_test.rb +10 -10
- data/test/unit/single_return_value_test.rb +3 -3
- data/test/unit/single_yield_test.rb +2 -2
- data/test/unit/state_machine_test.rb +19 -19
- data/test/unit/string_inspect_test.rb +2 -2
- data/test/unit/thrower_test.rb +1 -1
- data/test/unit/yield_parameters_test.rb +11 -11
- metadata +113 -101
@@ -4,15 +4,15 @@ require 'mocha'
|
|
4
4
|
class MockedMethodDispatchTest < Test::Unit::TestCase
|
5
5
|
|
6
6
|
include AcceptanceTest
|
7
|
-
|
7
|
+
|
8
8
|
def setup
|
9
9
|
setup_acceptance_test
|
10
10
|
end
|
11
|
-
|
11
|
+
|
12
12
|
def teardown
|
13
13
|
teardown_acceptance_test
|
14
14
|
end
|
15
|
-
|
15
|
+
|
16
16
|
def test_should_find_latest_matching_expectation
|
17
17
|
test_result = run_as_test do
|
18
18
|
mock = mock()
|
@@ -75,4 +75,4 @@ class MockedMethodDispatchTest < Test::Unit::TestCase
|
|
75
75
|
assert_passed(test_result)
|
76
76
|
end
|
77
77
|
|
78
|
-
end
|
78
|
+
end
|
@@ -2,17 +2,17 @@ require File.expand_path('../acceptance_test_helper', __FILE__)
|
|
2
2
|
require 'mocha'
|
3
3
|
|
4
4
|
class OptionalParameterMatcherTest < Test::Unit::TestCase
|
5
|
-
|
5
|
+
|
6
6
|
include AcceptanceTest
|
7
|
-
|
7
|
+
|
8
8
|
def setup
|
9
9
|
setup_acceptance_test
|
10
10
|
end
|
11
|
-
|
11
|
+
|
12
12
|
def teardown
|
13
13
|
teardown_acceptance_test
|
14
14
|
end
|
15
|
-
|
15
|
+
|
16
16
|
def test_should_pass_if_all_required_parameters_match_and_no_optional_parameters_are_supplied
|
17
17
|
test_result = run_as_test do
|
18
18
|
mock = mock()
|
@@ -67,4 +67,4 @@ class OptionalParameterMatcherTest < Test::Unit::TestCase
|
|
67
67
|
assert_failed(test_result)
|
68
68
|
end
|
69
69
|
|
70
|
-
end
|
70
|
+
end
|
@@ -2,17 +2,17 @@ require File.expand_path('../acceptance_test_helper', __FILE__)
|
|
2
2
|
require 'mocha'
|
3
3
|
|
4
4
|
class ParameterMatcherTest < Test::Unit::TestCase
|
5
|
-
|
5
|
+
|
6
6
|
include AcceptanceTest
|
7
|
-
|
7
|
+
|
8
8
|
def setup
|
9
9
|
setup_acceptance_test
|
10
10
|
end
|
11
|
-
|
11
|
+
|
12
12
|
def teardown
|
13
13
|
teardown_acceptance_test
|
14
14
|
end
|
15
|
-
|
15
|
+
|
16
16
|
def test_should_match_hash_parameter_with_specified_key
|
17
17
|
test_result = run_as_test do
|
18
18
|
mock = mock()
|
@@ -30,7 +30,7 @@ class ParameterMatcherTest < Test::Unit::TestCase
|
|
30
30
|
end
|
31
31
|
assert_failed(test_result)
|
32
32
|
end
|
33
|
-
|
33
|
+
|
34
34
|
def test_should_match_hash_parameter_with_specified_value
|
35
35
|
test_result = run_as_test do
|
36
36
|
mock = mock()
|
@@ -48,7 +48,7 @@ class ParameterMatcherTest < Test::Unit::TestCase
|
|
48
48
|
end
|
49
49
|
assert_failed(test_result)
|
50
50
|
end
|
51
|
-
|
51
|
+
|
52
52
|
def test_should_match_hash_parameter_with_specified_key_value_pair
|
53
53
|
test_result = run_as_test do
|
54
54
|
mock = mock()
|
@@ -66,7 +66,7 @@ class ParameterMatcherTest < Test::Unit::TestCase
|
|
66
66
|
end
|
67
67
|
assert_failed(test_result)
|
68
68
|
end
|
69
|
-
|
69
|
+
|
70
70
|
def test_should_match_hash_parameter_with_specified_hash_entry
|
71
71
|
test_result = run_as_test do
|
72
72
|
mock = mock()
|
@@ -84,7 +84,7 @@ class ParameterMatcherTest < Test::Unit::TestCase
|
|
84
84
|
end
|
85
85
|
assert_failed(test_result)
|
86
86
|
end
|
87
|
-
|
87
|
+
|
88
88
|
def test_should_match_hash_parameter_with_specified_entries
|
89
89
|
test_result = run_as_test do
|
90
90
|
mock = mock()
|
@@ -102,7 +102,7 @@ class ParameterMatcherTest < Test::Unit::TestCase
|
|
102
102
|
end
|
103
103
|
assert_failed(test_result)
|
104
104
|
end
|
105
|
-
|
105
|
+
|
106
106
|
def test_should_match_parameter_that_matches_regular_expression
|
107
107
|
test_result = run_as_test do
|
108
108
|
mock = mock()
|
@@ -120,7 +120,7 @@ class ParameterMatcherTest < Test::Unit::TestCase
|
|
120
120
|
end
|
121
121
|
assert_failed(test_result)
|
122
122
|
end
|
123
|
-
|
123
|
+
|
124
124
|
def test_should_match_hash_parameter_with_specified_entries_using_nested_matchers
|
125
125
|
test_result = run_as_test do
|
126
126
|
mock = mock()
|
@@ -129,7 +129,7 @@ class ParameterMatcherTest < Test::Unit::TestCase
|
|
129
129
|
end
|
130
130
|
assert_passed(test_result)
|
131
131
|
end
|
132
|
-
|
132
|
+
|
133
133
|
def test_should_not_match_hash_parameter_with_specified_entries_using_nested_matchers
|
134
134
|
test_result = run_as_test do
|
135
135
|
mock = mock()
|
@@ -138,7 +138,7 @@ class ParameterMatcherTest < Test::Unit::TestCase
|
|
138
138
|
end
|
139
139
|
assert_failed(test_result)
|
140
140
|
end
|
141
|
-
|
141
|
+
|
142
142
|
def test_should_match_parameter_that_matches_any_value
|
143
143
|
test_result = run_as_test do
|
144
144
|
mock = mock()
|
@@ -148,7 +148,7 @@ class ParameterMatcherTest < Test::Unit::TestCase
|
|
148
148
|
end
|
149
149
|
assert_passed(test_result)
|
150
150
|
end
|
151
|
-
|
151
|
+
|
152
152
|
def test_should_not_match_parameter_that_does_not_match_any_value
|
153
153
|
test_result = run_as_test do
|
154
154
|
mock = mock()
|
@@ -157,7 +157,7 @@ class ParameterMatcherTest < Test::Unit::TestCase
|
|
157
157
|
end
|
158
158
|
assert_failed(test_result)
|
159
159
|
end
|
160
|
-
|
160
|
+
|
161
161
|
def test_should_match_parameter_that_matches_any_of_the_given_matchers
|
162
162
|
test_result = run_as_test do
|
163
163
|
mock = mock()
|
@@ -167,7 +167,7 @@ class ParameterMatcherTest < Test::Unit::TestCase
|
|
167
167
|
end
|
168
168
|
assert_passed(test_result)
|
169
169
|
end
|
170
|
-
|
170
|
+
|
171
171
|
def test_should_not_match_parameter_that_does_not_match_any_of_the_given_matchers
|
172
172
|
test_result = run_as_test do
|
173
173
|
mock = mock()
|
@@ -185,7 +185,7 @@ class ParameterMatcherTest < Test::Unit::TestCase
|
|
185
185
|
end
|
186
186
|
assert_passed(test_result)
|
187
187
|
end
|
188
|
-
|
188
|
+
|
189
189
|
def test_should_not_match_parameter_that_does_not_match_all_values
|
190
190
|
test_result = run_as_test do
|
191
191
|
mock = mock()
|
@@ -194,7 +194,7 @@ class ParameterMatcherTest < Test::Unit::TestCase
|
|
194
194
|
end
|
195
195
|
assert_failed(test_result)
|
196
196
|
end
|
197
|
-
|
197
|
+
|
198
198
|
def test_should_match_parameter_that_matches_all_matchers
|
199
199
|
test_result = run_as_test do
|
200
200
|
mock = mock()
|
@@ -203,7 +203,7 @@ class ParameterMatcherTest < Test::Unit::TestCase
|
|
203
203
|
end
|
204
204
|
assert_passed(test_result)
|
205
205
|
end
|
206
|
-
|
206
|
+
|
207
207
|
def test_should_not_match_parameter_that_does_not_match_all_matchers
|
208
208
|
test_result = run_as_test do
|
209
209
|
mock = mock()
|
@@ -2,26 +2,26 @@ require File.expand_path('../acceptance_test_helper', __FILE__)
|
|
2
2
|
require 'mocha'
|
3
3
|
|
4
4
|
class PartialMockTest < Test::Unit::TestCase
|
5
|
-
|
5
|
+
|
6
6
|
include AcceptanceTest
|
7
|
-
|
7
|
+
|
8
8
|
def setup
|
9
9
|
setup_acceptance_test
|
10
10
|
end
|
11
|
-
|
11
|
+
|
12
12
|
def teardown
|
13
13
|
teardown_acceptance_test
|
14
14
|
end
|
15
|
-
|
15
|
+
|
16
16
|
def test_should_pass_if_all_expectations_are_satisfied
|
17
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
|
+
|
21
21
|
partial_mock_one.expects(:first)
|
22
22
|
partial_mock_one.expects(:second)
|
23
23
|
partial_mock_two.expects(:third)
|
24
|
-
|
24
|
+
|
25
25
|
partial_mock_one.first
|
26
26
|
partial_mock_one.second
|
27
27
|
partial_mock_two.third
|
@@ -33,15 +33,15 @@ class PartialMockTest < Test::Unit::TestCase
|
|
33
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
|
+
|
37
37
|
partial_mock_one.expects(:first)
|
38
38
|
partial_mock_one.expects(:second)
|
39
39
|
partial_mock_two.expects(:third)
|
40
|
-
|
40
|
+
|
41
41
|
partial_mock_one.first
|
42
42
|
partial_mock_two.third
|
43
43
|
end
|
44
44
|
assert_failed(test_result)
|
45
45
|
end
|
46
46
|
|
47
|
-
end
|
47
|
+
end
|
@@ -2,17 +2,17 @@ require File.expand_path('../acceptance_test_helper', __FILE__)
|
|
2
2
|
require 'mocha'
|
3
3
|
|
4
4
|
class ReturnValueTest < Test::Unit::TestCase
|
5
|
-
|
5
|
+
|
6
6
|
include AcceptanceTest
|
7
|
-
|
7
|
+
|
8
8
|
def setup
|
9
9
|
setup_acceptance_test
|
10
10
|
end
|
11
|
-
|
11
|
+
|
12
12
|
def teardown
|
13
13
|
teardown_acceptance_test
|
14
14
|
end
|
15
|
-
|
15
|
+
|
16
16
|
def test_should_build_mock_and_explicitly_add_an_expectation_with_a_return_value
|
17
17
|
test_result = run_as_test do
|
18
18
|
foo = mock('foo')
|
@@ -49,4 +49,4 @@ class ReturnValueTest < Test::Unit::TestCase
|
|
49
49
|
assert_passed(test_result)
|
50
50
|
end
|
51
51
|
|
52
|
-
end
|
52
|
+
end
|
@@ -2,25 +2,25 @@ require File.expand_path('../acceptance_test_helper', __FILE__)
|
|
2
2
|
require 'mocha'
|
3
3
|
|
4
4
|
class SequenceTest < Test::Unit::TestCase
|
5
|
-
|
5
|
+
|
6
6
|
include AcceptanceTest
|
7
|
-
|
7
|
+
|
8
8
|
def setup
|
9
9
|
setup_acceptance_test
|
10
10
|
end
|
11
|
-
|
11
|
+
|
12
12
|
def teardown
|
13
13
|
teardown_acceptance_test
|
14
14
|
end
|
15
|
-
|
15
|
+
|
16
16
|
def test_should_constrain_invocations_to_occur_in_expected_order
|
17
17
|
test_result = run_as_test do
|
18
18
|
mock = mock()
|
19
19
|
sequence = sequence('one')
|
20
|
-
|
20
|
+
|
21
21
|
mock.expects(:first).in_sequence(sequence)
|
22
22
|
mock.expects(:second).in_sequence(sequence)
|
23
|
-
|
23
|
+
|
24
24
|
mock.second
|
25
25
|
mock.first
|
26
26
|
end
|
@@ -31,10 +31,10 @@ class SequenceTest < Test::Unit::TestCase
|
|
31
31
|
test_result = run_as_test do
|
32
32
|
mock = mock()
|
33
33
|
sequence = sequence('one')
|
34
|
-
|
34
|
+
|
35
35
|
mock.expects(:first).in_sequence(sequence)
|
36
36
|
mock.expects(:second).in_sequence(sequence)
|
37
|
-
|
37
|
+
|
38
38
|
mock.first
|
39
39
|
mock.second
|
40
40
|
end
|
@@ -46,10 +46,10 @@ class SequenceTest < Test::Unit::TestCase
|
|
46
46
|
mock_one = mock('1')
|
47
47
|
mock_two = mock('2')
|
48
48
|
sequence = sequence('one')
|
49
|
-
|
49
|
+
|
50
50
|
mock_one.expects(:first).in_sequence(sequence)
|
51
51
|
mock_two.expects(:second).in_sequence(sequence)
|
52
|
-
|
52
|
+
|
53
53
|
mock_two.second
|
54
54
|
mock_one.first
|
55
55
|
end
|
@@ -61,10 +61,10 @@ class SequenceTest < Test::Unit::TestCase
|
|
61
61
|
mock_one = mock('1')
|
62
62
|
mock_two = mock('2')
|
63
63
|
sequence = sequence('one')
|
64
|
-
|
64
|
+
|
65
65
|
mock_one.expects(:first).in_sequence(sequence)
|
66
66
|
mock_two.expects(:second).in_sequence(sequence)
|
67
|
-
|
67
|
+
|
68
68
|
mock_one.first
|
69
69
|
mock_two.second
|
70
70
|
end
|
@@ -76,10 +76,10 @@ class SequenceTest < Test::Unit::TestCase
|
|
76
76
|
partial_mock_one = "1"
|
77
77
|
partial_mock_two = "2"
|
78
78
|
sequence = sequence('one')
|
79
|
-
|
79
|
+
|
80
80
|
partial_mock_one.expects(:first).in_sequence(sequence)
|
81
81
|
partial_mock_two.expects(:second).in_sequence(sequence)
|
82
|
-
|
82
|
+
|
83
83
|
partial_mock_two.second
|
84
84
|
partial_mock_one.first
|
85
85
|
end
|
@@ -91,10 +91,10 @@ class SequenceTest < Test::Unit::TestCase
|
|
91
91
|
partial_mock_one = "1"
|
92
92
|
partial_mock_two = "2"
|
93
93
|
sequence = sequence('one')
|
94
|
-
|
94
|
+
|
95
95
|
partial_mock_one.expects(:first).in_sequence(sequence)
|
96
96
|
partial_mock_two.expects(:second).in_sequence(sequence)
|
97
|
-
|
97
|
+
|
98
98
|
partial_mock_one.first
|
99
99
|
partial_mock_two.second
|
100
100
|
end
|
@@ -105,11 +105,11 @@ class SequenceTest < Test::Unit::TestCase
|
|
105
105
|
test_result = run_as_test do
|
106
106
|
mock = mock()
|
107
107
|
sequence = sequence('one')
|
108
|
-
|
108
|
+
|
109
109
|
mock.expects(:first).in_sequence(sequence)
|
110
110
|
mock.stubs(:second).in_sequence(sequence)
|
111
111
|
mock.expects(:third).in_sequence(sequence)
|
112
|
-
|
112
|
+
|
113
113
|
mock.first
|
114
114
|
mock.third
|
115
115
|
end
|
@@ -121,13 +121,13 @@ class SequenceTest < Test::Unit::TestCase
|
|
121
121
|
mock = mock()
|
122
122
|
sequence_one = sequence('one')
|
123
123
|
sequence_two = sequence('two')
|
124
|
-
|
124
|
+
|
125
125
|
mock.expects(:first).in_sequence(sequence_one)
|
126
126
|
mock.expects(:second).in_sequence(sequence_one)
|
127
|
-
|
127
|
+
|
128
128
|
mock.expects(:third).in_sequence(sequence_two)
|
129
129
|
mock.expects(:fourth).in_sequence(sequence_two)
|
130
|
-
|
130
|
+
|
131
131
|
mock.first
|
132
132
|
mock.third
|
133
133
|
mock.second
|
@@ -135,15 +135,15 @@ class SequenceTest < Test::Unit::TestCase
|
|
135
135
|
end
|
136
136
|
assert_passed(test_result)
|
137
137
|
end
|
138
|
-
|
138
|
+
|
139
139
|
def test_should_include_sequence_in_failure_message
|
140
140
|
test_result = run_as_test do
|
141
141
|
mock = mock()
|
142
142
|
sequence = sequence('one')
|
143
|
-
|
143
|
+
|
144
144
|
mock.expects(:first).in_sequence(sequence)
|
145
145
|
mock.expects(:second).in_sequence(sequence)
|
146
|
-
|
146
|
+
|
147
147
|
mock.second
|
148
148
|
mock.first
|
149
149
|
end
|
@@ -156,11 +156,11 @@ class SequenceTest < Test::Unit::TestCase
|
|
156
156
|
mock = mock()
|
157
157
|
sequence_one = sequence('one')
|
158
158
|
sequence_two = sequence('two')
|
159
|
-
|
159
|
+
|
160
160
|
mock.expects(:first).in_sequence(sequence_one)
|
161
161
|
mock.expects(:second).in_sequence(sequence_two)
|
162
162
|
mock.expects(:third).in_sequence(sequence_one).in_sequence(sequence_two)
|
163
|
-
|
163
|
+
|
164
164
|
mock.first
|
165
165
|
mock.third
|
166
166
|
mock.second
|
@@ -175,11 +175,11 @@ class SequenceTest < Test::Unit::TestCase
|
|
175
175
|
mock = mock()
|
176
176
|
sequence_one = sequence('one')
|
177
177
|
sequence_two = sequence('two')
|
178
|
-
|
178
|
+
|
179
179
|
mock.expects(:first).in_sequence(sequence_one)
|
180
180
|
mock.expects(:second).in_sequence(sequence_two)
|
181
181
|
mock.expects(:third).in_sequence(sequence_one, sequence_two)
|
182
|
-
|
182
|
+
|
183
183
|
mock.first
|
184
184
|
mock.third
|
185
185
|
mock.second
|
@@ -189,4 +189,4 @@ class SequenceTest < Test::Unit::TestCase
|
|
189
189
|
assert_match Regexp.new("in sequence 'two'"), test_result.failures.first.message
|
190
190
|
end
|
191
191
|
|
192
|
-
end
|
192
|
+
end
|