Normalize access to response headers in adapters
This commit is contained in:
parent
56b2f342da
commit
67febe9072
|
@ -39,6 +39,10 @@ module Webrat #:nodoc:
|
||||||
@response.code.to_i
|
@response.code.to_i
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def response_headers
|
||||||
|
@response.header
|
||||||
|
end
|
||||||
|
|
||||||
def mechanize
|
def mechanize
|
||||||
unless @mechanize
|
unless @mechanize
|
||||||
@mechanize = Mechanize.new
|
@mechanize = Mechanize.new
|
||||||
|
|
|
@ -18,6 +18,10 @@ module Webrat
|
||||||
response.status
|
response.status
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def response_headers
|
||||||
|
response.headers
|
||||||
|
end
|
||||||
|
|
||||||
def response
|
def response
|
||||||
@session.last_response
|
@session.last_response
|
||||||
end
|
end
|
||||||
|
|
|
@ -35,6 +35,10 @@ module Webrat
|
||||||
response.code.to_i
|
response.code.to_i
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def response_headers
|
||||||
|
response.headers
|
||||||
|
end
|
||||||
|
|
||||||
def xml_content_type?
|
def xml_content_type?
|
||||||
response.headers["Content-Type"].to_s =~ /xml/
|
response.headers["Content-Type"].to_s =~ /xml/
|
||||||
end
|
end
|
||||||
|
|
|
@ -281,7 +281,7 @@ For example:
|
||||||
end
|
end
|
||||||
|
|
||||||
def response_location
|
def response_location
|
||||||
response.headers["Location"]
|
response_headers['Location']
|
||||||
end
|
end
|
||||||
|
|
||||||
def current_host
|
def current_host
|
||||||
|
|
|
@ -78,4 +78,16 @@ describe Webrat::MechanizeAdapter do
|
||||||
@session.absolute_url(relative_url).should == 'https://test.host/wilma'
|
@session.absolute_url(relative_url).should == 'https://test.host/wilma'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe "response_headers" do
|
||||||
|
it "should return the Headers object from the response" do
|
||||||
|
mech = @mech.mechanize
|
||||||
|
resp = mock('Mechanize::File')
|
||||||
|
hdr = Mechanize::Headers.new
|
||||||
|
resp.should_receive(:header).and_return(hdr)
|
||||||
|
mech.stub!(:get).and_return(resp)
|
||||||
|
@mech.get('/', nil)
|
||||||
|
@mech.response_headers.should == hdr
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue