Class: RSpec::Core::Configuration

### Home Classes Methods

### In Files

- lib/rspec/core/configuration.rb

### Parent

Object

### Namespace

- MODULE RSpec::Core::Configuration::ExposeCurrentExample
- CLASS RSpec::Core::Configuration::DeprecationReporterBuffer
- CLASS RSpec::Core::Configuration::MustBeConfiguredBeforeExampleGroupsError

### Methods

- ::add_read_only_setting
- ::add_setting
- ::define_aliases
- ::define_predicate_for
- ::define_reader
- ::delegate_to_ordering_manager
- ::new
- #add_formatter
- #add_setting
- #after
- #alias_example_group_to
- #alias_example_to
- #alias_it_behaves_like_to
- #alias_it_should_behave_like_to
- #append_after
- #append_before
- #apply_derived_metadata_to
- #backtrace_exclusion_patterns
- #backtrace_exclusion_patterns=
- #backtrace_inclusion_patterns
- #backtrace_inclusion_patterns=
- #before
- #color
- #color=
- #color_enabled?
- #configure_example
- #configure_existing_groups
- #configure_expectation_framework
- #configure_group
- #configure_group_with
- #configure_mock_framework
- #default_formatter
- #default_formatter=
- #define_derived_metadata
- #deprecation_stream=
- #disable_monkey_patching!
- #example_status_persistence_file_path=
- #exclude_pattern=
- #exclusion_filter
- #exclusion_filter=
- #expect_with
- #expectation_framework=
- #expectation_frameworks
- #expose_current_running_example_as
- #expose_dsl_globally=
- #expose_dsl_globally?
- #extend
- #files_or_directories_to_run=
- #files_to_run
- #filter
- #filter=
- #filter_gems_from_backtrace
- #filter_run
- #filter_run_excluding
- #filter_run_including
- #force
- #format_docstrings
- #format_docstrings_block
- #formatter=
- #formatter_loader
- #formatters
- #full_backtrace=
- #full_backtrace?
- #full_description
- #full_description=
- #hooks
- #include
- #inclusion_filter
- #inclusion_filter=
- #last_run_statuses
- #libs=
- #load_spec_files
- #mock_framework
- #mock_framework=
- #mock_with
- #only_failures_but_not_configured?
- #output_stream=
- #pattern=
- #prepend
- #prepend_after
- #prepend_before
- #profile_examples
- #raise_errors_for_deprecations!
- #reporter
- #requires=
- #reset
- #reset_filters
- #safe_extend
- #safe_include
- #safe_prepend
- #spec_files_with_failures
- #treat_symbols_as_metadata_keys_with_true_values=
- #warnings=
- #warnings?
- #with_suite_hooks

### Included Modules

- RSpec::Core::Hooks
- Readers
- RSpec::Core::Configuration::ExposeCurrentExample

### Class/Module Index

Quicksearch

- RSpec
- RSpec::Core
- RSpec::Core::AnonymousExampleGroup
- RSpec::Core::BacktraceFormatter
- RSpec::Core::Bisect
- RSpec::Core::Bisect::Coordinator
- RSpec::Core::Bisect::ExampleMinimizer
- RSpec::Core::Bisect::Runner
- RSpec::Core::Bisect::Server
- RSpec::Core::Bisect::SubsetEnumerator
- RSpec::Core::Configuration
- RSpec::Core::Configuration::DeprecationReporterBuffer
- RSpec::Core::Configuration::ExposeCurrentExample
- RSpec::Core::Configuration::MustBeConfiguredBeforeExampleGroupsError
- RSpec::Core::ConfigurationOptions
- RSpec::Core::DRbOptions
- RSpec::Core::DRbRunner
- RSpec::Core::DSL
- RSpec::Core::DSL::RSpec
- RSpec::Core::Example
- RSpec::Core::Example::ExecutionResult
- RSpec::Core::Example::Procsy
- RSpec::Core::ExampleGroup
- RSpec::Core::ExampleStatusDumper
- RSpec::Core::ExampleStatusMerger
- RSpec::Core::ExampleStatusParser
- RSpec::Core::ExampleStatusPersister
- RSpec::Core::ExclusionRules
- RSpec::Core::FilterManager
- RSpec::Core::FilterRules
- RSpec::Core::FilterableItemRepository
- RSpec::Core::FilterableItemRepository::QueryOptimized
- RSpec::Core::FilterableItemRepository::UpdateOptimized
- RSpec::Core::FlatMap
- RSpec::Core::Formatters
- RSpec::Core::Formatters::BaseFormatter
- RSpec::Core::Formatters::BaseTextFormatter
- RSpec::Core::Formatters::BisectDebugFormatter
- RSpec::Core::Formatters::BisectFormatter
- RSpec::Core::Formatters::BisectProgressFormatter
- RSpec::Core::Formatters::ConsoleCodes
- RSpec::Core::Formatters::DeprecationFormatter
- RSpec::Core::Formatters::DeprecationFormatter::DelayedPrinter
- RSpec::Core::Formatters::DeprecationFormatter::FileStream
- RSpec::Core::Formatters::DeprecationFormatter::ImmediatePrinter
- RSpec::Core::Formatters::DeprecationFormatter::RaiseErrorStream
- RSpec::Core::Formatters::DocumentationFormatter
- RSpec::Core::Formatters::ExceptionPresenter
- RSpec::Core::Formatters::ExceptionPresenter::Factory
- RSpec::Core::Formatters::ExceptionPresenter::Factory::CommonBacktraceTruncater
- RSpec::Core::Formatters::ExceptionPresenter::Factory::EmptyBacktraceFormatter
- RSpec::Core::Formatters::FallbackMessageFormatter
- RSpec::Core::Formatters::Helpers
- RSpec::Core::Formatters::HtmlFormatter
- RSpec::Core::Formatters::HtmlPrinter
- RSpec::Core::Formatters::JsonFormatter
- RSpec::Core::Formatters::Loader
- RSpec::Core::Formatters::ProfileFormatter
- RSpec::Core::Formatters::ProgressFormatter
- RSpec::Core::Formatters::Protocol
- RSpec::Core::Formatters::SnippetExtractor
- RSpec::Core::Formatters::SnippetExtractor::CoderayConverter
- RSpec::Core::Formatters::SnippetExtractor::NullConverter
- RSpec::Core::HashImitatable
- RSpec::Core::HashImitatable::ClassMethods
- RSpec::Core::Hooks
- RSpec::Core::Hooks::AfterContextHook
- RSpec::Core::Hooks::AfterHook
- RSpec::Core::Hooks::AroundHook
- RSpec::Core::Hooks::BeforeHook
- RSpec::Core::Hooks::Hook
- RSpec::Core::Hooks::HookCollections
- RSpec::Core::InclusionRules
- RSpec::Core::LegacyExampleGroupHash
- RSpec::Core::MemoizedHelpers
- RSpec::Core::MemoizedHelpers::ClassMethods
- RSpec::Core::MemoizedHelpers::ContextHookMemoized
- RSpec::Core::MemoizedHelpers::ContextHookMemoized::After
- RSpec::Core::MemoizedHelpers::ContextHookMemoized::Before
- RSpec::Core::MemoizedHelpers::NonThreadSafeMemoized
- RSpec::Core::MemoizedHelpers::ThreadsafeMemoized
- RSpec::Core::Metadata
- RSpec::Core::Metadata::ExampleGroupHash
- RSpec::Core::Metadata::ExampleHash
- RSpec::Core::Metadata::HashPopulator
- RSpec::Core::MetadataFilter
- RSpec::Core::MinitestAssertionsAdapter
- RSpec::Core::MockingAdapters
- RSpec::Core::MockingAdapters::Flexmock
- RSpec::Core::MockingAdapters::Mocha
- RSpec::Core::MockingAdapters::Null
- RSpec::Core::MockingAdapters::RR
- RSpec::Core::MockingAdapters::RSpec
- RSpec::Core::MultipleExceptionError
- RSpec::Core::MultipleExceptionError::InterfaceTag
- RSpec::Core::Mutex
- RSpec::Core::Notifications
- RSpec::Core::Notifications::CustomNotification
- RSpec::Core::Notifications::DeprecationNotification
- RSpec::Core::Notifications::ExampleNotification
- RSpec::Core::Notifications::ExamplesNotification
- RSpec::Core::Notifications::FailedExampleNotification
- RSpec::Core::Notifications::NullColorizer
- RSpec::Core::Notifications::NullNotification
- RSpec::Core::Notifications::PendingExampleFailedAsExpectedNotification
- RSpec::Core::Notifications::PendingExampleFixedNotification
- RSpec::Core::Notifications::ProfileNotification
- RSpec::Core::Notifications::SeedNotification
- RSpec::Core::Notifications::SkippedExampleNotification
- RSpec::Core::Notifications::SummaryNotification
- RSpec::Core::NullReporter
- RSpec::Core::Ordering
- RSpec::Core::Ordering::ConfigurationManager
- RSpec::Core::Ordering::Custom
- RSpec::Core::Ordering::Identity
- RSpec::Core::Ordering::Random
- RSpec::Core::Ordering::Registry
- RSpec::Core::Parser
- RSpec::Core::Pending
- RSpec::Core::Pending::PendingExampleFixedError
- RSpec::Core::Pending::SkipDeclaredInExample
- RSpec::Core::Profiler
- RSpec::Core::ProjectInitializer
- RSpec::Core::RakeTask
- RSpec::Core::ReentrantMutex
- RSpec::Core::Reporter
- RSpec::Core::RubyProject
- RSpec::Core::Runner
- RSpec::Core::Sandbox
- RSpec::Core::Set
- RSpec::Core::SharedContext
- RSpec::Core::SharedExampleGroup
- RSpec::Core::SharedExampleGroup::Registry
- RSpec::Core::SharedExampleGroup::TopLevelDSL
- RSpec::Core::SharedExampleGroupInclusionStackFrame
- RSpec::Core::SharedExampleGroupModule
- RSpec::Core::ShellEscape
- RSpec::Core::SuiteHookContext
- RSpec::Core::TestUnitAssertionsAdapter
- RSpec::Core::Time
- RSpec::Core::Version
- RSpec::Core::Warnings
- RSpec::Core::World
- RSpec::ExampleGroups
- Object

