From c5247a0e9580d90642dbd0baaa8c534955d54f5c Mon Sep 17 00:00:00 2001 From: Daniel Cunha Date: Fri, 23 Nov 2012 01:52:52 -0300 Subject: [PATCH] small changes in cucumber paths file --- features/support/paths.rb | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/features/support/paths.rb b/features/support/paths.rb index ac707c8..6c4d1e5 100644 --- a/features/support/paths.rb +++ b/features/support/paths.rb @@ -3,7 +3,7 @@ module NavigationHelpers # # When /^I go to (.+)$/ do |page_name| # - # step definition in webrat_steps.rb + # step definition in web_steps.rb # def path_to(page_name) case page_name @@ -11,6 +11,12 @@ module NavigationHelpers when /the homepage/ '/' + # Add more mappings here. + # Here is an example that pulls values out of the Regexp: + # + # when /^(.*)'s profile page$/i + # user_profile_path(User.find_by_login($1)) + when /^\// page_name @@ -111,15 +117,15 @@ module NavigationHelpers when /^(.+)'s members page/ '/profile/%s/members' % Profile.find_by_name($1).identifier - # Add more mappings here. - # Here is a more fancy example: - # - # when /^(.*)'s profile page$/i - # user_profile_path(User.find_by_login($1)) - else - raise "Can't find mapping from \"#{page_name}\" to a path.\n" + - "Now, go and add a mapping in #{__FILE__}" + begin + page_name =~ /the (.*) page/ + path_components = $1.split(/\s+/) + self.send(path_components.push('path').join('_').to_sym) + rescue Object => e + raise "Can't find mapping from \"#{page_name}\" to a path.\n" + + "Now, go and add a mapping in #{__FILE__}" + end end end end -- libgit2 0.21.2