# frozen_string_literal: true ENV['RAILS_ENV'] ||= 'test' require File.expand_path('../dummy/config/environment', __FILE__) abort('Rails is running in production mode!') if Rails.env.production? require 'spec_helper' require 'rspec/rails' require 'factory_girl_rails' require 'capybara-screenshot/rspec' Rails.backtrace_cleaner.remove_silencers! require File.dirname(__FILE__) + '/support/factory_girl.rb' Dir["#{File.dirname(__FILE__)}/factories/**/*.rb"].each { |f| require f } # Checks for pending migration and applies them before tests are run. # If you are not using ActiveRecord, you can remove this line. # TODO remove comment below # ActiveRecord::Migration.maintain_test_schema! RSpec.configure do |config| config.use_transactional_fixtures = false config.infer_spec_type_from_file_location! config.filter_rails_from_backtrace! config.include Warden::Test::Helpers config.before(:suite) do DatabaseCleaner.clean_with(:truncation) load 'spec/support/feature_seeds.rb' end config.before(:each, :admin_test) do @user = C::User.first login_as(@user, scope: :user) # Capybara.javascript_driver = :poltergeist end config.around(:each) do |exmple| DatabaseCleaner.strategy = exmple.metadata[:js] ? :truncation : :transaction DatabaseCleaner.cleaning do exmple.run end load 'support/feature_seeds.rb' if exmple.metadata[:js] Capybara.reset_sessions! end end