summaryrefslogtreecommitdiffstats
path: root/spec/integration/application/puppet.rb
blob: 1342f3c5fe1e41458d63e64c4834d6ffcba59eb0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/usr/bin/env ruby

require File.dirname(__FILE__) + '/../../spec_helper'

require 'puppet_spec/files'

require 'puppet/application/puppet'

describe "Puppet" do
    include PuppetSpec::Files

    describe "when applying provided catalogs" do
        confine "PSON library is missing; cannot test applying catalogs" => Puppet.features.pson?
        it "should be able to apply catalogs provided in a file in pson" do
            file_to_create = tmpfile("pson_catalog")
            catalog = Puppet::Resource::Catalog.new
            resource = Puppet::Resource.new(:file, file_to_create, :content => "my stuff")
            catalog.add_resource resource

            manifest = tmpfile("manifest")

            File.open(manifest, "w") { |f| f.print catalog.to_pson }

            puppet = Puppet::Application[:puppet]
            puppet.options[:catalog] = manifest

            puppet.apply

            File.should be_exist(file_to_create)
            File.read(file_to_create).should == "my stuff"
        end
    end
end