我有以下黄瓜场景:
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))
但是,一旦我运行 cucumber,我就会收到以下错误:
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'
ETC...
我不确定为什么 edit_vegetable_path 有效,但vegetable_path 无效。我什至尝试硬编码一个特定的蔬菜页面(就像一个测试),我得到了同样的错误:
when /^the details page for "(.*)"$/
'/vegetables/1'
我现在不知道如何进一步调试这个问题。任何帮助将不胜感激。