Sha256: 434e2a62a82d81c21b78c0a1def2c24030932a4d5e28c29847a83361dd327f68
Contents?: true
Size: 1.85 KB
Versions: 4
Compression:
Stored size: 1.85 KB
Contents
require 'spec_helper' require 'pact/mock_service/interaction_decorator' module Pact module MockService describe InteractionDecorator do describe "#to_json" do let(:request) do { method: 'post', path: '/foo', body: Term.new(generate: 'waffle', matcher: /ffl/), headers: { 'Content-Type' => 'application/json' }, query: '', } end let(:response) do { body: { baz: /qux/, wiffle: Term.new(generate: 'wiffle', matcher: /iff/) } } end let(:interaction) do Interaction.from_hash( 'description' => 'description', 'provider_state' => 'provider_state', 'response' => response, 'request' => request) end subject { InteractionDecorator.new(interaction) } let(:parsed_result) do JSON.load(subject.to_json) end it "contains the request" do expect(parsed_result).to have_key('request') end it "contains the response" do expect(parsed_result).to have_key('request') end it "contains the description" do expect(parsed_result['description']).to eq 'description' end context "with a provider state" do it "contains the provider_state" do expect(parsed_result['provider_state']).to eq 'provider_state' end end context "without a provider state" do let(:interaction) do Interaction.from_hash( 'description' => 'description', 'response' => response, 'request' => request) end it "does not contain the provider_state" do expect(parsed_result).to_not have_key 'provider_state' end end end end end end
Version data entries
4 entries across 4 versions & 1 rubygems