<commit_before>require 'spec_helper'
require 'pact_broker/api/decorators/pact_decorator'

module PactBroker

  module Api

    module Decorators

      describe PactDecorator do

        let(:json_content) {
          {
            'consumer' => {'name' => 'Consumer'},
            'provider' => {'name' => 'Provider'},
            'interactions' => [],
            'metadata' => {}
          }.to_json
        }

        let(:base_url) { 'http://example.org' }
        let(:created_at) { Time.new(2014, 3, 4) }
        let(:updated_at) { Time.new(2014, 3, 5) }
        let(:pact) { double('pact', json_content: json_content, created_at: created_at, updated_at: updated_at, consumer: consumer, provider: provider, consumer_version: consumer_version)}
        let(:consumer) { instance_double(PactBroker::Models::Pacticipant, name: 'Consumer')}
        let(:provider) { instance_double(PactBroker::Models::Pacticipant, name: 'Provider')}
        let(:consumer_version) { instance_double(PactBroker::Models::Version, number: '1234')}

        subject { JSON.parse PactDecorator.new(pact).to_json(base_url: base_url), symbolize_names: true}

        describe "#to_json" do

          it "includes the json_content" do
            expect(subject[:consumer]).to eq name: 'Consumer'
          end

          it "includes the createdAt date" do
            expect(subject[:createdAt]).to eq created_at.xmlschema
          end

          it "includes a link to the webhooks for this pact" do
            expect(subject[:_links][:'pact-webhooks'][:href]).to eq "http://example.org/webhooks/provider/Provider/consumer/Consumer"
          end

          it "includes a link to the latest pact" do
            expect(subject[:_links][:'latest-pact'][:title]).to eq "Latest pact between Consumer and Provider"
            expect(subject[:_links][:'latest-pact'][:href]).to eq "http://example.org/pacts/provider/Provider/consumer/Consumer/latest"
          end
        end

      end
    end
  end
end<commit_msg>Fixed spec<commit_after>require 'spec_helper'
require 'pact_broker/api/decorators/pact_decorator'

module PactBroker

  module Api

    module Decorators

      describe PactDecorator do

        let(:json_content) {
          {
            'consumer' => {'name' => 'Consumer'},
            'provider' => {'name' => 'Provider'},
            'interactions' => [],
            'metadata' => {}
          }.to_json
        }

        let(:base_url) { 'http://example.org' }
        let(:created_at) { Time.new(2014, 3, 4) }
        let(:updated_at) { Time.new(2014, 3, 5) }
        let(:pact) { double('pact', json_content: json_content, created_at: created_at, updated_at: updated_at, consumer: consumer, provider: provider, consumer_version: consumer_version)}
        let(:consumer) { instance_double(PactBroker::Models::Pacticipant, name: 'Consumer')}
        let(:provider) { instance_double(PactBroker::Models::Pacticipant, name: 'Provider')}
        let(:consumer_version) { instance_double(PactBroker::Models::Version, number: '1234')}

        subject { JSON.parse PactDecorator.new(pact).to_json(base_url: base_url), symbolize_names: true}

        describe "#to_json" do

          it "includes the json_content" do
            expect(subject[:consumer]).to eq name: 'Consumer'
          end

          it "includes the createdAt date" do
            expect(subject[:createdAt]).to eq created_at.xmlschema
          end

          it "includes a link to the webhooks for this pact" do
            expect(subject[:_links][:'pact-webhooks'][:href]).to eq "http://example.org/webhooks/provider/Provider/consumer/Consumer"
          end

          it "includes a link to the latest pact" do
            expect(subject[:_links][:'latest-pact'][:title]).to eq "Latest version of the pact between Consumer and Provider"
            expect(subject[:_links][:'latest-pact'][:href]).to eq "http://example.org/pacts/provider/Provider/consumer/Consumer/latest"
          end
        end

      end
    end
  end
end
{'fraction_non_alphanumeric': 0.13117206982543642, 'fraction_numerical': 0.00798004987531172, 'mean_word_length': 2.773283160865475, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2273365', 'n_tokens_mistral': 1241, 'n_tokens_neox': 1176, 'n_words': 261}