Skip to content

Instantly share code, notes, and snippets.

@twalpole
Created June 8, 2018 00:03
Show Gist options
  • Save twalpole/5f14160e792ce64f06499376adb95558 to your computer and use it in GitHub Desktop.
Save twalpole/5f14160e792ce64f06499376adb95558 to your computer and use it in GitHub Desktop.
test current path
gem 'poltergeist', '1.18.1'
require "capybara/dsl"
require 'capybara/poltergeist'
html = DATA.read
app = proc { |env| [200, { "Content-Type" => "text/html" }, [html] ] }
sess = Capybara::Session.new(:poltergeist, app)
sess.visit('/')
sess.assert_current_path('/')
puts sess.current_path
sess.visit('/something')
sess.assert_current_path('/something')
puts sess.current_path
__END__
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Snippet</title>
</head>
<body>
<div>Contents</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment