Initial Commit from Base app
[base_ror3_portal.git] / features / support / paths.rb
blobe5065d0f16154598bce115f8f8f7ad6098d29534
1 module NavigationHelpers
2   # Maps a name to a path. Used by the
3   #
4   #   When /^I go to (.+)$/ do |page_name|
5   #
6   # step definition in web_steps.rb
7   #
8   def path_to(page_name)
9     case page_name
11     when /the home\s?page/
12       '/'
13     when /devise_register/
14       '/users/sign_up'
16     # Add more mappings here.
17     # Here is an example that pulls values out of the Regexp:
18     #
19     #   when /^(.*)'s profile page$/i
20     #     user_profile_path(User.find_by_login($1))
22     else
23       begin
24         page_name =~ /the (.*) page/
25         path_components = $1.split(/\s+/)
26         self.send(path_components.push('path').join('_').to_sym)
27       rescue Object => e
28         raise "Can't find mapping from \"#{page_name}\" to a path.\n" +
29           "Now, go and add a mapping in #{__FILE__}"
30       end
31     end
32   end
33 end
35 World(NavigationHelpers)