Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: rspec/rspec-expectations
...
head fork: rspec/rspec-expectations
Checking mergeability… Don't worry, you can still create the pull request.
  • 1 commit
  • 1 file changed
  • 0 commit comments
  • 1 contributor
Showing with 22 additions and 5 deletions.
  1. +22 −5 features/built_in_matchers/README.md
View
27 features/built_in_matchers/README.md
@@ -1,16 +1,33 @@
+# Built-in Matchers
+
+Here is a list of matchers that ship with rspec-expectations. Each matcher
+can be used with `should` or `should_not` e.g.
+
+ result.should eq(3)
+ list.should_not be_empty
+
## Object identity
- actual.should equal(expected) # passes if actual.equal?(expected)
+ actual.should be(expected) # passes if actual.equal?(expected)
## Object equivalence
- actual.should == expected # passes if actual == expected
- actual.should eql(expected) # passes if actual.eql?(expected)
+ actual.should eq(expected) # passes if actual == expected
## Optional APIs for identity/equivalence
- actual.should eq(expected) # passes if actual == expected
- actual.should be(expected) # passes if actual.equal?(expected)
+ actual.should == expected # passes if actual == expected
+ actual.should eql(expected) # passes if actual.eql?(expected)
+ actual.should equal(expected) # passes if actual.equal?(expected)
+
+ # NOTE: this can't work in Ruby 1.8, so we don't support it at all:
+ # actual.should != expected
+ # The reason is that Ruby 1.8 parses it as:
+ # !(actual.should.==(expected)),
+ # so by the time RSpec sees it it has no way to know that it's
+ # been negated. Use either of these instead:
+ # actual.should_not eq(expected)
+ # actual.should_not == expected
## Comparisons

No commit comments for this range

Something went wrong with that request. Please try again.