Module RSpec::Expectations
In: lib/rspec/expectations.rb
lib/rspec/expectations/syntax.rb
lib/rspec/expectations/differ.rb
lib/rspec/expectations/fail_with.rb
lib/rspec/expectations/errors.rb
lib/rspec/expectations/version.rb
lib/rspec/expectations/handler.rb
lib/rspec/expectations/expectation_target.rb
lib/rspec/expectations/extensions/object.rb

RSpec::Expectations adds two instance methods to every object:

    should(matcher=nil)
    should_not(matcher=nil)

Both methods take an optional matcher object (See [RSpec::Matchers](../RSpec/Matchers)). When `should` is invoked with a matcher, it turns around and calls `matcher.matches?(self)`. For example, in the expression:

    order.total.should eq(Money.new(5.55, :USD))

the `should` method invokes the equivalent of `eq.matches?(order.total)`. If `matches?` returns true, the expectation is met and execution continues. If `false`, then the spec fails with the message returned by `eq.failure_message_for_should`.

Given the expression:

    order.entries.should_not include(entry)

the `should_not` method invokes the equivalent of `include.matches?(order.entries)`, but it interprets `false` as success, and `true` as a failure, using the message generated by `eq.failure_message_for_should_not`.

rspec-expectations ships with a standard set of useful matchers, and writing your own matchers is quite simple.

See [RSpec::Matchers](../RSpec/Matchers) for more information about the built-in matchers that ship with rspec-expectations, and how to write your own custom matchers.

Methods

differ   differ=   fail_with  

Classes and Modules

Module RSpec::Expectations::DeprecatedConstants
Module RSpec::Expectations::Syntax
Module RSpec::Expectations::Version
Class RSpec::Expectations::Differ
Class RSpec::Expectations::ExpectationNotMetError
Class RSpec::Expectations::ExpectationTarget
Class RSpec::Expectations::NegativeExpectationHandler
Class RSpec::Expectations::PositiveExpectationHandler

Public Class methods

@private

Raises an RSpec::Expectations::ExpectationNotMetError with message. @param [String] message @param [Object] expected @param [Object] actual

Adds a diff to the failure message when `expected` and `actual` are both present.

Public Instance methods

@deprecated (no replacement)

[Validate]