Sha256: 28d11cfc0bba3ef13fa2d8c04261dddd5177e7a519693be8783b0e9be6c60e76

Contents?: true

Size: 1.44 KB

Versions: 213

Compression:

Stored size: 1.44 KB

Contents

rspec-expectations is used to define expected outcomes.

    describe Account do
      it "has a balance of zero when first created" do
        Account.new.balance.should eq(Money.new(0))
      end
    end

## Basic structure

The basic structure of an rspec expectation is:

    actual.should matcher(expected)
    actual.should_not matcher(expected)

## `should` and `should_not`

`rspec-expectations` adds `should` and `should_not` to every object in
the system. These methods each accept a matcher as an argument. This allows
each matcher to work in a positive or negative mode:

    5.should eq(5)
    5.should_not eq(4)

## What is a matcher?

A Matcher is any object that responds to the following methods:

    matches?(actual)
    failure_message_for_should

These methods are also part of the matcher protocol, but are optional:

    does_not_match?(actual)
    failure_message_for_should_not
    description

RSpec ships with a number of built-in matchers and a DSL for writing custom
matchers.

## Issues

The documentation for rspec-expectations is a work in progress. We'll be adding
Cucumber features over time, and clarifying existing ones.  If you have
specific features you'd like to see added, find the existing documentation
incomplete or confusing, or, better yet, wish to write a missing Cucumber
feature yourself, please [submit an
issue](http://github.com/rspec/rspec-expectations/issues) or a [pull
request](http://github.com/rspec/rspec-expectations).

Version data entries

213 entries across 112 versions & 19 rubygems

Version Path
classiccms-0.7.5 vendor/bundle/gems/rspec-expectations-2.9.1/features/README.markdown
classiccms-0.7.5 vendor/bundle/gems/rspec-expectations-2.10.0/features/README.md
classiccms-0.7.5 vendor/bundle/gems/rspec-expectations-2.9.0/features/README.markdown
classiccms-0.7.4 vendor/bundle/gems/rspec-expectations-2.9.1/features/README.markdown
classiccms-0.7.4 vendor/bundle/gems/rspec-expectations-2.9.0/features/README.markdown
classiccms-0.7.4 vendor/bundle/gems/rspec-expectations-2.10.0/features/README.md
classiccms-0.7.3 vendor/bundle/gems/rspec-expectations-2.10.0/features/README.md
classiccms-0.7.3 vendor/bundle/gems/rspec-expectations-2.9.0/features/README.markdown
classiccms-0.7.3 vendor/bundle/gems/rspec-expectations-2.9.1/features/README.markdown
judge-2.0.5 vendor/bundle/ruby/2.1.0/gems/rspec-expectations-2.13.0/features/README.md
tnargav-1.3.3 vendor/bundle/ruby/1.9.1/gems/rspec-expectations-2.11.3/features/README.md
tnargav-1.2.3 vendor/bundle/ruby/1.9.1/gems/rspec-expectations-2.11.3/features/README.md
classiccms-0.7.2 vendor/bundle/gems/rspec-expectations-2.10.0/features/README.md
classiccms-0.7.2 vendor/bundle/gems/rspec-expectations-2.9.0/features/README.markdown
classiccms-0.7.2 vendor/bundle/gems/rspec-expectations-2.9.1/features/README.markdown
classiccms-0.7.1 vendor/bundle/gems/rspec-expectations-2.10.0/features/README.md
classiccms-0.7.1 vendor/bundle/gems/rspec-expectations-2.9.0/features/README.markdown
classiccms-0.7.1 vendor/bundle/gems/rspec-expectations-2.9.1/features/README.markdown
sshp-0.0.2 vendor/ruby/1.9.1/gems/rspec-expectations-2.13.0/features/README.md
sshp-0.0.1 vendor/ruby/1.9.1/gems/rspec-expectations-2.13.0/features/README.md