Skip to content

Commit 55a5160

Browse files
committed
Update inifile to 606de69
606de69 Merge pull request redhat-openstack#147 from cyberious/SpecinfraUpgrade 4dfb8e1 Force acceptance test ordering with require and before 8867610 Merge pull request redhat-openstack#146 from cyberious/SpecinfraUpgrade 8e2689b Fixes issues due to serverspec upgrade and usage of obsolete should contain method for files 03417e5 Merge pull request redhat-openstack#144 from cmurphy/rspec f84f058 Pin rspec gems Signed-off-by: Gael Chamoulaud <gchamoul@redhat.com>
1 parent e2d0692 commit 55a5160

File tree

5 files changed

+97
-88
lines changed

5 files changed

+97
-88
lines changed

Puppetfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ mod 'horizon',
5959
:git => 'https://github.com/stackforge/puppet-horizon.git'
6060

6161
mod 'inifile',
62-
:commit => 'be5fc47f00466a2e6293145b3a0d4fcb586bcf15',
62+
:commit => '606de6971d019fa9557d0866e90942a3d6e06a97',
6363
:git => 'https://github.com/puppetlabs/puppetlabs-inifile.git'
6464

6565
mod 'ipa',

inifile/Gemfile

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,25 @@ end
1212

1313
group :development, :unit_tests do
1414
gem 'rake', :require => false
15-
gem 'rspec-puppet', :require => false
15+
gem 'rspec-core', '3.1.7', :require => false
16+
gem 'rspec-puppet', '~> 1.0', :require => false
1617
gem 'puppetlabs_spec_helper', :require => false
1718
gem 'puppet-lint', :require => false
1819
gem 'simplecov', :require => false
1920
gem 'puppet_facts', :require => false
2021
gem 'json', :require => false
22+
gem 'pry', :require => false
2123
end
2224

25+
beaker_version = ENV['BEAKER_VERSION']
2326
beaker_rspec_version = ENV['BEAKER_RSPEC_VERSION']
2427
group :system_tests do
28+
if beaker_version
29+
gem 'beaker', *location_for(beaker_version)
30+
end
2531
if beaker_rspec_version
2632
gem 'beaker-rspec', *location_for(beaker_rspec_version)
27-
else
33+
else
2834
gem 'beaker-rspec', :require => false
2935
end
3036
gem 'serverspec', :require => false

inifile/spec/acceptance/ini_setting_spec.rb

Lines changed: 42 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@
44

55
describe 'ini_setting resource' do
66
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])
88
end
99

10-
shared_examples 'has_content' do |path,pp,content|
10+
shared_examples 'has_content' do |path, pp, content|
1111
before :all do
12-
shell("rm #{path}", :acceptable_exit_codes => [0,1,2])
12+
shell("rm #{path}", :acceptable_exit_codes => [0, 1, 2])
1313
end
1414
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])
1717
end
1818

1919
it 'applies the manifest twice' do
@@ -23,20 +23,17 @@
2323

2424
describe file(path) do
2525
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 }
3027
end
3128
end
3229

33-
shared_examples 'has_error' do |path,pp,error|
30+
shared_examples 'has_error' do |path, pp, error|
3431
before :all do
35-
shell("rm #{path}", :acceptable_exit_codes => [0,1,2])
32+
shell("rm #{path}", :acceptable_exit_codes => [0, 1, 2])
3633
end
3734
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])
4037
end
4138

4239
it 'applies the manifest and gets a failure message' do
@@ -72,13 +69,13 @@
7269
apply_manifest(pp, :catch_changes => true)
7370
end
7471

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/
7673
end
7774

7875
context '=> absent for key/value' do
7976
before :all do
8077
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")
8279
else
8380
shell("echo -e \"four = five\n[one]\ntwo = three\" > #{tmpdir}/ini_setting.ini")
8481
end
@@ -96,14 +93,16 @@
9693

9794
it 'applies the manifest twice' do
9895
apply_manifest(pp, :catch_failures => true)
99-
apply_manifest(pp, :catch_changes => true)
96+
apply_manifest(pp, :catch_changes => true)
10097
end
10198

10299
describe file("#{tmpdir}/ini_setting.ini") do
103100
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+
}
107106
end
108107
end
109108

@@ -116,8 +115,8 @@
116115
end
117116
end
118117
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])
121120
end
122121

