Sha256: 77160b124ecaea2bdba22736d1088b9437e345edb081d204a4639ae7217291f2

Contents?: true

Size: 1.21 KB

Versions: 21

Compression:

Stored size: 1.21 KB

Contents

require 'spec_helper'
require 'pact_broker/api/decorators/latest_pact_decorator'

module PactBroker

  module Api

    module Decorators

      describe LatestPactDecorator do

        let(:pact) { RepresentablePact.new(ProviderStateBuilder.new.create_pact_with_hierarchy 'Consumer', '1.2.3', 'Provider') }
        let(:base_url) { 'http://example.org' }

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

        it "includes the createdAt date" do
          expect(subject[:createdAt]).to_not be_nil
        end

        context "when the updatedAt is the same as the createdAt" do
          it "does not include the updatedAt date" do
            expect(subject[:updatedAt]).to be_nil
          end
        end

        context "when the updatedAt is not the same as the createdAt" do
          let(:pact) do
            pact = ProviderStateBuilder.new.create_pact_with_hierarchy 'Consumer', '1.2.3', 'Provider'
            pact.updated_at = pact.created_at + 1
            RepresentablePact.new(pact)
          end

          it "includes the updatedAt date" do
            expect(subject[:updatedAt]).to_not be_nil
          end
        end

      end
    end
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
pact_broker-1.14.0 spec/lib/pact_broker/api/decorators/latest_pact_decorator_spec.rb
pact_broker-1.13.0 spec/lib/pact_broker/api/decorators/latest_pact_decorator_spec.rb
pact_broker-1.12.0 spec/lib/pact_broker/api/decorators/latest_pact_decorator_spec.rb
pact_broker-1.11.2 spec/lib/pact_broker/api/decorators/latest_pact_decorator_spec.rb
pact_broker-1.11.1 spec/lib/pact_broker/api/decorators/latest_pact_decorator_spec.rb
pact_broker-1.11.0 spec/lib/pact_broker/api/decorators/latest_pact_decorator_spec.rb
pact_broker-1.10.0 spec/lib/pact_broker/api/decorators/latest_pact_decorator_spec.rb
pact_broker-1.9.3 spec/lib/pact_broker/api/decorators/latest_pact_decorator_spec.rb
pact_broker-1.9.2 spec/lib/pact_broker/api/decorators/latest_pact_decorator_spec.rb
pact_broker-1.9.1 spec/lib/pact_broker/api/decorators/latest_pact_decorator_spec.rb
pact_broker-1.9.0 spec/lib/pact_broker/api/decorators/latest_pact_decorator_spec.rb
pact_broker-1.9.0.rc1 spec/lib/pact_broker/api/decorators/latest_pact_decorator_spec.rb
pact_broker-1.8.1 spec/lib/pact_broker/api/decorators/latest_pact_decorator_spec.rb
pact_broker-1.8.0 spec/lib/pact_broker/api/decorators/latest_pact_decorator_spec.rb
pact_broker-1.7.0 spec/lib/pact_broker/api/decorators/latest_pact_decorator_spec.rb
pact_broker-1.6.0 spec/lib/pact_broker/api/decorators/latest_pact_decorator_spec.rb
pact_broker-1.5.0 spec/lib/pact_broker/api/decorators/latest_pact_decorator_spec.rb
pact_broker-1.4.0 spec/lib/pact_broker/api/decorators/latest_pact_decorator_spec.rb
pact_broker-1.3.2.rc1 spec/lib/pact_broker/api/decorators/latest_pact_decorator_spec.rb
pact_broker-1.3.1 spec/lib/pact_broker/api/decorators/latest_pact_decorator_spec.rb