Update stdlib and concat to 6.1.0 both
[mirror/dsa-puppet.git] / 3rdparty / modules / concat / spec / unit / type / concat_file_spec.rb
1 require 'spec_helper'
2
3 describe Puppet::Type.type(:concat_file) do
4   let(:resource) { described_class.new(name: '/foo/bar') }
5
6   describe 'key attributes' do
7     let(:subject) { described_class.key_attributes }
8
9     it 'contain only :path' do
10       is_expected.to eq([:path])
11     end
12   end
13
14   describe 'parameter :path' do
15     it 'does not accept unqualified paths' do
16       expect { resource[:path] = 'foo' }.to raise_error(
17         %r{File paths must be fully qualified},
18       )
19     end
20   end
21
22   describe 'parameter :owner' do
23     subject { described_class.attrclass(:owner) }
24
25     it 'inherits Puppet::Type::File::Owner' do
26       is_expected.to be < Puppet::Type::File::Owner
27     end
28   end
29
30   describe 'parameter :group' do
31     subject { described_class.attrclass(:group) }
32
33     it 'inherits Puppet::Type::File::Group' do
34       is_expected.to be < Puppet::Type::File::Group
35     end
36   end
37
38   describe 'parameter :mode' do
39     subject { described_class.attrclass(:mode) }
40
41     it 'inherits Puppet::Type::File::Mode' do
42       is_expected.to be < Puppet::Type::File::Mode
43     end
44   end
45
46   describe 'parameter :order' do
47     it 'accepts "alpha" as a value' do
48       resource[:order] = 'alpha'
49       expect(resource[:order]).to eq(:alpha)
50     end
51
52     it 'accepts "numeric" as a value' do
53       resource[:order] = 'numeric'
54       expect(resource[:order]).to eq(:numeric)
55     end
56
57     it 'does not accept "bar" as a value' do
58       expect { resource[:order] = 'bar' }.to raise_error(%r{Invalid value "bar"})
59     end
60   end
61
62   describe 'parameter :backup' do
63     it 'accepts true (TrueClass) as a value' do
64       resource[:backup] = true
65       expect(resource[:backup]).to eq(true)
66     end
67
68     it 'accepts false (FalseClass) as a value' do
69       resource[:backup] = false
70       expect(resource[:backup]).to eq(false)
71     end
72
73     it 'accepts "foo" as a value' do
74       resource[:backup] = 'foo'
75       expect(resource[:backup]).to eq('foo')
76     end
77   end
78
79   describe 'parameter :selrange' do
80     it_behaves_like 'a parameter that accepts only string values', :selrange
81   end
82
83   describe 'parameter :selrole' do
84     it_behaves_like 'a parameter that accepts only string values', :selrole
85   end
86
87   describe 'parameter :seltype' do
88     it_behaves_like 'a parameter that accepts only string values', :seltype
89   end
90
91   describe 'parameter :seluser' do
92     it_behaves_like 'a parameter that accepts only string values', :seluser
93   end
94
95   describe 'parameter :replace' do
96     it_behaves_like 'Puppet::Parameter::Boolean', :replace
97   end
98
99   describe 'parameter :ensure_newline' do
100     it_behaves_like 'Puppet::Parameter::Boolean', :ensure_newline
101   end
102
103   describe 'parameter :show_diff' do
104     it_behaves_like 'Puppet::Parameter::Boolean', :show_diff
105   end
106
107   describe 'parameter :selinux_ignore_defaults' do
108     it_behaves_like 'Puppet::Parameter::Boolean', :selinux_ignore_defaults
109   end
110
111   describe 'parameter :force' do
112     it_behaves_like 'Puppet::Parameter::Boolean', :force
113   end
114
115   describe 'parameter :format' do
116     it 'accepts "plain" as a value' do
117       resource[:format] = 'plain'
118       expect(resource[:format]).to eq(:plain)
119     end
120
121     it 'accepts "yaml" as a value' do
122       resource[:format] = 'yaml'
123       expect(resource[:format]).to eq(:yaml)
124     end
125
126     it 'accepts "json" as a value' do
127       resource[:format] = 'json'
128       expect(resource[:format]).to eq(:json)
129     end
130
131     it 'accepts "json-array" as a value' do
132       resource[:format] = 'json-array'
133       expect(resource[:format]).to eq(:'json-array')
134     end
135
136     it 'accepts "json-pretty" as a value' do
137       resource[:format] = 'json-pretty'
138       expect(resource[:format]).to eq(:'json-pretty')
139     end
140
141     it 'accepts "json-array-pretty" as a value' do
142       resource[:format] = 'json-array-pretty'
143       expect(resource[:format]).to eq(:'json-array-pretty')
144     end
145
146     it 'does not accept "bar" as a value' do
147       expect { resource[:format] = 'bar' }.to raise_error(%r{Invalid value "bar"})
148     end
149   end
150 end