Sha256: b3b4d46ae47cae20508e1eeda27a786f0ed430cb581885f62d9e927381161853

Contents?: true

Size: 1.33 KB

Versions: 33

Compression:

Stored size: 1.33 KB

Contents

require 'pact_broker/client/matrix/abbreviate_version_number'

module PactBroker
  module Client
    describe Matrix::AbbreviateVersionNumber do
      describe '.call' do
        subject(:result) { described_class.call(version) }

        context 'when version is nil' do
          let(:version) { nil }
          it { is_expected.to be_nil }
        end

        context 'when version is git sha' do
          let(:version) { '182f9c6e4d7a5779c4507cb8b3e505ac927d0394' }
          it { is_expected.to eq('182f9c6...') }
        end

        context 'when version is too long' do
          let(:version) { '182f9c6e4d7a5779c4507cb8b3e505ac927d0394' * 2 }
          it { is_expected.to eq(version[0...60] + '...') }
        end

        context 'when the version is something unknown and fits max length' do
          let(:version) { '123' }
          it { is_expected.to eq('123') }
        end

        context 'when version is embedded into semantic version v1' do
          let(:version) { 'v1.3.4+182f9c6e4d7a5779c4507cb8b3e505ac927d0394' }
          it { is_expected.to eq('v1.3.4+182f9c6...') }
        end

        context 'when version is embedded into semantic version v2' do
          let(:version) { '1.3.4(182f9c6e4d7a5779c4507cb8b3e505ac927d0394)' }
          it { is_expected.to eq('1.3.4(182f9c6...)') }
        end
      end
    end
  end
end

Version data entries

33 entries across 33 versions & 1 rubygems

Version Path
pact_broker-client-1.75.3 spec/lib/pact_broker/client/matrix/abbreviate_version_number_spec.rb
pact_broker-client-1.75.1 spec/lib/pact_broker/client/matrix/abbreviate_version_number_spec.rb
pact_broker-client-1.75.0 spec/lib/pact_broker/client/matrix/abbreviate_version_number_spec.rb
pact_broker-client-1.74.0 spec/lib/pact_broker/client/matrix/abbreviate_version_number_spec.rb
pact_broker-client-1.73.0 spec/lib/pact_broker/client/matrix/abbreviate_version_number_spec.rb
pact_broker-client-1.72.0 spec/lib/pact_broker/client/matrix/abbreviate_version_number_spec.rb
pact_broker-client-1.71.0 spec/lib/pact_broker/client/matrix/abbreviate_version_number_spec.rb
pact_broker-client-1.70.0 spec/lib/pact_broker/client/matrix/abbreviate_version_number_spec.rb
pact_broker-client-1.69.0 spec/lib/pact_broker/client/matrix/abbreviate_version_number_spec.rb
pact_broker-client-1.68.0 spec/lib/pact_broker/client/matrix/abbreviate_version_number_spec.rb
pact_broker-client-1.67.0 spec/lib/pact_broker/client/matrix/abbreviate_version_number_spec.rb
pact_broker-client-1.66.1 spec/lib/pact_broker/client/matrix/abbreviate_version_number_spec.rb
pact_broker-client-1.66.0 spec/lib/pact_broker/client/matrix/abbreviate_version_number_spec.rb
pact_broker-client-1.65.0 spec/lib/pact_broker/client/matrix/abbreviate_version_number_spec.rb
pact_broker-client-1.64.0 spec/lib/pact_broker/client/matrix/abbreviate_version_number_spec.rb
pact_broker-client-1.63.0 spec/lib/pact_broker/client/matrix/abbreviate_version_number_spec.rb
pact_broker-client-1.62.1 spec/lib/pact_broker/client/matrix/abbreviate_version_number_spec.rb
pact_broker-client-1.62.0 spec/lib/pact_broker/client/matrix/abbreviate_version_number_spec.rb
pact_broker-client-1.61.1 spec/lib/pact_broker/client/matrix/abbreviate_version_number_spec.rb
pact_broker-client-1.61.0 spec/lib/pact_broker/client/matrix/abbreviate_version_number_spec.rb