Skip to content

Instantly share code, notes, and snippets.

@dasibre
Created September 25, 2018 15:38
Show Gist options
  • Save dasibre/2a2c320826f5ebe31ca19d275c58856b to your computer and use it in GitHub Desktop.
Save dasibre/2a2c320826f5ebe31ca19d275c58856b to your computer and use it in GitHub Desktop.
configuring selenium capybara
ENV["RAILS_ENV"] = "test"
require File.expand_path("../../config/environment", __FILE__)
require "minitest/autorun"
require "capybara/rails"
require "active_support/testing/setup_and_teardown"
Dir[Rails.root.join("test/support/**/*.rb")].each {|f| require f}
DatabaseCleaner.strategy = :truncation
class IntegrationTest < MiniTest::Spec
include Rails.application.routes.url_helpers
include Capybara::DSL
register_spec_type(/integration$/, self)
Capybara.javascript_driver = :selenium
after do
DatabaseCleaner.clean # Truncate the database
Capybara.reset_sessions! # Forget the (simulated) browser state
Capybara.use_default_driver # Revert Capybara.current_driver to Capybara.default_driver
end
end
class HelperTest < MiniTest::Spec
include ActiveSupport::Testing::SetupAndTeardown
include ActionView::TestCase::Behavior
register_spec_type(/Helper$/, self)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment