From 6484d1682948675256468def010c4c65e939d97d Mon Sep 17 00:00:00 2001 From: Daniela Wellisz Date: Tue, 19 Feb 2013 09:11:30 -0800 Subject: [PATCH] can assert on non-block arguments when method is called with a block Conflicts: lib/rspec-spies.rb spec/rspec-spies_spec.rb --- lib/rspec-spies.rb | 1 - spec/rspec-spies_spec.rb | 8 ++++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/rspec-spies.rb b/lib/rspec-spies.rb index 42d62a9..9139617 100644 --- a/lib/rspec-spies.rb +++ b/lib/rspec-spies.rb @@ -38,7 +38,6 @@ def visibility_for_method received_method_name, received_args, received_block = *message result = (received_method_name == method_name) result &&= argument_expectation_class.new(@args || any_args).args_match?(received_args) - result &&= (received_block == block) end end diff --git a/spec/rspec-spies_spec.rb b/spec/rspec-spies_spec.rb index 4b91c9a..f895cd4 100644 --- a/spec/rspec-spies_spec.rb +++ b/spec/rspec-spies_spec.rb @@ -37,6 +37,14 @@ module Matchers have_received(:slice).with(hash_including({ :foo => :baz })).matches?(@object).should be_false end + it "matches if third argument is a block" do + @object.stub!(:slice) + @object.slice(5) do; end + + have_received(:slice).with(5).matches?(@object).should be_true + have_received(:slice).with(5,anything).matches?(@object).should be_false + end + it "does not match if method is called with incorrect args" do @object.stub!(:slice) @object.slice(3)