Skip to content

Commit f8f147e

Browse files
committed
Add success/fail groups
1 parent fcbc4b5 commit f8f147e

16 files changed

+317
-217
lines changed

Gemfile

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@ group :development, :test do
1414
gem 'rake', '~> 10.1.0', :require => false
1515
gem 'rspec-puppet', :require => false
1616
gem 'puppetlabs_spec_helper', :require => false
17-
gem 'rspec-system', :require => false
18-
gem 'rspec-system-puppet', :require => false
19-
gem 'rspec-system-serverspec', :require => false
2017
gem 'serverspec', :require => false
2118
gem 'puppet-lint', :require => false
2219
gem 'pry', :require => false

spec/acceptance/abs_spec.rb

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,29 @@
11
require 'spec_helper_acceptance'
22

33
describe 'abs function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
4-
it 'should accept a string' do
5-
pp = <<-EOS
6-
$input = '-34.56'
7-
$output = abs($input)
8-
notify { $output: }
9-
EOS
4+
describe 'success' do
5+
it 'should accept a string' do
6+
pp = <<-EOS
7+
$input = '-34.56'
8+
$output = abs($input)
9+
notify { $output: }
10+
EOS
1011

11-
apply_manifest(pp, :catch_failures => true) do |r|
12-
expect(r.stdout).to match(/Notice: 34.56/)
12+
apply_manifest(pp, :catch_failures => true) do |r|
13+
expect(r.stdout).to match(/Notice: 34.56/)
14+
end
1315
end
14-
end
1516

16-
it 'should accept a float' do
17-
pp = <<-EOS
18-
$input = -34.56
19-
$output = abs($input)
20-
notify { $output: }
21-
EOS
17+
it 'should accept a float' do
18+
pp = <<-EOS
19+
$input = -34.56
20+
$output = abs($input)
21+
notify { $output: }
22+
EOS
2223

23-
apply_manifest(pp, :catch_failures => true) do |r|
24-
expect(r.stdout).to match(/Notice: 34.56/)
24+
apply_manifest(pp, :catch_failures => true) do |r|
25+
expect(r.stdout).to match(/Notice: 34.56/)
26+
end
2527
end
2628
end
2729
end

spec/acceptance/any2array_spec.rb

Lines changed: 34 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,48 @@
11
require 'spec_helper_acceptance'
22

33
describe 'any2array function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
4-
it 'should create an empty array' do
5-
pp = <<-EOS
6-
$input = ''
7-
$output = any2array($input)
8-
validate_array($output)
9-
notify { "Output: ${output}": }
10-
EOS
4+
describe 'success' do
5+
it 'should create an empty array' do
6+
pp = <<-EOS
7+
$input = ''
8+
$output = any2array($input)
9+
validate_array($output)
10+
notify { "Output: ${output}": }
11+
EOS
1112

12-
apply_manifest(pp, :catch_failures => true) do |r|
13-
expect(r.stdout).to match(/Notice: Output: /)
13+
apply_manifest(pp, :catch_failures => true) do |r|
14+
expect(r.stdout).to match(/Notice: Output: /)
15+
end
1416
end
15-
end
1617

17-
it 'should leave arrays modified' do
18-
pp = <<-EOS
19-
$input = ['test', 'array']
20-
$output = any2array($input)
21-
validate_array($output)
22-
notify { "Output: ${output}": }
23-
EOS
18+
it 'should leave arrays modified' do
19+
pp = <<-EOS
20+
$input = ['test', 'array']
21+
$output = any2array($input)
22+
validate_array($output)
23+
notify { "Output: ${output}": }
24+
EOS
2425

25-
apply_manifest(pp, :catch_failures => true) do |r|
26-
expect(r.stdout).to match(/Notice: Output: testarray/)
26+
apply_manifest(pp, :catch_failures => true) do |r|
27+
expect(r.stdout).to match(/Notice: Output: testarray/)
28+
end
2729
end
28-
end
2930

30-
it 'should turn a hash into an array' do
31-
pp = <<-EOS
32-
$input = {'test' => 'array'}
33-
$output = any2array($input)
31+
it 'should turn a hash into an array' do
32+
pp = <<-EOS
33+
$input = {'test' => 'array'}
34+
$output = any2array($input)
3435
35-
validate_array($output)
36-
# Check each element of the array is a plain string.
37-
validate_string($output[0])
38-
validate_string($output[1])
39-
notify { "Output: ${output}": }
40-
EOS
36+
validate_array($output)
37+
# Check each element of the array is a plain string.
38+
validate_string($output[0])
39+
validate_string($output[1])
40+
notify { "Output: ${output}": }
41+
EOS
4142

