mocha 0.5.6 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (120) hide show
  1. data/README +4 -4
  2. data/RELEASE +45 -0
  3. data/Rakefile +55 -33
  4. data/lib/mocha.rb +1 -0
  5. data/lib/mocha/any_instance_method.rb +24 -4
  6. data/lib/mocha/backtrace_filter.rb +17 -0
  7. data/lib/mocha/cardinality.rb +92 -0
  8. data/lib/mocha/central.rb +1 -9
  9. data/lib/mocha/change_state_side_effect.rb +19 -0
  10. data/lib/mocha/class_method.rb +25 -5
  11. data/lib/mocha/configuration.rb +60 -0
  12. data/lib/mocha/exception_raiser.rb +1 -1
  13. data/lib/mocha/expectation.rb +109 -48
  14. data/lib/mocha/expectation_error.rb +6 -6
  15. data/lib/mocha/expectation_list.rb +10 -14
  16. data/lib/mocha/in_state_ordering_constraint.rb +19 -0
  17. data/lib/mocha/instance_method.rb +9 -0
  18. data/lib/mocha/logger.rb +15 -0
  19. data/lib/mocha/mock.rb +19 -14
  20. data/lib/mocha/mockery.rb +166 -0
  21. data/lib/mocha/module_method.rb +17 -0
  22. data/lib/mocha/names.rb +53 -0
  23. data/lib/mocha/object.rb +26 -9
  24. data/lib/mocha/parameter_matchers.rb +2 -1
  25. data/lib/mocha/parameter_matchers/all_of.rb +3 -3
  26. data/lib/mocha/parameter_matchers/any_of.rb +3 -3
  27. data/lib/mocha/parameter_matchers/anything.rb +1 -1
  28. data/lib/mocha/parameter_matchers/has_entries.rb +4 -1
  29. data/lib/mocha/parameter_matchers/has_entry.rb +3 -2
  30. data/lib/mocha/parameter_matchers/has_key.rb +1 -1
  31. data/lib/mocha/parameter_matchers/has_value.rb +1 -1
  32. data/lib/mocha/parameter_matchers/not.rb +2 -2
  33. data/lib/mocha/parameter_matchers/object.rb +1 -1
  34. data/lib/mocha/parameter_matchers/optionally.rb +22 -0
  35. data/lib/mocha/parameter_matchers/regexp_matches.rb +2 -2
  36. data/lib/mocha/parameter_matchers/responds_with.rb +43 -0
  37. data/lib/mocha/parameter_matchers/yaml_equivalent.rb +43 -0
  38. data/lib/mocha/single_return_value.rb +2 -9
  39. data/lib/mocha/standalone.rb +151 -17
  40. data/lib/mocha/state_machine.rb +91 -0
  41. data/lib/mocha/stubbing_error.rb +16 -0
  42. data/lib/mocha/test_case_adapter.rb +76 -22
  43. data/lib/stubba.rb +2 -1
  44. data/test/acceptance/acceptance_test_helper.rb +38 -0
  45. data/test/acceptance/bug_18914_test.rb +43 -0
  46. data/test/acceptance/{expected_invocation_count_acceptance_test.rb → expected_invocation_count_test.rb} +29 -20
  47. data/test/acceptance/failure_messages_test.rb +64 -0
  48. data/test/acceptance/{mocha_acceptance_test.rb → mocha_example_test.rb} +5 -5
  49. data/test/{integration/mocha_test_result_integration_test.rb → acceptance/mocha_test_result_test.rb} +19 -40
  50. data/test/acceptance/mock_test.rb +100 -0
  51. data/test/acceptance/{mock_with_initializer_block_acceptance_test.rb → mock_with_initializer_block_test.rb} +12 -5
  52. data/test/acceptance/{mocked_methods_dispatch_acceptance_test.rb → mocked_methods_dispatch_test.rb} +12 -5
  53. data/test/acceptance/{optional_parameters_acceptance_test.rb → optional_parameters_test.rb} +11 -4
  54. data/test/acceptance/{parameter_matcher_acceptance_test.rb → parameter_matcher_test.rb} +67 -5
  55. data/test/acceptance/{partial_mocks_acceptance_test.rb → partial_mocks_test.rb} +12 -5
  56. data/test/acceptance/return_value_test.rb +52 -0
  57. data/test/acceptance/{sequence_acceptance_test.rb → sequence_test.rb} +13 -6
  58. data/test/acceptance/{standalone_acceptance_test.rb → standalone_test.rb} +19 -11
  59. data/test/acceptance/states_test.rb +70 -0
  60. data/test/acceptance/stub_any_instance_method_test.rb +195 -0
  61. data/test/acceptance/stub_class_method_test.rb +203 -0
  62. data/test/acceptance/stub_everything_test.rb +56 -0
  63. data/test/acceptance/stub_instance_method_test.rb +165 -0
  64. data/test/acceptance/stub_module_method_test.rb +163 -0
  65. data/test/acceptance/stub_test.rb +52 -0
  66. data/test/acceptance/{stubba_acceptance_test.rb → stubba_example_test.rb} +1 -1
  67. data/test/{integration/stubba_test_result_integration_test.rb → acceptance/stubba_test_result_test.rb} +17 -36
  68. data/test/acceptance/stubbing_error_backtrace_test.rb +64 -0
  69. data/test/acceptance/stubbing_method_unnecessarily_test.rb +65 -0
  70. data/test/acceptance/stubbing_non_existent_any_instance_method_test.rb +130 -0
  71. data/test/acceptance/stubbing_non_existent_class_method_test.rb +155 -0
  72. data/test/acceptance/stubbing_non_existent_instance_method_test.rb +145 -0
  73. data/test/acceptance/stubbing_non_public_any_instance_method_test.rb +130 -0
  74. data/test/acceptance/stubbing_non_public_class_method_test.rb +161 -0
  75. data/test/acceptance/stubbing_non_public_instance_method_test.rb +141 -0
  76. data/test/acceptance/stubbing_on_non_mock_object_test.rb +64 -0
  77. data/test/execution_point.rb +3 -1
  78. data/test/simple_counter.rb +13 -0
  79. data/test/test_helper.rb +0 -1
  80. data/test/test_runner.rb +6 -4
  81. data/test/unit/any_instance_method_test.rb +1 -1
  82. data/test/unit/array_inspect_test.rb +1 -1
  83. data/test/unit/backtrace_filter_test.rb +19 -0
  84. data/test/unit/cardinality_test.rb +56 -0
  85. data/test/unit/central_test.rb +4 -63
  86. data/test/unit/change_state_side_effect_test.rb +41 -0
  87. data/test/unit/class_method_test.rb +38 -1
  88. data/test/unit/date_time_inspect_test.rb +1 -1
  89. data/test/unit/{expectation_raiser_test.rb → exception_raiser_test.rb} +14 -0
  90. data/test/unit/expectation_list_test.rb +4 -22
  91. data/test/unit/expectation_test.rb +70 -94
  92. data/test/unit/in_state_ordering_constraint_test.rb +43 -0
  93. data/test/unit/mock_test.rb +16 -37
  94. data/test/unit/mockery_test.rb +149 -0
  95. data/test/unit/{no_yield_test.rb → no_yields_test.rb} +0 -0
  96. data/test/unit/object_test.rb +6 -89
  97. data/test/unit/parameter_matchers/equals_test.rb +25 -0
  98. data/test/unit/parameter_matchers/has_entries_test.rb +22 -1
  99. data/test/unit/parameter_matchers/has_entry_test.rb +24 -2
  100. data/test/unit/parameter_matchers/has_key_test.rb +11 -0
  101. data/test/unit/parameter_matchers/has_value_test.rb +12 -0
  102. data/test/unit/parameter_matchers/regexp_matches_test.rb +1 -1
  103. data/test/unit/parameter_matchers/responds_with_test.rb +25 -0
  104. data/test/unit/parameter_matchers/stub_matcher.rb +4 -0
  105. data/test/unit/parameter_matchers/yaml_equivalent_test.rb +25 -0
  106. data/test/unit/single_return_value_test.rb +0 -19
  107. data/test/unit/state_machine_test.rb +98 -0
  108. metadata +108 -69
  109. data/lib/mocha/auto_verify.rb +0 -118
  110. data/lib/mocha/infinite_range.rb +0 -25
  111. data/lib/mocha/missing_expectation.rb +0 -17
  112. data/lib/mocha/setup_and_teardown.rb +0 -23
  113. data/lib/mocha/stub.rb +0 -18
  114. data/test/integration/stubba_integration_test.rb +0 -89
  115. data/test/unit/auto_verify_test.rb +0 -129
  116. data/test/unit/expectation_error_test.rb +0 -24
  117. data/test/unit/infinite_range_test.rb +0 -53
  118. data/test/unit/missing_expectation_test.rb +0 -42
  119. data/test/unit/setup_and_teardown_test.rb +0 -76
  120. data/test/unit/stub_test.rb +0 -24
