|
4 | 4 |
|
5 | 5 | describe 'ini_setting resource' do |
6 | 6 | after :all do |
7 | | - shell("rm #{tmpdir}/*.ini", :acceptable_exit_codes => [0,1,2]) |
| 7 | + shell("rm #{tmpdir}/*.ini", :acceptable_exit_codes => [0, 1, 2]) |
8 | 8 | end |
9 | 9 |
|
10 | | - shared_examples 'has_content' do |path,pp,content| |
| 10 | + shared_examples 'has_content' do |path, pp, content| |
11 | 11 | before :all do |
12 | | - shell("rm #{path}", :acceptable_exit_codes => [0,1,2]) |
| 12 | + shell("rm #{path}", :acceptable_exit_codes => [0, 1, 2]) |
13 | 13 | end |
14 | 14 | after :all do |
15 | | - shell("cat #{path}", :acceptable_exit_codes => [0,1,2]) |
16 | | - shell("rm #{path}", :acceptable_exit_codes => [0,1,2]) |
| 15 | + shell("cat #{path}", :acceptable_exit_codes => [0, 1, 2]) |
| 16 | + shell("rm #{path}", :acceptable_exit_codes => [0, 1, 2]) |
17 | 17 | end |
18 | 18 |
|
19 | 19 | it 'applies the manifest twice' do |
|
23 | 23 |
|
24 | 24 | describe file(path) do |
25 | 25 | it { should be_file } |
26 | | - #XXX Solaris 10 doesn't support multi-line grep |
27 | | - it("should contain #{content}", :unless => fact('osfamily') == 'Solaris') { |
28 | | - should contain(content) |
29 | | - } |
| 26 | + its(:content) { should match content } |
30 | 27 | end |
31 | 28 | end |
32 | 29 |
|
33 | | - shared_examples 'has_error' do |path,pp,error| |
| 30 | + shared_examples 'has_error' do |path, pp, error| |
34 | 31 | before :all do |
35 | | - shell("rm #{path}", :acceptable_exit_codes => [0,1,2]) |
| 32 | + shell("rm #{path}", :acceptable_exit_codes => [0, 1, 2]) |
36 | 33 | end |
37 | 34 | after :all do |
38 | | - shell("cat #{path}", :acceptable_exit_codes => [0,1,2]) |
39 | | - shell("rm #{path}", :acceptable_exit_codes => [0,1,2]) |
| 35 | + shell("cat #{path}", :acceptable_exit_codes => [0, 1, 2]) |
| 36 | + shell("rm #{path}", :acceptable_exit_codes => [0, 1, 2]) |
40 | 37 | end |
41 | 38 |
|
42 | 39 | it 'applies the manifest and gets a failure message' do |
|
72 | 69 | apply_manifest(pp, :catch_changes => true) |
73 | 70 | end |
74 | 71 |
|
75 | | - it_behaves_like 'has_content', "#{tmpdir}/ini_setting.ini", pp, "four = five\n[one]\ntwo = three" |
| 72 | + it_behaves_like 'has_content', "#{tmpdir}/ini_setting.ini", pp, /four = five\n\n\[one\]\ntwo = three/ |
76 | 73 | end |
77 | 74 |
|
78 | 75 | context '=> absent for key/value' do |
79 | 76 | before :all do |
80 | 77 | if fact('osfamily') == 'Darwin' |
81 | | - shell("echo \"four = five\n[one]\ntwo = three\" > #{tmpdir}/ini_setting.ini") |
| 78 | + shell("echo \"four = five[one]\ntwo = three\" > #{tmpdir}/ini_setting.ini") |
82 | 79 | else |
83 | 80 | shell("echo -e \"four = five\n[one]\ntwo = three\" > #{tmpdir}/ini_setting.ini") |
84 | 81 | end |
|
96 | 93 |
|
97 | 94 | it 'applies the manifest twice' do |
98 | 95 | apply_manifest(pp, :catch_failures => true) |
99 | | - apply_manifest(pp, :catch_changes => true) |
| 96 | + apply_manifest(pp, :catch_changes => true) |
100 | 97 | end |
101 | 98 |
|
102 | 99 | describe file("#{tmpdir}/ini_setting.ini") do |
103 | 100 | it { should be_file } |
104 | | - it { should contain('four = five') } |
105 | | - it { should contain('[one]') } |
106 | | - it { should_not contain('two = three') } |
| 101 | + its(:content) { |
| 102 | + should match /four = five/ |
| 103 | + should match /\[one\]/ |
| 104 | + should_not match /two = three/ |
| 105 | + } |
107 | 106 | end |
108 | 107 | end |
109 | 108 |
|
|
116 | 115 | end |
117 | 116 | end |
118 | 117 | after :all do |
119 | | - shell("cat #{tmpdir}/ini_setting.ini", :acceptable_exit_codes => [0,1,2]) |
120 | | - shell("rm #{tmpdir}/ini_setting.ini", :acceptable_exit_codes => [0,1,2]) |
| 118 | + shell("cat #{tmpdir}/ini_setting.ini", :acceptable_exit_codes => [0, 1, 2]) |
| 119 | + shell("rm #{tmpdir}/ini_setting.ini", :acceptable_exit_codes => [0, 1, 2]) |
121 | 120 | end |
122 | 121 |
|
123 | 122 | pp = <<-EOS |
|
132 | 131 |
|
133 | 132 | it 'applies the manifest twice' do |
134 | 133 | apply_manifest(pp, :catch_failures => true) |
135 | | - apply_manifest(pp, :catch_changes => true) |
| 134 | + apply_manifest(pp, :catch_changes => true) |
136 | 135 | end |
137 | 136 |
|
138 | 137 | describe file("#{tmpdir}/ini_setting.ini") do |
139 | 138 | it { should be_file } |
140 | | - it { should_not contain('four = five') } |
141 | | - it { should contain('[one]') } |
142 | | - it { should contain('two = three') } |
| 139 | + its(:content) { |
| 140 | + should_not match /four = five/ |
| 141 | + should match /\[one\]/ |
| 142 | + should match /two = three/ |
| 143 | + } |
143 | 144 | end |
144 | 145 | end |
145 | 146 | end |
146 | 147 |
|
147 | 148 | describe 'section, setting, value parameters' do |
148 | 149 | { |
149 | | - "section => 'test', setting => 'foo', value => 'bar'," => "[test]\nfoo = bar", |
150 | | - "section => 'more', setting => 'baz', value => 'quux'," => "[more]\nbaz = quux", |
151 | | - "section => '', setting => 'top', value => 'level'," => "top = level", |
| 150 | + "section => 'test', setting => 'foo', value => 'bar'," => /\[test\]\nfoo = bar/, |
| 151 | + "section => 'more', setting => 'baz', value => 'quux'," => /\[more\]\nbaz = quux/, |
| 152 | + "section => '', setting => 'top', value => 'level'," => /top = level/, |
152 | 153 | }.each do |parameter_list, content| |
153 | 154 | context parameter_list do |
154 | 155 | pp = <<-EOS |
|
164 | 165 | end |
165 | 166 |
|
166 | 167 | { |
167 | | - "section => 'test'," => /setting is a required.+value is a required/, |
168 | | - "setting => 'foo', value => 'bar'," => /section is a required/, |
169 | | - "section => 'test', setting => 'foo'," => /value is a required/, |
170 | | - "section => 'test', value => 'bar'," => /setting is a required/, |
171 | | - "value => 'bar'," => /section is a required.+setting is a required/, |
172 | | - "setting => 'foo'," => /section is a required.+value is a required/, |
| 168 | + "section => 'test'," => /setting is a required.+value is a required/, |
| 169 | + "setting => 'foo', value => 'bar'," => /section is a required/, |
| 170 | + "section => 'test', setting => 'foo'," => /value is a required/, |
| 171 | + "section => 'test', value => 'bar'," => /setting is a required/, |
| 172 | + "value => 'bar'," => /section is a required.+setting is a required/, |
| 173 | + "setting => 'foo'," => /section is a required.+value is a required/, |
173 | 174 | }.each do |parameter_list, error| |
174 | 175 | context parameter_list, :pending => 'no error checking yet' do |
175 | 176 | pp = <<-EOS |
|
187 | 188 |
|
188 | 189 | describe 'path parameter' do |
189 | 190 | [ |
190 | | - "#{tmpdir}/one.ini", |
191 | | - "#{tmpdir}/two.ini", |
192 | | - "#{tmpdir}/three.ini", |
| 191 | + "#{tmpdir}/one.ini", |
| 192 | + "#{tmpdir}/two.ini", |
| 193 | + "#{tmpdir}/three.ini", |
193 | 194 | ].each do |path| |
194 | 195 | context "path => #{path}" do |
195 | 196 | pp = <<-EOS |
|
202 | 203 | } |
203 | 204 | EOS |
204 | 205 |
|
205 | | - it_behaves_like 'has_content', path, pp, "[one]\ntwo = three" |
| 206 | + it_behaves_like 'has_content', path, pp, /\[one\]\ntwo = three/ |
206 | 207 | end |
207 | 208 | end |
208 | 209 |
|
|
223 | 224 |
|
224 | 225 | describe 'key_val_separator parameter' do |
225 | 226 | { |
226 | | - "" => "two = three", |
227 | | - "key_val_separator => '='," => "two=three", |
228 | | - "key_val_separator => ' = '," => "two = three", |
| 227 | + "" => /two = three/, |
| 228 | + "key_val_separator => '='," => /two=three/, |
| 229 | + "key_val_separator => ' = '," => /two = three/, |
229 | 230 | }.each do |parameter, content| |
230 | 231 | context "with \"#{parameter}\" makes \"#{content}\"" do |
231 | 232 | pp = <<-EOS |
|
0 commit comments