Commit c5247a0e9580d90642dbd0baaa8c534955d54f5c
1 parent
7fe87c62
Exists in
master
and in
29 other branches
small changes in cucumber paths file
Showing
1 changed file
with
15 additions
and
9 deletions
Show diff stats
features/support/paths.rb
| ... | ... | @@ -3,7 +3,7 @@ module NavigationHelpers |
| 3 | 3 | # |
| 4 | 4 | # When /^I go to (.+)$/ do |page_name| |
| 5 | 5 | # |
| 6 | - # step definition in webrat_steps.rb | |
| 6 | + # step definition in web_steps.rb | |
| 7 | 7 | # |
| 8 | 8 | def path_to(page_name) |
| 9 | 9 | case page_name |
| ... | ... | @@ -11,6 +11,12 @@ module NavigationHelpers |
| 11 | 11 | when /the homepage/ |
| 12 | 12 | '/' |
| 13 | 13 | |
| 14 | + # Add more mappings here. | |
| 15 | + # Here is an example that pulls values out of the Regexp: | |
| 16 | + # | |
| 17 | + # when /^(.*)'s profile page$/i | |
| 18 | + # user_profile_path(User.find_by_login($1)) | |
| 19 | + | |
| 14 | 20 | when /^\// |
| 15 | 21 | page_name |
| 16 | 22 | |
| ... | ... | @@ -111,15 +117,15 @@ module NavigationHelpers |
| 111 | 117 | when /^(.+)'s members page/ |
| 112 | 118 | '/profile/%s/members' % Profile.find_by_name($1).identifier |
| 113 | 119 | |
| 114 | - # Add more mappings here. | |
| 115 | - # Here is a more fancy example: | |
| 116 | - # | |
| 117 | - # when /^(.*)'s profile page$/i | |
| 118 | - # user_profile_path(User.find_by_login($1)) | |
| 119 | - | |
| 120 | 120 | else |
| 121 | - raise "Can't find mapping from \"#{page_name}\" to a path.\n" + | |
| 122 | - "Now, go and add a mapping in #{__FILE__}" | |
| 121 | + begin | |
| 122 | + page_name =~ /the (.*) page/ | |
| 123 | + path_components = $1.split(/\s+/) | |
| 124 | + self.send(path_components.push('path').join('_').to_sym) | |
| 125 | + rescue Object => e | |
| 126 | + raise "Can't find mapping from \"#{page_name}\" to a path.\n" + | |
| 127 | + "Now, go and add a mapping in #{__FILE__}" | |
| 128 | + end | |
| 123 | 129 | end |
| 124 | 130 | end |
| 125 | 131 | end | ... | ... |