@@ -0,0 +1,15 @@
1
+ module Mocha
2
+
3
+ class Logger
4
+
5
+ def initialize(io)
6
+ @io = io
7
+ end
8
+
9
+ def warn(message)
10
+ @io.puts "WARNING: #{message}"
11
+ end
12
+
13
+ end
14
+
15
+ end
@@ -1,8 +1,10 @@
1
1
  require 'mocha/expectation'
2
2
  require 'mocha/expectation_list'
3
- require 'mocha/stub'
4
- require 'mocha/missing_expectation'
5
3
  require 'mocha/metaclass'
4
+ require 'mocha/names'
5
+ require 'mocha/mockery'
6
+ require 'mocha/method_matcher'
7
+ require 'mocha/parameters_matcher'
6
8
 
7
9
  module Mocha # :nodoc:
8
10
 
@@ -72,11 +74,11 @@ module Mocha # :nodoc:
72
74
  if method_name_or_hash.is_a?(Hash) then
73
75
  method_name_or_hash.each do |method_name, return_value|
74
76
  ensure_method_not_already_defined(method_name)
75
- @expectations.add(Stub.new(self, method_name, backtrace).returns(return_value))
77
+ @expectations.add(Expectation.new(self, method_name, backtrace).at_least(0).returns(return_value))
76
78
  end