42-
apply_manifest(pp, :catch_failures => true) do |r|
43-
expect(r.stdout).to match(/Notice: Output: testarray/)
43+
apply_manifest(pp, :catch_failures => true) do |r|
44+
expect(r.stdout).to match(/Notice: Output: testarray/)
45+
end
4446
end
4547
end
4648
end

spec/acceptance/base64_spec.rb

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
require 'spec_helper_acceptance'
22

33
describe 'base64 function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
4-
it 'should encode then decode a string' do
5-
pp = <<-EOS
6-
$encodestring = base64('encode', 'thestring')
7-
$decodestring = base64('decode', $encodestring)
8-
notify { $decodestring: }
9-
EOS
4+
describe 'success' do
5+
it 'should encode then decode a string' do
6+
pp = <<-EOS
7+
$encodestring = base64('encode', 'thestring')
8+
$decodestring = base64('decode', $encodestring)
9+
notify { $decodestring: }
10+
EOS
1011

11-
apply_manifest(pp, :catch_failures => true) do |r|
12-
expect(r.stdout).to match(/thestring/)
12+
apply_manifest(pp, :catch_failures => true) do |r|
13+
expect(r.stdout).to match(/thestring/)
14+
end
1315
end
1416
end
1517
end

spec/acceptance/bool2num_spec.rb

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,32 @@
11
require 'spec_helper_acceptance'
22

33
describe 'bool2num function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
4-
['false', 'f', '0', 'n', 'no'].each do |bool|
5-
it 'should convert a given boolean, #{bool}, to 0' do
6-
pp = <<-EOS
7-
$input = #{bool}
8-
$output = bool2num($input)
9-
notify { $output: }
10-
EOS
4+
describe 'success' do
5+
['false', 'f', '0', 'n', 'no'].each do |bool|
6+
it 'should convert a given boolean, #{bool}, to 0' do
7+
pp = <<-EOS
8+
$input = #{bool}
9+
$output = bool2num($input)
10+
notify { $output: }
11+
EOS
1112

12-
apply_manifest(pp, :catch_failures => true) do |r|
13-
expect(r.stdout).to match(/Notice: 0/)
13+
apply_manifest(pp, :catch_failures => true) do |r|
14+
expect(r.stdout).to match(/Notice: 0/)
15+
end
1416
end
1517
end
16-
end
1718

18-
['true', 't', '1', 'y', 'yes'].each do |bool|
19-
it 'should convert a given boolean, #{bool}, to 1' do
20-
pp = <<-EOS
21-
$input = #{bool}
22-
$output = bool2num($input)
23-
notify { $output: }
24-
EOS
19+
['true', 't', '1', 'y', 'yes'].each do |bool|
20+
it 'should convert a given boolean, #{bool}, to 1' do
21+
pp = <<-EOS
22+
$input = #{bool}
23+
$output = bool2num($input)
24+
notify { $output: }
25+
EOS
2526

26-
apply_manifest(pp, :catch_failures => true) do |r|
27-
expect(r.stdout).to match(/Notice: 1/)
27+
apply_manifest(pp, :catch_failures => true) do |r|
28+
expect(r.stdout).to match(/Notice: 1/)
29+
end
2830
end
2931
end
3032
end

spec/acceptance/capitalize_spec.rb

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,32 @@
11
require 'spec_helper_acceptance'
22

33
describe 'capitalize function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
4-
it 'should capitalize the first letter of a string' do
5-
pp = <<-EOS
6-
$input = 'this is a string'
7-
$output = capitalize($input)
8-
notify { $output: }
9-
EOS
4+
describe 'success' do
5+
it 'should capitalize the first letter of a string' do
6+
pp = <<-EOS
7+
$input = 'this is a string'
8+
$output = capitalize($input)
9+
notify { $output: }
10+
EOS
1011

11-
apply_manifest(pp, :catch_failures => true) do |r|
12-
expect(r.stdout).to match(/Notice: This is a string/)
12+
apply_manifest(pp, :catch_failures => true) do |r|
13+
expect(r.stdout).to match(/Notice: This is a string/)
14+
end
1315
end
14-
end
1516

