Class: RSpec::Expectations::Configuration

### Home Classes Methods

### In Files

- lib/rspec/expectations/configuration.rb

### Parent

Object

### Methods

- #add_should_and_should_not_to
- #backtrace_formatter
- #color?
- #include_chain_clauses_in_custom_matcher_descriptions?
- #reset_syntaxes_to_default
- #syntax
- #syntax=

### Class/Module Index

Quicksearch

- RSpec
- RSpec::Expectations
- RSpec::Expectations::BlockExpectationTarget
- RSpec::Expectations::Configuration
- RSpec::Expectations::ExpectationHelper
- RSpec::Expectations::ExpectationNotMetError
- RSpec::Expectations::ExpectationTarget
- RSpec::Expectations::LegacyMacherAdapter
- RSpec::Expectations::LegacyMatcherAdapter
- RSpec::Expectations::LegacyMatcherAdapter::RSpec1
- RSpec::Expectations::LegacyMatcherAdapter::RSpec2
- RSpec::Expectations::NegativeExpectationHandler
- RSpec::Expectations::PositiveExpectationHandler
- RSpec::Expectations::Syntax
- RSpec::Expectations::Version
- RSpec::Matchers
- RSpec::Matchers::AliasedMatcher
- RSpec::Matchers::AliasedMatcherWithOperatorSupport
- RSpec::Matchers::AliasedNegatedMatcher
- RSpec::Matchers::BuiltIn
- RSpec::Matchers::BuiltIn::All
- RSpec::Matchers::BuiltIn::BaseMatcher
- RSpec::Matchers::BuiltIn::BaseMatcher::DefaultFailureMessages
- RSpec::Matchers::BuiltIn::Be
- RSpec::Matchers::BuiltIn::BeAKindOf
- RSpec::Matchers::BuiltIn::BeAnInstanceOf
- RSpec::Matchers::BuiltIn::BeBetween
- RSpec::Matchers::BuiltIn::BeComparedTo
- RSpec::Matchers::BuiltIn::BeFalsey
- RSpec::Matchers::BuiltIn::BeHelpers
- RSpec::Matchers::BuiltIn::BeNil
- RSpec::Matchers::BuiltIn::BePredicate
- RSpec::Matchers::BuiltIn::BeTruthy
- RSpec::Matchers::BuiltIn::BeWithin
- RSpec::Matchers::BuiltIn::CaptureStderr
- RSpec::Matchers::BuiltIn::CaptureStdout
- RSpec::Matchers::BuiltIn::CaptureStreamToTempfile
- RSpec::Matchers::BuiltIn::Change
- RSpec::Matchers::BuiltIn::ChangeDetails
- RSpec::Matchers::BuiltIn::ChangeFromValue
- RSpec::Matchers::BuiltIn::ChangeRelatively
- RSpec::Matchers::BuiltIn::ChangeToValue
- RSpec::Matchers::BuiltIn::Compound
- RSpec::Matchers::BuiltIn::Compound::And
- RSpec::Matchers::BuiltIn::Compound::NestedEvaluator
- RSpec::Matchers::BuiltIn::Compound::Or
- RSpec::Matchers::BuiltIn::Compound::SequentialEvaluator
- RSpec::Matchers::BuiltIn::ContainExactly
- RSpec::Matchers::BuiltIn::ContainExactly::PairingsMaximizer
- RSpec::Matchers::BuiltIn::Cover
- RSpec::Matchers::BuiltIn::EndWith
- RSpec::Matchers::BuiltIn::Eq
- RSpec::Matchers::BuiltIn::Eql
- RSpec::Matchers::BuiltIn::Equal
- RSpec::Matchers::BuiltIn::Exist
- RSpec::Matchers::BuiltIn::Exist::ExistenceTest
- RSpec::Matchers::BuiltIn::Has
- RSpec::Matchers::BuiltIn::HaveAttributes
- RSpec::Matchers::BuiltIn::Include
- RSpec::Matchers::BuiltIn::Match
- RSpec::Matchers::BuiltIn::NegativeOperatorMatcher
- RSpec::Matchers::BuiltIn::NullCapture
- RSpec::Matchers::BuiltIn::OperatorMatcher
- RSpec::Matchers::BuiltIn::Output
- RSpec::Matchers::BuiltIn::PositiveOperatorMatcher
- RSpec::Matchers::BuiltIn::RaiseError
- RSpec::Matchers::BuiltIn::RespondTo
- RSpec::Matchers::BuiltIn::Satisfy
- RSpec::Matchers::BuiltIn::SpecificValuesChange
- RSpec::Matchers::BuiltIn::StartAndEndWith
- RSpec::Matchers::BuiltIn::StartOrEndWith
- RSpec::Matchers::BuiltIn::StartWith
- RSpec::Matchers::BuiltIn::ThrowSymbol
- RSpec::Matchers::BuiltIn::YieldControl
- RSpec::Matchers::BuiltIn::YieldProbe
- RSpec::Matchers::BuiltIn::YieldSuccessiveArgs
- RSpec::Matchers::BuiltIn::YieldWithArgs
- RSpec::Matchers::BuiltIn::YieldWithNoArgs
- RSpec::Matchers::Composable
- RSpec::Matchers::DSL
- RSpec::Matchers::DSL::DefaultImplementations
- RSpec::Matchers::DSL::Macros
- RSpec::Matchers::DSL::Macros::Deprecated
- RSpec::Matchers::DSL::Matcher
- RSpec::Matchers::ExpectedsForMultipleDiffs
- RSpec::Matchers::MatcherDelegator
- RSpec::Matchers::MatcherProtocol
- RSpec::Matchers::Pretty
- BasicObject
- Object

