我的功能文件:
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
在我的paths.rb中,我有
when /the home\s?page/ then root_path
和 rake 路线给出:
root /(.:format) {:controller=>"home", :action=>"home"}
当我尝试运行“bundle exec cucumber”时,我收到以下消息:
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
这是一个微不足道的测试,但我不知道从哪里开始调查这个失败。有任何想法吗?谢谢。
另外,我的 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