I'm testing the active
scope of SystemCommission
, I have the following test:
expected = [active, no_starting, no_ending]
expect(SystemCommission.active.map(&:id)).to include expected.map(&:id)
it fails with:
Failure/Error: expect(SystemCommission.active.map(&:id)).to include expected.map(&:id)
expected [1, 2, 3] to include [1, 2, 3]
I had to use the id
s because it wasn't matching the objects.
any clues?
The array [1, 2, 3]
does not include [1, 2, 3]
To make that pass it would look something like: [1, 2, 3, [1, 2, 3]]
splat your array:
expect(SystemCommission.active.map(&:id)).to include *expected.map(&:id)