Merge commit 'david/master'
This commit is contained in:
commit
6f7325aa53
|
@ -82,7 +82,7 @@ module Webrat
|
||||||
end
|
end
|
||||||
|
|
||||||
def success_code?
|
def success_code?
|
||||||
(200..299).include?(response_code)
|
(200..499).include?(response_code)
|
||||||
end
|
end
|
||||||
|
|
||||||
def exception_caught?
|
def exception_caught?
|
||||||
|
|
|
@ -21,10 +21,22 @@ describe "clicks_area" do
|
||||||
<area href="/page" title="Berlin" id="berlin" shape="poly" alt="Berlin" coords="180,89,180" />
|
<area href="/page" title="Berlin" id="berlin" shape="poly" alt="Berlin" coords="180,89,180" />
|
||||||
</map>
|
</map>
|
||||||
EOS
|
EOS
|
||||||
@session.response_code = 404
|
@session.response_code = 501
|
||||||
lambda { @session.clicks_area "Berlin" }.should raise_error
|
lambda { @session.clicks_area "Berlin" }.should raise_error
|
||||||
end
|
end
|
||||||
|
|
||||||
|
[200, 300, 400, 499].each do |status|
|
||||||
|
it "should consider the status code as success" do
|
||||||
|
@session.response_body = <<-EOS
|
||||||
|
<map name="map_de" id="map_de">
|
||||||
|
<area href="/page" title="Berlin" id="berlin" shape="poly" alt="Berlin" coords="180,89,180" />
|
||||||
|
</map>
|
||||||
|
EOS
|
||||||
|
@session.response_code = status
|
||||||
|
lambda { @session.clicks_area "Berlin" }.should_not raise_error
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
it "should fail if the area doesn't exist" do
|
it "should fail if the area doesn't exist" do
|
||||||
@session.response_body = <<-EOS
|
@session.response_body = <<-EOS
|
||||||
<map name="map_de" id="map_de">
|
<map name="map_de" id="map_de">
|
||||||
|
|
|
@ -50,10 +50,22 @@ describe "clicks_button" do
|
||||||
<input type="submit" />
|
<input type="submit" />
|
||||||
</form>
|
</form>
|
||||||
EOS
|
EOS
|
||||||
@session.response_code = 404
|
@session.response_code = 501
|
||||||
lambda { @session.clicks_button }.should raise_error
|
lambda { @session.clicks_button }.should raise_error
|
||||||
end
|
end
|
||||||
|
|
||||||
|
[200, 300, 400, 499].each do |status|
|
||||||
|
it "should consider the status code as success" do
|
||||||
|
@session.response_body = <<-EOS
|
||||||
|
<form action="/login">
|
||||||
|
<input type="submit" />
|
||||||
|
</form>
|
||||||
|
EOS
|
||||||
|
@session.response_code = status
|
||||||
|
lambda { @session.clicks_button }.should_not raise_error
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
it "should submit the first form by default" do
|
it "should submit the first form by default" do
|
||||||
@session.response_body = <<-EOS
|
@session.response_body = <<-EOS
|
||||||
<form method="get" action="/form1">
|
<form method="get" action="/form1">
|
||||||
|
|
|
@ -155,10 +155,20 @@ describe "clicks_link" do
|
||||||
@session.response_body = <<-EOS
|
@session.response_body = <<-EOS
|
||||||
<a href="/page">Link text</a>
|
<a href="/page">Link text</a>
|
||||||
EOS
|
EOS
|
||||||
@session.response_code = 404
|
@session.response_code = 501
|
||||||
lambda { @session.clicks_link "Link text" }.should raise_error
|
lambda { @session.clicks_link "Link text" }.should raise_error
|
||||||
end
|
end
|
||||||
|
|
||||||
|
[200, 300, 400, 499].each do |status|
|
||||||
|
it "should consider the status code as success" do
|
||||||
|
@session.response_body = <<-EOS
|
||||||
|
<a href="/page">Link text</a>
|
||||||
|
EOS
|
||||||
|
@session.response_code = status
|
||||||
|
lambda { @session.clicks_link "Link text" }.should_not raise_error
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
it "should fail is the link doesn't exist" do
|
it "should fail is the link doesn't exist" do
|
||||||
@session.response_body = <<-EOS
|
@session.response_body = <<-EOS
|
||||||
<a href="/page">Link text</a>
|
<a href="/page">Link text</a>
|
||||||
|
|
|
@ -12,10 +12,17 @@ describe "visits" do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should assert valid response" do
|
it "should assert valid response" do
|
||||||
@session.response_code = 404
|
@session.response_code = 501
|
||||||
lambda { @session.visits("/") }.should raise_error
|
lambda { @session.visits("/") }.should raise_error
|
||||||
end
|
end
|
||||||
|
|
||||||
|
[200, 300, 400, 499].each do |status|
|
||||||
|
it "should consider the status code as success" do
|
||||||
|
@session.response_code = status
|
||||||
|
lambda { @session.visits("/") }.should_not raise_error
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
it "should require a visit before manipulating page" do
|
it "should require a visit before manipulating page" do
|
||||||
lambda { @session.fills_in "foo", :with => "blah" }.should raise_error
|
lambda { @session.fills_in "foo", :with => "blah" }.should raise_error
|
||||||
end
|
end
|
||||||
|
@ -33,4 +40,4 @@ describe "visits with referer" do
|
||||||
@session.visits("/")
|
@session.visits("/")
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue