2009-04-13 22:26:20 +02:00
|
|
|
module NavigationHelpers
|
2010-07-22 13:54:26 +02:00
|
|
|
# Maps a name to a path. Used by the
|
|
|
|
|
#
|
|
|
|
|
# When /^I go to (.+)$/ do |page_name|
|
|
|
|
|
#
|
|
|
|
|
# step definition in web_steps.rb
|
|
|
|
|
#
|
2009-04-13 22:26:20 +02:00
|
|
|
def path_to(page_name)
|
|
|
|
|
case page_name
|
2010-07-22 13:54:26 +02:00
|
|
|
|
|
|
|
|
when /the home\s?page/
|
2010-07-27 23:32:22 +02:00
|
|
|
root_path
|
|
|
|
|
when /the statistics page/
|
|
|
|
|
stats_path
|
|
|
|
|
when /the signup page/
|
|
|
|
|
signup_path
|
|
|
|
|
when /the login page/
|
|
|
|
|
login_path
|
|
|
|
|
when /the notes page/
|
|
|
|
|
notes_path
|
|
|
|
|
when /the contexts page/
|
|
|
|
|
contexts_path
|
|
|
|
|
when /the manage users page/
|
|
|
|
|
users_path
|
|
|
|
|
when /the repeating todos page/
|
|
|
|
|
recurring_todos_path
|
|
|
|
|
when /the integrations page/
|
|
|
|
|
integrations_path
|
2010-07-14 15:13:20 +02:00
|
|
|
when /the tickler page/
|
|
|
|
|
tickler_path
|
2010-07-22 13:54:26 +02:00
|
|
|
|
2010-07-14 15:13:20 +02:00
|
|
|
# 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))
|
2010-07-22 13:54:26 +02:00
|
|
|
|
2009-04-13 22:26:20 +02:00
|
|
|
else
|
2010-07-22 13:54:26 +02:00
|
|
|
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
|
2009-04-13 22:26:20 +02:00
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2009-05-25 20:30:20 +02:00
|
|
|
World(NavigationHelpers)
|