Sha256: 040898d462af83df1dfd9988be3ef75a36dde8e0ba0ecafbfbd8aa1599d09ad3
Contents?: true
Size: 1.68 KB
Versions: 2
Compression:
Stored size: 1.68 KB
Contents
require 'pact/consumer' require 'pact/consumer/rspec' load 'pact/consumer/world.rb' describe "A service consumer side of a pact", :pact => true do context "with no matching interaction found" do let(:expected_response) do { "message"=>"No interaction found for GET /path", "interaction_diffs"=>[{ "description" => "a request that will not be properly matched", "provider_state" => "something", "body"=>{ "a"=>{ "EXPECTED"=>"some body", "ACTUAL"=>"not matching body" } } }] } end it "returns an error" do Pact.clear_configuration Pact.service_consumer "Consumer" do has_pact_with "Mary Service" do mock_service :mary_service do verify false port 1236 end end end mary_service .given("something") .upon_receiving("a request that will not be properly matched") .with(method: 'get', path: '/path', body: {a: 'some body'}, headers: {'Content-Type' => 'application/json'}) .will_respond_with(status: 200) uri = URI('http://localhost:1236/path') post_req = Net::HTTP::Get.new(uri.path) post_req['Content-Type'] = "application/json" post_req.body = {a: "not matching body"}.to_json response = Net::HTTP.start(uri.hostname, uri.port) do |http| http.request post_req end expect(JSON.load(response.body)).to eq expected_response end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
pact-1.4.0.rc4 | spec/integration/consumer_no_matching_interaction_spec.rb |
pact-1.4.0.rc3 | spec/integration/consumer_no_matching_interaction_spec.rb |