When I use the visit
method in Cucumber's step definitions and then run the step through Capybara's Selenium driver it's passed despite the controller isn't implemented.
Here's an example:
Feature
# features/one.feature
Feature: One
@selenium
Scenario: One
Given I visit the example page
Step definition
# features/step_definitions/example_steps.rb
Given /^I visit the example page$/ do
visit example_path
end
Route
# config/routes.rb
Example::Application.routes.draw do
resource :example
end
Controller
isn't implemented
开发者_StackOverflow中文版Result
Feature: One
@selenium
Scenario: One
Given I visit the example page
1 scenario (1 passed)
1 step (1 passed)
0m18.162s
However, when I use the RackTest driver all works as it expected to be and the routing exception is risen unless a controller is implemented.
Here's the same example but with the usage of RackTest:
Feature
# features/one.feature
Feature: One
@rack_test
Scenario: One
Given I visit the example page
Result
Feature: One
@rack_test
Scenario: One
Given I visit the example page
uninitialized constant ExamplesController (ActionController::RoutingError)
./features/step_definitions/example_steps.rb:2:in `/^I visit the example page$/'
features/one.feature:5:in `Given I visit the example page'
Failing Scenarios:
cucumber features/one.feature:4 # Scenario: One
1 scenario (1 failed)
1 step (1 failed)
How can I force Capybara to raise the routing error when using the Selenium driver?
Thanks.
Ruby 1.9.2;
Ruby on Rails 3.1.0.rc1;
Cucumber 0.10.3;
Cucumber-rails 0.5.0;
Capybara 1.0.0.beta1;
Selenium-webdriver 0.2.0.
The Selenium driver does not fail when it receives a "failure" http code like 500. If you left your config/environments/test.rb at it's defaults, there should be a line config.action_dispatch.show_exceptions = false. So you can either set this to true or you would have to add some more steps to ensure the page is actually showing what you expect.
精彩评论