Sha256: e8fef9ac97bd6016cdde7e2a29f3c60de988c822dff9b89bdb22817fd6dcb36d

Contents?: true

Size: 1.05 KB

Versions: 37

Compression:

Stored size: 1.05 KB

Contents

require 'spec_helper'
require 'puppet/pops'
require 'puppet/loaders'

describe "the versioncmp function" do

  before(:all) do
    loaders = Puppet::Pops::Loaders.new(Puppet::Node::Environment.create(:testing, []))
    Puppet.push_context({:loaders => loaders}, "test-examples")
  end

  after(:all) do
    Puppet::Pops::Loaders.clear
    Puppet::pop_context()
  end

  def versioncmp(*args)
    Puppet.lookup(:loaders).puppet_system_loader.load(:function, 'versioncmp').call({}, *args)
  end

  let(:type_parser) { Puppet::Pops::Types::TypeParser.new }

  it 'should raise an Error if there is less than 2 arguments' do
    expect { versioncmp('a,b') }.to raise_error(/expects 2 arguments, got 1/)
  end

  it 'should raise an Error if there is more than 2 arguments' do
    expect { versioncmp('a,b','foo', 'bar') }.to raise_error(/expects 2 arguments, got 3/)
  end

  it "should call Puppet::Util::Package.versioncmp (included in scope)" do
    Puppet::Util::Package.expects(:versioncmp).with('1.2', '1.3').returns(-1)

    expect(versioncmp('1.2', '1.3')).to eq -1
  end
end

Version data entries

37 entries across 37 versions & 1 rubygems

Version Path
puppet-4.5.3 spec/unit/functions/versioncmp_spec.rb
puppet-4.5.3-x86-mingw32 spec/unit/functions/versioncmp_spec.rb
puppet-4.5.3-x64-mingw32 spec/unit/functions/versioncmp_spec.rb
puppet-4.5.3-universal-darwin spec/unit/functions/versioncmp_spec.rb
puppet-4.5.2 spec/unit/functions/versioncmp_spec.rb
puppet-4.5.2-x86-mingw32 spec/unit/functions/versioncmp_spec.rb
puppet-4.5.2-x64-mingw32 spec/unit/functions/versioncmp_spec.rb
puppet-4.5.2-universal-darwin spec/unit/functions/versioncmp_spec.rb
puppet-4.5.1 spec/unit/functions/versioncmp_spec.rb
puppet-4.5.1-x86-mingw32 spec/unit/functions/versioncmp_spec.rb
puppet-4.5.1-x64-mingw32 spec/unit/functions/versioncmp_spec.rb
puppet-4.5.1-universal-darwin spec/unit/functions/versioncmp_spec.rb
puppet-4.5.0 spec/unit/functions/versioncmp_spec.rb
puppet-4.5.0-x86-mingw32 spec/unit/functions/versioncmp_spec.rb
puppet-4.5.0-x64-mingw32 spec/unit/functions/versioncmp_spec.rb
puppet-4.5.0-universal-darwin spec/unit/functions/versioncmp_spec.rb
puppet-4.4.2 spec/unit/functions/versioncmp_spec.rb
puppet-4.4.2-x86-mingw32 spec/unit/functions/versioncmp_spec.rb
puppet-4.4.2-x64-mingw32 spec/unit/functions/versioncmp_spec.rb
puppet-4.4.2-universal-darwin spec/unit/functions/versioncmp_spec.rb