我有以下黄瓜情景:
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))
但是,一旦我运行黄瓜,我会收到以下错误:
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 :(得分:0)
我发现我的视图文件存在问题。一旦我做出改变,一切都会成功。