Sha256: 7b2fe3b6877553093fa636619b9a53b175cac44e8abb3884e314f73719e8aeb0

Contents?: true

Size: 983 Bytes

Versions: 2

Compression:

Stored size: 983 Bytes

Contents

require 'spec_helper'
require 'pact/consumer_contract/request_decorator'
require 'pact/consumer/request'

module Pact
  describe RequestDecorator do

    let(:options) { { some: 'opts' } }
    let(:body) { { some: "bod" } }
    let(:headers) { { some: "header" } }
    let(:query) { "param=foo" }
    let(:request_params) do
      {
        method: :get,
        query: query,
        headers: headers,
        path: "/",
        body: body,
        options: options
      }
    end

    let(:request) { Pact::Request::Expected.from_hash(request_params) }

    subject { RequestDecorator.new(request) }

    describe "#to_json" do

      let(:parsed_json) { JSON.parse subject.to_json, symbolize_names: true }

      it "renders the keys in a meaningful order" do
        expect(subject.to_json).to match(/method.*path.*query.*headers.*body/)
      end

      it "does not render the options" do
        expect(subject.to_json).to_not include('options')
      end

    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
pact-mock_service-0.2.2 spec/lib/pact/consumer_contract/request_decorator_spec.rb
pact-mock_service-0.2.1 spec/lib/pact/consumer_contract/request_decorator_spec.rb