Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Initializing message expectation args to match any args

  • Loading branch information...
commit 917dca21bb551f1989adb1c900b1d3cc8cdbe7c3 1 parent 56a5ccd
@preethiramdev preethiramdev authored
View
3  lib/rspec/mocks/message_expectation.rb
@@ -4,7 +4,7 @@ module Mocks
class MessageExpectation
# @private
attr_reader :message
- attr_writer :expected_received_count, :method_block, :expected_from
+ attr_writer :expected_received_count, :method_block, :expected_from, :args_expectation
protected :expected_received_count=, :method_block=, :expected_from=
attr_accessor :error_generator
protected :error_generator, :error_generator=
@@ -45,6 +45,7 @@ def build_child(expected_from, method_block, expected_received_count, opts={})
new_gen.opts = opts
child.error_generator = new_gen
child.clone_args_to_yield(*@args_to_yield)
+ child.args_expectation = ArgumentExpectation.new(ArgumentMatchers::AnyArgsMatcher.new)
child
end
View
12 spec/rspec/mocks/stubbed_message_expectations_spec.rb
@@ -21,6 +21,16 @@ module Mocks
double.rspec_reset
end
end
-
+
+ describe "Example with stubbed with args and expectation with no args" do
+ it "matches any args even if previously stubbed with arguments" do
+ double = double("mock")
+ double.stub(:foo).with(3).and_return("stub")
+ double.should_receive(:foo).at_least(:once).and_return("expectation")
+ double.foo
+ double.rspec_verify
+ end
+ end
+
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.