1

我的功能文件:

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
4

2 回答 2

0

我再也找不到警告了,但我认为现在建议将Capybara gem与 Cucumber on Rails3 一起使用。

好的,经过一番搜索,它可能工作正常,但看看这里的评论。这个问题与你的不完全一样,但它可能是相关的。

于 2010-12-29T05:22:40.213 回答
0

实际上,我曾经遇到过同样的问题。我认为 Cucumber 是负责任的,但仔细观察,似乎错误在于您的观点:ActionView::Template::Error

Cucumber 使用测试数据库,如果您的主页需要种子,则不会加载它们。

在您的情况下,您似乎写了一个被误解的内容controller,可能是在输入类似的内容时params[controller]

于 2010-12-30T22:34:02.097 回答