77
79
  else
78
80
  ensure_method_not_already_defined(method_name_or_hash)
79
- @expectations.add(Stub.new(self, method_name_or_hash, backtrace))
81
+ @expectations.add(Expectation.new(self, method_name_or_hash, backtrace).at_least(0))
80
82
  end
81
83
  end
82
84
 
@@ -128,7 +130,7 @@ module Mocha # :nodoc:
128
130
  # :stopdoc:
129
131
 
130
132
  def initialize(name = nil, &block)
131
- @mock_name = name
133
+ @name = name || DefaultName.new(self)
132
134
  @expectations = ExpectationList.new
133
135
  @everything_stubbed = false
134
136
  @responder = nil
@@ -172,19 +174,22 @@ module Mocha # :nodoc:
172
174
  @expectations.matches_method?(symbol)
173
175
  end
174
176
  end
175
-
177
+
176
178
  def unexpected_method_called(symbol, *arguments)
177
- MissingExpectation.new(self, symbol).with(*arguments).verify
179
+ method_matcher = MethodMatcher.new(symbol)
180
+ parameters_matcher = ParametersMatcher.new(arguments)
181
+ method_signature = "#{mocha_inspect}.#{method_matcher.mocha_inspect}#{parameters_matcher.mocha_inspect}"
182
+ message = "unexpected invocation: #{method_signature}\n"
183
+ message << Mockery.instance.mocha_inspect
184
+ raise ExpectationError.new(message, caller)
178
185
  end
179
-
180
- def verify(&block)
181
- @expectations.verify(&block)
186
+
187
+ def verified?(assertion_counter = nil)
188
+ @expectations.verified?(assertion_counter)
182
189
  end
183
-
190
+
184
191
  def mocha_inspect
185
- address = self.__id__ * 2
186
- address += 0x100000000 if address < 0
187
- @mock_name ? "#<Mock:#{@mock_name}>" : "#<Mock:0x#{'%x' % address}>"
192
+ @name.mocha_inspect
188
193
  end
189
194
 
190
195
  def inspect
