A developer notebook I should have started 10 years ago..

RSpec expectations chaining

How can I chain RSpec expectations?

# chaining multiple changes assertions
expect { user.destroy }
  .to change { User.count }.by(-1)
  .and change { Group.count }.by(-1)

# chaining optional assertions
expect(color)
  .to eq("blue")
  .or eq("red")