Skip to content

Commit

Permalink
Merge pull request #661 from eloyesp/composing_matcher
Browse files Browse the repository at this point in the history
Add support for matchers in the message expectation.
  • Loading branch information
tjarratt committed Feb 13, 2015
2 parents 459e378 + 000b216 commit bc554e9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/savon/mock/expectation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ def verify_operation_name!
end

def verify_message!
return if @expected[:message] == :any
unless @expected[:message] == @actual[:message]
return if @expected[:message].eql? :any
unless @expected[:message] === @actual[:message]
expected_message = " with this message: #{@expected[:message].inspect}" if @expected[:message]
expected_message ||= " with no message."

Expand Down
6 changes: 6 additions & 0 deletions spec/savon/mock_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,12 @@
expect { new_client.call(:find_user) }.to_not raise_error
end

it "matchers can be used to specify the message" do
savon.expects(:find_user).with(:message => include(:username)).returns("<fixture/>")
message = { :username => "Han Solo", password: "querty"}

expect { new_client.call(:find_user, :message => message) }.to_not raise_error
end

it "allows code to rescue Savon::Error and still report test failures" do
message = { :username => "luke" }
Expand Down

0 comments on commit bc554e9

Please sign in to comment.