Skip to content

Instantly share code, notes, and snippets.

@SebAshton
Created June 4, 2013 15:45
Show Gist options
  • Save SebAshton/5706958 to your computer and use it in GitHub Desktop.
Save SebAshton/5706958 to your computer and use it in GitHub Desktop.
Cucumber Steps for HTTP Redirection. Only tested using Capybara's default driver (RackTest)
# Feature: HTTP redirects
# Scenario: 301 redirect
# When I visit the path "<old_path>"
# Then I should get a response with status 301
# And the url path should be "<new_path>"
Then /^I should get a response with status (\d+)$/ do |status|
assert @response.status.should == status
end
Then /^the url path should be "(.*?)"$/ do |path|
assert page.current_path == path,
"#{page.current_path} != #{path}"
end
When /^I visit the path "(.*?)"$/ do |path|
current_driver = Capybara.current_session.driver
@response = current_driver.get path
visit "#{path}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment