summaryrefslogtreecommitdiffstats
path: root/spec/integration/application/puppet.rb
blob: 0047dd5a3ec5ea2ec1aaa1e67f99b6274b408efc (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
#!/usr/bin/env ruby

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

require 'puppet_spec/files'

require 'puppet/application/puppet'

describe "Puppet" do
    include PuppetSpec::Files

    it "should be able to apply catalogs provided in a file in json" do
        file_to_create = tmpfile("json_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_json }

        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