I have the following Cucumber scenario:
Scenario: find vegetable with same color
Given I am on the details page for "Potato"
Since I’m able to piggy back off a web_step:
Given /^(?:|I )am on (.+)$/ do |page_name|
visit path_to(page_name)
end
All I have to do is and to the paths.rb file which I did:
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))
However, once I run cucumber, I get the following error:
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…
I’m not sure why edit_vegetable_path works, but vegetable_path doesn’t. I even tried hard-coding a particular vegetable page (just as a test) and I got the same error:
when /^the details page for "(.*)"$/
'/vegetables/1'
I have no idea how to further debug this issue at this point. Any assistance will be appreciated.
I found out that there was an issue with my view file. Once I made the change, everything worked out.