Testing
Setup
# This file is copied to spec/ when you run 'rails generate rspec:install'
require "spec_helper"
ENV["RAILS_ENV"] ||= "test"
require File.expand_path("../config/environment", __dir__)
# Prevent database truncation if the environment is production
abort("The Rails environment is running in production mode!") if Rails.env.production?
require "rspec/rails"
Dir[File.join File.dirname(__FILE__), "support", "**", "*.rb"].each { |f| require f }
# Add additional requires below this line. Rails is not loaded until this point!require "capybara/rspec"
require "capybara/rails"
require "selenium/webdriver"
# port used for debugging (explained later)
Capybara.server_port = 33123
Capybara.server_host = "0.0.0.0"
Capybara.register_driver :headless_chrome do |app|
chrome_options = Selenium::WebDriver::Chrome::Options.new.tap do |o|
o.add_argument "--headless"
o.add_argument "--no-sandbox"
o.add_argument "--disable-dev-shm-usage"
o.add_argument "--disable-gpu"
o.add_argument "--enable-features=NetworkService,NetworkServiceInProcess"
end
Capybara::Selenium::Driver.new(app, browser: :chrome, options: chrome_options)
end
Capybara.default_driver = :headless_chromeWriting basic specs
Testing asynchronous features
Testing forms and actions
Debugging specs
Last updated