Logo: Relish

  1. Sign in

Project: RSpec Expectations 2.5

RSpec Expectations 2.5

rspec-expectations is used to set expectations in executable examples.

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

should and should_not

rspec-expectations adds should and should_not to every object. Each of
these can accept a matcher and, in most cases, an optional custom failure
message (see customized message).


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


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


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


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 or a pull request.


  1. Upgrade
  2. customized message
  3. diffing
  4. implicit docstrings
  5. Built in matchers
  6. Custom matchers
  7. Test frameworks
  8. Changelog

Last published about 7 years ago by dchelimsky.