Sha256: 8b66e4e5284530d4edb49a18a50f189a70381f7b3c78f77665695c4a223d5d7a

Contents?: true

Size: 1000 Bytes

Versions: 234

Compression:

Stored size: 1000 Bytes

Contents

#! /usr/bin/env ruby
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
    Puppet::Util::Package.expects(:versioncmp).with("1.2", "1.3").returns(-1)

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

end

Version data entries

234 entries across 234 versions & 1 rubygems

Version Path
puppet-5.5.12 spec/unit/parser/functions/versioncmp_spec.rb
puppet-5.5.12-x86-mingw32 spec/unit/parser/functions/versioncmp_spec.rb
puppet-5.5.12-x64-mingw32 spec/unit/parser/functions/versioncmp_spec.rb
puppet-5.5.12-universal-darwin spec/unit/parser/functions/versioncmp_spec.rb
puppet-5.5.10 spec/unit/parser/functions/versioncmp_spec.rb
puppet-5.5.10-x86-mingw32 spec/unit/parser/functions/versioncmp_spec.rb
puppet-5.5.10-x64-mingw32 spec/unit/parser/functions/versioncmp_spec.rb
puppet-5.5.10-universal-darwin spec/unit/parser/functions/versioncmp_spec.rb
puppet-5.5.8 spec/unit/parser/functions/versioncmp_spec.rb
puppet-5.5.8-x86-mingw32 spec/unit/parser/functions/versioncmp_spec.rb
puppet-5.5.8-x64-mingw32 spec/unit/parser/functions/versioncmp_spec.rb
puppet-5.5.8-universal-darwin spec/unit/parser/functions/versioncmp_spec.rb
puppet-5.5.7 spec/unit/parser/functions/versioncmp_spec.rb
puppet-5.5.7-x86-mingw32 spec/unit/parser/functions/versioncmp_spec.rb
puppet-5.5.7-x64-mingw32 spec/unit/parser/functions/versioncmp_spec.rb
puppet-5.5.7-universal-darwin spec/unit/parser/functions/versioncmp_spec.rb
puppet-5.5.6 spec/unit/parser/functions/versioncmp_spec.rb
puppet-5.5.6-x86-mingw32 spec/unit/parser/functions/versioncmp_spec.rb
puppet-5.5.6-x64-mingw32 spec/unit/parser/functions/versioncmp_spec.rb
puppet-5.5.6-universal-darwin spec/unit/parser/functions/versioncmp_spec.rb