thoughtworks/pacto — pull request #71 by maxlinc (2013-12-15 18:01:45+00:00)
Title: Use Faraday instead of HTTParty

> Faraday is an HTTP client lib that provides a common interface over many adapters (such as Net::HTTP) and embraces the concept of Rack middleware when processing the request/response cycle.

Faraday is a useful choice for Pacto in several ways.

First, since it aims to provide a common interface, it does some normalization that we had been doing ourselves. I removed some unneeded normalization code, like the ResponseAdapter class, but our work with Headers can be cleaned up further (Faraday is indifferent about 'user-agent' vs 'User-Agent' for simple array access, but not for the array operations used by `subsetOf`).

Second, Faraday's middleware is useful for things like logging requests/responses in debug mode, or generating authentication tokens required to validate contracts.

Finally, supporting other backends can be useful. In particular, I find my self in situations where I need an asynchronous library like em-http-request. I'm currently using that in combination with Pacto to support an rspec suite with a Pacto server running on a second thread (so I can test non-Ruby processes).

Note: Faraday only applies to requests *generated* by Pacto, usually via `request#execute`.