Equality matchers in RSpec Expectations

Ruby exposes several different methods for handling equality:

a.equal?(b) # object identity - a and b refer to the same object
a.eql?(b)   # object equivalence - a and b have the same value
a == b      # object equivalence - a and b have the same value with type conversions

rspec-expectations ships with matchers that align with each of these methods:

expect(a).to equal(b) # passes if a.equal?(b)
expect(a).to eql(b) # passes if a.eql?(b)
expect(a).to be == b # passes if a == b

It also ships with two matchers that have more of a DSL feel to them:

expect(a).to be(b) # passes if a.equal?(b)
expect(a).to eq(b) # passes if a == b

via Equality matchers – Built in matchers – RSpec Expectations – RSpec – Relish