9

当我运行我的功能时,我收到此错误:

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
# […]

我在这里缺少什么吗?

4

3 回答 3

16

我不得不设置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
# […]

现在按预期工作。

于 2010-08-23T10:01:20.617 回答
1

I also encountered this error on two separate occasions: the first instance the adjustment to confg.mode solved the problem; the second time, however, after a lot of frustration I found a link that suggested a buggy version of bundler could be the culprit. Updating it solved the problem.

于 2011-01-22T15:55:37.110 回答
1

Paul Nelligan try adding this to env.rb to fix the error : "no such file to load -- action_controller/integration"

World(Webrat::Methods)
World(Webrat::Matchers)
于 2010-10-08T04:43:09.560 回答