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

前端之家收集整理的这篇文章主要介绍了ruby-on-rails-3 – 黄瓜step_definitions中未定义的webrat方法前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
@H_301_1@当我运行我的功能,我得到这个错误
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
# […]

现在按预期工作.

原文链接:https://www.f2er.com/ruby/266489.html

猜你在找的Ruby相关文章