No matching classes.

# RSpec::Expectations::Configuration

Provides configuration options for rspec-expectations. If you are using rspec-core, you can access this via a block passed to `RSpec::Core::Configuration#expect_with`. Otherwise, you can access it via RSpec::Expectations.configuration.

@example

    RSpec.configure do |rspec|
      rspec.expect_with :rspec do |c|
        # c is the config object
      end
    end

    # or

    RSpec::Expectations.configuration

### Constants

NullBacktraceFormatter

  @api private Null implementation of a backtrace formatter used by default when rspec-core is not loaded. Does no filtering.

### Attributes

backtrace_formatter[W]

Sets or gets the backtrace formatter. The backtrace formatter should implement `format_backtrace(Array)`. This is used to format backtraces of errors handled by the `raise_error` matcher.

If you are using rspec-core, rspec-core's backtrace formatting will be used (including respecting the presence or absence of the `--backtrace` option).

@!attribute [rw] backtrace_formatter

include_chain_clauses_in_custom_matcher_descriptions[W]

Sets if custom matcher descriptions and failure messages should include clauses from methods defined using `chain`. @param value [Boolean]

### Public Instance Methods

add_should_and_should_not_to(*modules) click to toggle source

Adds `should` and `should_not` to the given classes or modules. This can be used to ensure `should` works properly on things like proxy objects (particular `Delegator`-subclassed objects on 1.8).

@param [Array<Module>] modules the list of classes or modules

    to add `should` and `should_not` to.

    # File lib/rspec/expectations/configuration.rb, line 85
    def add_should_and_should_not_to(*modules)
      modules.each do |mod|
        Expectations::Syntax.enable_should(mod)
      end
    end

backtrace_formatter() click to toggle source

    # File lib/rspec/expectations/configuration.rb, line 102
    def backtrace_formatter
      @backtrace_formatter ||= if defined?(::RSpec.configuration.backtrace_formatter)
                                 ::RSpec.configuration.backtrace_formatter
                               else
                                 NullBacktraceFormatter
                               end
    end

color?() click to toggle source

    # File lib/rspec/expectations/configuration.rb, line 61
    def color?
      ::RSpec.configuration.color_enabled?
    end

include_chain_clauses_in_custom_matcher_descriptions?() click to toggle source

Indicates whether or not custom matcher descriptions and failure messages should include clauses from methods defined using `chain`. It is false by default for backwards compatibility.

    # File lib/rspec/expectations/configuration.rb, line 118
    def include_chain_clauses_in_custom_matcher_descriptions?
      @include_chain_clauses_in_custom_matcher_descriptions ||= false
    end

reset_syntaxes_to_default() click to toggle source

@private

    # File lib/rspec/expectations/configuration.rb, line 123
    def reset_syntaxes_to_default
      self.syntax = [:should, :expect]
      RSpec::Expectations::Syntax.warn_about_should!
    end

syntax() click to toggle source

The list of configured syntaxes. @return [Array<Symbol>] the list of configured syntaxes. @example

    unless RSpec::Matchers.configuration.syntax.include?(:expect)
      raise "this RSpec extension gem requires the rspec-expectations `:expect` syntax"
    end

    # File lib/rspec/expectations/configuration.rb, line 53
    def syntax
      syntaxes = []
      syntaxes << :should if Expectations::Syntax.should_enabled?
      syntaxes << :expect if Expectations::Syntax.expect_enabled?
      syntaxes
    end

syntax=(values) click to toggle source

Configures the supported syntax. @param [Array<Symbol>, Symbol] values the syntaxes to enable @example

    RSpec.configure do |rspec|
      rspec.expect_with :rspec do |c|
        c.syntax = :should
        # or
        c.syntax = :expect
        # or
        c.syntax = [:should, :expect]
      end
    end

    # File lib/rspec/expectations/configuration.rb, line 33
    def syntax=(values)
      if Array(values).include?(:expect)
        Expectations::Syntax.enable_expect
      else
        Expectations::Syntax.disable_expect
      end

      if Array(values).include?(:should)
        Expectations::Syntax.enable_should
      else
        Expectations::Syntax.disable_should
      end
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.