Sha256: 3f2e09176e479639c18dc627d2bbe969c86f41bc94153202a197151b191f075c

Contents?: true

Size: 1.45 KB

Versions: 58

Compression:

Stored size: 1.45 KB

Contents

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

describe "The require function" do
  before :each do
    @node = Puppet::Node.new("mynode")
    @compiler = Puppet::Parser::Compiler.new(@node)

    @compiler.send(:evaluate_main)
    @compiler.catalog.client_version = "0.25"
    @scope = @compiler.topscope
    # preload our functions
    Puppet::Parser::Functions.function(:include)
    Puppet::Parser::Functions.function(:require)
  end

  it "should add a dependency between the 'required' class and our class" do
    @compiler.known_resource_types.add Puppet::Resource::Type.new(:hostclass, "requiredclass")

    @scope.function_require(["requiredclass"])
    expect(@scope.resource["require"]).not_to be_nil
    ref = @scope.resource["require"].shift
    expect(ref.type).to eq("Class")
    expect(ref.title).to eq("Requiredclass")
  end

  it "should queue relationships between the 'required' class and our classes" do
    @compiler.known_resource_types.add Puppet::Resource::Type.new(:hostclass, "requiredclass1")
    @compiler.known_resource_types.add Puppet::Resource::Type.new(:hostclass, "requiredclass2")

    @scope.function_require(["requiredclass1"])
    @scope.function_require(["requiredclass2"])

    expect(@scope.resource["require"]).not_to be_nil

    (ref1,ref2) = @scope.resource["require"]
    expect(ref1.type).to eq("Class")
    expect(ref1.title).to eq("Requiredclass1")
    expect(ref2.type).to eq("Class")
    expect(ref2.title).to eq("Requiredclass2")
  end

end

Version data entries

58 entries across 58 versions & 1 rubygems

Version Path
puppet-4.4.1 spec/integration/parser/functions/require_spec.rb
puppet-4.4.1-x86-mingw32 spec/integration/parser/functions/require_spec.rb
puppet-4.4.1-x64-mingw32 spec/integration/parser/functions/require_spec.rb
puppet-4.4.1-universal-darwin spec/integration/parser/functions/require_spec.rb
puppet-4.4.0 spec/integration/parser/functions/require_spec.rb
puppet-4.4.0-x86-mingw32 spec/integration/parser/functions/require_spec.rb
puppet-4.4.0-x64-mingw32 spec/integration/parser/functions/require_spec.rb
puppet-4.4.0-universal-darwin spec/integration/parser/functions/require_spec.rb
puppet-4.3.2 spec/integration/parser/functions/require_spec.rb
puppet-4.3.2-x86-mingw32 spec/integration/parser/functions/require_spec.rb
puppet-4.3.2-x64-mingw32 spec/integration/parser/functions/require_spec.rb
puppet-4.3.1 spec/integration/parser/functions/require_spec.rb
puppet-4.3.1-x86-mingw32 spec/integration/parser/functions/require_spec.rb
puppet-4.3.1-x64-mingw32 spec/integration/parser/functions/require_spec.rb
puppet-4.3.0 spec/integration/parser/functions/require_spec.rb
puppet-4.3.0-x86-mingw32 spec/integration/parser/functions/require_spec.rb
puppet-4.3.0-x64-mingw32 spec/integration/parser/functions/require_spec.rb
puppet-4.2.3 spec/integration/parser/functions/require_spec.rb
puppet-4.2.3-x86-mingw32 spec/integration/parser/functions/require_spec.rb
puppet-4.2.3-x64-mingw32 spec/integration/parser/functions/require_spec.rb