Merge remote branch 'wemrysi/master' into mechanize_redirects
Conflicts: lib/webrat/adapters/mechanize.rb
This commit is contained in:
commit
38e699820f
|
@ -41,8 +41,16 @@ module Webrat #:nodoc:
|
|||
@response.code.to_i
|
||||
end
|
||||
|
||||
def response_headers
|
||||
@response.header
|
||||
end
|
||||
|
||||
def mechanize
|
||||
@mechanize ||= Mechanize.new
|
||||
@mechanize ||= begin
|
||||
mechanize = Mechanize.new
|
||||
mechanize.redirect_ok = false
|
||||
mechanize
|
||||
end
|
||||
end
|
||||
|
||||
def_delegators :mechanize, :basic_auth
|
||||
|
|
|
@ -18,6 +18,10 @@ module Webrat
|
|||
response.status
|
||||
end
|
||||
|
||||
def response_headers
|
||||
response.headers
|
||||
end
|
||||
|
||||
def response
|
||||
@session.last_response
|
||||
end
|
||||
|
|
|
@ -35,6 +35,10 @@ module Webrat
|
|||
response.code.to_i
|
||||
end
|
||||
|
||||
def response_headers
|
||||
response.headers
|
||||
end
|
||||
|
||||
def xml_content_type?
|
||||
response.headers["Content-Type"].to_s =~ /xml/
|
||||
end
|
||||
|
|
|
@ -282,7 +282,7 @@ For example:
|
|||
end
|
||||
|
||||
def response_location
|
||||
response.headers["Location"]
|
||||
response_headers['Location']
|
||||
end
|
||||
|
||||
def current_host
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
|
||||
|
||||
describe Webrat::MechanizeAdapter do
|
||||
|
||||
Mechanize = WWW::Mechanize if defined?(WWW::Mechanize)
|
||||
|
||||
before :each do
|
||||
Webrat.configuration.mode = :mechanize
|
||||
end
|
||||
|
@ -9,6 +12,13 @@ describe Webrat::MechanizeAdapter do
|
|||
@mech = Webrat::MechanizeAdapter.new
|
||||
end
|
||||
|
||||
describe "mechanize" do
|
||||
it "should disable the following of redirects on the mechanize instance" do
|
||||
mech = @mech.mechanize
|
||||
mech.redirect_ok.should be_false
|
||||
end
|
||||
end
|
||||
|
||||
describe "post" do
|
||||
def url
|
||||
'http://test.host/users'
|
||||
|
@ -24,7 +34,8 @@ describe Webrat::MechanizeAdapter do
|
|||
|
||||
it "should flatten model post data" do
|
||||
mechanize = mock(:mechanize)
|
||||
WWW::Mechanize.stub!(:new => mechanize)
|
||||
mechanize.stub!(:redirect_ok=)
|
||||
Mechanize.stub!(:new => mechanize)
|
||||
mechanize.should_receive(:post).with(url, flattened_data)
|
||||
Webrat::MechanizeAdapter.new.post(url, data)
|
||||
end
|
||||
|
@ -70,4 +81,16 @@ describe Webrat::MechanizeAdapter do
|
|||
@session.absolute_url(relative_url).should == 'https://test.host/wilma'
|
||||
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
|
||||
|
|
Loading…
Reference in New Issue