No matching classes.

# RSpec::Core::Configuration

Stores runtime configuration information.

Configuration options are loaded from `~/.rspec`, `.rspec`, `.rspec-local`, command line switches, and the `SPEC_OPTS` environment variable (listed in lowest to highest precedence; for example, an option in `~/.rspec` can be overridden by an option in `.rspec-local`).

@example Standard settings

    RSpec.configure do |c|
      c.drb          = true
      c.drb_port     = 1234
      c.default_path = 'behavior'
    end

@example Hooks

    RSpec.configure do |c|
      c.before(:suite)   { establish_connection }
      c.before(:example) { log_in_as :authorized }
      c.around(:example) { |ex| Database.transaction(&ex) }
    end

@see RSpec.configure @see Hooks

### Constants

DEFAULT_FORMATTER

  @private

FAILED_STATUS

  @private

MOCKING_ADAPTERS

  @private

ON_SQUARE_BRACKETS

  @private

Readers

  Module that holds `attr_reader` declarations. It's in a separate module to allow us to override those methods and use `super`. @private

UNKNOWN_STATUS

  @private

### Attributes

backtrace_formatter[R]

@private

disable_monkey_patching[RW]

@private

files_to_run[W]

@private

filter_manager[RW]

@private

loaded_spec_files[R]

@private

ordering_manager[R]

@private

static_config_filter_manager[RW]

@private

### Public Class Methods

add_read_only_setting(name, opts={}) click to toggle source

@private

As `add_setting` but only add the reader.

    # File lib/rspec/core/configuration.rb, line 83
    def self.add_read_only_setting(name, opts={})
      raise "Use the instance add_setting method if you want to set a default" if opts.key?(:default)
      define_reader name
      define_predicate_for name
    end

add_setting(name, opts={}) click to toggle source

@private

Invoked by the `add_setting` instance method. Use that method on a `Configuration` instance rather than this class method.

    # File lib/rspec/core/configuration.rb, line 70
    def self.add_setting(name, opts={})
      raise "Use the instance add_setting method if you want to set a default" if opts.key?(:default)
      attr_writer name
      add_read_only_setting name

      Array(opts[:alias_with]).each do |alias_name|
        define_aliases(name, alias_name)
      end
    end

define_aliases(name, alias_name) click to toggle source

@private

    # File lib/rspec/core/configuration.rb, line 55
    def self.define_aliases(name, alias_name)
      alias_method alias_name, name
      alias_method "#{alias_name}=", "#{name}="
      define_predicate_for alias_name
    end

define_predicate_for(*names) click to toggle source

@private

    # File lib/rspec/core/configuration.rb, line 62
    def self.define_predicate_for(*names)
      names.each { |name| alias_method "#{name}?", name }
    end

define_reader(name) click to toggle source

@private

    # File lib/rspec/core/configuration.rb, line 45
    def self.define_reader(name)
      Readers.class_eval do
        remove_method name if method_defined?(name)
        attr_reader name
      end

      define_method(name) { value_for(name) { super() } }
    end

delegate_to_ordering_manager(*methods) click to toggle source

@private @macro [attach] delegate_to_ordering_manager

    @!method $1

    # File lib/rspec/core/configuration.rb, line 1357
    def self.delegate_to_ordering_manager(*methods)
      methods.each do |method|
        define_method method do |*args, &block|
          ordering_manager.__send__(method, *args, &block)
        end
      end
    end

new() click to toggle source

    # File lib/rspec/core/configuration.rb, line 327
    def initialize
      # rubocop:disable Style/GlobalVars
      @start_time = $_rspec_core_load_started_at || ::RSpec::Core::Time.now
      # rubocop:enable Style/GlobalVars
      @expectation_frameworks = []
      @include_modules = FilterableItemRepository::QueryOptimized.new(:any?)
      @extend_modules  = FilterableItemRepository::QueryOptimized.new(:any?)
      @prepend_modules = FilterableItemRepository::QueryOptimized.new(:any?)

      @before_suite_hooks = []
      @after_suite_hooks  = []

      @mock_framework = nil
      @files_or_directories_to_run = []
      @loaded_spec_files = Set.new
      @color = false
      @pattern = '**{,/*/**}/*_spec.rb'
      @exclude_pattern = ''
      @failure_exit_code = 1
      @spec_files_loaded = false

      @backtrace_formatter = BacktraceFormatter.new

      @default_path = 'spec'
      @deprecation_stream = $stderr
      @output_stream = $stdout
      @reporter = nil
      @reporter_buffer = nil
      @filter_manager = FilterManager.new
      @static_config_filter_manager = FilterManager.new
      @ordering_manager = Ordering::ConfigurationManager.new
      @preferred_options = {}
      @failure_color = :red
      @success_color = :green
      @pending_color = :yellow
      @default_color = :white
      @fixed_color = :blue
      @detail_color = :cyan
      @profile_examples = false
      @requires = []
      @libs = []
      @derived_metadata_blocks = FilterableItemRepository::QueryOptimized.new(:any?)
      @threadsafe = true

      define_built_in_hooks
    end

