Created
November 9, 2009 08:21
-
-
Save ihoka/229781 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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