Skip to content

Instantly share code, notes, and snippets.

@garyharan
Created December 27, 2022 16:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save garyharan/e11111ac47cd82804d81ff9ad7dca73b to your computer and use it in GitHub Desktop.
Save garyharan/e11111ac47cd82804d81ff9ad7dca73b to your computer and use it in GitHub Desktop.
How to test using capybara in latest rails and chrome
# as per https://rubydoc.info/github/teamcapybara/capybara/master#using-capybara-with-minitest
require 'capybara/rails'
require 'capybara/minitest'
class ActionDispatch::IntegrationTest
# Make the Capybara DSL available in all integration tests
include Capybara::DSL
# Make `assert_*` methods behave like Minitest assertions
include Capybara::Minitest::Assertions
# Reset sessions and driver between tests
teardown do
Capybara.reset_sessions!
Capybara.use_default_driver
end
end
# To see each step
Capybara.default_driver = :selenium_chrome
# if you want headless:
Capybara.default_driver = :selenium_chrome_headless
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment