You can use these step definitions:
Then /^I should not see an error$/ do
(200 .. 399).should include(page.status_code)
end
Then /^I should see an error$/ do
(400 .. 599).should include(page.status_code)
end
Note that you need to tag the scenario with @allow-rescue
to test that an error is shown like this
@allow-rescue
Scenario: Accessing the admin area requires a login
When I go to the admin area
Then I should see an error
These step definitions will not work for @javascript
scenarios using the selenium web-driver
@allow-rescue @javascript
Scenario: Accessing the admin area requires a login
When I go to the admin area
Then I should see an error
# This throws `Capybara::Driver::Base#status_code (Capybara::NotSupportedByDriverError)`
Posted by Henning Koch to makandra dev (2010-12-10 18:02)