RSpec has a tiny little matcher to test arrays which is not so easy to be found
in documentation. The matcher is:
=~ (same as regex match operator). Example:
The documentation for this matcher says that this matcher checks whether actual array contains all elements of the expected array regardless the order. Well this isn’t fortunate description because if actual array will include expected array together with some additional elements the test will fail:
The result is:
So the matcher in fact tests if both actual and expected arrays contain same elements regardless the order.
This matcher doesn’t support
should_not. More information can be found here.