Adding spec for disabling automatic redirects in Mechanize

This commit is contained in:
Emrys Ingersoll 2010-02-18 19:04:11 -05:00
parent b2dddf2f09
commit 56b2f342da

View File

@ -9,6 +9,13 @@ describe Webrat::MechanizeAdapter do
@mech = Webrat::MechanizeAdapter.new @mech = Webrat::MechanizeAdapter.new
end 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 describe "post" do
def url def url
'http://test.host/users' 'http://test.host/users'
@ -24,7 +31,8 @@ describe Webrat::MechanizeAdapter do
it "should flatten model post data" do it "should flatten model post data" do
mechanize = mock(:mechanize) mechanize = mock(:mechanize)
WWW::Mechanize.stub!(:new => mechanize) mechanize.stub!(:redirect_ok=)
Mechanize.stub!(:new => mechanize)
mechanize.should_receive(:post).with(url, flattened_data) mechanize.should_receive(:post).with(url, flattened_data)
Webrat::MechanizeAdapter.new.post(url, data) Webrat::MechanizeAdapter.new.post(url, data)
end end