Skip to content

Commit

Permalink
Add #headers to Savon::Response
Browse files Browse the repository at this point in the history
Shout out to @ashrocket for suggesting this. Closes #544.
  • Loading branch information
tjarratt committed Jan 28, 2014
1 parent c10f52e commit 3fa5293
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/savon/response.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ def body
end
alias to_hash body

def header
hash[:envelope][:header]
end

def hash
@hash ||= nori.parse(raw)
end
Expand Down
17 changes: 17 additions & 0 deletions spec/savon/response_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
require 'spec_helper'

describe Savon::Response do
subject(:response) do
response = Savon::Response.new(nil)
response.send(:instance_variable_set, :@hash, {
:envelope => {:header => 'the-spice-must-flow'}
})
response
end

describe '#headers' do
it 'returns the headers for the underlying response' do
expect(response.header).to eq('the-spice-must-flow')
end
end
end

0 comments on commit 3fa5293

Please sign in to comment.