Sha256: c6c34d1abf9e5d672122b97d06fb80990229aadefb52aca2f7a2d7fa7a8312a3

Contents?: true

Size: 1.52 KB

Versions: 233

Compression:

Stored size: 1.52 KB

Contents

require 'spec_helper'
require 'matchers/resource'
require 'puppet_spec/compiler'

describe "the realize function" do
  include Matchers::Resource
  include PuppetSpec::Compiler

  it "realizes a single, referenced resource" do
    catalog = compile_to_catalog(<<-EOM)
      @notify { testing: }
      realize(Notify[testing])
    EOM

    expect(catalog).to have_resource("Notify[testing]")
  end

  it "realizes multiple resources" do
    catalog = compile_to_catalog(<<-EOM)
      @notify { testing: }
      @notify { other: }
      realize(Notify[testing], Notify[other])
    EOM

    expect(catalog).to have_resource("Notify[testing]")
    expect(catalog).to have_resource("Notify[other]")
  end

  it "realizes resources provided in arrays" do
    catalog = compile_to_catalog(<<-EOM)
      @notify { testing: }
      @notify { other: }
      realize([Notify[testing], [Notify[other]]])
    EOM

    expect(catalog).to have_resource("Notify[testing]")
    expect(catalog).to have_resource("Notify[other]")
  end

  it "fails when the resource does not exist" do
    expect do
      compile_to_catalog(<<-EOM)
        realize(Notify[missing])
      EOM
    end.to raise_error(Puppet::Error, /Failed to realize/)
  end

  it "fails when no parameters given" do
    expect do
      compile_to_catalog(<<-EOM)
        realize()
      EOM
    end.to raise_error(Puppet::Error, /Wrong number of arguments/)
  end

  it "silently does nothing when an empty array of resources is given" do
    compile_to_catalog(<<-EOM)
      realize([])
    EOM
  end
end

Version data entries

233 entries across 233 versions & 1 rubygems

Version Path
puppet-5.3.7 spec/unit/parser/functions/realize_spec.rb
puppet-5.3.7-x86-mingw32 spec/unit/parser/functions/realize_spec.rb
puppet-5.3.7-x64-mingw32 spec/unit/parser/functions/realize_spec.rb
puppet-5.3.7-universal-darwin spec/unit/parser/functions/realize_spec.rb
puppet-4.10.12 spec/unit/parser/functions/realize_spec.rb
puppet-4.10.12-x86-mingw32 spec/unit/parser/functions/realize_spec.rb
puppet-4.10.12-x64-mingw32 spec/unit/parser/functions/realize_spec.rb
puppet-4.10.12-universal-darwin spec/unit/parser/functions/realize_spec.rb
puppet-4.10.11 spec/unit/parser/functions/realize_spec.rb
puppet-4.10.11-x86-mingw32 spec/unit/parser/functions/realize_spec.rb
puppet-4.10.11-x64-mingw32 spec/unit/parser/functions/realize_spec.rb
puppet-4.10.11-universal-darwin spec/unit/parser/functions/realize_spec.rb
puppet-5.3.6 spec/unit/parser/functions/realize_spec.rb
puppet-5.3.6-x86-mingw32 spec/unit/parser/functions/realize_spec.rb
puppet-5.3.6-x64-mingw32 spec/unit/parser/functions/realize_spec.rb
puppet-5.3.6-universal-darwin spec/unit/parser/functions/realize_spec.rb
puppet-5.3.5 spec/unit/parser/functions/realize_spec.rb
puppet-5.3.5-x86-mingw32 spec/unit/parser/functions/realize_spec.rb
puppet-5.3.5-x64-mingw32 spec/unit/parser/functions/realize_spec.rb
puppet-5.3.5-universal-darwin spec/unit/parser/functions/realize_spec.rb