mocha-macruby 0.9.8.20100129120100 → 0.9.9.20101102121900
Sign up to get free protection for your applications and to get access to all the features.
- data/COPYING.rdoc +3 -0
- data/{MIT-LICENSE → MIT-LICENSE.rdoc} +0 -0
- data/{README → README.rdoc} +7 -7
- data/{RELEASE → RELEASE.rdoc} +18 -0
- data/Rakefile +44 -28
- data/lib/mocha.rb +1 -0
- data/lib/mocha/class_method.rb +1 -3
- data/lib/mocha/expectation.rb +37 -34
- data/lib/mocha/integration/mini_test.rb +32 -4
- data/lib/mocha/integration/mini_test/exception_translation.rb +20 -0
- data/lib/mocha/integration/mini_test/{version_131_and_above.rb → version_13.rb} +7 -13
- data/lib/mocha/integration/mini_test/version_140.rb +52 -0
- data/lib/mocha/integration/mini_test/version_141.rb +56 -0
- data/lib/mocha/integration/mini_test/version_142_and_above.rb +47 -0
- data/lib/mocha/integration/test_unit.rb +23 -8
- data/lib/mocha/integration/test_unit/gem_version_200.rb +3 -0
- data/lib/mocha/integration/test_unit/{gem_version_201_and_above.rb → gem_version_201_to_202.rb} +4 -1
- data/lib/mocha/integration/test_unit/gem_version_203_to_209.rb +52 -0
- data/lib/mocha/integration/test_unit/ruby_version_185_and_below.rb +3 -0
- data/lib/mocha/integration/test_unit/ruby_version_186_and_above.rb +3 -0
- data/lib/mocha/mock.rb +33 -18
- data/lib/mocha/module_method.rb +1 -1
- data/lib/mocha/object.rb +144 -160
- data/lib/mocha/options.rb +1 -0
- data/lib/mocha/parameter_matchers/base.rb +50 -2
- data/test/acceptance/acceptance_test_helper.rb +1 -1
- data/test/acceptance/api_test.rb +1 -1
- data/test/acceptance/bug_18914_test.rb +1 -1
- data/test/acceptance/bug_21465_test.rb +1 -1
- data/test/acceptance/bug_21563_test.rb +1 -1
- data/test/acceptance/expected_invocation_count_test.rb +1 -1
- data/test/acceptance/failure_messages_test.rb +1 -1
- data/test/acceptance/minitest_test.rb +128 -124
- data/test/acceptance/mocha_example_test.rb +1 -1
- data/test/acceptance/mocha_test_result_test.rb +1 -1
- data/test/acceptance/mock_test.rb +1 -1
- data/test/acceptance/mock_with_initializer_block_test.rb +1 -1
- data/test/acceptance/mocked_methods_dispatch_test.rb +1 -1
- data/test/acceptance/optional_parameters_test.rb +1 -1
- data/test/acceptance/parameter_matcher_test.rb +38 -1
- data/test/acceptance/partial_mocks_test.rb +1 -1
- data/test/acceptance/return_value_test.rb +1 -1
- data/test/acceptance/sequence_test.rb +1 -1
- data/test/acceptance/states_test.rb +1 -1
- data/test/acceptance/stub_any_instance_method_test.rb +5 -2
- data/test/acceptance/stub_class_method_test.rb +5 -2
- data/test/acceptance/stub_everything_test.rb +1 -1
- data/test/acceptance/stub_instance_method_test.rb +5 -2
- data/test/acceptance/stub_module_method_test.rb +3 -3
- data/test/acceptance/stub_test.rb +1 -1
- data/test/acceptance/stubba_example_test.rb +1 -1
- data/test/acceptance/stubba_test.rb +1 -1
- data/test/acceptance/stubba_test_result_test.rb +1 -1
- data/test/acceptance/stubbing_error_backtrace_test.rb +1 -1
- data/test/acceptance/stubbing_method_unnecessarily_test.rb +1 -1
- data/test/acceptance/stubbing_non_existent_any_instance_method_test.rb +5 -5
- data/test/acceptance/stubbing_non_existent_class_method_test.rb +5 -5
- data/test/acceptance/stubbing_non_existent_instance_method_test.rb +5 -5
- data/test/acceptance/stubbing_non_public_any_instance_method_test.rb +9 -9
- data/test/acceptance/stubbing_non_public_class_method_test.rb +9 -9
- data/test/acceptance/stubbing_non_public_instance_method_test.rb +9 -9
- data/test/acceptance/stubbing_on_non_mock_object_test.rb +5 -5
- data/test/mini_test_result.rb +74 -0
- data/test/test_helper.rb +3 -1
- data/test/test_runner.rb +25 -11
- data/test/unit/any_instance_method_test.rb +1 -1
- data/test/unit/array_inspect_test.rb +1 -1
- data/test/unit/backtrace_filter_test.rb +1 -1
- data/test/unit/cardinality_test.rb +1 -1
- data/test/unit/central_test.rb +1 -1
- data/test/unit/change_state_side_effect_test.rb +1 -1
- data/test/unit/class_method_test.rb +2 -2
- data/test/unit/configuration_test.rb +1 -1
- data/test/unit/date_time_inspect_test.rb +1 -1
- data/test/unit/exception_raiser_test.rb +1 -1
- data/test/unit/expectation_list_test.rb +1 -1
- data/test/unit/expectation_test.rb +1 -1
- data/test/unit/hash_inspect_test.rb +1 -1
- data/test/unit/in_state_ordering_constraint_test.rb +1 -1
- data/test/unit/metaclass_test.rb +1 -1
- data/test/unit/method_matcher_test.rb +1 -1
- data/test/unit/mock_test.rb +16 -14
- data/test/unit/mockery_test.rb +1 -1
- data/test/unit/multiple_yields_test.rb +1 -1
- data/test/unit/no_yields_test.rb +1 -1
- data/test/unit/object_inspect_test.rb +10 -9
- data/test/unit/object_test.rb +11 -10
- data/test/unit/parameter_matchers/all_of_test.rb +1 -1
- data/test/unit/parameter_matchers/any_of_test.rb +1 -1
- data/test/unit/parameter_matchers/anything_test.rb +1 -1
- data/test/unit/parameter_matchers/equals_test.rb +1 -1
- data/test/unit/parameter_matchers/has_entries_test.rb +1 -1
- data/test/unit/parameter_matchers/has_entry_test.rb +1 -1
- data/test/unit/parameter_matchers/has_key_test.rb +1 -1
- data/test/unit/parameter_matchers/has_value_test.rb +1 -1
- data/test/unit/parameter_matchers/includes_test.rb +5 -5
- data/test/unit/parameter_matchers/instance_of_test.rb +2 -2
- data/test/unit/parameter_matchers/is_a_test.rb +1 -1
- data/test/unit/parameter_matchers/kind_of_test.rb +1 -1
- data/test/unit/parameter_matchers/not_test.rb +1 -1
- data/test/unit/parameter_matchers/regexp_matches_test.rb +1 -1
- data/test/unit/parameter_matchers/responds_with_test.rb +1 -1
- data/test/unit/parameter_matchers/yaml_equivalent_test.rb +1 -1
- data/test/unit/parameters_matcher_test.rb +1 -1
- data/test/unit/return_values_test.rb +1 -1
- data/test/unit/sequence_test.rb +1 -1
- data/test/unit/single_return_value_test.rb +1 -1
- data/test/unit/single_yield_test.rb +1 -1
- data/test/unit/state_machine_test.rb +1 -1
- data/test/unit/string_inspect_test.rb +1 -1
- data/test/unit/yield_parameters_test.rb +1 -1
- metadata +43 -19
- data/COPYING +0 -3
data/lib/mocha/module_method.rb
CHANGED
data/lib/mocha/object.rb
CHANGED
@@ -5,183 +5,167 @@ require 'mocha/module_method'
|
|
5
5
|
require 'mocha/any_instance_method'
|
6
6
|
require 'mocha/argument_iterator'
|
7
7
|
|
8
|
-
|
9
|
-
|
10
|
-
|
8
|
+
# Methods added all objects to allow mocking and stubbing on real objects.
|
9
|
+
#
|
10
|
+
# Methods return a Mocha::Expectation which can be further modified by methods on Mocha::Expectation.
|
11
|
+
class Object
|
12
|
+
|
13
|
+
def mocha # :nodoc:
|
14
|
+
@mocha ||= Mocha::Mockery.instance.mock_impersonating(self)
|
15
|
+
end
|
16
|
+
|
17
|
+
def reset_mocha # :nodoc:
|
18
|
+
@mocha = nil
|
19
|
+
end
|
20
|
+
|
21
|
+
def stubba_method # :nodoc:
|
22
|
+
Mocha::InstanceMethod
|
23
|
+
end
|
24
|
+
|
25
|
+
def stubba_object # :nodoc:
|
26
|
+
self
|
27
|
+
end
|
28
|
+
|
29
|
+
# :call-seq: expects(method_name) -> expectation
|
30
|
+
# expects(method_names_vs_return_values) -> last expectation
|
11
31
|
#
|
12
|
-
#
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
32
|
+
# Adds an expectation that a method identified by +method_name+ Symbol must be called exactly once with any parameters.
|
33
|
+
# Returns the new expectation which can be further modified by methods on Mocha::Expectation.
|
34
|
+
# product = Product.new
|
35
|
+
# product.expects(:save).returns(true)
|
36
|
+
# assert_equal true, product.save
|
37
|
+
#
|
38
|
+
# The original implementation of <tt>Product#save</tt> is replaced temporarily.
|
39
|
+
#
|
40
|
+
# The original implementation of <tt>Product#save</tt> is restored at the end of the test.
|
41
|
+
#
|
42
|
+
# If +method_names_vs_return_values+ is a +Hash+, an expectation will be set up for each entry using the key as +method_name+ and value as +return_value+.
|
43
|
+
# product = Product.new
|
44
|
+
# product.expects(:valid? => true, :save => true)
|
45
|
+
#
|
46
|
+
# # exactly equivalent to
|
47
|
+
#
|
48
|
+
# product = Product.new
|
49
|
+
# product.expects(:valid?).returns(true)
|
50
|
+
# product.expects(:save).returns(true)
|
51
|
+
def expects(method_name_or_hash)
|
52
|
+
expectation = nil
|
53
|
+
mockery = Mocha::Mockery.instance
|
54
|
+
iterator = Mocha::ArgumentIterator.new(method_name_or_hash)
|
55
|
+
iterator.each { |*args|
|
56
|
+
method_name = args.shift
|
57
|
+
mockery.on_stubbing(self, method_name)
|
58
|
+
method = stubba_method.new(stubba_object, method_name)
|
59
|
+
mockery.stubba.stub(method)
|
60
|
+
expectation = mocha.expects(method_name, caller)
|
61
|
+
expectation.returns(args.shift) if args.length > 0
|
62
|
+
}
|
63
|
+
expectation
|
64
|
+
end
|
65
|
+
|
66
|
+
# :call-seq: stubs(method_name) -> expectation
|
67
|
+
# stubs(method_names_vs_return_values) -> last expectation
|
68
|
+
#
|
69
|
+
# Adds an expectation that a method identified by +method_name+ Symbol may be called any number of times with any parameters.
|
70
|
+
# Returns the new expectation which can be further modified by methods on Mocha::Expectation.
|
71
|
+
# product = Product.new
|
72
|
+
# product.stubs(:save).returns(true)
|
73
|
+
# assert_equal true, product.save
|
74
|
+
#
|
75
|
+
# The original implementation of <tt>Product#save</tt> is replaced temporarily.
|
76
|
+
#
|
77
|
+
# The original implementation of <tt>Product#save</tt> is restored at the end of the test.
|
78
|
+
#
|
79
|
+
# If +method_names_vs_return_values+ is a +Hash+, an expectation will be set up for each entry using the key as +method_name+ and value as +return_value+.
|
80
|
+
# product = Product.new
|
81
|
+
# product.stubs(:valid? => true, :save => true)
|
82
|
+
#
|
83
|
+
# # exactly equivalent to
|
84
|
+
#
|
85
|
+
# product = Product.new
|
86
|
+
# product.stubs(:valid?).returns(true)
|
87
|
+
# product.stubs(:save).returns(true)
|
88
|
+
def stubs(method_name_or_hash)
|
89
|
+
expectation = nil
|
90
|
+
mockery = Mocha::Mockery.instance
|
91
|
+
iterator = Mocha::ArgumentIterator.new(method_name_or_hash)
|
92
|
+
iterator.each { |*args|
|
93
|
+
method_name = args.shift
|
94
|
+
mockery.on_stubbing(self, method_name)
|
95
|
+
method = stubba_method.new(stubba_object, method_name)
|
96
|
+
mockery.stubba.stub(method)
|
97
|
+
expectation = mocha.stubs(method_name, caller)
|
98
|
+
expectation.returns(args.shift) if args.length > 0
|
99
|
+
}
|
100
|
+
expectation
|
101
|
+
end
|
102
|
+
|
103
|
+
def method_exists?(method, include_public_methods = true) # :nodoc:
|
104
|
+
if include_public_methods
|
105
|
+
return true if public_methods(include_superclass_methods = true).include?(method)
|
106
|
+
return true if respond_to?(method.to_sym)
|
17
107
|
end
|
108
|
+
return true if protected_methods(include_superclass_methods = true).include?(method)
|
109
|
+
return true if private_methods(include_superclass_methods = true).include?(method)
|
110
|
+
return false
|
111
|
+
end
|
112
|
+
|
113
|
+
end
|
114
|
+
|
115
|
+
class Module # :nodoc:
|
18
116
|
|
19
|
-
|
20
|
-
|
21
|
-
|
117
|
+
def stubba_method
|
118
|
+
Mocha::ModuleMethod
|
119
|
+
end
|
22
120
|
|
23
|
-
|
24
|
-
|
25
|
-
|
121
|
+
end
|
122
|
+
|
123
|
+
# Methods added all classes to allow mocking and stubbing on real objects.
|
124
|
+
class Class
|
125
|
+
|
126
|
+
def stubba_method # :nodoc:
|
127
|
+
Mocha::ClassMethod
|
128
|
+
end
|
129
|
+
|
130
|
+
class AnyInstance # :nodoc:
|
26
131
|
|
27
|
-
def
|
28
|
-
|
132
|
+
def initialize(klass)
|
133
|
+
@stubba_object = klass
|
29
134
|
end
|
30
135
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
# product.expects(:save).returns(true)
|
38
|
-
# assert_equal true, product.save
|
39
|
-
#
|
40
|
-
# The original implementation of <tt>Product#save</tt> is replaced temporarily.
|
41
|
-
#
|
42
|
-
# The original implementation of <tt>Product#save</tt> is restored at the end of the test.
|
43
|
-
#
|
44
|
-
# If +method_names_vs_return_values+ is a +Hash+, an expectation will be set up for each entry using the key as +method_name+ and value as +return_value+.
|
45
|
-
# product = Product.new
|
46
|
-
# product.expects(:valid? => true, :save => true)
|
47
|
-
#
|
48
|
-
# # exactly equivalent to
|
49
|
-
#
|
50
|
-
# product = Product.new
|
51
|
-
# product.expects(:valid?).returns(true)
|
52
|
-
# product.expects(:save).returns(true)
|
53
|
-
def expects(method_name_or_hash)
|
54
|
-
expectation = nil
|
55
|
-
mockery = Mocha::Mockery.instance
|
56
|
-
iterator = ArgumentIterator.new(method_name_or_hash)
|
57
|
-
iterator.each { |*args|
|
58
|
-
method_name = args.shift
|
59
|
-
mockery.on_stubbing(self, method_name)
|
60
|
-
method = stubba_method.new(stubba_object, method_name)
|
61
|
-
mockery.stubba.stub(method)
|
62
|
-
expectation = mocha.expects(method_name, caller)
|
63
|
-
expectation.returns(args.shift) if args.length > 0
|
64
|
-
}
|
65
|
-
expectation
|
136
|
+
def mocha
|
137
|
+
@mocha ||= Mocha::Mockery.instance.mock_impersonating_any_instance_of(@stubba_object)
|
138
|
+
end
|
139
|
+
|
140
|
+
def stubba_method
|
141
|
+
Mocha::AnyInstanceMethod
|
66
142
|
end
|
67
143
|
|
68
|
-
|
69
|
-
|
70
|
-
#
|
71
|
-
# Adds an expectation that a method identified by +method_name+ Symbol may be called any number of times with any parameters.
|
72
|
-
# Returns the new expectation which can be further modified by methods on Mocha::Expectation.
|
73
|
-
# product = Product.new
|
74
|
-
# product.stubs(:save).returns(true)
|
75
|
-
# assert_equal true, product.save
|
76
|
-
#
|
77
|
-
# The original implementation of <tt>Product#save</tt> is replaced temporarily.
|
78
|
-
#
|
79
|
-
# The original implementation of <tt>Product#save</tt> is restored at the end of the test.
|
80
|
-
#
|
81
|
-
# If +method_names_vs_return_values+ is a +Hash+, an expectation will be set up for each entry using the key as +method_name+ and value as +return_value+.
|
82
|
-
# product = Product.new
|
83
|
-
# product.stubs(:valid? => true, :save => true)
|
84
|
-
#
|
85
|
-
# # exactly equivalent to
|
86
|
-
#
|
87
|
-
# product = Product.new
|
88
|
-
# product.stubs(:valid?).returns(true)
|
89
|
-
# product.stubs(:save).returns(true)
|
90
|
-
def stubs(method_name_or_hash)
|
91
|
-
expectation = nil
|
92
|
-
mockery = Mocha::Mockery.instance
|
93
|
-
iterator = ArgumentIterator.new(method_name_or_hash)
|
94
|
-
iterator.each { |*args|
|
95
|
-
method_name = args.shift
|
96
|
-
mockery.on_stubbing(self, method_name)
|
97
|
-
method = stubba_method.new(stubba_object, method_name)
|
98
|
-
mockery.stubba.stub(method)
|
99
|
-
expectation = mocha.stubs(method_name, caller)
|
100
|
-
expectation.returns(args.shift) if args.length > 0
|
101
|
-
}
|
102
|
-
expectation
|
144
|
+
def stubba_object
|
145
|
+
@stubba_object
|
103
146
|
end
|
104
147
|
|
105
|
-
def method_exists?(method, include_public_methods = true)
|
148
|
+
def method_exists?(method, include_public_methods = true)
|
106
149
|
if include_public_methods
|
107
|
-
return true if
|
108
|
-
return true if respond_to?(method.to_sym)
|
150
|
+
return true if @stubba_object.public_instance_methods(include_superclass_methods = true).include?(method)
|
109
151
|
end
|
110
|
-
return true if
|
111
|
-
return true if
|
152
|
+
return true if @stubba_object.protected_instance_methods(include_superclass_methods = true).include?(method)
|
153
|
+
return true if @stubba_object.private_instance_methods(include_superclass_methods = true).include?(method)
|
112
154
|
return false
|
113
155
|
end
|
114
156
|
|
115
157
|
end
|
116
|
-
|
117
|
-
module ModuleMethods # :nodoc:
|
118
|
-
|
119
|
-
def stubba_method
|
120
|
-
Mocha::ModuleMethod
|
121
|
-
end
|
122
|
-
|
123
|
-
end
|
124
|
-
|
125
|
-
# Methods added all classes to allow mocking and stubbing on real objects.
|
126
|
-
module ClassMethods
|
127
|
-
|
128
|
-
def stubba_method # :nodoc:
|
129
|
-
Mocha::ClassMethod
|
130
|
-
end
|
131
|
-
|
132
|
-
class AnyInstance # :nodoc:
|
133
|
-
|
134
|
-
def initialize(klass)
|
135
|
-
@stubba_object = klass
|
136
|
-
end
|
137
|
-
|
138
|
-
def mocha
|
139
|
-
@mocha ||= Mocha::Mockery.instance.mock_impersonating_any_instance_of(@stubba_object)
|
140
|
-
end
|
141
158
|
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
return true if @stubba_object.public_instance_methods(include_superclass_methods = true).include?(method)
|
153
|
-
end
|
154
|
-
return true if @stubba_object.protected_instance_methods(include_superclass_methods = true).include?(method)
|
155
|
-
return true if @stubba_object.private_instance_methods(include_superclass_methods = true).include?(method)
|
156
|
-
return false
|
157
|
-
end
|
158
|
-
|
159
|
-
end
|
160
|
-
|
161
|
-
# :call-seq: any_instance -> mock object
|
162
|
-
#
|
163
|
-
# Returns a mock object which will detect calls to any instance of this class.
|
164
|
-
# Product.any_instance.stubs(:save).returns(false)
|
165
|
-
# product_1 = Product.new
|
166
|
-
# assert_equal false, product_1.save
|
167
|
-
# product_2 = Product.new
|
168
|
-
# assert_equal false, product_2.save
|
169
|
-
def any_instance
|
170
|
-
@any_instance ||= AnyInstance.new(self)
|
171
|
-
end
|
172
|
-
|
159
|
+
# :call-seq: any_instance -> mock object
|
160
|
+
#
|
161
|
+
# Returns a mock object which will detect calls to any instance of this class.
|
162
|
+
# Product.any_instance.stubs(:save).returns(false)
|
163
|
+
# product_1 = Product.new
|
164
|
+
# assert_equal false, product_1.save
|
165
|
+
# product_2 = Product.new
|
166
|
+
# assert_equal false, product_2.save
|
167
|
+
def any_instance
|
168
|
+
@any_instance ||= AnyInstance.new(self)
|
173
169
|
end
|
174
|
-
|
175
|
-
end
|
176
|
-
|
177
|
-
class Object # :nodoc:
|
178
|
-
include Mocha::ObjectMethods
|
179
|
-
end
|
180
170
|
|
181
|
-
|
182
|
-
include Mocha::ModuleMethods
|
183
|
-
end
|
184
|
-
|
185
|
-
class Class # :nodoc:
|
186
|
-
include Mocha::ClassMethods
|
187
|
-
end
|
171
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
$options = (ENV['MOCHA_OPTIONS'] || '').split(',').inject({}) { |hash, key| hash[key] = true; hash }
|
@@ -2,12 +2,60 @@ module Mocha
|
|
2
2
|
|
3
3
|
module ParameterMatchers
|
4
4
|
|
5
|
-
class Base
|
5
|
+
class Base
|
6
6
|
|
7
|
-
def to_matcher
|
7
|
+
def to_matcher # :nodoc:
|
8
8
|
self
|
9
9
|
end
|
10
10
|
|
11
|
+
# :call-seq: &(matcher) -> parameter_matcher
|
12
|
+
#
|
13
|
+
# A short hand way of specifying multiple matchers that should
|
14
|
+
# all match.
|
15
|
+
#
|
16
|
+
# Returns a new +AllOf+ parameter matcher combining the
|
17
|
+
# given matcher and the receiver.
|
18
|
+
#
|
19
|
+
# The following statements are equivalent:
|
20
|
+
# object = mock()
|
21
|
+
# object.expects(:run).with(all_of(has_key(:foo), has_key(:bar)))
|
22
|
+
# object.run(:foo => 'foovalue', :bar => 'barvalue')
|
23
|
+
#
|
24
|
+
# # with the shorthand
|
25
|
+
# object.expects(:run).with(has_key(:foo) & has_key(:bar))
|
26
|
+
# object.run(:foo => 'foovalue', :bar => 'barvalue)
|
27
|
+
def &(matcher)
|
28
|
+
AllOf.new(self, matcher)
|
29
|
+
end
|
30
|
+
|
31
|
+
# :call-seq: |(matcher) -> parameter_matcher
|
32
|
+
#
|
33
|
+
# A short hand way of specifying multiple matchers, only at least
|
34
|
+
# one of which should pass.
|
35
|
+
#
|
36
|
+
# Returns a new +AnyOf+ parameter matcher combining the
|
37
|
+
# given matcher and the receiver.
|
38
|
+
#
|
39
|
+
# The following statements are equivalent:
|
40
|
+
# object = mock()
|
41
|
+
# object.expects(:run).with(any_of(has_key(:foo), has_key(:bar)))
|
42
|
+
# object.run(:foo => 'foovalue')
|
43
|
+
#
|
44
|
+
# # with the shorthand
|
45
|
+
# object.expects(:run).with(has_key(:foo) | has_key(:bar))
|
46
|
+
# object.run(:foo => 'foovalue')
|
47
|
+
#
|
48
|
+
# This shorthand will not work with an implicit equals match. Instead,
|
49
|
+
# an explicit equals matcher should be used:
|
50
|
+
#
|
51
|
+
# object.expects(:run).with(equals(1) | equals(2))
|
52
|
+
# object.run(1) # passes
|
53
|
+
# object.run(2) # passes
|
54
|
+
# object.run(3) # fails
|
55
|
+
def |(matcher)
|
56
|
+
AnyOf.new(self, matcher)
|
57
|
+
end
|
58
|
+
|
11
59
|
end
|
12
60
|
|
13
61
|
end
|
data/test/acceptance/api_test.rb
CHANGED