16-
it 'should capitalize the first letter of an array of strings' do
17-
pp = <<-EOS
18-
$input = ['this', 'is', 'a', 'string']
19-
$output = capitalize($input)
20-
notify { $output: }
21-
EOS
17+
it 'should capitalize the first letter of an array of strings' do
18+
pp = <<-EOS
19+
$input = ['this', 'is', 'a', 'string']
20+
$output = capitalize($input)
21+
notify { $output: }
22+
EOS
2223

23-
apply_manifest(pp, :catch_failures => true) do |r|
24-
expect(r.stdout).to match(/Notice: This/)
25-
expect(r.stdout).to match(/Notice: Is/)
26-
expect(r.stdout).to match(/Notice: A/)
27-
expect(r.stdout).to match(/Notice: String/)
24+
apply_manifest(pp, :catch_failures => true) do |r|
25+
expect(r.stdout).to match(/Notice: This/)
26+
expect(r.stdout).to match(/Notice: Is/)
27+
expect(r.stdout).to match(/Notice: A/)
28+
expect(r.stdout).to match(/Notice: String/)
29+
end
2830
end
2931
end
3032
end

spec/acceptance/chomp_spec.rb

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
11
require 'spec_helper_acceptance'
22

33
describe 'chomp function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
4-
it 'should eat the newline' do
5-
pp = <<-EOS
6-
$input = "test\n"
7-
if size($input) != 5 {
8-
fail("Size of ${input} is not 5.")
9-
}
10-
$output = chomp($input)
11-
if size($output) != 4 {
12-
fail("Size of ${input} is not 4.")
13-
}
14-
EOS
4+
describe 'success' do
5+
it 'should eat the newline' do
6+
pp = <<-EOS
7+
$input = "test\n"
8+
if size($input) != 5 {
9+
fail("Size of ${input} is not 5.")
10+
}
11+
$output = chomp($input)
12+
if size($output) != 4 {
13+
fail("Size of ${input} is not 4.")
14+
}
15+
EOS
1516

16-
apply_manifest(pp, :catch_failures => true)
17+
apply_manifest(pp, :catch_failures => true)
18+
end
1719
end
1820
end

spec/acceptance/chop_spec.rb

Lines changed: 34 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,44 @@
11
require 'spec_helper_acceptance'
22

33
describe 'chop function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
4-
it 'should eat the last character' do
5-
pp = <<-EOS
6-
$input = "test"
7-
if size($input) != 4 {
8-
fail("Size of ${input} is not 4.")
9-
}
10-
$output = chop($input)
11-
if size($output) != 3 {
12-
fail("Size of ${input} is not 3.")
13-
}
14-
EOS
4+
describe 'success' do
5+
it 'should eat the last character' do
6+
pp = <<-EOS
7+
$input = "test"
8+
if size($input) != 4 {
9+
fail("Size of ${input} is not 4.")
10+
}
11+
$output = chop($input)
12+
if size($output) != 3 {
13+
fail("Size of ${input} is not 3.")
14+
}
15+
EOS
1516

16-
apply_manifest(pp, :catch_failures => true)
17-
end
17+
apply_manifest(pp, :catch_failures => true)
18+
end
1819

19-
it 'should eat the last two characters of \r\n' do
20-
pp = <<-EOS
21-
$input = "test\r\n"
22-
if size($input) != 6 {
23-
fail("Size of ${input} is not 6.")
24-
}
25-
$output = chop($input)
26-
if size($output) != 4 {
27-
fail("Size of ${input} is not 4.")
28-
}
29-
EOS
20+
it 'should eat the last two characters of \r\n' do
21+
pp = <<-EOS
22+
$input = "test\r\n"
23+
if size($input) != 6 {
24+
fail("Size of ${input} is not 6.")
25+
}
26+
$output = chop($input)
27+
if size($output) != 4 {
28+
fail("Size of ${input} is not 4.")
29+
}
30+
EOS
3031

31-
apply_manifest(pp, :catch_failures => true)
32-
end
32+
apply_manifest(pp, :catch_failures => true)
33+
end
3334

34-
it 'should not fail on empty strings' do
35-
pp = <<-EOS
36-
$input = ""
37-
$output = chop($input)
38-
EOS
35+
it 'should not fail on empty strings' do
36+
pp = <<-EOS
37+
$input = ""
38+
$output = chop($input)
39+
EOS
3940

40-
apply_manifest(pp, :catch_failures => true)
41+
apply_manifest(pp, :catch_failures => true)
42+
end
4143
end
4244
end

0 commit comments

Comments
 (0)