# This file is copied to spec/ when you run 'rails generate rspec:install' ENV['RAILS_ENV'] ||= 'test' require 'spec_helper' require File.expand_path('../dummy/config/environment', __FILE__) require 'rspec/rails' require 'rails-controller-testing' require 'factory_bot_rails' require 'database_cleaner' require 'shoulda-matchers' require 'faker' require 'selenium/webdriver' require 'webdrivers/chromedriver' ActiveRecord::Migration.maintain_test_schema! # Adding support files Dir[Exposition::Engine.root.join("spec/support/**/*.rb")].each { |f| require f } Capybara.register_driver :chrome do |app| Capybara::Selenium::Driver.new(app, browser: :chrome) end Capybara.register_driver :headless_chrome do |app| capabilities = Selenium::WebDriver::Remote::Capabilities.chrome( chromeOptions: { args: %w(headless disable-gpu) } ) Capybara::Selenium::Driver.new app, browser: :chrome, desired_capabilities: capabilities end Capybara.javascript_driver = :headless_chrome Capybara.server = :webrick Shoulda::Matchers.configure do |config| config.integrate do |with| with.test_framework :rspec with.library :rails end end RSpec.configure do |config| config.use_transactional_fixtures = true config.infer_spec_type_from_file_location! config.include FactoryBot::Syntax::Methods config.use_transactional_fixtures = false config.expect_with :rspec do |expectations| expectations.include_chain_clauses_in_custom_matcher_descriptions = true end config.mock_with :rspec do |mocks| mocks.verify_partial_doubles = true end config.before(:suite) do DatabaseCleaner.clean_with(:truncation) end config.before(:each) do |example| DatabaseCleaner.strategy= example.metadata[:js] ? :truncation : :transaction DatabaseCleaner.start end config.after(:each) do DatabaseCleaner.clean end [:controller, :view, :request].each do |type| config.include ::Rails::Controller::Testing::TestProcess, :type => type config.include ::Rails::Controller::Testing::TemplateAssertions, :type => type config.include ::Rails::Controller::Testing::Integration, :type => type end end