9

When i run my features i get this error:

undefined method `visit' for #<Cucumber::Rails::World:0x81b17ac0> (NoMethodError)

This is the relevant part of my 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

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

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

Anything i am missing here?

nocksock
  • 5,369
  • 6
  • 38
  • 63
  • Wow… since i just got a popular questions badge for this one it seems to me this hasn't yet been patched. Will check that out later… – nocksock May 18 '11 at 13:04

3 Answers3

16

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

now works as expected.

nocksock
  • 5,369
  • 6
  • 38
  • 63
  • 5
    In case people don't know this is to be edited in features/support/env.rb – Victor Martins Dec 31 '10 at 09:00
  • 2
    This solution worked for me... However, why is it required? I would think that the rails generator should generate the correct thing, whether that's a mode of :rails (which the [webrat readme](https://github.com/brynary/webrat#readme) seems to say is the right thing, by the way) or of :rack... But this seems not to be the case. Does anyone know why? – lindes Mar 02 '11 at 07:35
  • Thx you so much, it was such an annoying issue. – Denis Apr 06 '11 at 08:56
  • I've run into this, but when I change the webrat method to :rack instead of :rails, all the response.should be_success tests fail. Everyone one of them with this: undefined method `success?' for # (NoMethodError) – BeepDog Apr 30 '11 at 21:23
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)
pagetribe
  • 15,031
  • 3
  • 24
  • 18
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.

newUser
  • 661
  • 1
  • 6
  • 10