waterlink / rspec-json_expectations

Set of matchers and helpers to allow you test your APIs responses like a pro.
https://www.relishapp.com/waterlink/rspec-json-expectations/docs
MIT License
140 stars 23 forks source link

Add UnorderedArray matcher #16

Closed waterlink closed 8 years ago

waterlink commented 8 years ago

Closes #7

This introduces a new special syntax for defining unordered array expectations:

expect(response).to include_json(
  users: UnorderedArray(
    { .. },
    { .. },
    ......
  )
)

This matcher succeeds, if all expected elements can be found in the actual array in any order. It fails if at least one element can not be found. Elements are matched the same way include_json matcher works, so it is possible to have regex and even another UnorderedArray inside of element expectations.

/cc @benoittgt

benoittgt commented 8 years ago

Looks good to me @waterlink.