Skip to content

Instantly share code, notes, and snippets.

@JohnBat26
Created October 30, 2011 18:59
Show Gist options
  • Save JohnBat26/1326282 to your computer and use it in GitHub Desktop.
Save JohnBat26/1326282 to your computer and use it in GitHub Desktop.
require 'uri'
require 'cgi'
require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "paths"))
Given /^(?:|I )am on (.+)$/ do |page_name|
visit ProjectsHelper.path_to(page_name)
end
When /^(?:|I )follow "([^"]*)"$/ do |link|
click_link(link)
end
And /^(?:|I )fill in "([^"]*)" with "([^"]*)"$/ do |field, value|
fill_in(field, :with => value)
end
And /^(?:|I )press "([^"]*)"$/ do |button|
click_button(button)
end
Then /^(?:|I )should see "([^"]*)"$/ do |text|
if page.respond_to? :should
page.should have_content(text)
else
assert page.has_content?(text)
end
end
Then /^(?:|I )should see \/([^\/]*)\/$/ do |regexp|
regexp = Regexp.new(regexp)
if page.respond_to? :should
page.should have_xpath('//*', :text => regexp)
else
assert page.has_xpath?('//*', :text => regexp)
end
end
Then /^(?:|I )should be on (.+)$/ do |page_name|
current_path = URI.parse(current_url).path
if current_path.respond_to? :should
current_path.should == ProjectsHelper.path_to(page_name)
else
assert_equal ProjectsHelper.path_to(page_name), current_path
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment