Rails 3.1 Capybara的Selenium驱动程序未捕获路由错误

问题描述

|| 当我在Cucumber的步骤定义中使用“ 0”方法,然后通过Capybara的Selenium驱动程序运行该步骤时,尽管未实现控制器,但该步骤已通过。 这是一个例子: 特征
# features/one.feature

Feature: One

  @selenium
  Scenario: One
    Given I visit the example page
步骤定义
# features/step_definitions/example_steps.rb

Given /^I visit the example page$/ do
  visit example_path
end
路线
# config/routes.rb

Example::Application.routes.draw do
  resource :example
end
控制者 未实施 结果
Feature: One

    @selenium
    Scenario: One
      Given I visit the example page

    1 scenario (1 passed)
    1 step (1 passed)
    0m18.162s
但是,当我使用RackTest驱动程序时,所有功能都会按预期运行,除非实现了控制器,否则路由异常会上升。 这是相同的示例,但使用了RackTest: 特征
# features/one.feature

Feature: One

  @rack_test
  Scenario: One
    Given I visit the example page
结果
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)
使用Selenium驱动程序时,如何强制Capybara引发路由错误? 谢谢。 Ruby 1.9.2; Ruby on Rails 3.1.0.rc1; 黄瓜0.10.3; 黄瓜轨0.5.0; 水豚1.0.0.beta1; Selenium-webdriver 0.2.0。     

解决方法

Selenium驱动程序在收到“失败” http代码(如500)时不会失败。如果您将config / environments / test.rb保留为默认设置,则应该有一行config.action_dispatch.show_exceptions = false 。因此,您可以将其设置为true,或者必须添加更多步骤以确保页面实际显示了您期望的内容。     

相关问答

依赖报错 idea导入项目后依赖报错,解决方案:https://blog....
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下...
错误1:gradle项目控制台输出为乱码 # 解决方案:https://bl...
错误还原:在查询的过程中,传入的workType为0时,该条件不起...
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct...