diff --git a/lib/savon/response.rb b/lib/savon/response.rb index c75d51eb..aee676b2 100644 --- a/lib/savon/response.rb +++ b/lib/savon/response.rb @@ -16,6 +16,10 @@ def body end alias to_hash body + def header + hash[:envelope][:header] + end + def hash @hash ||= nori.parse(raw) end diff --git a/spec/savon/response_spec.rb b/spec/savon/response_spec.rb new file mode 100644 index 00000000..772941f7 --- /dev/null +++ b/spec/savon/response_spec.rb @@ -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