payout / rester

An exceedingly quick way of creating restful interfaces between Ruby services.
https://www.payout.com
MIT License
2 stars 0 forks source link

Add custom matcher for RSpec contract testing #64

Closed kayvonghaffari closed 9 years ago

kayvonghaffari commented 9 years ago

Currently, we use it { is_expected.to include stub_response }. This doesn't work for responses that return arrays of hashes. For example:

response:
  page_count: 1
  transfers:
  - &valid_transfer_response
    token: DXR1bkh1PS80g
    amount_cents: 100
    is_deposit: true
    created_at: "2015-02-22T00:00:00+00:00"
    updated_at: "2015-02-22T00:00:00+00:00"
    state: cleared
    effective_balance: 100
  - &valid_transfer_scheduled_response
    <<: *valid_transfer_response
    state: scheduled
  - &valid_transfer_pending_response
    <<: *valid_transfer_response
    state: pending
  - &valid_transfer_cleared_response
    <<: *valid_transfer_response
    state: cleared
  - &valid_transfer_failed_response
    <<: *valid_transfer_response
    state: failed

The transfers array would be checked for an exact match with the service response when the intended behavior is just inclusion within the underlying transfer hashses