Sha256: 037763e0b4b2d01a1efc97829544e1bd0f6e3bf05c744cea7af28c159d5e96e4

Contents?: true

Size: 1.23 KB

Versions: 7

Compression:

Stored size: 1.23 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(user_options: { 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

7 entries across 7 versions & 1 rubygems

Version Path
pact_broker-1.18.0 spec/lib/pact_broker/api/decorators/latest_pact_decorator_spec.rb
pact_broker-1.18.0.beta.1 spec/lib/pact_broker/api/decorators/latest_pact_decorator_spec.rb
pact_broker-1.17.2 spec/lib/pact_broker/api/decorators/latest_pact_decorator_spec.rb
pact_broker-1.17.1 spec/lib/pact_broker/api/decorators/latest_pact_decorator_spec.rb
pact_broker-1.17.0 spec/lib/pact_broker/api/decorators/latest_pact_decorator_spec.rb
pact_broker-1.16.0 spec/lib/pact_broker/api/decorators/latest_pact_decorator_spec.rb
pact_broker-1.15.0 spec/lib/pact_broker/api/decorators/latest_pact_decorator_spec.rb