Skip to content

Instantly share code, notes, and snippets.

@twalpole
Created February 1, 2017 23:00
Show Gist options
  • Save twalpole/7287b8d2e9b2ba6287c93df519e90765 to your computer and use it in GitHub Desktop.
Save twalpole/7287b8d2e9b2ba6287c93df519e90765 to your computer and use it in GitHub Desktop.
require 'capybara/dsl'
require 'capybara/webkit'
app = proc do |env|
[200, { "Content-Type" => "text/html" }, [
%{<!doctype html>
<html>
<head>
<title>Title: #{env["REQUEST_PATH"]}</title>
</head>
<body>
<button onclick="window.location.href = '/next'">Move on</button>
</body>
</html>%}
] ]
end
session = Capybara::Session.new(:webkit, app)
session.visit('/')
session.assert_current_path('/')
session.assert_title("Title: /")
session.click_button('Move on')
session.assert_current_path('/next')
session.assert_title("Title: /next")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment