# frozen_string_literal: true ### # If DATABASE_URL is set, it means we're in production and running the tests # would be very bad news. # abort('DATABASE_URL environment variable is set') if ENV['DATABASE_URL'] RSpec.configure do |config| ############################################################################## # RSPEC 4 PREP ############################################################################## config.shared_context_metadata_behavior = :apply_to_host_groups ############################################################################## # RAILS ############################################################################## if defined?(RSpec::Rails) require 'rspeckled/plugins/rails/engine' config.infer_base_class_for_anonymous_controllers = true config.use_transactional_fixtures = true config.infer_spec_type_from_file_location! if config.respond_to?(:infer_spec_type_from_file_location!) if Pathname.pwd.join('spec', 'dummy', 'config', 'environment.rb').exist? require 'rspeckled/plugins/rails/engine' config.include Rspeckled::NamespacedEngineControllerRouteFix, :type => :controller end end ############################################################################## # MOCKING ############################################################################## config.mock_with :rspec do |mocks| mocks.verify_partial_doubles = true mocks.verify_doubled_constant_names = true mocks.syntax = :expect mocks.allow_message_expectations_on_nil = false end ############################################################################## # INTERNATIONALIZATION ############################################################################## if defined? ActionView::Helpers::TranslationHelper config.include ActionView::Helpers::TranslationHelper end ############################################################################## # PROFILING ############################################################################## if config.files_to_run.length > 1 config.profile_examples = [(config.files_to_run.length * 0.1).to_i, 10].max end config.reporter.register_listener Rspeckled::Reporting::Runner.new, :example_failed, :example_passed, :example_pending, :example_started, :start ############################################################################## # FORMATTING ############################################################################## config.color = true config.add_formatter 'Fuubar' config.add_formatter 'documentation', 'tmp/rspec.txt' if ENV['CIRCLE_TEST_REPORTS'] && defined?(RSpecJUnitFormatter) config.add_formatter 'RSpecJUnitFormatter', "#{ENV['CIRCLE_TEST_REPORTS']}/rspec.xml" end ############################################################################## # FILTERING AND RUN ORDER ############################################################################## # Pending Specs config.alias_example_to :pit, :pending => true # Focused Specs config.filter_run_when_matching :focused config.alias_example_to :fit, :focused => true # Focus and Force Selenium config.alias_example_to :sit, :focused => true, :autofocus => true, :js => true, :debug => true, :driver => :selenium config.alias_example_to :sscenario, :focused => true, :autofocus => true, :js => true, :debug => true, :driver => :selenium config.order = 'random' config.silence_filter_announcements = true # Make all randomization deterministic based on the random run order seed Kernel.srand config.seed ############################################################################## # PERSISTENT FAILURES ############################################################################## if config.respond_to?(:example_status_persistence_file_path=) config.example_status_persistence_file_path = 'tmp/rspec_examples.txt' end ############################################################################## # EXPECTATIONS ############################################################################## config.define_derived_metadata do |metadata| metadata[:aggregate_failures] = true end config.expect_with :rspec do |c| c.syntax = :expect c.include_chain_clauses_in_custom_matcher_descriptions = true end end