@@ -0,0 +1,166 @@
1
+ require 'mocha/central'
2
+ require 'mocha/mock'
3
+ require 'mocha/names'
4
+ require 'mocha/state_machine'
5
+ require 'mocha/logger'
6
+ require 'mocha/configuration'
7
+ require 'mocha/stubbing_error'
8
+
9
+ module Mocha
10
+
11
+ class Mockery
12
+
13
+ class << self
14
+
15
+ def instance
16
+ @instance ||= new
17
+ end
18
+
19
+ def reset_instance
20
+ @instance = nil
21
+ end
22
+
23
+ end
24
+
25
+ def named_mock(name, &block)
26
+ add_mock(Mock.new(Name.new(name), &block))
27
+ end
28
+
29
+ def unnamed_mock(&block)
30
+ add_mock(Mock.new(&block))
31
+ end
32
+
33
+ def mock_impersonating(object, &block)
34
+ add_mock(Mock.new(ImpersonatingName.new(object), &block))
35
+ end
36
+
37
+ def mock_impersonating_any_instance_of(klass, &block)
38
+ add_mock(Mock.new(ImpersonatingAnyInstanceName.new(klass), &block))
39
+ end
40
+
41
+ def new_state_machine(name)
42
+ add_state_machine(StateMachine.new(name))
43
+ end
44
+
45
+ def verify(assertion_counter = nil)
46
+ unless mocks.all? { |mock| mock.verified?(assertion_counter) }
47
+ message = "not all expectations were satisfied\n#{mocha_inspect}"
48
+ if unsatisfied_expectations.empty?
49
+ backtrace = caller
50
+ else
51
+ backtrace = unsatisfied_expectations[0].backtrace
52
+ end
53
+ raise ExpectationError.new(message, backtrace)
54
+ end
55
+ expectations.each do |e|
56
+ on_stubbing_method_unnecessarily(e) unless e.used?
57
+ end
58
+ end
59
+
60
+ def teardown
61
+ stubba.unstub_all
62
+ reset
63
+ end
64
+
65
+ def stubba
66
+ @stubba ||= Central.new
67
+ end
68
+
69
+ def mocks
70
+ @mocks ||= []
71
+ end
72
+
73
+ def state_machines
74
+ @state_machines ||= []
75
+ end
76
+
77
+ def mocha_inspect
78
+ message = ""
79
+ message << "unsatisfied expectations:\n- #{unsatisfied_expectations.map { |e| e.mocha_inspect }.join("\n- ")}\n" unless unsatisfied_expectations.empty?
80
+ message << "satisfied expectations:\n- #{satisfied_expectations.map { |e| e.mocha_inspect }.join("\n- ")}\n" unless satisfied_expectations.empty?
81
+ message << "states:\n- #{state_machines.map { |sm| sm.mocha_inspect }.join("\n- ")}" unless state_machines.empty?
82
+ message
83
+ end
84
+
85
+ def on_stubbing(object, symbol)
86
+ on_stubbing_non_existent_method(object, symbol) unless object.method_exists?(symbol, include_public_methods = true)
87
+ on_stubbing_non_public_method(object, symbol) if object.method_exists?(symbol, include_public_methods = false)
88
+ on_stubbing_method_on_non_mock_object(object, symbol)
89
+ end
90
+
91
+ def on_stubbing_non_existent_method(object, symbol)
92
+ if Mocha::Configuration.prevent?(:stubbing_non_existent_method)
93
+ raise StubbingError.new("stubbing non-existent method: #{object.mocha_inspect}.#{symbol}", caller)
94
+ end
95
+ if Mocha::Configuration.warn_when?(:stubbing_non_existent_method)
96
+ logger.warn "stubbing non-existent method: #{object.mocha_inspect}.#{symbol}"
97
+ end
98
+ end
99
+
100
+ def on_stubbing_non_public_method(object, symbol)
101
+ if Mocha::Configuration.prevent?(:stubbing_non_public_method)
102
+ raise StubbingError.new("stubbing non-public method: #{object.mocha_inspect}.#{symbol}", caller)
103
+ end
104
+ if Mocha::Configuration.warn_when?(:stubbing_non_public_method)
105
+ logger.warn "stubbing non-public method: #{object.mocha_inspect}.#{symbol}"
106
+ end
107
+ end
108
+
109
+ def on_stubbing_method_on_non_mock_object(object, symbol)
110
+ if Mocha::Configuration.prevent?(:stubbing_method_on_non_mock_object)
111
+ raise StubbingError.new("stubbing method on non-mock object: #{object.mocha_inspect}.#{symbol}", caller)
112
+ end
113
+ if Mocha::Configuration.warn_when?(:stubbing_method_on_non_mock_object)
114
+ logger.warn "stubbing method on non-mock object: #{object.mocha_inspect}.#{symbol}"
115
+ end
116
+ end
117
+
118
+ def on_stubbing_method_unnecessarily(expectation)
119
+ if Mocha::Configuration.prevent?(:stubbing_method_unnecessarily)
120
+ raise StubbingError.new("stubbing method unnecessarily: #{expectation.method_signature}", expectation.backtrace)
121
+ end
122
+ if Mocha::Configuration.warn_when?(:stubbing_method_unnecessarily)
123
+ logger.warn "stubbing method unnecessarily: #{expectation.method_signature}"
124
+ end
125
+ end
126
+
127
+ attr_writer :logger
128
+
129
+ def logger
130
+ @logger ||= Logger.new($stderr)
131
+ end
132
+
133
+
134
+ private
135
+
136
+ def expectations
137
+ mocks.map { |mock| mock.expectations.to_a }.flatten
138
+ end
139
+
140
+ def unsatisfied_expectations
141
+ expectations.reject { |e| e.verified? }
142
+ end
143
+
144
+ def satisfied_expectations
145
+ expectations.select { |e| e.verified? }
146
+ end
147
+
148
+ def add_mock(mock)
149
+ mocks << mock
150
+ mock
151
+ end
152
+
153
+ def add_state_machine(state_machine)
154
+ state_machines << state_machine
155
+ state_machine
156
+ end
157
+
158
+ def reset
159
+ @stubba = nil
160
+ @mocks = nil
161
+ @state_machines = nil
162
+ end
163
+
164
+ end
165
+
166
+ end
@@ -0,0 +1,17 @@
1
+ require 'mocha/module_method'
2
+
3
+ module Mocha
4
+
5
+ class ModuleMethod < ClassMethod
6
+
7
+ def method_exists?(method)
8
+ existing_methods = []
9
+ existing_methods += stubbee.public_methods(false)
10
+ existing_methods += stubbee.protected_methods(false)
11
+ existing_methods += stubbee.private_methods(false)
12
+ existing_methods.any? { |m| m.to_s == method.to_s }
13
+ end
14
+
15
+ end
16
+
17
+ end
@@ -0,0 +1,53 @@
1
+ module Mocha
2
+
3
+ class ImpersonatingName
4
+
5
+ def initialize(object)
6
+ @object = object
7
+ end
8
+
9
+ def mocha_inspect
10
+ @object.mocha_inspect
11
+ end
12
+
13
+ end
14
+
15
+ class ImpersonatingAnyInstanceName
16
+
17
+ def initialize(klass)
18
+ @klass = klass
19
+ end
20
+
21
+ def mocha_inspect
22
+ "#<AnyInstance:#{@klass.mocha_inspect}>"
23
+ end
24
+
25
+ end
26
+
27
+ class Name
28
+
29
+ def initialize(name)
30
+ @name = name
31
+ end
32
+
33
+ def mocha_inspect
34
+ "#<Mock:#{@name}>"
35
+ end
36
+
37
+ end
38
+
39
+ class DefaultName
40
+
41
+ def initialize(mock)
42
+ @mock = mock
43
+ end
44
+
45
+ def mocha_inspect
46
+ address = @mock.__id__ * 2
47
+ address += 0x100000000 if address < 0
48
+ "#<Mock:0x#{'%x' % address}>"
49
+ end
50
+
51
+ end
52
+
53
+ end
@@ -1,6 +1,7 @@
1
- require 'mocha/mock'
1
+ require 'mocha/mockery'
2
2
  require 'mocha/instance_method'
