Sha256: f10e7994a98059a9a82922ebc681382b6515c2190cb7525858a2b55e9bdfe728

Contents?: true

Size: 1.58 KB

Versions: 18

Compression:

Stored size: 1.58 KB

Contents

require 'spec_helper'
require 'pact_broker/api/decorators/version_decorator'

module PactBroker
  module Api
    module Decorators
      describe VersionDecorator do

        let(:version) do
          ProviderStateBuilder.new
            .create_consumer("Consumer")
            .create_consumer_version("1.2.3")
            .create_consumer_version_tag("prod")
          PactBroker::Repositories::VersionRepository.new.find_by_pacticipant_name_and_number "Consumer", "1.2.3"
        end

        let(:options) { {base_url: 'http://example.org' }}

        subject { JSON.parse VersionDecorator.new(version).to_json(options), symbolize_names: true }

        it "includes a link to itself" do
          expect(subject[:_links][:self][:href]).to eq "http://example.org/pacticipants/Consumer/versions/1.2.3"
        end

        it "includes the version number in the link" do
          expect(subject[:_links][:self][:name]).to eq "1.2.3"
        end

        it "includes its title in the link" do
          expect(subject[:_links][:self][:title]).to eq "Version"
        end

        it "includes the version number" do
          expect(subject[:number]).to eq "1.2.3"
        end

        it "includes a link to the pacticipant" do
          expect(subject[:_links][:pacticipant]).to eq title: "Pacticipant", name: "Consumer", href: "http://example.org/pacticipants/Consumer"
        end

        it "includes a list of the tags" do
          expect(subject[:_embedded][:tags]).to be_instance_of(Array)
          expect(subject[:_embedded][:tags].first[:name]).to eq "prod"
        end

      end
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

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