Created
August 13, 2009 00:07
-
-
Save nicholasf/166867 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
#requires nokogori | |
#these steps will let you match the text of a link to its path, to test specific links | |
Given /^I see link "([^\"]*)" to "([^\"]*)"$/ do |arg1, arg2| | |
doc = Nokogiri::HTML(response.body) | |
nodeset = doc.xpath("//a[@href='#{arg2}']") | |
if nodeset.nil? or nodeset.size == 0 | |
fail("No matching link for #{arg2}") | |
else | |
nodeset.first.text.should eql arg1 | |
end | |
end | |
When /^I follow "([^\"]*)" to "([^\"]*)"$/ do |arg1, arg2| | |
doc = Nokogiri::HTML(response.body) | |
nodeset = doc.xpath("//a[@href='#{arg2}']") | |
if nodeset and nodeset.first.text == arg1 | |
visit arg2 | |
else | |
fail("No link called #{arg1} leading to #{arg2}") | |
end | |
end | |
#for e.g. | |
Scenario Outline: As a visitor I can access all links matched with appropriate text | |
Given I visit "/sitemap" | |
Given I see link "<link_name>" to "<link>" | |
When I follow "<link_name>" to "<link>" | |
Then response code should be "200" | |
Examples: | |
| link_name | link | | |
| Accessing Data | /protocols/accessing-data | | |
| Depositing | /protocols/depositing | | |
| Ethics | /protocols/ethics | | |
| Repatriation | /protocols/repatriation | | |
| IP Copyright | /protocols/ip-copyright | | |
| Links | /protocols/links | | |
| Restricted | /protocols/restricted | | |
| Offensive | /protocols/offensive | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment