Skip to content

Commit

Permalink
fixed bug whereby regexes were not being properly matched
Browse files Browse the repository at this point in the history
  • Loading branch information
alenia authored and Daniela Wellisz and Lars Petrus committed Feb 20, 2013
1 parent e0e7305 commit 8b87f71
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/rspec-spies.rb
Expand Up @@ -37,7 +37,7 @@ def visibility_for_method
messages_received.any? do |message|
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 &&= argument_expectation_class.new(*@args || any_args).args_match?(*received_args)
result &&= (received_block == block)
end
end
Expand Down
8 changes: 8 additions & 0 deletions spec/rspec-spies_spec.rb
Expand Up @@ -37,6 +37,14 @@ module Matchers
have_received(:slice).with(hash_including({ :foo => :baz })).matches?(@object).should be_false
end

it "matches if specifies regex, if method is called with matches arguments" do
@object.stub!(:slice)
@object.slice('foobar')

have_received(:slice).with(/foo/).matches?(@object).should be_true
have_received(:slice).with(/foox/).matches?(@object).should be_false
end

it "does not match if method is called with incorrect args" do
@object.stub!(:slice)
@object.slice(3)
Expand Down

0 comments on commit 8b87f71

Please sign in to comment.