thoughtworks/pacto — pull request #12 by jesusmercado (2013-08-18 23:34:25+00:00)
Title: Refactor to use stub providers

The main idea is to move code from the InstantiatedContract that deals with the stubbing logic, this logic should be managed by a stub provider.

Currently we use WebMock to stub the requests but in the future we could plug another stub provider like an external server.

To achieve this were created two new classes:
- Stubs::BuiltIn: Code for stubbing the contract with WebMock
- Stubs::StubProvider: Factory for provide the current stub provider

This is WIP, possible improvments are:
- Naming the provider for strategy, actually we are talking about different strategies for stubbing contracts.
- We could change the way the InstantiatedContract asks for the current provider because now is very verbose. One alternative could be ask directly to Pacto.current_provider.
- Renaming BuiltIt to WebMockProvider.
- During this refactoring I noticed that the response body comes from two sources of truth: @response.body and @response_body. This might be a good candidate for another refactoring.

Feedback is very welcome :).