Skip to content

Commit 8867610

Browse files
author
Morgan Haskel
committed
Merge pull request #146 from cyberious/SpecinfraUpgrade
Fixes issues due to serverspec upgrade
2 parents 03417e5 + 8e2689b commit 8867610

4 files changed

Lines changed: 92 additions & 86 deletions

File tree

Gemfile

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,18 @@ group :development, :unit_tests do
1919
gem 'simplecov', :require => false
2020
gem 'puppet_facts', :require => false
2121
gem 'json', :require => false
22+
gem 'pry', :require => false
2223
end
2324

25+
beaker_version = ENV['BEAKER_VERSION']
2426
beaker_rspec_version = ENV['BEAKER_RSPEC_VERSION']
2527
group :system_tests do
28+
if beaker_version
29+
gem 'beaker', *location_for(beaker_version)
30+
end
2631
if beaker_rspec_version
2732
gem 'beaker-rspec', *location_for(beaker_rspec_version)
28-
else
33+
else
2934
gem 'beaker-rspec', :require => false
3035
end
3136
gem 'serverspec', :require => false

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

spec/acceptance/ini_subsetting_spec.rb

Lines changed: 37 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
@@ -68,14 +70,13 @@
6870

6971
it 'applies the manifest twice' do
7072
apply_manifest(pp, :catch_failures => true)
71-
apply_manifest(pp, :catch_changes => true)
73+
apply_manifest(pp, :catch_changes => true)
7274
end
7375

7476
describe file("#{tmpdir}/ini_subsetting.ini") do
7577
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")
78+
its(:content) {
79+
should match /\[one\]\nkey = alphabet betatrons/
7980
}
8081
end
8182
end
@@ -101,27 +102,27 @@
101102

102103
it 'applies the manifest twice' do
103104
apply_manifest(pp, :catch_failures => true)
104-
apply_manifest(pp, :catch_changes => true)
105+
apply_manifest(pp, :catch_changes => true)
105106
end
106107

107108
describe file("#{tmpdir}/ini_subsetting.ini") do
108109
it { should be_file }
109-
it { should contain('[one]') }
110-
it { should contain('key = betatrons') }
111-
it { should_not contain('alphabet') }
110+
its(:content) {
111+
should match /\[one\]/
112+
should match /key = betatrons/
113+
should_not match /alphabet/
114+
}
112115
end
113116
end
114117
end
115118

116119
describe 'subsetting_separator' do
117120
{
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
121+
"" => /two = twinethree foobar/,
122+
"subsetting_separator => ','," => /two = twinethree,foobar/,
123+
"subsetting_separator => ' '," => /two = twinethree foobar/,
124+
"subsetting_separator => ' == '," => /two = twinethree == foobar/,
125+
"subsetting_separator => '='," => /two = twinethree=foobar/,
125126
}.each do |parameter, content|
126127
context "with \"#{parameter}\" makes \"#{content}\"" do
127128
pp = <<-EOS
@@ -152,10 +153,10 @@
152153

153154
describe 'quote_char' do
154155
{
155-
['-Xmx'] => 'args=""',
156-
['-Xmx', '256m'] => 'args=-Xmx256m',
157-
['-Xmx', '512m'] => 'args="-Xmx512m"',
158-
['-Xms', '256m'] => 'args="-Xmx256m -Xms256m"',
156+
['-Xmx'] => /args=""/,
157+
['-Xmx', '256m'] => /args=-Xmx256m/,
158+
['-Xmx', '512m'] => /args="-Xmx512m"/,
159+
['-Xms', '256m'] => /args="-Xmx256m -Xms256m"/,
159160
}.each do |parameter, content|
160161
context %Q{with '#{parameter.first}' #{parameter.length > 1 ? '=> \'' << parameter[1] << '\'' : 'absent'} makes '#{content}'} do
161162
path = File.join(tmpdir, 'ini_subsetting.ini')
@@ -164,8 +165,8 @@
164165
shell(%Q{echo '[java]\nargs=-Xmx256m' > #{path}})
165166
end
166167
after :all do
167-
shell("cat #{path}", :acceptable_exit_codes => [0,1,2])
168-
shell("rm #{path}", :acceptable_exit_codes => [0,1,2])
168+
shell("cat #{path}", :acceptable_exit_codes => [0, 1, 2])
169+
shell("rm #{path}", :acceptable_exit_codes => [0, 1, 2])
169170
end
170171

171172
pp = <<-EOS
@@ -182,12 +183,14 @@
182183

183184
it 'applies the manifest twice' do
184185
apply_manifest(pp, :catch_failures => true)
185-
apply_manifest(pp, :catch_changes => true)
186+
apply_manifest(pp, :catch_changes => true)
186187
end
187188

188189
describe file("#{tmpdir}/ini_subsetting.ini") do
189190
it { should be_file }
190-
it { should contain(content) }
191+
its(:content) {
192+
should match content
193+
}
191194
end
192195
end
193196
end

spec/spec_helper_acceptance.rb

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,13 @@
44
unless ENV['RS_PROVISION'] == 'no'
55
# This will install the latest available package on el and deb based
66
# systems fail on windows and osx, and install via gem on other *nixes
7-
foss_opts = { :default_action => 'gem_install' }
7+
foss_opts = {:default_action => 'gem_install'}
88

9-
if default.is_pe?; then install_pe; else install_puppet( foss_opts ); end
9+
if default.is_pe?; then
10+
install_pe;
11+
else
12+
install_puppet(foss_opts);
13+
end
1014

1115
hosts.each do |host|
1216
if host['platform'] =~ /debian/
@@ -27,14 +31,7 @@
2731
c.before :suite do
2832
# Install module and dependencies
2933
hosts.each do |host|
30-
if host['platform'] !~ /windows/i
31-
copy_root_module_to(host, :source => proj_root, :module_name => 'inifile')
32-
end
33-
end
34-
hosts.each do |host|
35-
if host['platform'] =~ /windows/i
36-
on host, puppet('plugin download')
37-
end
34+
copy_root_module_to(host, :source => proj_root, :module_name => 'inifile')
3835
end
3936
end
4037

0 commit comments

Comments
 (0)