Sha256: feb2faa5adf814520265a2605a28016dbd5eb3ae1f7ef6ed31d973958b14318a

Contents?: true

Size: 1.15 KB

Versions: 6

Compression:

Stored size: 1.15 KB

Contents

require 'spec_helper'
require 'pact_broker/versions/parse_semantic_version'

module PactBroker
  module Versions
    describe ParseSemanticVersion do

      describe ".call" do
        context "when parsing a semantic version" do

          subject { ParseSemanticVersion.call("1.2.3") }

          it "returns the version" do
            expect(subject.major).to eq 1
            expect(subject.minor).to eq 2
            expect(subject.to_s).to eq "1.2.3"
          end

          it "returns a comparable version" do
            expect(subject).to be > ParseSemanticVersion.call("1.2.2")
            expect(subject).to be == ParseSemanticVersion.call("1.2.3")
            expect(subject).to be < ParseSemanticVersion.call("1.3.1")
          end

          it "returns nil when version is invalid" do
            expect(ParseSemanticVersion.call("abc")).to be_nil
            expect(ParseSemanticVersion.call("1")).to be_nil
            expect(ParseSemanticVersion.call("1.2")).to be_nil
          end

          it "accepts semver metadata" do
            expect(ParseSemanticVersion.call("1.2.3+abc.234")).not_to be_nil
          end
        end
      end

    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
pact_broker-2.0.0.beta.6 spec/lib/pact_broker/versions/parse_semantic_version_spec.rb
pact_broker-2.0.0.beta.5 spec/lib/pact_broker/versions/parse_semantic_version_spec.rb
pact_broker-2.0.0.beta.4 spec/lib/pact_broker/versions/parse_semantic_version_spec.rb
pact_broker-2.0.0.beta.3 spec/lib/pact_broker/versions/parse_semantic_version_spec.rb
pact_broker-2.0.0.beta.2 spec/lib/pact_broker/versions/parse_semantic_version_spec.rb
pact_broker-2.0.0.beta.1 spec/lib/pact_broker/versions/parse_semantic_version_spec.rb