### Public Instance Methods

add_formatter(formatter_to_use, *paths) click to toggle source

@overload add_formatter(formatter)

Adds a formatter to the formatters collection. `formatter` can be a string representing any of the built-in formatters (see `built_in_formatter`), or a custom formatter class.

### Note

For internal purposes, `add_formatter` also accepts the name of a class and paths to use for output streams, but you should consider that a private api that may change at any time without notice.

    # File lib/rspec/core/configuration.rb, line 750
    def add_formatter(formatter_to_use, *paths)
      paths << output_stream if paths.empty?
      formatter_loader.add formatter_to_use, *paths
    end

Also aliased as: formatter=
add_setting(name, opts={}) click to toggle source

@overload add_setting(name) @overload add_setting(name, opts) @option opts [Symbol] :default

    Set a default value for the generated getter and predicate methods:

        add_setting(:foo, :default => "default value")

@option opts [Symbol] :alias_with

    Use `:alias_with` to alias the setter, getter, and predicate to
    another name, or names:

        add_setting(:foo, :alias_with => :bar)
        add_setting(:foo, :alias_with => [:bar, :baz])

Adds a custom setting to the RSpec.configuration object.

    RSpec.configuration.add_setting :foo

Used internally and by extension frameworks like rspec-rails, so they can add config settings that are domain specific. For example:

    RSpec.configure do |c|
      c.add_setting :use_transactional_fixtures,
        :default => true,
        :alias_with => :use_transactional_examples
    end

`add_setting` creates three methods on the configuration object, a setter, a getter, and a predicate:

    RSpec.configuration.foo=(value)
    RSpec.configuration.foo
    RSpec.configuration.foo? # Returns true if foo returns anything but nil or false.

    # File lib/rspec/core/configuration.rb, line 438
    def add_setting(name, opts={})
      default = opts.delete(:default)
      (class << self; self; end).class_exec do
        add_setting(name, opts)
      end
      __send__("#{name}=", default) if default
    end

after(*args, &block) click to toggle source