3
3
  require 'mocha/class_method'
4
+ require 'mocha/module_method'
4
5
  require 'mocha/any_instance_method'
5
6
 
6
7
  # Methods added all objects to allow mocking and stubbing on real objects.
@@ -9,7 +10,7 @@ require 'mocha/any_instance_method'
9
10
  class Object
10
11
 
11
12
  def mocha # :nodoc:
12
- @mocha ||= Mocha::Mock.new
13
+ @mocha ||= Mocha::Mockery.instance.mock_impersonating(self)
13
14
  end
14
15
 
15
16
  def reset_mocha # :nodoc:
@@ -35,9 +36,11 @@ class Object
35
36
  # The original implementation of <tt>Product#save</tt> is replaced temporarily.
36
37
  #
37
38
  # The original implementation of <tt>Product#save</tt> is restored at the end of the test.
38
- def expects(symbol)
39
+ def expects(symbol)
40
+ mockery = Mocha::Mockery.instance
41
+ mockery.on_stubbing(self, symbol)
39
42
  method = stubba_method.new(stubba_object, symbol)
40
- $stubba.stub(method)
43
+ mockery.stubba.stub(method)
41
44
  mocha.expects(symbol, caller)
42
45
  end
43
46
 
@@ -52,14 +55,18 @@ class Object
52
55
  # The original implementation of <tt>Product#save</tt> is replaced temporarily.
53
56
  #
54
57
  # The original implementation of <tt>Product#save</tt> is restored at the end of the test.
55
- def stubs(symbol)
58
+ def stubs(symbol)
59
+ mockery = Mocha::Mockery.instance
60
+ mockery.on_stubbing(self, symbol)
56
61
  method = stubba_method.new(stubba_object, symbol)
