Sha256: 84260ac8119788c2adec7b77414609662e408f9489eb919bbcc0f6e6b7cf361e

Contents?: true

Size: 1001 Bytes

Versions: 14

Compression:

Stored size: 1001 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
    Puppet::Parser::Functions.function("versioncmp").should == "function_versioncmp"
  end

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

  it "should raise a ArgumentError if there is more than 2 arguments" do
    lambda { @scope.function_versioncmp(["1.2", "2.4.5", "3.5.6"]) }.should 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

14 entries across 14 versions & 2 rubygems

Version Path
puppet-3.2.4 spec/unit/parser/functions/versioncmp_spec.rb
puppet-3.2.3 spec/unit/parser/functions/versioncmp_spec.rb
puppet-3.2.3.rc1 spec/unit/parser/functions/versioncmp_spec.rb
puppet-3.2.2 spec/unit/parser/functions/versioncmp_spec.rb
puppet-3.2.1 spec/unit/parser/functions/versioncmp_spec.rb
puppet-3.2.1.rc1 spec/unit/parser/functions/versioncmp_spec.rb
puppet-3.2.0.rc2 spec/unit/parser/functions/versioncmp_spec.rb
librarian-puppet-0.9.9 vendor/gems/ruby/1.9.1/gems/puppet-3.1.0/spec/unit/parser/functions/versioncmp_spec.rb
puppet-3.2.0.rc1 spec/unit/parser/functions/versioncmp_spec.rb
puppet-3.1.1 spec/unit/parser/functions/versioncmp_spec.rb
librarian-puppet-0.9.8 vendor/gems/ruby/1.9.1/gems/puppet-3.1.0/spec/unit/parser/functions/versioncmp_spec.rb
puppet-3.1.0 spec/unit/parser/functions/versioncmp_spec.rb
puppet-3.1.0.rc2 spec/unit/parser/functions/versioncmp_spec.rb
puppet-3.1.0.rc1 spec/unit/parser/functions/versioncmp_spec.rb