Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow code to rescue and ignore Savon::Error's and still have mocks trigger test failures #430

Merged
merged 1 commit into from Apr 20, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/savon/mock.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module Savon
class ExpectationError < Error; end
class ExpectationError < ::Exception; end
end

require "savon/mock/expectation"
16 changes: 16 additions & 0 deletions spec/savon/mock_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,22 @@
" with this message: #{message.inspect}")
end

it "allows code to rescue Savon::Error and still report test failures" do
message = { :username => "luke" }
savon.expects(:find_user).with(:message => message).returns("<fixture/>")

expect do
begin
new_client.call(:find_user)
rescue Savon::Error => e
puts "any real error (e.g. SOAP fault or HTTP error) is OK in the big picture, move on"
end
end.to raise_error(Savon::ExpectationError, "Expected a request to the :find_user operation\n" \
" with this message: #{message.inspect}\n" \
"Received a request to the :find_user operation\n" \
" with no message.")
end

def new_client(globals = {})
defaults = {
:endpoint => "http://example.com",
Expand Down