加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

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

发布时间:2020-12-16 22:07:53 所属栏目:百科 来源:网络整理
导读:当我运行我的功能,我得到这个错误: 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
当我运行我的功能,我得到这个错误:
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
# […]

现在按预期工作.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读