Module: Spec::Expectations

Module | Spec::Expectations
In: | lib/spec/expectations/differs/default.rb lib/spec/expectations/errors.rb lib/spec/expectations/extensions/object.rb lib/spec/expectations/extensions/string_and_symbol.rb lib/spec/expectations/handler.rb lib/spec/expectations.rb

Spec::Expectations lets you set expectations on your objects.

      result.should == 37
      team.should have(11).players_on_the_field

## How Expectations work.

Spec::Expectations adds two methods to Object:

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

Both methods take an optional Expression Matcher (See Spec::Matchers).

When `should` receives an Expression Matcher, it calls `matches?(self)`. If it returns `true`, the spec passes and execution continues. If it returns `false`, then the spec fails with the message returned by `matcher.failure_message`.

Similarly, when `should_not` receives a matcher, it calls `matches?(self)`. If it returns `false`, the spec passes and execution continues. If it returns `true`, then the spec fails with the message returned by `matcher.negative_failure_message`.

RSpec ships with a standard set of useful matchers, and writing your own matchers is quite simple. See Spec::Matchers for details.

### Classes and Modules

Module Spec::Expectations::Differs
Module Spec::Expectations::MatcherHandlerHelper
Module Spec::Expectations::ObjectExpectations
Module Spec::Expectations::StringHelpers
Class Spec::Expectations::ExpectationMatcherHandler
Class Spec::Expectations::ExpectationNotMetError
Class Spec::Expectations::InvalidMatcherError
Class Spec::Expectations::NegativeExpectationMatcherHandler

### Attributes

differ | [RW] |

[Validate]