From 9e53777674f4a66f8634235053355ab8147dba0c Mon Sep 17 00:00:00 2001 From: Ian White Date: Thu, 9 Jul 2009 10:40:44 +0100 Subject: [PATCH] Update generated paths.rb for cucumber features --- features/support/paths.rb | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/features/support/paths.rb b/features/support/paths.rb index ce4ea0e6..cd932151 100644 --- a/features/support/paths.rb +++ b/features/support/paths.rb @@ -1,24 +1,22 @@ module NavigationHelpers - # Maps a static name to a static route. + # Maps a name to a path. Used by the # - # This method is *not* designed to map from a dynamic name to a - # dynamic route like post_comments_path(post). For dynamic - # routes like this you should *not* rely on #path_to, but write - # your own step definitions instead. Example: + # When /^I go to (.+)$/ do |page_name| # - # Given /I am on the comments page for the "(.+)" post/ |name| - # post = Post.find_by_name(name) - # visit post_comments_path(post) - # end + # step definition in webrat_steps.rb # def path_to(page_name) case page_name when /the homepage/ - root_path - - # Add more page name => path mappings here + '/' + # Add more mappings here. + # Here is a more fancy example: + # + # when /^(.*)'s profile page$/i + # user_profile_path(User.find_by_login($1)) + # added by script/generate pickle path when /^#{capture_model}(?:'s)? page$/ # eg. the forum's page @@ -40,7 +38,7 @@ def path_to(page_name) else raise "Can't find mapping from \"#{page_name}\" to a path.\n" + - "Now, go and add a mapping in features/support/paths.rb" + "Now, go and add a mapping in #{__FILE__}" end end end