Defines a `after` hook. See {Hooks#after} for full docs.

This method differs from {Hooks#after} in only one way: it supports the `:suite` scope. Hooks with the `:suite` scope will be run once after the last example of the entire suite is executed.

@see append_after @see before @see prepend_before

    # File lib/rspec/core/configuration.rb, line 1596
    def after(*args, &block)
      handle_suite_hook(args, @after_suite_hooks, :unshift,
                        Hooks::AfterHook, block) || super(*args, &block)
    end

Also aliased as: prepend_after
alias_example_group_to(new_name, *args) click to toggle source

Creates a method that defines an example group with the provided metadata. Can be used to define example group/metadata shortcuts.

@example

    RSpec.configure do |config|
      config.alias_example_group_to :describe_model, :type => :model
    end

    shared_context_for "model tests", :type => :model do
      # define common model test helper methods, `let` declarations, etc
    end

    # This lets you do this:

    RSpec.describe_model User do
    end

    # ... which is the equivalent of

    RSpec.describe User, :type => :model do
    end

@note The defined aliased will also be added to the top level

    (e.g. `main` and from within modules) if
    `expose_dsl_globally` is set to true.

@see alias_example_to @see expose_dsl_globally=

    # File lib/rspec/core/configuration.rb, line 953
    def alias_example_group_to(new_name, *args)
      extra_options = Metadata.build_hash_from(args)
      RSpec::Core::ExampleGroup.define_example_group_method(new_name, extra_options)
    end

alias_example_to(name, *args) click to toggle source

Creates a method that delegates to `example` including the submitted `args`. Used internally to add variants of `example` like `pending`: @param name [String] example name alias @param args [Array<Symbol>, Hash] metadata for the generated example

@note The specific example alias below (`pending`) is already

    defined for you.

@note Use with caution. This extends the language used in your

    specs, but does not add any additional documentation. We use this
    in RSpec to define methods like `focus` and `xit`, but we also add
    docs for those methods.

@example

    RSpec.configure do |config|
      config.alias_example_to :pending, :pending => true
    end

    # This lets you do this:

    describe Thing do
      pending "does something" do
        thing = Thing.new
      end
    end

    # ... which is the equivalent of

    describe Thing do
      it "does something", :pending => true do
        thing = Thing.new
      end
    end

    # File lib/rspec/core/configuration.rb, line 921
    def alias_example_to(name, *args)
      extra_options = Metadata.build_hash_from(args)
      RSpec::Core::ExampleGroup.define_example_method(name, extra_options)
    end

alias_it_behaves_like_to(new_name, report_label='') click to toggle source

Define an alias for it_should_behave_like that allows different language (like "it_has_behavior" or "it_behaves_like") to be employed when including shared examples.

@example

    RSpec.configure do |config|
      config.alias_it_behaves_like_to(:it_has_behavior, 'has behavior:')
    end

    # allows the user to include a shared example group like:

    describe Entity do
      it_has_behavior 'sortability' do
        let(:sortable) { Entity.new }
      end
    end

    # which is reported in the output as:
    # Entity
    #   has behavior: sortability
    #     ...sortability examples here

@note Use with caution. This extends the language used in your

    specs, but does not add any additional documentation. We use this
    in RSpec to define `it_should_behave_like` (for backward
    compatibility), but we also add docs for that method.

    # File lib/rspec/core/configuration.rb, line 984
    def alias_it_behaves_like_to(new_name, report_label='')
      RSpec::Core::ExampleGroup.define_nested_shared_group_method(new_name, report_label)
    end

Also aliased as: alias_it_should_behave_like_to
alias_it_should_behave_like_to(new_name, report_label='') click to toggle source
Alias for: alias_it_behaves_like_to
append_after(*args, &block) click to toggle source

Adds `block` to the end of the list of `after` blocks in the same scope (`:example`, `:context`, or `:suite`), in contrast to {after}, which adds the hook to the start of the list.

See {Hooks#after} for full `after` hook docs.

This method differs from {Hooks#append_after} in only one way: it supports the `:suite` scope. Hooks with the `:suite` scope will be run once after the last example of the entire suite is executed.

@see append_after @see before @see prepend_before

    # File lib/rspec/core/configuration.rb, line 1615
    def append_after(*args, &block)
      handle_suite_hook(args, @after_suite_hooks, :push,
                        Hooks::AfterHook, block) || super(*args, &block)
    end

append_before(*args, &block) click to toggle source
Alias for: before
apply_derived_metadata_to(metadata) click to toggle source

@private

    # File lib/rspec/core/configuration.rb, line 1548
    def apply_derived_metadata_to(metadata)
      @derived_metadata_blocks.items_for(metadata).each do |block|
        block.call(metadata)
      end
    end

backtrace_exclusion_patterns() click to toggle source

Regexps used to exclude lines from backtraces.

Excludes lines from ruby (and jruby) source, installed gems, anything in any "bin" directory, and any of the RSpec libs (outside gem installs) by default.

You can modify the list via the getter, or replace it with the setter.

To override this behaviour and display a full backtrace, use `--backtrace` on the command line, in a `.rspec` file, or in the `rspec_options` attribute of RSpec's rake task.

    # File lib/rspec/core/configuration.rb, line 474
    def backtrace_exclusion_patterns
      @backtrace_formatter.exclusion_patterns
    end

backtrace_exclusion_patterns=(patterns) click to toggle source

Set regular expressions used to exclude lines in backtrace. @param patterns [Regexp] set the backtrace exlusion pattern

    # File lib/rspec/core/configuration.rb, line 480
    def backtrace_exclusion_patterns=(patterns)
      @backtrace_formatter.exclusion_patterns = patterns
    end

backtrace_inclusion_patterns() click to toggle source

Regexps used to include lines in backtraces.

Defaults to [Regexp.new Dir.getwd].

Lines that match an exclusion and an inclusion pattern will be included.

You can modify the list via the getter, or replace it with the setter.

    # File lib/rspec/core/configuration.rb, line 492
    def backtrace_inclusion_patterns
      @backtrace_formatter.inclusion_patterns
    end

backtrace_inclusion_patterns=(patterns) click to toggle source

Set regular expressions used to include lines in backtrace. @attr patterns [Regexp] set backtrace_formatter inclusion_patterns

    # File lib/rspec/core/configuration.rb, line 498
    def backtrace_inclusion_patterns=(patterns)
      @backtrace_formatter.inclusion_patterns = patterns
    end

before(*args, &block) click to toggle source

Defines a `before` hook. See {Hooks#before} for full docs.

This method differs from {Hooks#before} in only one way: it supports the `:suite` scope. Hooks with the `:suite` scope will be run once before the first example of the entire suite is executed.

@see prepend_before @see after @see append_after

    # File lib/rspec/core/configuration.rb, line 1563
    def before(*args, &block)
      handle_suite_hook(args, @before_suite_hooks, :push,
                        Hooks::BeforeHook, block) || super(*args, &block)
    end

Also aliased as: append_before
color() click to toggle source

Returns the configuration option for color, but should not be used to check if color is supported.

@see color_enabled? @return [Boolean]

    # File lib/rspec/core/configuration.rb, line 693
    def color
      value_for(:color) { @color }
    end

color=(true_or_false) click to toggle source

Toggle output color. @attr true_or_false [Boolean] toggle color enabled

    # File lib/rspec/core/configuration.rb, line 707
    def color=(true_or_false)
      return unless true_or_false

      if RSpec::Support::OS.windows? && !ENV['ANSICON']
        RSpec.warning "You must use ANSICON 1.31 or later "                          "(http://adoxa.3eeweb.com/ansicon/) to use colour "                          "on Windows"
        @color = false
      else
        @color = true
      end
    end

color_enabled?(output=output_stream) click to toggle source

Check if color is enabled for a particular output. @param output [IO] an output stream to use, defaults to the current

    `output_stream`

@return [Boolean]

    # File lib/rspec/core/configuration.rb, line 701
    def color_enabled?(output=output_stream)
      output_to_tty?(output) && color
    end

configure_example(example) click to toggle source

@private

Used internally to extend the singleton class of a single example's example group instance with modules using `include` and/or `extend`.

    # File lib/rspec/core/configuration.rb, line 1254
    def configure_example(example)
      singleton_group = example.example_group_instance.singleton_class

      # We replace the metadata so that SharedExampleGroupModule#included
      # has access to the example's metadata[:location].
      singleton_group.with_replaced_metadata(example.metadata) do
        modules = @include_modules.items_for(example.metadata)
        modules.each do |mod|
          safe_include(mod, example.example_group_instance.singleton_class)
        end

        MemoizedHelpers.define_helpers_on(singleton_group) unless modules.empty?
      end
    end

configure_existing_groups(mod, meta, application_method) click to toggle source

@private

    # File lib/rspec/core/configuration.rb, line 1243
    def configure_existing_groups(mod, meta, application_method)
      RSpec.world.all_example_groups.each do |group|
        next unless meta.empty? || MetadataFilter.apply?(:any?, meta, group.metadata)
        __send__(application_method, mod, group)
      end
    end

configure_expectation_framework() click to toggle source

@private

    # File lib/rspec/core/configuration.rb, line 1316
    def configure_expectation_framework
      expectation_frameworks.each do |framework|
        RSpec::Core::ExampleGroup.__send__(:include, framework)
      end
      conditionally_disable_expectations_monkey_patching
    end

configure_group(group) click to toggle source

@private

Used internally to extend a group with modules using `include`, `prepend` and/or `extend`.

    # File lib/rspec/core/configuration.rb, line 1229
    def configure_group(group)
      configure_group_with group, @include_modules, :safe_include
      configure_group_with group, @extend_modules,  :safe_extend
      configure_group_with group, @prepend_modules, :safe_prepend
    end

configure_group_with(group, module_list, application_method) click to toggle source

@private

    # File lib/rspec/core/configuration.rb, line 1236
    def configure_group_with(group, module_list, application_method)
      module_list.items_for(group.metadata).each do |mod|
        __send__(application_method, mod, group)
      end
    end

configure_mock_framework() click to toggle source

@private

    # File lib/rspec/core/configuration.rb, line 1310
    def configure_mock_framework
      RSpec::Core::ExampleGroup.__send__(:include, mock_framework)
      conditionally_disable_mocks_monkey_patching
    end

default_formatter() click to toggle source

The formatter that will be used if no formatter has been set. Defaults to 'progress'.

    # File lib/rspec/core/configuration.rb, line 758
    def default_formatter
      formatter_loader.default_formatter
    end

default_formatter=(value) click to toggle source

Sets a fallback formatter to use if none other has been set.

@example

    RSpec.configure do |rspec|
      rspec.default_formatter = 'doc'
    end

    # File lib/rspec/core/configuration.rb, line 769
    def default_formatter=(value)
      formatter_loader.default_formatter = value
    end

define_derived_metadata(*filters, &block) click to toggle source

Defines a callback that can assign derived metadata values.

@param filters [Array<Symbol>, Hash] metadata filters that determine

    which example or group metadata hashes the callback will be triggered
    for. If none are given, the callback will be run against the metadata
    hashes of all groups and examples.

@yieldparam metadata [Hash] original metadata hash from an example or

    group. Mutate this in your block as needed.

@example

    RSpec.configure do |config|
      # Tag all groups and examples in the spec/unit directory with
      # :type => :unit
      config.define_derived_metadata(:file_path => %r{/spec/unit/}) do |metadata|
        metadata[:type] = :unit
      end
    end

    # File lib/rspec/core/configuration.rb, line 1542
    def define_derived_metadata(*filters, &block)
      meta = Metadata.build_hash_from(filters, :warn_about_example_group_filtering)
      @derived_metadata_blocks.append(block, meta)
    end

deprecation_stream=(value) click to toggle source

Determines where deprecation warnings are printed. @param value [IO, String] IO to write to or filename to write to

    # File lib/rspec/core/configuration.rb, line 145
    def deprecation_stream=(value)
      if @reporter && !value.equal?(@deprecation_stream)
        warn "RSpec's reporter has already been initialized with "              "#{deprecation_stream.inspect} as the deprecation stream, so your change to "             "`deprecation_stream` will be ignored. You should configure it earlier for "              "it to take effect, or use the `--deprecation-out` CLI option. "              "(Called from #{CallerFilter.first_non_rspec_line})"
      else
        @deprecation_stream = value
      end
    end

disable_monkey_patching!() click to toggle source

Enables zero monkey patching mode for RSpec. It removes monkey patching of the top-level DSL methods (`describe`, `shared_examples_for`, etc) onto `main` and `Module`, instead requiring you to prefix these methods with `RSpec.`. It enables expect-only syntax for rspec-mocks and rspec-expectations. It simply disables monkey patching on whatever pieces of RSpec the user is using.

@note It configures rspec-mocks and rspec-expectations only

    if the user is using those (either explicitly or implicitly
    by not setting `mock_with` or `expect_with` to anything else).

@note If the user uses this options with `mock_with :mocha`

    (or similiar) they will still have monkey patching active
    in their test environment from mocha.

@example

    # It disables all monkey patching.
    RSpec.configure do |config|
      config.disable_monkey_patching!
    end

    # Is an equivalent to
    RSpec.configure do |config|
      config.expose_dsl_globally = false

      config.mock_with :rspec do |mocks|
        mocks.syntax = :expect
        mocks.patch_marshal_to_support_partial_doubles = false
      end

      config.mock_with :rspec do |expectations|
        expectations.syntax = :expect
      end
    end

    # File lib/rspec/core/configuration.rb, line 1515
    def disable_monkey_patching!
      self.expose_dsl_globally = false
      self.disable_monkey_patching = true
      conditionally_disable_mocks_monkey_patching
      conditionally_disable_expectations_monkey_patching
    end

example_status_persistence_file_path=(value) click to toggle source

Sets the file path to use for persisting example statuses. Necessary for the `--only-failures` and `--next-failures` CLI options.

    # File lib/rspec/core/configuration.rb, line 169
    def example_status_persistence_file_path=(value)
      @example_status_persistence_file_path = value
      clear_values_derived_from_example_status_persistence_file_path
    end

exclude_pattern=(value) click to toggle source

Set pattern to match files to exclude. @attr value [String] the filename pattern to exclude spec files by

    # File lib/rspec/core/configuration.rb, line 240
    def exclude_pattern=(value)
      update_pattern_attr :exclude_pattern, value
    end

exclusion_filter() click to toggle source

Returns the `exclusion_filter`. If none has been set, returns an empty hash.

    # File lib/rspec/core/configuration.rb, line 1099
    def exclusion_filter
      filter_manager.exclusions
    end

exclusion_filter=(filter) click to toggle source

Clears and reassigns the `exclusion_filter`. Set to `nil` if you don't want any exclusion filter at all.

### Warning

This overrides any exclusion filters/tags set on the command line or in configuration files.

    # File lib/rspec/core/configuration.rb, line 1092
    def exclusion_filter=(filter)
      meta = Metadata.build_hash_from([filter], :warn_about_example_group_filtering)
      filter_manager.exclude_only meta
    end

expect_with(*frameworks) click to toggle source

Sets the expectation framework module(s) to be included in each example group.

`frameworks` can be `:rspec`, `:test_unit`, `:minitest`, a custom module, or any combination thereof:

    config.expect_with :rspec
    config.expect_with :test_unit
    config.expect_with :minitest
    config.expect_with :rspec, :minitest
    config.expect_with OtherExpectationFramework

RSpec will translate `:rspec`, `:minitest`, and `:test_unit` into the appropriate modules.

## Configuration

If the module responds to `configuration`, `expect_with` will yield the `configuration` object if given a block:

    config.expect_with OtherExpectationFramework do |custom_config|
      custom_config.custom_setting = true
    end

    # File lib/rspec/core/configuration.rb, line 634
    def expect_with(*frameworks)
      modules = frameworks.map do |framework|
        case framework
        when Module
          framework
        when :rspec
          require 'rspec/expectations'

          # Tag this exception class so our exception formatting logic knows
          # that it satisfies the `MultipleExceptionError` interface.
          ::RSpec::Expectations::MultipleExpectationsNotMetError.__send__(
            :include, MultipleExceptionError::InterfaceTag
          )

          ::RSpec::Matchers
        when :test_unit
          require 'rspec/core/test_unit_assertions_adapter'
          ::RSpec::Core::TestUnitAssertionsAdapter
        when :minitest
          require 'rspec/core/minitest_assertions_adapter'
          ::RSpec::Core::MinitestAssertionsAdapter
        else
          raise ArgumentError, "#{framework.inspect} is not supported"
        end
      end

      if (modules - @expectation_frameworks).any?
        assert_no_example_groups_defined(:expect_with)
      end

      if block_given?
        raise "expect_with only accepts a block with a single argument. "                  "Call expect_with #{modules.length} times, "                  "once with each argument, instead." if modules.length > 1
        raise "#{modules.first} must respond to `configuration` so that "                  "expect_with can yield it." unless modules.first.respond_to?(:configuration)
        yield modules.first.configuration
      end

      @expectation_frameworks.push(*modules)
    end

expectation_framework=(framework) click to toggle source

Delegates to expect_with(framework).

    # File lib/rspec/core/configuration.rb, line 607
    def expectation_framework=(framework)
      expect_with(framework)
    end

expectation_frameworks() click to toggle source

Returns the configured expectation framework adapter module(s)

    # File lib/rspec/core/configuration.rb, line 595
    def expectation_frameworks
      if @expectation_frameworks.empty?
        begin
          expect_with :rspec
        rescue LoadError
          expect_with Module.new
        end
      end
      @expectation_frameworks
    end

expose_current_running_example_as(method_name) click to toggle source

Exposes the current running example via the named helper method. RSpec 2.x exposed this via `example`, but in RSpec 3.0, the example is instead exposed via an arg yielded to `it`, `before`, `let`, etc. However, some extension gems (such as Capybara) depend on the RSpec 2.x's `example` method, so this config option can be used to maintain compatibility.

@param method_name [Symbol] the name of the helper method

@example

    RSpec.configure do |rspec|
      rspec.expose_current_running_example_as :example
    end

    describe MyClass do
      before do
        # `example` can be used here because of the above config.
        do_something if example.metadata[:type] == "foo"
      end
    end

    # File lib/rspec/core/configuration.rb, line 1453
    def expose_current_running_example_as(method_name)
      ExposeCurrentExample.module_exec do
        extend RSpec::SharedContext
        let(method_name) { |ex| ex }
      end

      include ExposeCurrentExample
    end

expose_dsl_globally=(value) click to toggle source

Use this to expose the core RSpec DSL via `Module` and the `main` object. It will be set automatically but you can override it to remove the DSL. Default: true

    # File lib/rspec/core/configuration.rb, line 128
    def expose_dsl_globally=(value)
      if value
        Core::DSL.expose_globally!
        Core::SharedExampleGroup::TopLevelDSL.expose_globally!
      else
        Core::DSL.remove_globally!
        Core::SharedExampleGroup::TopLevelDSL.remove_globally!
      end
    end

expose_dsl_globally?() click to toggle source

Indicates if the DSL has been exposed off of modules and `main`. Default: true

    # File lib/rspec/core/configuration.rb, line 120
    def expose_dsl_globally?
      Core::DSL.exposed_globally?
    end

extend(mod, *filters) click to toggle source

Tells RSpec to extend example groups with `mod`. Methods defined in `mod` are exposed to example groups (not examples). Use `filters` to constrain the groups to extend.

Similar to `include`, but behavior is added to example groups, which are classes, rather than the examples, which are instances of those classes.

@example

    module UiHelpers
      def run_in_browser
        # ...
      end
    end

    RSpec.configure do |config|
      config.extend(UiHelpers, :type => :request)
    end

    describe "edit profile", :type => :request do
      run_in_browser

      it "does stuff in the client" do
        # ...
      end
    end

@see include @see prepend

    # File lib/rspec/core/configuration.rb, line 1179
    def extend(mod, *filters)
      meta = Metadata.build_hash_from(filters, :warn_about_example_group_filtering)
      @extend_modules.append(mod, meta)
      configure_existing_groups(mod, meta, :safe_extend)
    end

files_or_directories_to_run=(*files) click to toggle source

@private

    # File lib/rspec/core/configuration.rb, line 838
    def files_or_directories_to_run=(*files)
      files = files.flatten

      if (command == 'rspec' || Runner.running_in_drb?) && default_path && files.empty?
        files << default_path
      end

      @files_or_directories_to_run = files
      @files_to_run = nil
    end

files_to_run() click to toggle source

The spec files RSpec will run. @return [Array] specified files about to run

    # File lib/rspec/core/configuration.rb, line 851
    def files_to_run
      @files_to_run ||= get_files_to_run(@files_or_directories_to_run)
    end

filter() click to toggle source
Alias for: inclusion_filter
filter=(filter) click to toggle source
Alias for: inclusion_filter=
filter_gems_from_backtrace(*gem_names) click to toggle source

Adds {backtrace_exclusion_patterns} that will filter lines from the named gems from backtraces.

@param gem_names [Array<String>] Names of the gems to filter

@example

    RSpec.configure do |config|
      config.filter_gems_from_backtrace "rack", "rake"
    end

@note The patterns this adds will match the named gems in their common

    locations (e.g. system gems, vendored with bundler, installed as a
    :git dependency with bundler, etc) but is not guaranteed to work for
    all possible gem locations. For example, if you have the gem source
    in a directory with a completely unrelated name, and use bundler's
    :path option, this will not filter it.

    # File lib/rspec/core/configuration.rb, line 518
    def filter_gems_from_backtrace(*gem_names)
      gem_names.each do |name|
        @backtrace_formatter.filter_gem(name)
      end
    end

filter_run(*args) click to toggle source
Alias for: filter_run_including
filter_run_excluding(*args) click to toggle source

Adds key/value pairs to the `exclusion_filter`. If `args` includes any symbols that are not part of the hash, each symbol is treated as a key in the hash with the value `true`.

### Note

Filters set using this method can be overridden from the command line or config files (e.g. `.rspec`).

@example

    # Given this declaration.
    describe "something", :foo => 'bar' do
      # ...
    end

    # Any of the following will exclude that group.
    config.filter_run_excluding :foo => 'bar'
    config.filter_run_excluding :foo => /^ba/
    config.filter_run_excluding :foo => lambda {|v| v == 'bar'}
    config.filter_run_excluding :foo => lambda {|v,m| m[:foo] == 'bar'}

    # Given a proc with an arity of 1, the lambda is passed the value
    # related to the key, e.g.
    config.filter_run_excluding :foo => lambda {|v| v == 'bar'}

    # Given a proc with an arity of 2, the lambda is passed the value
    # related to the key, and the metadata itself e.g.
    config.filter_run_excluding :foo => lambda {|v,m| m[:foo] == 'bar'}

    filter_run_excluding :foo # same as filter_run_excluding :foo => true

    # File lib/rspec/core/configuration.rb, line 1079
    def filter_run_excluding(*args)
      meta = Metadata.build_hash_from(args, :warn_about_example_group_filtering)
      filter_manager.exclude_with_low_priority meta
      static_config_filter_manager.exclude_with_low_priority Metadata.deep_hash_dup(meta)
    end

filter_run_including(*args) click to toggle source

Adds key/value pairs to the `inclusion_filter`. If `args` includes any symbols that are not part of the hash, each symbol is treated as a key in the hash with the value `true`.

### Note

Filters set using this method can be overridden from the command line or config files (e.g. `.rspec`).

@example

    # Given this declaration.
    describe "something", :foo => 'bar' do
      # ...
    end

    # Any of the following will include that group.
    config.filter_run_including :foo => 'bar'
    config.filter_run_including :foo => /^ba/
    config.filter_run_including :foo => lambda {|v| v == 'bar'}
    config.filter_run_including :foo => lambda {|v,m| m[:foo] == 'bar'}

    # Given a proc with an arity of 1, the lambda is passed the value
    # related to the key, e.g.
    config.filter_run_including :foo => lambda {|v| v == 'bar'}

    # Given a proc with an arity of 2, the lambda is passed the value
    # related to the key, and the metadata itself e.g.
    config.filter_run_including :foo => lambda {|v,m| m[:foo] == 'bar'}

    filter_run_including :foo # same as filter_run_including :foo => true

    # File lib/rspec/core/configuration.rb, line 1019
    def filter_run_including(*args)
      meta = Metadata.build_hash_from(args, :warn_about_example_group_filtering)
      filter_manager.include_with_low_priority meta
      static_config_filter_manager.include_with_low_priority Metadata.deep_hash_dup(meta)
    end

Also aliased as: filter_run
force(hash) click to toggle source

@private

Used to set higher priority option values from the command line.

    # File lib/rspec/core/configuration.rb, line 377
    def force(hash)
      ordering_manager.force(hash)
      @preferred_options.merge!(hash)

      return unless hash.key?(:example_status_persistence_file_path)
      clear_values_derived_from_example_status_persistence_file_path
    end

format_docstrings(&block) click to toggle source

Formats the docstring output using the block provided.

@example

    # This will strip the descriptions of both examples and example
    # groups.
    RSpec.configure do |config|
      config.format_docstrings { |s| s.strip }
    end

    # File lib/rspec/core/configuration.rb, line 1345
    def format_docstrings(&block)
      @format_docstrings_block = block_given? ? block : DEFAULT_FORMATTER
    end

format_docstrings_block() click to toggle source

@private

    # File lib/rspec/core/configuration.rb, line 1350
    def format_docstrings_block
      @format_docstrings_block ||= DEFAULT_FORMATTER
    end

formatter=(formatter_to_use, *paths) click to toggle source
Alias for: add_formatter
formatter_loader() click to toggle source

@private

    # File lib/rspec/core/configuration.rb, line 784
    def formatter_loader
      @formatter_loader ||= Formatters::Loader.new(Reporter.new(self))
    end

formatters() click to toggle source

Returns a duplicate of the formatters currently loaded in the `FormatterLoader` for introspection.

Note as this is a duplicate, any mutations will be disregarded.

@return [Array] the formatters currently loaded

    # File lib/rspec/core/configuration.rb, line 779
    def formatters
      formatter_loader.formatters.dup
    end

full_backtrace=(true_or_false) click to toggle source

Toggle full backtrace. @attr true_or_false [Boolean] toggle full backtrace display

    # File lib/rspec/core/configuration.rb, line 684
    def full_backtrace=(true_or_false)
      @backtrace_formatter.full_backtrace = true_or_false
    end

full_backtrace?() click to toggle source

Check if full backtrace is enabled. @return [Boolean] is full backtrace enabled

    # File lib/rspec/core/configuration.rb, line 678
    def full_backtrace?
      @backtrace_formatter.full_backtrace?
    end

full_description() click to toggle source

@return [Array] full description filter

    # File lib/rspec/core/configuration.rb, line 735
    def full_description
      filter.fetch :full_description, nil
    end

full_description=(description) click to toggle source

Run examples matching on `description` in all files to run. @param description [String, Regexp] the pattern to filter on

    # File lib/rspec/core/configuration.rb, line 730
    def full_description=(description)
      filter_run :full_description => Regexp.union(*Array(description).map { |d| Regexp.new(d) })
    end

hooks() click to toggle source

@private Holds the various registered hooks. Here we use a FilterableItemRepository implementation that is specifically optimized for the read/write patterns of the config object.

    # File lib/rspec/core/configuration.rb, line 1637
    def hooks
      @hooks ||= HookCollections.new(self, FilterableItemRepository::QueryOptimized)
    end

include(mod, *filters) click to toggle source

Tells RSpec to include `mod` in example groups. Methods defined in `mod` are exposed to examples (not example groups). Use `filters` to constrain the groups or examples in which to include the module.

@example

    module AuthenticationHelpers
      def login_as(user)
        # ...
      end
    end

    module UserHelpers
      def users(username)
        # ...
      end
    end

    RSpec.configure do |config|
      config.include(UserHelpers) # included in all modules
      config.include(AuthenticationHelpers, :type => :request)
    end

    describe "edit profile", :type => :request do
      it "can be viewed by owning user" do
        login_as users(:jdoe)
        get "/profiles/jdoe"
        assert_select ".username", :text => 'jdoe'
      end
    end

@note Filtered module inclusions can also be applied to

    individual examples that have matching metadata. Just like
    Ruby's object model is that every object has a singleton class
    which has only a single instance, RSpec's model is that every
    example has a singleton example group containing just the one
    example.

@see extend @see prepend

    # File lib/rspec/core/configuration.rb, line 1143
    def include(mod, *filters)
      meta = Metadata.build_hash_from(filters, :warn_about_example_group_filtering)
      @include_modules.append(mod, meta)
      configure_existing_groups(mod, meta, :safe_include)
    end

inclusion_filter() click to toggle source

Returns the `inclusion_filter`. If none has been set, returns an empty hash.

    # File lib/rspec/core/configuration.rb, line 1043
    def inclusion_filter
      filter_manager.inclusions
    end

Also aliased as: filter
inclusion_filter=(filter) click to toggle source

Clears and reassigns the `inclusion_filter`. Set to `nil` if you don't want any inclusion filter at all.

### Warning

This overrides any inclusion filters/tags set on the command line or in configuration files.

    # File lib/rspec/core/configuration.rb, line 1034
    def inclusion_filter=(filter)
      meta = Metadata.build_hash_from([filter], :warn_about_example_group_filtering)
      filter_manager.include_only meta
    end

Also aliased as: filter=
last_run_statuses() click to toggle source

@private

    # File lib/rspec/core/configuration.rb, line 856
    def last_run_statuses
      @last_run_statuses ||= Hash.new(UNKNOWN_STATUS).tap do |statuses|
        if (path = example_status_persistence_file_path)
          begin
            ExampleStatusPersister.load_from(path).inject(statuses) do |hash, example|
              hash[example.fetch(:example_id)] = example.fetch(:status)
              hash
            end
          rescue SystemCallError => e
            RSpec.warning "Could not read from #{path.inspect} (configured as "                              "`config.example_status_persistence_file_path`) due "                              "to a system error: #{e.inspect}. Please check that "                              "the config option is set to an accessible, valid "                              "file path", :call_site => nil
          end
        end
      end
    end

libs=(libs) click to toggle source

@private

    # File lib/rspec/core/configuration.rb, line 721
    def libs=(libs)
      libs.map do |lib|
        @libs.unshift lib
        $LOAD_PATH.unshift lib
      end
    end

load_spec_files() click to toggle source

@private

    # File lib/rspec/core/configuration.rb, line 1324
    def load_spec_files
      files_to_run.uniq.each do |f|
        file = File.expand_path(f)
        load file
        loaded_spec_files << file
      end

      @spec_files_loaded = true
    end

mock_framework() click to toggle source

Returns the configured mock framework adapter module.

    # File lib/rspec/core/configuration.rb, line 447
    def mock_framework
      if @mock_framework.nil?
        begin
          mock_with :rspec
        rescue LoadError
          mock_with :nothing
        end
      end
      @mock_framework
    end

mock_framework=(framework) click to toggle source

Delegates to mock_framework=(framework).

    # File lib/rspec/core/configuration.rb, line 459
    def mock_framework=(framework)
      mock_with framework
    end

mock_with(framework) click to toggle source

Sets the mock framework adapter module.

`framework` can be a Symbol or a Module.

Given any of `:rspec`, `:mocha`, `:flexmock`, or `:rr`, configures the named framework.

Given `:nothing`, configures no framework. Use this if you don't use any mocking framework to save a little bit of overhead.

Given a Module, includes that module in every example group. The module should adhere to RSpec's mock framework adapter API:

    setup_mocks_for_rspec
      - called before each example

    verify_mocks_for_rspec
      - called after each example if the example hasn't yet failed.
        Framework should raise an exception when expectations fail

    teardown_mocks_for_rspec
      - called after verify_mocks_for_rspec (even if there are errors)

If the module responds to `configuration` and `mock_with` receives a block, it will yield the configuration object to the block e.g.

    config.mock_with OtherMockFrameworkAdapter do |mod_config|
      mod_config.custom_setting = true
    end

    # File lib/rspec/core/configuration.rb, line 562
    def mock_with(framework)
      framework_module =
        if framework.is_a?(Module)
          framework
        else
          const_name = MOCKING_ADAPTERS.fetch(framework) do
            raise ArgumentError,
                  "Unknown mocking framework: #{framework.inspect}. "                      "Pass a module or one of #{MOCKING_ADAPTERS.keys.inspect}"
          end

          RSpec::Support.require_rspec_core "mocking_adapters/#{const_name.to_s.downcase}"
          RSpec::Core::MockingAdapters.const_get(const_name)
        end

      new_name, old_name = [framework_module, @mock_framework].map do |mod|
        mod.respond_to?(:framework_name) ?  mod.framework_name : :unnamed
      end

      unless new_name == old_name
        assert_no_example_groups_defined(:mock_framework)
      end

      if block_given?
        raise "#{framework_module} must respond to `configuration` so that "                  "mock_with can yield it." unless framework_module.respond_to?(:configuration)
        yield framework_module.configuration
      end

      @mock_framework = framework_module
    end

only_failures_but_not_configured?() click to toggle source

@private

    # File lib/rspec/core/configuration.rb, line 180
    def only_failures_but_not_configured?
      only_failures? && !example_status_persistence_file_path
    end

output_stream=(value) click to toggle source

Set the output stream for reporter. @attr value [IO] value for output, defaults to $stdout

    # File lib/rspec/core/configuration.rb, line 213
    def output_stream=(value)
      if @reporter && !value.equal?(@output_stream)
        warn "RSpec's reporter has already been initialized with "              "#{output_stream.inspect} as the output stream, so your change to "             "`output_stream` will be ignored. You should configure it earlier for "              "it to take effect. (Called from #{CallerFilter.first_non_rspec_line})"
      else
        @output_stream = value
      end
    end

pattern=(value) click to toggle source

Set pattern to match files to load. @attr value [String] the filename pattern to filter spec files by

    # File lib/rspec/core/configuration.rb, line 230
    def pattern=(value)
      update_pattern_attr :pattern, value
    end

prepend(mod, *filters) click to toggle source

Tells RSpec to prepend example groups with `mod`. Methods defined in `mod` are exposed to examples (not example groups). Use `filters` to constrain the groups in which to prepend the module.

Similar to `include`, but module is included before the example group's class in the ancestor chain.

@example

    module OverrideMod
      def override_me
        "overridden"
      end
    end

    RSpec.configure do |config|
      config.prepend(OverrideMod, :method => :prepend)
    end

    describe "overriding example's class", :method => :prepend do
      it "finds the user" do
        self.class.class_eval do
          def override_me
          end
        end
        override_me # => "overridden"
        # ...
      end
    end

@see include @see extend

    # File lib/rspec/core/configuration.rb, line 1218
    def prepend(mod, *filters)
      meta = Metadata.build_hash_from(filters, :warn_about_example_group_filtering)
      @prepend_modules.append(mod, meta)
      configure_existing_groups(mod, meta, :safe_prepend)
    end

prepend_after(*args, &block) click to toggle source
Alias for: after
prepend_before(*args, &block) click to toggle source

Adds `block` to the start of the list of `before` blocks in the same scope (`:example`, `:context`, or `:suite`), in contrast to {before}, which adds the hook to the end of the list.

See {Hooks#before} for full `before` hook docs.

This method differs from {Hooks#prepend_before} in only one way: it supports the `:suite` scope. Hooks with the `:suite` scope will be run once before the first example of the entire suite is executed.

@see before @see after @see append_after

    # File lib/rspec/core/configuration.rb, line 1582
    def prepend_before(*args, &block)
      handle_suite_hook(args, @before_suite_hooks, :unshift,
                        Hooks::BeforeHook, block) || super(*args, &block)
    end

profile_examples() click to toggle source

@api private

Defaults `profile_examples` to 10 examples when `@profile_examples` is `true`.

    # File lib/rspec/core/configuration.rb, line 828
    def profile_examples
      profile = value_for(:profile_examples) { @profile_examples }
      if profile && !profile.is_a?(Integer)
        10
      else
        profile
      end
    end

raise_errors_for_deprecations!() click to toggle source

Turns deprecation warnings into errors, in order to surface the full backtrace of the call site. This can be useful when you need more context to address a deprecation than the single-line call site normally provided.

@example

    RSpec.configure do |rspec|
      rspec.raise_errors_for_deprecations!
    end

    # File lib/rspec/core/configuration.rb, line 1475
    def raise_errors_for_deprecations!
      self.deprecation_stream = Formatters::DeprecationFormatter::RaiseErrorStream.new
    end

reporter() click to toggle source

@private

    # File lib/rspec/core/configuration.rb, line 811
    def reporter
      # @reporter_buffer should only ever be set in this method to cover
      # initialization of @reporter.
      @reporter_buffer || @reporter ||=
        begin
          @reporter_buffer = DeprecationReporterBuffer.new
          formatter_loader.setup_default output_stream, deprecation_stream
          @reporter_buffer.play_onto(formatter_loader.reporter)
          @reporter_buffer = nil
          formatter_loader.reporter
        end
    end

requires=(paths) click to toggle source

@private

    # File lib/rspec/core/configuration.rb, line 1277
    def requires=(paths)
      directories = ['lib', default_path].select { |p| File.directory? p }
      RSpec::Core::RubyProject.add_to_load_path(*directories)
      paths.each { |path| require path }
      @requires += paths
    end

reset() click to toggle source

@private

    # File lib/rspec/core/configuration.rb, line 386
    def reset
      @spec_files_loaded = false
      @reporter = nil
      @formatter_loader = nil
    end

reset_filters() click to toggle source

@private

    # File lib/rspec/core/configuration.rb, line 393
    def reset_filters
      self.filter_manager = FilterManager.new
      filter_manager.include_only(
        Metadata.deep_hash_dup(static_config_filter_manager.inclusions.rules)
      )
      filter_manager.exclude_only(
        Metadata.deep_hash_dup(static_config_filter_manager.exclusions.rules)
      )
    end

safe_extend(mod, host) click to toggle source

@private

    # File lib/rspec/core/configuration.rb, line 1292
    def safe_extend(mod, host)
      host.extend(mod) unless host.singleton_class < mod
    end

safe_include(mod, host) click to toggle source

@private

    # File lib/rspec/core/configuration.rb, line 1287
    def safe_include(mod, host)
      host.__send__(:include, mod) unless host < mod
    end

safe_prepend(mod, host) click to toggle source

@private

    # File lib/rspec/core/configuration.rb, line 1271
    def safe_prepend(mod, host)
      host.__send__(:prepend, mod) unless host < mod
    end

spec_files_with_failures() click to toggle source

@private

    # File lib/rspec/core/configuration.rb, line 882
    def spec_files_with_failures
      @spec_files_with_failures ||= last_run_statuses.inject(Set.new) do |files, (id, status)|
        files << id.split(ON_SQUARE_BRACKETS).first if status == FAILED_STATUS
        files
      end.to_a
    end

treat_symbols_as_metadata_keys_with_true_values=(_value) click to toggle source

Deprecated. This config option was added in RSpec 2 to pave the way for this being the default behavior in RSpec 3. Now this option is a no-op.

    # File lib/rspec/core/configuration.rb, line 299
    def treat_symbols_as_metadata_keys_with_true_values=(_value)
      RSpec.deprecate(
        "RSpec::Core::Configuration#treat_symbols_as_metadata_keys_with_true_values=",
        :message => "RSpec::Core::Configuration#treat_symbols_as_metadata_keys_with_true_values= "                        "is deprecated, it is now set to true as default and "                        "setting it to false has no effect."
      )
    end

warnings=(value) click to toggle source

Set Ruby warnings on or off.

    # File lib/rspec/core/configuration.rb, line 1422
    def warnings=(value)
      $VERBOSE = !!value
    end

warnings?() click to toggle source

@return [Boolean] Whether or not ruby warnings are enabled.

    # File lib/rspec/core/configuration.rb, line 1427
    def warnings?
      $VERBOSE
    end

with_suite_hooks() click to toggle source

@private

    # File lib/rspec/core/configuration.rb, line 1621
    def with_suite_hooks
      return yield if dry_run?

      hook_context = SuiteHookContext.new
      begin
        run_hooks_with(@before_suite_hooks, hook_context)
        yield
      ensure
        run_hooks_with(@after_suite_hooks, hook_context)
      end
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.