Search code examples
cucumberruby-on-rails-3webrat

Rails 3 Cucumber/Webrat fails on simple "Given": did I set up something wrong?


My feature file:

Feature: home page links

  Background: I am on the home page
    Given I am on the home page

  Scenario: I visit the about page
    When I follow "About"
    Then I should be on the about page

In my paths.rb, I have

when /the home\s?page/ then root_path

and rake routes gives:

    root  /(.:format)         {:controller=>"home", :action=>"home"}

When I try to run "bundle exec cucumber", I get the message:

undefined local variable or method `controller' for #<HomeController:0xb29583c> (ActionView::Template::Error)
<a lot of crap>
./features/step_definitions/web_steps.rb:16:in `/^(?:|I )am on (.+)$/'
features/home_page.feature:4:in `Given I am on the home page'

Failing Scenarios:
cucumber features/home_page.feature:6 # Scenario: I visit the about page

It's a trivial test, but I don't know where to start investigating this failure. Any ideas? Thanks.


Also, my Gemfile:

source :rubygems

gem "rails", "~>3.0"
gem "haml", "~>3.0"

group :test do
  gem 'cucumber'
  gem 'cucumber-rails'
  gem 'nokogiri'
  gem 'webrat'
end

group :development do
  gem "rspec-rails", "~>2.0.pre"
  gem "heroku"
  gem "will_paginate", "~>3.0.pre2"
end

Solution

  • I can't find the warnings anymore, but I think the Capybara gem is now recommended for use with Cucumber on Rails3.

    Okay, after some searching, it may work fine, but take a look at the comments here. The problem isn't exactly like yours but it could be related.