Skip to content

Commit

Permalink
Merge commit 'david/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
brynary committed Oct 25, 2008
2 parents c2203cf + a4f5e71 commit 6f7325a
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 6 deletions.
2 changes: 1 addition & 1 deletion lib/webrat/core/session.rb
Expand Up @@ -82,7 +82,7 @@ def request_page(url, http_method, data)
end

def success_code?
(200..299).include?(response_code)
(200..499).include?(response_code)
end

def exception_caught?
Expand Down
14 changes: 13 additions & 1 deletion spec/api/clicks_area_spec.rb
Expand Up @@ -21,10 +21,22 @@
<area href="/page" title="Berlin" id="berlin" shape="poly" alt="Berlin" coords="180,89,180" />
</map>
EOS
@session.response_code = 404
@session.response_code = 501
lambda { @session.clicks_area "Berlin" }.should raise_error
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
@session.response_body = <<-EOS
<map name="map_de" id="map_de">
Expand Down
14 changes: 13 additions & 1 deletion spec/api/clicks_button_spec.rb
Expand Up @@ -50,10 +50,22 @@
<input type="submit" />
</form>
EOS
@session.response_code = 404
@session.response_code = 501
lambda { @session.clicks_button }.should raise_error
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
@session.response_body = <<-EOS
<form method="get" action="/form1">
Expand Down
12 changes: 11 additions & 1 deletion spec/api/clicks_link_spec.rb
Expand Up @@ -155,10 +155,20 @@
@session.response_body = <<-EOS
<a href="/page">Link text</a>
EOS
@session.response_code = 404
@session.response_code = 501
lambda { @session.clicks_link "Link text" }.should raise_error
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
@session.response_body = <<-EOS
<a href="/page">Link text</a>
Expand Down
11 changes: 9 additions & 2 deletions spec/api/visits_spec.rb
Expand Up @@ -12,10 +12,17 @@
end

it "should assert valid response" do
@session.response_code = 404
@session.response_code = 501
lambda { @session.visits("/") }.should raise_error
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
lambda { @session.fills_in "foo", :with => "blah" }.should raise_error
end
Expand All @@ -33,4 +40,4 @@
@session.visits("/")
end

end
end

0 comments on commit 6f7325a

Please sign in to comment.