Sha256: e6cdb7e96edb289354129997c5d15b97db2e581556d9d2593f5b8c3f0b28b061

Contents?: true

Size: 1.07 KB

Versions: 36

Compression:

Stored size: 1.07 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.singleton }

  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
    expect(Puppet::Util::Package).to receive(:versioncmp).with('1.2', '1.3').and_return(-1)

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

Version data entries

36 entries across 36 versions & 1 rubygems

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