RSpec
Certain RSpec patterns.
Subject should match what is being described
Instead of:
spec.rb
It is clearer to handle the update in subject
and then frame the assertion as a change.
.to match
vs. .to eq
.to match
vs. .to eq
Unlike in Jest, subset matchers only work with the looser .to match
. When using Jest, expect.objectContaining
, etc. can be used with both .toEqual
and .toBe
. However, a_hash_including
, etc. will simply fail when used with .to eq
! This is especially frustrating because nothing about the error message indicates that the failure comes from using the wrong matcher.
Diffing JSON blobs
Last updated