Sha256: 9f0d26327a0b38035a5b50439678c86233800dd9676b582ca293a509c0cbba08

Contents?: true

Size: 927 Bytes

Versions: 44

Compression:

Stored size: 927 Bytes

Contents

#! /usr/bin/env ruby
require 'spec_helper'

describe "the versioncmp function" do
  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

44 entries across 44 versions & 1 rubygems

Version Path
puppet-6.4.0 spec/unit/parser/functions/versioncmp_spec.rb
puppet-6.4.0-x86-mingw32 spec/unit/parser/functions/versioncmp_spec.rb
puppet-6.4.0-x64-mingw32 spec/unit/parser/functions/versioncmp_spec.rb
puppet-6.4.0-universal-darwin spec/unit/parser/functions/versioncmp_spec.rb
puppet-6.0.7 spec/unit/parser/functions/versioncmp_spec.rb
puppet-6.0.7-x86-mingw32 spec/unit/parser/functions/versioncmp_spec.rb
puppet-6.0.7-x64-mingw32 spec/unit/parser/functions/versioncmp_spec.rb
puppet-6.0.7-universal-darwin spec/unit/parser/functions/versioncmp_spec.rb
puppet-6.3.0 spec/unit/parser/functions/versioncmp_spec.rb
puppet-6.3.0-x86-mingw32 spec/unit/parser/functions/versioncmp_spec.rb
puppet-6.3.0-x64-mingw32 spec/unit/parser/functions/versioncmp_spec.rb
puppet-6.3.0-universal-darwin spec/unit/parser/functions/versioncmp_spec.rb
puppet-6.2.0 spec/unit/parser/functions/versioncmp_spec.rb
puppet-6.2.0-x86-mingw32 spec/unit/parser/functions/versioncmp_spec.rb
puppet-6.2.0-x64-mingw32 spec/unit/parser/functions/versioncmp_spec.rb
puppet-6.2.0-universal-darwin spec/unit/parser/functions/versioncmp_spec.rb
puppet-6.0.5 spec/unit/parser/functions/versioncmp_spec.rb
puppet-6.0.5-x86-mingw32 spec/unit/parser/functions/versioncmp_spec.rb
puppet-6.0.5-x64-mingw32 spec/unit/parser/functions/versioncmp_spec.rb
puppet-6.0.5-universal-darwin spec/unit/parser/functions/versioncmp_spec.rb