Skip to content

Instantly share code, notes, and snippets.

@fnichol
Created January 17, 2011 17:10
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save fnichol/783102 to your computer and use it in GitHub Desktop.
Feature: Website navigation
In order to navigate the website by links
As a site visitor
I want to have a top level navigation
Scenario: About us nav link
Given I am on the home page
When I follow "About Us"
Then I should be on the aboutus page
module NavigationHelpers
def path_to(page_name)
case page_name
when /the home\s? page/
'/'
when /the aboutus page/
'/about'
else
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
World(NavigationHelpers)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment