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

Answers


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.


Actually, I did have the same problem once. I thought Cucumber was responsible but look closer, it seems the error lies in your view: ActionView::Template::Error

Cucumber uses the test database, if you require seeds for your homepage, they aren't loaded.

In your case, it seems you've written a misunderstood controller, maybe while typing something like params[controller]


Need Your Help

Can i do conditional or selective SELECT statement on SQL?

sql oracle select

Is there a a way to select a SELECT statement?

why is my viewcontroller not in the window hierarchy?

uiviewcontroller ios6 xcode4.5 xib uistoryboardsegue

Using storyboards, MainMenuViewController presents Number1ViewController modally with this:

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.