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

rename Savon::Response#hash #985

Merged
merged 3 commits into from
Oct 19, 2022
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
6 changes: 3 additions & 3 deletions lib/savon/response.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ def to_array(*path)
result.kind_of?(Array) ? result.compact : [result].compact
end

def hash
@hash ||= nori.parse(xml)
def full_hash
@full_hash ||= nori.parse(xml)
end

def xml
Expand All @@ -79,7 +79,7 @@ def xpath(path, namespaces = nil)
end

def find(*path)
envelope = nori.find(hash, 'Envelope')
envelope = nori.find(full_hash, 'Envelope')
raise_invalid_response_error! unless envelope.is_a?(Hash)

nori.find(envelope, *path)
Expand Down
2 changes: 1 addition & 1 deletion spec/savon/mock_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@

it "accepts a Hash to specify the response code, headers and body" do
soap_fault = Fixture.response(:soap_fault)
response = { :code => 500, :headers => { "X-Result" => "invalid" }, :body => soap_fault }
response = { :code => 500, :headers => { "x-result" => "invalid" }, :body => soap_fault }

savon.expects(:authenticate).returns(response)
response = new_client(:raise_errors => false).call(:authenticate)
Expand Down
8 changes: 4 additions & 4 deletions spec/savon/options_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ def to_s
client = new_client(:endpoint => @server.url, :log => true)
client.call(:authenticate)
}
soap_header = stdout.string.include? "content-type"
soap_header = stdout.string.downcase.include? "content-type"
expect(soap_header).to be true
end

Expand Down Expand Up @@ -850,7 +850,7 @@ def to_s

response = client.call(:authenticate, :xml => Fixture.response(:authentication))

expect(response.hash["soap:envelope"]["soap:body"]).to include("ns2:authenticate_response")
expect(response.full_hash["soap:envelope"]["soap:body"]).to include("ns2:authenticate_response")
end
end

Expand Down Expand Up @@ -880,7 +880,7 @@ def to_s
client = new_client(:endpoint => @server.url(:repeat), :convert_response_tags_to => lambda { |tag| tag.snakecase.upcase })
response = client.call(:authenticate, :xml => Fixture.response(:authentication))

expect(response.hash["ENVELOPE"]["BODY"]).to include("AUTHENTICATE_RESPONSE")
expect(response.full_hash["ENVELOPE"]["BODY"]).to include("AUTHENTICATE_RESPONSE")
end

it "accepts a block in the block-based interface" do
Expand All @@ -895,7 +895,7 @@ def to_s
locals.xml Fixture.response(:authentication)
end

expect(response.hash["ENVELOPE"]["BODY"]).to include("AUTHENTICATE_RESPONSE")
expect(response.full_hash["ENVELOPE"]["BODY"]).to include("AUTHENTICATE_RESPONSE")
end
end

Expand Down
6 changes: 3 additions & 3 deletions spec/savon/response_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@
describe "##{method}" do
it "should return the SOAP response body as a Hash" do
expect(soap_response.send(method)[:authenticate_response][:return]).to eq(
Fixture.response_hash(:authentication)[:authenticate_response][:return]
Fixture.full_hash(:authentication)[:authenticate_response][:return]
)
end

Expand Down Expand Up @@ -180,7 +180,7 @@
context "when the given path exists" do
it "should return an Array containing the path value" do
expect(soap_response.to_array(:authenticate_response, :return)).to eq(
[Fixture.response_hash(:authentication)[:authenticate_response][:return]]
[Fixture.full_hash(:authentication)[:authenticate_response][:return]]
)
end

Expand All @@ -206,7 +206,7 @@
describe "#hash" do
it "should return the complete SOAP response XML as a Hash" do
response = soap_response :body => Fixture.response(:header)
expect(response.hash[:envelope][:header][:session_number]).to eq("ABCD1234")
expect(response.full_hash[:envelope][:header][:session_number]).to eq("ABCD1234")
end
end

Expand Down
6 changes: 3 additions & 3 deletions spec/support/fixture.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ def [](type, fixture)
fixtures(type)[fixture] ||= read_file type, fixture
end

def response_hash(fixture)
@response_hash ||= {}
@response_hash[fixture] ||= nori.parse(response(fixture))[:envelope][:body]
def full_hash(fixture)
@full_hash ||= {}
@full_hash[fixture] ||= nori.parse(response(fixture))[:envelope][:body]
end

TYPES.each do |type, ext|
Expand Down