Skip to content

Instantly share code, notes, and snippets.

@ihoka
Created November 9, 2009 08:21
Show Gist options
  • Save ihoka/229781 to your computer and use it in GitHub Desktop.
Save ihoka/229781 to your computer and use it in GitHub Desktop.
def resource_to(page_name, record)
case page_name
when /the model page/
url_for(record)
when /the answers page/
question_answers_path(record)
else
raise "Can't find mapping from \"#{page_name}\" to a resource.\n" +
"Now, go and add a mapping in #{__FILE__}"
end
end
When /^I follow "([^\"]*)" for #{capture_model}$/ do |link, target|
record = model(target)
click_link_within("##{dom_id(record)}", link)
end
When /^I navigate to (.+?) for #{capture_model}$/ do |page_name, capture|
record = model(capture)
visit resource_to(page_name, record)
end
Then /^I should be at (.+?) for #{capture_model}$/ do |page_name, capture|
record = model(capture)
URI.parse(current_url).path.should == resource_to(page_name, record)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment