0

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 ids because it wasn't matching the objects.

any clues?

2 Answers 2

1

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)

Sign up to request clarification or add additional context in comments.

Comments

0

I figured that include parameters is not an array, but a list of items,

so changing the test to:

  expect(SystemCommission.active.map(&:id)).to include *expected.map(&:id)

did the trick

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.