Sha256: c372062fa8954ba55f6daaab50ef12d0f511b6dfef3f0f7dd89d600f241617d2

Contents?: true

Size: 1.41 KB

Versions: 32

Compression:

Stored size: 1.41 KB

Contents

rspec-expectations is used to define expected outcomes.

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

## Basic structure

The basic structure of an rspec expectation is:

    expect(actual).to matcher(expected)
    expect(actual).not_to matcher(expected)

Note: You can also use `expect(..).to_not` instead of `expect(..).not_to`.
      One is an alias to the other, so you can use whichever reads better to you.

#### Examples

    expect(5).to eq(5)
    expect(5).not_to 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

32 entries across 32 versions & 8 rubygems

Version Path
vagrant-unbundled-2.2.7.0 vendor/bundle/ruby/2.4.0/gems/rspec-expectations-2.14.5/features/README.md
vagrant-unbundled-1.9.5.1 vendor/bundle/ruby/2.4.0/gems/rspec-expectations-2.14.5/features/README.md
vagrant-unbundled-1.9.1.1 vendor/bundle/ruby/2.4.0/gems/rspec-expectations-2.14.5/features/README.md
vagrant-unbundled-1.8.5.2 vendor/bundle/ruby/2.3.0/gems/rspec-expectations-2.14.5/features/README.md
vagrant-unbundled-1.8.5.1 vendor/bundle/ruby/2.3.0/gems/rspec-expectations-2.14.5/features/README.md
vagrant-unbundled-1.8.4.2 vendor/bundle/ruby/2.3.0/gems/rspec-expectations-2.14.5/features/README.md
vagrant-unbundled-1.8.4.1 vendor/bundle/ruby/2.3.0/gems/rspec-expectations-2.14.5/features/README.md
vagrant-unbundled-1.8.1.1 vendor/bundle/ruby/2.3.0/gems/rspec-expectations-2.14.5/features/README.md
vagrant-cloudstack-1.1.0 vendor/bundle/gems/rspec-expectations-2.14.5/features/README.md
dxruby_rp5-0.0.4 spec/vendor/rspec-expectations-2.14.4/features/README.md
rspec-expectations-2.99.0.beta2 features/README.md
rspec-expectations-2.14.5 features/README.md
mango-0.8.0 vendor/bundler/ruby/2.1.0/gems/rspec-expectations-2.14.4/features/README.md
mango-0.7.1 vendor/bundler/ruby/2.0.0/gems/rspec-expectations-2.14.4/features/README.md
dxruby_rp5-0.0.3 spec/vendor/rspec-expectations-2.14.4/features/README.md
tuktuk-rails-0.0.10 vendor/bundle/ruby/2.0.0/gems/rspec-expectations-2.14.4/features/README.md
tuktuk-rails-0.0.9 vendor/bundle/ruby/2.0.0/gems/rspec-expectations-2.14.4/features/README.md
tuktuk-rails-0.0.8 vendor/bundle/ruby/2.0.0/gems/rspec-expectations-2.14.4/features/README.md
tuktuk-rails-0.0.7 vendor/bundle/ruby/2.0.0/gems/rspec-expectations-2.14.4/features/README.md
dxruby_rp5-0.0.2 spec/vendor/rspec-expectations-2.14.4/features/README.md