Sha256: 0698337cdcd91d56b45340c7fceb4eae598b05053f620a261c2ca0f8791a3bd7
Contents?: true
Size: 1.04 KB
Versions: 2
Compression:
Stored size: 1.04 KB
Contents
# -*- encoding : utf-8 -*- require 'rspec' require 'rspec/autorun' require 'pacto' Pacto.configure do |c| c.contracts_path = 'contracts' end Pacto.validate! # You can create a custom cop that investigates the request/response and sees if it complies with a # contract. The cop should return a list of citations if it finds any problems. 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 contracts = Pacto.load_contracts('contracts', 'http://localhost:5000') contracts.stub_providers puts contracts.simulate_consumers # Or you can completely replace the default set of validators Pacto::Cops.registered_cops.clear Pacto::Cops.register_cop Pacto::Cops::ResponseBodyCop contracts = Pacto.load_contracts('contracts', 'http://localhost:5000') puts contracts.simulate_consumers
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
pacto-0.4.0.rc3 | samples/cops.rb |
pacto-0.4.0.rc2 | samples/cops.rb |