You can use the operator =~ :
[:b, :a, :c].should =~ [:a, :b, :c]
From docs :
Passes if the actual contains everything expected, regardless of order. This works for collections. Go into multiple arguments, and this will only be if all arguments are found in the collection.
For RSpec, expect the syntax there match_array :
expect([:b, :a, :c]).to match_array([:a, :b, :c])
or contain_exactly if you pass individual elements:
expect([:b, :a, :c]).to contain_exactly(:a, :b, :c)
source share