黄瓜step_definitions中的未定义webrat方法 [英] Undefined webrat methods in cucumber step_definitions
本文介绍了黄瓜step_definitions中的未定义webrat方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我运行我的功能我得到这个错误:
When i run my features i get this error:
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这很重要)
The relating step_definition (though i don't think it's important)
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配置:
In the env.rb i have the following Webrat configuration:
# […]
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
:
I had to set config.mode
to :rack
instead of :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
# […]
现在可以正常工作。
这篇关于黄瓜step_definitions中的未定义webrat方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文