File tree 2 files changed +5
-3
lines changed
2 files changed +5
-3
lines changed Original file line number Diff line number Diff line change @@ -357,11 +357,11 @@ def any_expectations?
357
357
end
358
358
359
359
# @private
360
- def anticipates ( method_name_or_hash , backtrace = nil , object = Mock . new ( @mockery ) )
360
+ def anticipates ( method_name_or_hash , backtrace = nil , & block )
361
361
ExpectationSetting . new ( Array ( method_name_or_hash ) . map do |*args |
362
362
args = args . flatten
363
363
method_name = args . shift
364
- Mockery . instance . stub_method ( object , method_name ) unless object . is_a? ( Mock )
364
+ yield method_name if block
365
365
ensure_method_not_already_defined ( method_name )
366
366
expectation = Expectation . new ( self , method_name , backtrace )
367
367
expectation . returns ( args . shift ) unless args . empty?
Original file line number Diff line number Diff line change @@ -147,7 +147,9 @@ def anticipates(expected_methods_vs_return_values)
147
147
if frozen?
148
148
raise StubbingError . new ( "can't stub method on frozen object: #{ mocha_inspect } " , caller )
149
149
end
150
- mocha . anticipates ( expected_methods_vs_return_values , caller , self )
150
+ mocha . anticipates ( expected_methods_vs_return_values , caller ) do |method_name |
151
+ Mockery . instance . stub_method ( self , method_name )
152
+ end
151
153
end
152
154
end
153
155
end
You can’t perform that action at this time.
0 commit comments