Sha256: 72597896b1f761b78fe1ffde898df6dea46089aed8d3d612dd315baf4f496947

Contents?: true

Size: 1.04 KB

Versions: 3

Compression:

Stored size: 1.04 KB

Contents

require 'rspec'
require_relative '../comparator/version'

def expectBigger(smaller, bigger)
  expect(smaller <=> bigger).to eql(-1)
  expect(bigger <=> smaller).to eql(1)
  expect(smaller <=> smaller).to eql(0)
  expect(bigger <=> bigger).to eql(0)
end

describe 'Version' do
  it 'initializes with version string' do
    version = Version.new("1.1.2")
    expect(version.major).to eql(1)
    expect(version.minor).to eql(1)
    expect(version.patch).to eql(2)
  end

  it 'compares' do
    version1 = Version.new("1.1.2")
    version2 = Version.new("1.1.3")
    version3 = Version.new("1.2.1")
    version4 = Version.new("1.2.3")
    version5 = Version.new("4.1.1")
    version6 = Version.new("4.2.1")

    expectBigger(version1, version2)
    expectBigger(version2, version3)
    expectBigger(version3, version4)
    expectBigger(version4, version5)
    expectBigger(version5, version6)
    expectBigger(version2, version6)
  end

  it 'does not compare with strings' do
    version1 = Version.new("1.1.2")
    expect(version1 <=> "hello").to eql(nil)
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
build_promotion_tool-0.1.3 lib/build_promotion_tool/spec/version_spec.rb
build_promotion_tool-0.1.2 lib/build_promotion_tool/spec/version_spec.rb
build_promotion_tool-0.1.1 lib/build_promotion_tool/spec/version_spec.rb