123122
pp = <<-EOS
@@ -132,23 +131,25 @@
132131

133132
it 'applies the manifest twice' do
134133
apply_manifest(pp, :catch_failures => true)
135-
apply_manifest(pp, :catch_changes => true)
134+
apply_manifest(pp, :catch_changes => true)
136135
end
137136

138137
describe file("#{tmpdir}/ini_setting.ini") do
139138
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+
}
143144
end
144145
end
145146
end
146147

147148
describe 'section, setting, value parameters' do
148149
{
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/,
152153
}.each do |parameter_list, content|
153154
context parameter_list do
154155
pp = <<-EOS
@@ -164,12 +165,12 @@
164165
end
165166

166167
{
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/,
173174
}.each do |parameter_list, error|
174175
context parameter_list, :pending => 'no error checking yet' do
175176
pp = <<-EOS
@@ -187,9 +188,9 @@
187188

188189
describe 'path parameter' do
189190
[
190-
"#{tmpdir}/one.ini",
191-
"#{tmpdir}/two.ini",
192-
"#{tmpdir}/three.ini",
191+
"#{tmpdir}/one.ini",
192+
"#{tmpdir}/two.ini",
193+
"#{tmpdir}/three.ini",
193194
].each do |path|
194195
context "path => #{path}" do
195196
pp = <<-EOS
@@ -202,7 +203,7 @@
202203
}
203204
EOS
204205

205-
it_behaves_like 'has_content', path, pp, "[one]\ntwo = three"
206+
it_behaves_like 'has_content', path, pp, /\[one\]\ntwo = three/
206207
end
207208
end
208209

@@ -223,9 +224,9 @@
223224

224225
describe 'key_val_separator parameter' do
225226
{
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/,
229230
}.each do |parameter, content|
230231
context "with \"#{parameter}\" makes \"#{content}\"" do
231232
pp = <<-EOS

inifile/spec/acceptance/ini_subsetting_spec.rb

Lines changed: 39 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -4,36 +4,38 @@
44

55
describe 'ini_subsetting resource' do
66
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])
88
end
99

10-
shared_examples 'has_content' do |path,pp,content|
10+
shared_examples 'has_content' do |path, pp, content|
1111
before :all do
12-
shell("rm #{path}", :acceptable_exit_codes => [0,1,2])
12+
shell("rm #{path}", :acceptable_exit_codes => [0, 1, 2])
1313
end
1414
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])
1717
end
1818

1919
it 'applies the manifest twice' do
2020
apply_manifest(pp, :catch_failures => true)
21-
apply_manifest(pp, :catch_changes => true)
21+
apply_manifest(pp, :catch_changes => true)
2222
end
2323

2424
describe file(path) do
2525
it { should be_file }
26-
it { should contain(content) }
26+
its(:content) {
27+
should match content
28+
}
2729
end
2830
end
2931

30-
shared_examples 'has_error' do |path,pp,error|
32+
shared_examples 'has_error' do |path, pp, error|
3133
before :all do
32-
shell("rm #{path}", :acceptable_exit_codes => [0,1,2])
34+
shell("rm #{path}", :acceptable_exit_codes => [0, 1, 2])
3335
end
3436
after :all do
35-
shell("cat #{path}", :acceptable_exit_codes => [0,1,2])
36-
shell("rm #{path}", :acceptable_exit_codes => [0,1,2])
37+
shell("cat #{path}", :acceptable_exit_codes => [0, 1, 2])
38+
shell("rm #{path}", :acceptable_exit_codes => [0, 1, 2])
3739
end
3840

3941
it 'applies the manifest and gets a failure message' do
@@ -63,19 +65,19 @@
6365
setting => 'key',
6466
subsetting => 'beta',
6567
value => 'trons',
68+
require => Ini_subsetting['ensure => present for alpha'],
6669
}
6770
EOS
6871

6972
it 'applies the manifest twice' do
7073
apply_manifest(pp, :catch_failures => true)
71-
apply_manifest(pp, :catch_changes => true)
74+
apply_manifest(pp, :catch_changes => true)
7275
end
7376

