Velhotes/Vinyl

Configurable request matching

dmcrodrigues opened this issue · 3 comments

Every request is matched against a request previously recorded to determine the associated response. This match is currently done using request's URL but to accommodate every test-case this should be configurable. An example where this can be helpful are cases where requests are non-deterministic, e.g. query includes a timestamp parameter.

The following attributes can be combined and used to configure this match:

  • Method
  • URL
  • Path
  • Query
  • Headers
  • Body

In addition to this attributes and to promote a fine-tuning configuration it should be possible provide a custom matcher with a signature similar to this one:

func match(aRequest: Request, anotherRequest: Request) -> Bool

Should we address the idea of an array with pre-defined responses on this issue?

I think we can introduce that behaviour when the turntable is configured with an empty array of attributes, since there is not a single attribute to match we can use the pre-defined responses in order, first request receives first response and so on.

What do you think?

We can make it a separated piece of work (at least I put it like this in the RoadMap).