Sha256: a5c003fef8937450e04c7c5b5b60b15b5f09200391aa711ef146a4032f03ec31

Contents?: true

Size: 665 Bytes

Versions: 4

Compression:

Stored size: 665 Bytes

Contents

require 'pact/consumer_contract/response'

shared_examples_for "request decorator to_json" do

  describe "#to_json" do

    let(:response) { Pact::Response.new(status: 200, body: body) }
    let(:body) { { baz: /qux/, wiffle: Pact::Term.new(generate: 'wiffle', matcher: /iff/) } }

    let(:decorator) { described_class.new(response) }

    subject { JSON.load decorator.to_json }

    it "serialises regexes" do
      expect(subject['body']['baz']).to eql /qux/
    end

    it "serialises terms" do
      parsed_term = subject['body']['wiffle']
      expect(parsed_term.matcher).to eql /iff/
      expect(parsed_term.generate).to eql 'wiffle'
    end

  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
pact-mock_service-0.2.2 spec/support/shared_examples_for_response_decorator.rb
pact-mock_service-0.2.1 spec/support/shared_examples_for_response_decorator.rb
pact-mock_service-0.2.0 spec/support/shared_examples_for_response_decorator.rb
pact-mock_service-0.1.0 spec/support/shared_examples_for_response_decorator.rb