thoughtworks/pacto — pull request #131 by maxlinc (2014-07-02 19:22:33+00:00)
Title: Replace validator middlware stack with Cop plugins

This replaces the validator middleware with a much better, more extensible "Cop" system.

A cop investigates that a request/response complies with a contract. A custom cop could also check for organizational conventions that are outside of the contract (e.g. security requirements). A cop issues citations. The `samples/cops.rb` code shows a custom cop:

```ruby
class MyCustomCop
def investigate(_request, _response, contract)
citations = []
citations << 'Contract must have a request schema' if contract.request.schema.empty?
citations << 'Contract must have a response schema' if contract.response.schema.empty?
citations
end
end

Pacto::Cops.active_cops << MyCustomCop.new
```

Obsoletes #91, because there is no more "body_only" feature. Instead, you can set the active cops to only include Pacto::Cops::RequestBodyCop and/or Pacto::Cops::ResponseBodyCop.

I am planning to rename rspec matchers and rake tasks to go with `investigate` rather than `validate` when it makes sense, but I'm going to do that as a separate PR since it is a bigger breaking change while this is (more) internal.