7477
describe file("#{tmpdir}/ini_subsetting.ini") do
7578
it { should be_file }
76-
#XXX Solaris 10 doesn't support multi-line grep
77-
it("should contain [one]\nkey = alphabet betatrons", :unless => fact('osfamily') == 'Solaris') {
78-
should contain("[one]\nkey = alphabet betatrons")
79+
its(:content) {
80+
should match /\[one\]\nkey = alphabet betatrons/
7981
}
8082
end
8183
end
@@ -101,27 +103,27 @@
101103

102104
it 'applies the manifest twice' do
103105
apply_manifest(pp, :catch_failures => true)
104-
apply_manifest(pp, :catch_changes => true)
106+
apply_manifest(pp, :catch_changes => true)
105107
end
106108

107109
describe file("#{tmpdir}/ini_subsetting.ini") do
108110
it { should be_file }
109-
it { should contain('[one]') }
110-
it { should contain('key = betatrons') }
111-
it { should_not contain('alphabet') }
111+
its(:content) {
112+
should match /\[one\]/
113+
should match /key = betatrons/
114+
should_not match /alphabet/
115+
}
112116
end
113117
end
114118
end
115119

116120
describe 'subsetting_separator' do
117121
{
118-
"" => "two = twinethree foobar",
119-
#"subsetting_separator => ''," => "two = twinethreefoobar", # breaks regex
120-
"subsetting_separator => ','," => "two = twinethree,foobar",
121-
"subsetting_separator => ' '," => "two = twinethree foobar",
122-
"subsetting_separator => ' == '," => "two = twinethree == foobar",
123-
"subsetting_separator => '='," => "two = twinethree=foobar",
124-
#"subsetting_separator => '---'," => "two = twinethree---foobar", # breaks regex
122+
"" => /two = twinethree foobar/,
123+
"subsetting_separator => ','," => /two = twinethree,foobar/,
124+
"subsetting_separator => ' '," => /two = twinethree foobar/,
125+
"subsetting_separator => ' == '," => /two = twinethree == foobar/,
126+
"subsetting_separator => '='," => /two = twinethree=foobar/,
125127
}.each do |parameter, content|
126128
context "with \"#{parameter}\" makes \"#{content}\"" do
127129
pp = <<-EOS
@@ -132,6 +134,7 @@
132134
subsetting => 'twine',
133135
value => 'three',
134136
path => "#{tmpdir}/subsetting_separator.ini",
137+
before => Ini_subsetting['foobar'],
135138
#{parameter}
136139
}
137140
ini_subsetting { "foobar":
@@ -152,10 +155,10 @@
152155

153156
describe 'quote_char' do
154157
{
155-
['-Xmx'] => 'args=""',
156-
['-Xmx', '256m'] => 'args=-Xmx256m',
157-
['-Xmx', '512m'] => 'args="-Xmx512m"',
158-
['-Xms', '256m'] => 'args="-Xmx256m -Xms256m"',
158+
['-Xmx'] => /args=""/,
159+
['-Xmx', '256m'] => /args=-Xmx256m/,
160+
['-Xmx', '512m'] => /args="-Xmx512m"/,
161+
['-Xms', '256m'] => /args="-Xmx256m -Xms256m"/,
159162
}.each do |parameter, content|
160163
context %Q{with '#{parameter.first}' #{parameter.length > 1 ? '=> \'' << parameter[1] << '\'' : 'absent'} makes '#{content}'} do
161164
path = File.join(tmpdir, 'ini_subsetting.ini')
@@ -164,8 +167,8 @@
164167
shell(%Q{echo '[java]\nargs=-Xmx256m' > #{path}})
165168
end
166169
after :all do
167-
shell("cat #{path}", :acceptable_exit_codes => [0,1,2])
168-
shell("rm #{path}", :acceptable_exit_codes => [0,1,2])
170+
shell("cat #{path}", :acceptable_exit_codes => [0, 1, 2])
171+
shell("rm #{path}", :acceptable_exit_codes => [0, 1, 2])
169172
end
170173

171174
pp = <<-EOS
@@ -182,12 +185,14 @@
182185

183186
it 'applies the manifest twice' do
184187
apply_manifest(pp, :catch_failures => true)
185-
apply_manifest(pp, :catch_changes => true)
188+
apply_manifest(pp, :catch_changes => true)
186189
end
187190

188191
describe file("#{tmpdir}/ini_subsetting.ini") do
189192
it { should be_file }
190-
it { should contain(content) }
193+
its(:content) {
194+
should match content
195+
}
191196
end
192197
end
193198
end

0 commit comments

Comments
 (0)