To add a collaborator to this project you will need to use the Relish gem to add the collaborator via a terminal command. Soon you'll be able to also add collaborators here!More about adding a collaborator
RSpec Expectations 3.3
rspec-expectations is used to define expected outcomes.
RSpec.describe Account do it "has a balance of zero when first created" do expect(Account.new.balance).to eq(Money.new(0)) end end
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
One is an alias to the other, so you can use whichever reads better to you.
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:
These methods are also part of the matcher protocol, but are optional:
does_not_match?(actual) failure_message_when_negated description supports_block_expectations?
RSpec ships with a number of built-in matchers and a DSL for writing custom
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.
- Built in matchers
- Custom matchers
- Aggregating Failures
- Composing Matchers
- Compound Expectations
- Define negated matcher
- customized message
- implicit docstrings
- Syntax Configuration
- Test frameworks
Last published 23 days ago by myronmarston.
RSpec Expectations settings