2012-06-21 33 views
0

导航到详细信息页面paths.rb更新后,我有以下黄瓜场景:错误使用黄瓜

Scenario: find vegetable with same color 
    Given I am on the details page for "Potato" 

既然我能上捎带断web_step:

Given /^(?:|I)am on (.+)$/ do |page_name| 
    visit path_to(page_name) 
end 

所有我需要做的就是和我做了paths.rb文件:

def path_to(page_name) 
    case page_name 

    when /^the edit page for "(.*)"$/ 
    edit_vegetable_path(Vegetable.find_by_name($1)) 
    when /^the details page for "(.*)"$/ 
    vegetable_path(Vegetable.find_by_title($1)) 

但是,一旦我跑黄瓜,我得到以下ERR或:

Given I am on the details page for "Potato"    # features/step_definitions/web_steps.rb:44 
     undefined method `strftime' for nil:NilClass (ActionView::Template::Error) 
     /usr/local/lib/ruby/gems/1.9.1/gems/activesupport-3.1.0/lib/active_support/whiny_nil.rb:48:in `method_missing' 
     ./app/views/vegetables/show.html.haml:14:in `_app_views_vegetables_show_html_haml___295190995_93073700' 
     /usr/local/lib/ruby/gems/1.9.1/gems/actionpack-3.1.0/lib/action_view/template.rb:144:in `block in render' 
     /usr/local/lib/ruby/gems/1.9.1/gems/activesupport-3.1.0/lib/active_support/notifications.rb:55:in `instrument' 
     /usr/local/lib/ruby/gems/1.9.1/gems/actionpack-3.1.0/lib/action_view/template.rb:142:in `render' 

等等

我不知道为什么edit_vegetable_path作品,但vegetable_path没有。我甚至尝试硬编码特定的页面蔬菜(只是作为测试),我得到了同样的错误:

when /^the details page for "(.*)"$/ 
    '/vegetables/1' 

我不知道如何进一步调试这个问题,在这一点上。任何援助将不胜感激。

回答

0

我发现我的视图文件有问题。一旦我做出改变,一切都会奏效。