当我运行功能时,出现此错误:
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
# […]
现在可以正常工作了。
关于ruby-on-rails-3 - cucumber step_definitions中的未定义Webrat方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3546011/