Sha256: fee6058babcfc73355e34d0d5f7ed951136dd6006263198556122c1872a5606e

Contents?: true

Size: 1.19 KB

Versions: 36

Compression:

Stored size: 1.19 KB

Contents

require 'spec_helper'

describe "the 'tagged' 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(:tagged)).to eq("function_tagged")
  end

  it 'is not available when --tasks is on' do
    Puppet[:tasks] = true
    expect do
      @scope.function_tagged(['one', 'two'])
    end.to raise_error(Puppet::ParseError, /is only available when compiling a catalog/)
  end

  it 'should be case-insensitive' do
    resource = Puppet::Parser::Resource.new(:file, "/file", :scope => @scope)
    allow(@scope).to receive(:resource).and_return(resource)
    @scope.function_tag ["one"]

    expect(@scope.function_tagged(['One'])).to eq(true)
  end

  it 'should check if all specified tags are included' do
    resource = Puppet::Parser::Resource.new(:file, "/file", :scope => @scope)
    allow(@scope).to receive(:resource).and_return(resource)
    @scope.function_tag ["one"]

    expect(@scope.function_tagged(['one', 'two'])).to eq(false)
  end
end

Version data entries

36 entries across 36 versions & 1 rubygems

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