When I set up a new rails 3.1.3 project and write a Cucumber story with Webrat code, like this:
response.should contain("abc")
and I run rake cucumber
, I get:
undefined method `contain' for #<Cucumber::Rails::World:0x00000003d2c578> (NoMethodError)
I believe that either Cucumber or Webrat or Rails is broken because I did nothing special at all and stuck to documentation.
The following steps reproduce the error:
rvm 1.9.2
rails new testapp -d mysql
cd testapp
- {{ Edit database.yml }}
rake db:create
rake db:migrate
gem install cucumber-rails
gem install webrat
gem install database_cleaner
- {{ Edit Gemfile to include 'cucumber-rails', 'webrat' and 'database_cleaner' without version numbers }}
bundle install
rails g cucumber:install
rails g controller genres index
- add "resources :genres" to routes.rb
- {{ rails s and http://localhost:3000/genres works now }}
- Create /features/create_movie.feature with contents:
Feature: Create movie
Description
Scenario: Create a movie in genre
Given a genre named Comedy
When I create a movie Caddyshack in the Comedy genre
Then Caddyshack should be in the Comedy genre
- Create /features/step_definitions/movie_steps.rb with contents:
Given /^a genre named Comedy$/ do
end
When /^I create a movie Caddyshack in the Comedy genre$/ do
end
Then /^Caddyshack should be in the Comedy genre$/ do
visit genres_path
response.should contain("abc")
end
rake cucumber
- It fails with the error quoted above.
- Various suggestions in the internet did NOT work (e.g. Undefined webrat methods in cucumber step_definitions)
- My versions:
rails 3.1.3
cucumber 1.1.4
cucumber-rails 1.2.1
webrat 0.7.3
rack 1.3.5
rake 0.9.2.2
Any hints about how to resolve this?