Sha256: 7f82df684db8dbe14a659e0aa64a732bf680ae83219693aea9886b295d448735

Contents?: true

Size: 993 Bytes

Versions: 36

Compression:

Stored size: 993 Bytes

Contents

require 'spec_helper'

describe "the versioncmp function" do
  before :all do
    Puppet::Parser::Functions.autoloader.loadall
  end

  before :each do
    node     = Puppet::Node.new('localhost')
    compiler = Puppet::Parser::Compiler.new(node)
    @scope   = Puppet::Parser::Scope.new(compiler)
  end

  it "should exist" do
    expect(Puppet::Parser::Functions.function("versioncmp")).to eq("function_versioncmp")
  end

  it "should raise an ArgumentError if there is less than 2 arguments" do
    expect { @scope.function_versioncmp(["1.2"]) }.to raise_error(ArgumentError)
  end

  it "should raise an ArgumentError if there is more than 2 arguments" do
    expect { @scope.function_versioncmp(["1.2", "2.4.5", "3.5.6"]) }.to raise_error(ArgumentError)
  end

  it "should call Puppet::Util::Package.versioncmp (included in scope)" do
    expect(Puppet::Util::Package).to receive(:versioncmp).with("1.2", "1.3").and_return(-1)

    @scope.function_versioncmp(["1.2", "1.3"])
  end

end

Version data entries

36 entries across 36 versions & 1 rubygems

Version Path
puppet-5.5.22 spec/unit/parser/functions/versioncmp_spec.rb
puppet-5.5.22-x86-mingw32 spec/unit/parser/functions/versioncmp_spec.rb
puppet-5.5.22-x64-mingw32 spec/unit/parser/functions/versioncmp_spec.rb
puppet-5.5.22-universal-darwin spec/unit/parser/functions/versioncmp_spec.rb
puppet-5.5.21 spec/unit/parser/functions/versioncmp_spec.rb
puppet-5.5.21-x86-mingw32 spec/unit/parser/functions/versioncmp_spec.rb
puppet-5.5.21-x64-mingw32 spec/unit/parser/functions/versioncmp_spec.rb
puppet-5.5.21-universal-darwin spec/unit/parser/functions/versioncmp_spec.rb
puppet-5.5.20 spec/unit/parser/functions/versioncmp_spec.rb
puppet-5.5.20-x86-mingw32 spec/unit/parser/functions/versioncmp_spec.rb
puppet-5.5.20-x64-mingw32 spec/unit/parser/functions/versioncmp_spec.rb
puppet-5.5.20-universal-darwin spec/unit/parser/functions/versioncmp_spec.rb
puppet-5.5.19 spec/unit/parser/functions/versioncmp_spec.rb
puppet-5.5.19-x86-mingw32 spec/unit/parser/functions/versioncmp_spec.rb
puppet-5.5.19-x64-mingw32 spec/unit/parser/functions/versioncmp_spec.rb
puppet-5.5.19-universal-darwin spec/unit/parser/functions/versioncmp_spec.rb
puppet-5.5.18 spec/unit/parser/functions/versioncmp_spec.rb
puppet-5.5.18-x86-mingw32 spec/unit/parser/functions/versioncmp_spec.rb
puppet-5.5.18-x64-mingw32 spec/unit/parser/functions/versioncmp_spec.rb
puppet-5.5.18-universal-darwin spec/unit/parser/functions/versioncmp_spec.rb