When you see an expectation like the following one:
|||expect(deck.cards.count).to eq(52), 'not playing with a full deck'|
…you’ll notice several forms of punctuation in use: parentheses, dots, and whitespace. While there’s some variety here, the syntax consistently uses just a few simple parts:
A subject—the thing you’re testing—that is, an instance of a Ruby class
A matcher—an object that specifies what you expect to be true about the subject, and provides the pass/fail logic
(optionally) A custom failure message
These parts are held together with a bit of glue code: expect, together with either the to or not_to method.
Let’s get a feel for how these parts ...