57
- $stubba.stub(method)
62
+ mockery.stubba.stub(method)
58
63
  mocha.stubs(symbol, caller)
59
64
  end
60
65
 
61
- def verify # :nodoc:
62
- mocha.verify
66
+ def method_exists?(symbol, include_public_methods = true)
67
+ existing_methods = private_methods(include_superclass_methods = true) + protected_methods(include_superclass_methods = true)
68
+ existing_methods += public_methods(include_superclass_methods = true) if include_public_methods
69
+ existing_methods.any? { |m| m.to_s == symbol.to_s } || (respond_to?(symbol) && include_public_methods)
63
70
  end
64
71
 
65
72
  end
@@ -67,7 +74,7 @@ end
67
74
  class Module # :nodoc:
68
75
 
69
76
  def stubba_method
70
- Mocha::ClassMethod
77
+ Mocha::ModuleMethod
71
78
  end
72
79
 
73
80
  end
@@ -84,6 +91,10 @@ class Class
84
91
  @stubba_object = klass
85
92
  end
86
93
 
94
+ def mocha
95
+ @mocha ||= Mocha::Mockery.instance.mock_impersonating_any_instance_of(@stubba_object)
96
+ end
97
+
87
98
  def stubba_method
88
99
  Mocha::AnyInstanceMethod
89
100
  end
@@ -92,6 +103,12 @@ class Class
92
103
  @stubba_object
93
104
  end
94
105
 
106
+ def method_exists?(symbol, include_public_methods = true)
107
+ existing_methods = @stubba_object.private_instance_methods(include_superclass_methods = true) + @stubba_object.protected_instance_methods(include_superclass_methods = true)
108
+ existing_methods += @stubba_object.public_instance_methods(include_superclass_methods = true) if include_public_methods
109
+ existing_methods.any? { |m| m.to_s == symbol.to_s }
110
+ end
111
+
95
112
  end
96
113
 
97
114
  # :call-seq: any_instance -> mock object
@@ -1,6 +1,6 @@
1
1
  module Mocha
2
2
 
3
- # Used as parameters for Expectation#with to restrict the parameter values which will match the expectation.
3
+ # Used as parameters for Expectation#with to restrict the parameter values which will match the expectation. Can be nested.
4
4
  module ParameterMatchers; end
5
5
 
6
6
  end
@@ -23,3 +23,4 @@ require 'mocha/parameter_matchers/kind_of'
23
23
  require 'mocha/parameter_matchers/not'
24
24
  require 'mocha/parameter_matchers/optionally'
25
25
  require 'mocha/parameter_matchers/regexp_matches'
26
+ require 'mocha/parameter_matchers/yaml_equivalent'
@@ -4,9 +4,9 @@ module Mocha
4
4
 
5
5
  module ParameterMatchers
6
6
 
7
- # :call-seq: all_of -> parameter_matcher
7
+ # :call-seq: all_of(*parameter_matchers) -> parameter_matcher
8
8
  #
9
- # Matches if all +matchers+ match.
9
+ # Matches if all +parameter_matchers+ match.
10
10
  # object = mock()
11
11
  # object.expects(:method_1).with(all_of(includes(1), includes(3)))
12
12
  # object.method_1([1, 3])
@@ -28,7 +28,7 @@ module Mocha
28
28
 
29
29
  def matches?(available_parameters)
30
30
  parameter = available_parameters.shift
31
- @matchers.all? { |matcher| matcher.matches?([parameter]) }
31
+ @matchers.all? { |matcher| matcher.to_matcher.matches?([parameter]) }
32
32
  end
33
33
 
34
34
  def mocha_inspect
@@ -4,9 +4,9 @@ module Mocha
4
4
 
5
5
  module ParameterMatchers
6
6
 
7
- # :call-seq: any_of -> parameter_matcher
7
+ # :call-seq: any_of(*parameter_matchers) -> parameter_matcher
8
8
  #
9
- # Matches if any +matchers+ match.
9
+ # Matches if any +parameter_matchers+ match.
10
10
  # object = mock()
11
11
  # object.expects(:method_1).with(any_of(1, 3))
12
12
  # object.method_1(1)
@@ -33,7 +33,7 @@ module Mocha
33
33
 
34
34
  def matches?(available_parameters)
35
35
  parameter = available_parameters.shift
36
- @matchers.any? { |matcher| matcher.matches?([parameter]) }
36
+ @matchers.any? { |matcher| matcher.to_matcher.matches?([parameter]) }
37
37
  end
38
38
 
39
39
  def mocha_inspect