Read more

Test meta-refresh redirects with Cucumber

Dominik Schöler
September 12, 2012Software engineer at makandra GmbH

The step definition below allows you to write:

Then I should see an HTML redirect to "http://www.makandracards.com" in the page head

Capybara

Then /^I should see an HTML redirect to "([^\"]*)" in the page head$/ do |redirect_url|
  page.should have_xpath("//meta[@http-equiv=\"refresh\" and contains(@content, \"#{redirect_url}\")]")
end

Illustration online protection

Rails Long Term Support

Rails LTS provides security patches for old versions of Ruby on Rails (2.3, 3.2, 4.2 and 5.2)

  • Prevents you from data breaches and liability risks
  • Upgrade at your own pace
  • Works with modern Rubies
Read more Show archive.org snapshot

To find meta tags with Capybara, you can also use page.find('meta', visible: false).

Posted by Dominik Schöler to makandra dev (2012-09-12 11:41)