RSpec: How could I use the array include matcher in the expect syntax

You need to splat the arguments when passing them to the array matcher:

expect(array1).to include(*array2)

This is because you usually list out literals, e.g.:

expect([1, 2, 3]).to include(1, 2)

That said, expect(array1).to include(array2) should not fail with a weird error like you got, and in fact it works and passes in an example like:

  it 'includes a sub array' do
    array2 = ["a"]
    array1 = [array2]
    expect(array1).to include(array2)
  end

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)