I use new RSpec syntax (expect
instead of should
) and I'd like to test if an array includes elements of another array. In the old syntax it would be:
array1.should include(array2)
In the new syntax I tried to write:
expect(array1).to include(array2)
but I got an error (that's quite reasonable):
TypeError: wrong argument type Array (expected Module)
Then I wrote:
expect(array1).to be_include(array2)
but it's ugly and it didn't work: apparently it checks if array2 is element of array1 not if all elements of array2 are included in array1.
Finally I wrote:
expect(array1 & array2).to eq(array2)
but it's not the prettiest solution. Do you know any better?