ruby-on-rails-3 – 黄瓜step_definitions中未定义的webrat方法

当我运行我的功能,我得到这个错误:
undefined method `visit' for #<Cucumber::Rails::World:0x81b17ac0> (NoMethodError)

这是我的Gemfile的相关部分.

group :development,:test do
  gem "rspec-rails",">= 2.0.0.beta.19"
  gem "cucumber"
  gem "cucumber-rails",">= 0.3.2"
  gem 'webrat',">= 0.7.2.beta.1"
end

相关的step_definition(虽然我不认为这很重要)

When /^I create a movie Caddyshack in the Comendy genre$/ do
  visit movies_path
  click_link "Add Movie"
  fill_in "Title",:with => "Caddyshack"
  check "Comedy"
  click_button "Save"
end

在env.rb中,我有以下Webrat配置:

# […]
require 'webrat'
require 'webrat/core/matchers'

Webrat.configure do |config|
  config.mode = :rails
  config.open_error_files = false # Set to true if you want error pages to pop up in the browser
end
# […]

我在这里失踪了吗

解决方法

我必须将config.mode设置为:rack而不是:rails:
# […]
require 'webrat'
require 'webrat/core/matchers'

Webrat.configure do |config|
  config.mode = :rack
  config.open_error_files = false # Set to true if you want error pages to pop up in the browser
end
# […]

现在按预期工作.

相关文章

validates:conclusion,:presence=>true,:inclusion=>{...
一、redis集群搭建redis3.0以前,提供了Sentinel工具来监控各...
分享一下我老师大神的人工智能教程。零基础!通俗易懂!风趣...
上一篇博文 ruby传参之引用类型 里边定义了一个方法名 mo...
一编程与编程语言 什么是编程语言? 能够被计算机所识别的表...
Ruby类和对象Ruby是一种完美的面向对象编程语言。面向对象编...