# rubocop: disable Metrics/ModuleLengthmoduleRSpecmoduleRails# Fake class to document RSpec Rails configuration options. In practice,# these are dynamically added to the normal RSpec configuration object.classConfiguration# @!method infer_spec_type_from_file_location!# Automatically tag specs in conventional directories with matching `type`# metadata so that they have relevant helpers available to them. See# `RSpec::Rails::DIRECTORY_MAPPINGS` for details on which metadata is# applied to each directory.# @!method render_views=(val)## When set to `true`, controller specs will render the relevant view as# well. Defaults to `false`.# @!method render_views(val)# Enables view rendering for controllers specs.# @!method render_views?# Reader for currently value of `render_views` setting.end# Mappings used by `infer_spec_type_from_file_location!`.## @api privateDIRECTORY_MAPPINGS={channel: %w[spec channels],controller: %w[spec controllers],generator: %w[spec generator],helper: %w[spec helpers],job: %w[spec jobs],mailer: %w[spec mailers],model: %w[spec models],request: %w[spec (requests|integration|api)],routing: %w[spec routing],view: %w[spec views],feature: %w[spec features],system: %w[spec system],mailbox: %w[spec mailboxes]}# Sets up the different example group modules for the different spec types## @api privatedefself.add_test_type_configurations(config)config.includeRSpec::Rails::ControllerExampleGroup,type: :controllerconfig.includeRSpec::Rails::HelperExampleGroup,type: :helperconfig.includeRSpec::Rails::ModelExampleGroup,type: :modelconfig.includeRSpec::Rails::RequestExampleGroup,type: :requestconfig.includeRSpec::Rails::RoutingExampleGroup,type: :routingconfig.includeRSpec::Rails::ViewExampleGroup,type: :viewconfig.includeRSpec::Rails::FeatureExampleGroup,type: :featureconfig.includeRSpec::Rails::Matchersconfig.includeRSpec::Rails::SystemExampleGroup,type: :systemend# @privatedefself.initialize_configuration(config)# rubocop:disable Metrics/MethodLength,Metrics/CyclomaticComplexityconfig.backtrace_exclusion_patterns<</vendor\//config.backtrace_exclusion_patterns<<%r{lib/rspec/rails}# controller settingsconfig.add_setting:infer_base_class_for_anonymous_controllers,default: true# fixture supportconfig.add_setting:use_active_record,default: trueconfig.add_setting:use_transactional_fixtures,alias_with: :use_transactional_examplesconfig.add_setting:use_instantiated_fixturesconfig.add_setting:global_fixturesconfig.add_setting:fixture_pathconfig.includeRSpec::Rails::FixtureSupport,:use_fixtures# We'll need to create a deprecated module in order to properly report to# gems / projects which are relying on this being loaded globally.## See rspec/rspec-rails#1355 for history## @deprecated Include `RSpec::Rails::RailsExampleGroup` or# `RSpec::Rails::FixtureSupport` directly insteadconfig.includeRSpec::Rails::FixtureSupportconfig.add_setting:file_fixture_path,default: 'spec/fixtures/files'config.includeRSpec::Rails::FileFixtureSupport# Add support for fixture_path on fixture_file_uploadconfig.includeRSpec::Rails::FixtureFileUploadSupport# This allows us to expose `render_views` as a config option even though it# breaks the convention of other options by using `render_views` as a# command (i.e. `render_views = true`), where it would normally be used# as a getter. This makes it easier for rspec-rails users because we use# `render_views` directly in example groups, so this aligns the two APIs,# but requires this workaround:config.add_setting:rendering_views,default: falseconfig.instance_execdodefrender_views=(val)self.rendering_views=valenddefrender_viewsself.rendering_views=trueenddefrender_views?rendering_views?endundef:rendering_views?ifrespond_to?(:rendering_views?)defrendering_views?!!rendering_viewsend# Define boolean predicates rather than relying on rspec-core due# to the bug fix in rspec/rspec-core#2736, note some of these# predicates are a bit nonsensical, but they exist for backwards# compatibility, we can tidy these up in `rspec-rails` 5.undef:fixture_path?ifrespond_to?(:fixture_path?)deffixture_path?!!fixture_pathendundef:global_fixtures?ifrespond_to?(:global_fixtures?)defglobal_fixtures?!!global_fixturesendundef:infer_base_class_for_anonymous_controllers?ifrespond_to?(:infer_base_class_for_anonymous_controllers?)definfer_base_class_for_anonymous_controllers?!!infer_base_class_for_anonymous_controllersendundef:use_instantiated_fixtures?ifrespond_to?(:use_instantiated_fixtures?)defuse_instantiated_fixtures?!!use_instantiated_fixturesendundef:use_transactional_fixtures?ifrespond_to?(:use_transactional_fixtures?)defuse_transactional_fixtures?!!use_transactional_fixturesenddefinfer_spec_type_from_file_location!DIRECTORY_MAPPINGS.eachdo|type,dir_parts|escaped_path=Regexp.compile(dir_parts.join('[\\\/]')+'[\\\/]')define_derived_metadata(file_path: escaped_path)do|metadata|metadata[:type]||=typeendendend# Adds exclusion filters for gems included with Railsdeffilter_rails_from_backtrace!filter_gems_from_backtrace"actionmailer","actionpack","actionview"filter_gems_from_backtrace"activemodel","activerecord","activesupport","activejob"endendadd_test_type_configurations(config)ifdefined?(::Rails::Controller::Testing)[:controller,:view,:request].eachdo|type|config.include::Rails::Controller::Testing::TestProcess,type: typeconfig.include::Rails::Controller::Testing::TemplateAssertions,type: typeconfig.include::Rails::Controller::Testing::Integration,type: typeendendifRSpec::Rails::FeatureCheck.has_action_mailer?config.includeRSpec::Rails::MailerExampleGroup,type: :mailerconfig.after{ActionMailer::Base.deliveries.clear}endifRSpec::Rails::FeatureCheck.has_active_job?config.includeRSpec::Rails::JobExampleGroup,type: :jobendifRSpec::Rails::FeatureCheck.has_action_cable_testing?config.includeRSpec::Rails::ChannelExampleGroup,type: :channelendifRSpec::Rails::FeatureCheck.has_action_mailbox?config.includeRSpec::Rails::MailboxExampleGroup,type: :mailboxendendinitialize_configurationRSpec.configurationendend# rubocop: enable Metrics/ModuleLength