Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #109 from c42engineering/expectation_args

Initialize child message expectation args to match any args (See #103)
  • Loading branch information...
commit 408a09ca217e89b769c548dc87ff97a3e733fbe8 2 parents 56a5ccd + 917dca2
@dchelimsky dchelimsky 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.