Skip to content

Commit

Permalink
refactor to use the Responses helper to mock faraday responses
Browse files Browse the repository at this point in the history
  • Loading branch information
LukeIGS committed Jan 9, 2024
1 parent 4cebdf8 commit c5d8720
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 8 deletions.
2 changes: 1 addition & 1 deletion lib/savon/mock/expectation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def response!
unless @response
raise ExpectationError, "This expectation was not set up with a response."
end
env = Faraday::Env.new(status: @response[:code], response_headers: @response[:headers], response_body: @response[:body])
env = Faraday::Env.from(status: @response[:code], response_headers: @response[:headers], response_body: @response[:body])
Faraday::Response.new(env)
end

Expand Down
3 changes: 1 addition & 2 deletions spec/savon/http_error_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@ def new_response(options = {})
defaults = { :code => 200, :headers => {}, :body => Fixture.response(:authentication) }
response = defaults.merge options

env = Faraday::Env.new(status: response[:code], response_headers: response[:headers], response_body: response[:body])
Faraday::Response.new(env)
Responses.mock_faraday(response[:code], response[:headers], response[:body])
end

end
7 changes: 2 additions & 5 deletions spec/savon/response_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -252,9 +252,7 @@
def soap_response(options = {})
defaults = { :code => 200, :headers => {}, :body => Fixture.response(:authentication) }
response = defaults.merge options
env = Faraday::Env.new(status: response[:code], response_headers: response[:headers], response_body: response[:body])
http_response = Faraday::Response.new(env)

http_response = Responses.mock_faraday(response[:code], response[:headers], response[:body])
Savon::Response.new(http_response, globals, locals)
end

Expand All @@ -269,8 +267,7 @@ def http_error_response
def invalid_soap_response(options = {})
defaults = { :code => 200, :headers => {}, :body => "I'm not SOAP" }
response = defaults.merge options
env = Faraday::Env.new(status: response[:code], response_headers: response[:headers], response_body: response[:body])
http_response = Faraday::Response.new(env)
http_response = Responses.mock_faraday(response[:code], response[:headers], response[:body])

Savon::Response.new(http_response, globals, locals)
end
Expand Down

0 comments on commit c5d8720

Please sign in to comment.