rspec-puppet 0.1.6 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/README.md +71 -6
- data/lib/rspec-puppet.rb +45 -0
- data/lib/rspec-puppet/errors.rb +83 -0
- data/lib/rspec-puppet/example/class_example_group.rb +1 -55
- data/lib/rspec-puppet/example/define_example_group.rb +1 -57
- data/lib/rspec-puppet/example/function_example_group.rb +21 -35
- data/lib/rspec-puppet/example/host_example_group.rb +1 -26
- data/lib/rspec-puppet/matchers.rb +3 -1
- data/lib/rspec-puppet/matchers/compile.rb +133 -0
- data/lib/rspec-puppet/matchers/count_generic.rb +73 -0
- data/lib/rspec-puppet/matchers/create_generic.rb +155 -52
- data/lib/rspec-puppet/matchers/dynamic_matchers.rb +17 -0
- data/lib/rspec-puppet/matchers/include_class.rb +2 -1
- data/lib/rspec-puppet/matchers/parameter_matcher.rb +110 -0
- data/lib/rspec-puppet/matchers/run.rb +49 -31
- data/lib/rspec-puppet/setup.rb +57 -34
- data/lib/rspec-puppet/support.rb +154 -7
- metadata +18 -32
- data/LICENSE +0 -20
- data/Rakefile +0 -7
- data/lib/rspec-puppet/matchers/create_resource.rb +0 -53
- data/rspec-puppet.gemspec +0 -47
- data/spec/classes/boolean_regexp_spec.rb +0 -10
- data/spec/classes/boolean_spec.rb +0 -11
- data/spec/classes/sysctl_common_spec.rb +0 -40
- data/spec/defines/sysctl_before_spec.rb +0 -26
- data/spec/defines/sysctl_spec.rb +0 -14
- data/spec/fixtures/manifests/site.pp +0 -7
- data/spec/fixtures/modules/boolean/manifests/init.pp +0 -12
- data/spec/fixtures/modules/sysctl/manifests/init.pp +0 -39
- data/spec/functions/split_spec.rb +0 -17
- data/spec/hosts/foo_spec.rb +0 -6
- data/spec/hosts/testhost_spec.rb +0 -5
- data/spec/spec_helper.rb +0 -6
metadata
CHANGED
@@ -1,30 +1,27 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspec-puppet
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
5
|
-
prerelease:
|
4
|
+
version: 1.0.0
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Tim Sharpe
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date: 2013-
|
11
|
+
date: 2013-12-05 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: rspec
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - '>='
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: '0'
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- -
|
24
|
+
- - '>='
|
28
25
|
- !ruby/object:Gem::Version
|
29
26
|
version: '0'
|
30
27
|
description: RSpec tests for your Puppet manifests
|
@@ -34,58 +31,47 @@ executables:
|
|
34
31
|
extensions: []
|
35
32
|
extra_rdoc_files: []
|
36
33
|
files:
|
37
|
-
-
|
34
|
+
- README.md
|
35
|
+
- lib/rspec-puppet/errors.rb
|
38
36
|
- lib/rspec-puppet/example/class_example_group.rb
|
39
37
|
- lib/rspec-puppet/example/define_example_group.rb
|
40
38
|
- lib/rspec-puppet/example/function_example_group.rb
|
41
39
|
- lib/rspec-puppet/example/host_example_group.rb
|
42
40
|
- lib/rspec-puppet/example.rb
|
41
|
+
- lib/rspec-puppet/matchers/compile.rb
|
42
|
+
- lib/rspec-puppet/matchers/count_generic.rb
|
43
43
|
- lib/rspec-puppet/matchers/create_generic.rb
|
44
|
-
- lib/rspec-puppet/matchers/
|
44
|
+
- lib/rspec-puppet/matchers/dynamic_matchers.rb
|
45
45
|
- lib/rspec-puppet/matchers/include_class.rb
|
46
|
+
- lib/rspec-puppet/matchers/parameter_matcher.rb
|
46
47
|
- lib/rspec-puppet/matchers/run.rb
|
47
48
|
- lib/rspec-puppet/matchers.rb
|
48
49
|
- lib/rspec-puppet/setup.rb
|
49
50
|
- lib/rspec-puppet/support.rb
|
50
51
|
- lib/rspec-puppet.rb
|
51
|
-
-
|
52
|
-
- Rakefile
|
53
|
-
- README.md
|
54
|
-
- rspec-puppet.gemspec
|
55
|
-
- spec/classes/boolean_regexp_spec.rb
|
56
|
-
- spec/classes/boolean_spec.rb
|
57
|
-
- spec/classes/sysctl_common_spec.rb
|
58
|
-
- spec/defines/sysctl_before_spec.rb
|
59
|
-
- spec/defines/sysctl_spec.rb
|
60
|
-
- spec/hosts/foo_spec.rb
|
61
|
-
- spec/hosts/testhost_spec.rb
|
62
|
-
- spec/fixtures/manifests/site.pp
|
63
|
-
- spec/fixtures/modules/boolean/manifests/init.pp
|
64
|
-
- spec/fixtures/modules/sysctl/manifests/init.pp
|
65
|
-
- spec/functions/split_spec.rb
|
66
|
-
- spec/spec_helper.rb
|
52
|
+
- bin/rspec-puppet-init
|
67
53
|
homepage: https://github.com/rodjek/rspec-puppet/
|
68
|
-
licenses:
|
54
|
+
licenses:
|
55
|
+
- MIT
|
56
|
+
metadata: {}
|
69
57
|
post_install_message:
|
70
58
|
rdoc_options: []
|
71
59
|
require_paths:
|
72
60
|
- lib
|
73
61
|
required_ruby_version: !ruby/object:Gem::Requirement
|
74
|
-
none: false
|
75
62
|
requirements:
|
76
|
-
- -
|
63
|
+
- - '>='
|
77
64
|
- !ruby/object:Gem::Version
|
78
65
|
version: '0'
|
79
66
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
80
|
-
none: false
|
81
67
|
requirements:
|
82
|
-
- -
|
68
|
+
- - '>='
|
83
69
|
- !ruby/object:Gem::Version
|
84
70
|
version: '0'
|
85
71
|
requirements: []
|
86
72
|
rubyforge_project:
|
87
|
-
rubygems_version:
|
73
|
+
rubygems_version: 2.0.3
|
88
74
|
signing_key:
|
89
|
-
specification_version:
|
75
|
+
specification_version: 4
|
90
76
|
summary: RSpec tests for your Puppet manifests
|
91
77
|
test_files: []
|
data/LICENSE
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
Copyright (c) 2011 Tim Sharpe
|
2
|
-
|
3
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
-
a copy of this software and associated documentation files (the
|
5
|
-
"Software"), to deal in the Software without restriction, including
|
6
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
-
permit persons to whom the Software is furnished to do so, subject to
|
9
|
-
the following conditions:
|
10
|
-
|
11
|
-
The above copyright notice and this permission notice shall be
|
12
|
-
included in all copies or substantial portions of the Software.
|
13
|
-
|
14
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
17
|
-
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
18
|
-
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
19
|
-
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
20
|
-
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
DELETED
@@ -1,53 +0,0 @@
|
|
1
|
-
module RSpec::Puppet
|
2
|
-
module ManifestMatchers
|
3
|
-
extend RSpec::Matchers::DSL
|
4
|
-
|
5
|
-
matcher :create_resource do |expected_type, expected_title|
|
6
|
-
match do |catalogue|
|
7
|
-
ret = true
|
8
|
-
resources = catalogue.resources.select { |r|
|
9
|
-
r.type == referenced_type(expected_type)
|
10
|
-
}.select { |r|
|
11
|
-
r.title == expected_title if r.respond_to? :title
|
12
|
-
}
|
13
|
-
|
14
|
-
unless resources.length == 1
|
15
|
-
ret = false
|
16
|
-
end
|
17
|
-
|
18
|
-
if @expected_params and resources.length != 0
|
19
|
-
@expected_params.each do |name, value|
|
20
|
-
unless resources.first.send(:parameters)[name.to_sym] == value
|
21
|
-
ret = false
|
22
|
-
(@errors ||= []) << "the parameter #{name.to_s} set to `#{value}`"
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
ret
|
28
|
-
end
|
29
|
-
|
30
|
-
def errors
|
31
|
-
@errors.nil? ? "" : " with #{@errors.join(', ')}"
|
32
|
-
end
|
33
|
-
|
34
|
-
def referenced_type(type)
|
35
|
-
type.split('::').map { |r| r.capitalize }.join('::')
|
36
|
-
end
|
37
|
-
|
38
|
-
chain :with_param do |param_name,param_value|
|
39
|
-
(@expected_params ||= []) << [param_name, param_value]
|
40
|
-
end
|
41
|
-
|
42
|
-
description do
|
43
|
-
type = referenced_type(expected_type)
|
44
|
-
"create #{type}['#{expected_title}']"
|
45
|
-
end
|
46
|
-
|
47
|
-
failure_message_for_should do |actual|
|
48
|
-
type = referenced_type(expected_type)
|
49
|
-
"expected that the catalogue would contain #{type}['#{expected_title}']#{errors}"
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|
data/rspec-puppet.gemspec
DELETED
@@ -1,47 +0,0 @@
|
|
1
|
-
Gem::Specification.new do |s|
|
2
|
-
s.name = 'rspec-puppet'
|
3
|
-
s.version = '0.1.6'
|
4
|
-
s.homepage = 'https://github.com/rodjek/rspec-puppet/'
|
5
|
-
s.summary = 'RSpec tests for your Puppet manifests'
|
6
|
-
s.description = 'RSpec tests for your Puppet manifests'
|
7
|
-
|
8
|
-
s.executables = ['rspec-puppet-init']
|
9
|
-
|
10
|
-
s.files = [
|
11
|
-
'bin/rspec-puppet-init',
|
12
|
-
'lib/rspec-puppet/example/class_example_group.rb',
|
13
|
-
'lib/rspec-puppet/example/define_example_group.rb',
|
14
|
-
'lib/rspec-puppet/example/function_example_group.rb',
|
15
|
-
'lib/rspec-puppet/example/host_example_group.rb',
|
16
|
-
'lib/rspec-puppet/example.rb',
|
17
|
-
'lib/rspec-puppet/matchers/create_generic.rb',
|
18
|
-
'lib/rspec-puppet/matchers/create_resource.rb',
|
19
|
-
'lib/rspec-puppet/matchers/include_class.rb',
|
20
|
-
'lib/rspec-puppet/matchers/run.rb',
|
21
|
-
'lib/rspec-puppet/matchers.rb',
|
22
|
-
'lib/rspec-puppet/setup.rb',
|
23
|
-
'lib/rspec-puppet/support.rb',
|
24
|
-
'lib/rspec-puppet.rb',
|
25
|
-
'LICENSE',
|
26
|
-
'Rakefile',
|
27
|
-
'README.md',
|
28
|
-
'rspec-puppet.gemspec',
|
29
|
-
'spec/classes/boolean_regexp_spec.rb',
|
30
|
-
'spec/classes/boolean_spec.rb',
|
31
|
-
'spec/classes/sysctl_common_spec.rb',
|
32
|
-
'spec/defines/sysctl_before_spec.rb',
|
33
|
-
'spec/defines/sysctl_spec.rb',
|
34
|
-
'spec/hosts/foo_spec.rb',
|
35
|
-
'spec/hosts/testhost_spec.rb',
|
36
|
-
'spec/fixtures/manifests/site.pp',
|
37
|
-
'spec/fixtures/modules/boolean/manifests/init.pp',
|
38
|
-
'spec/fixtures/modules/sysctl/manifests/init.pp',
|
39
|
-
'spec/functions/split_spec.rb',
|
40
|
-
'spec/spec_helper.rb',
|
41
|
-
]
|
42
|
-
|
43
|
-
s.add_dependency 'rspec'
|
44
|
-
|
45
|
-
s.authors = ['Tim Sharpe']
|
46
|
-
s.email = 'tim@sharpe.id.au'
|
47
|
-
end
|
@@ -1,10 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe 'boolean' do
|
4
|
-
let(:title) { 'bool.testing' }
|
5
|
-
let(:params) { { :bool => false } }
|
6
|
-
let(:message_re) { /bool is false/ }
|
7
|
-
|
8
|
-
it { should create_notify("bool testing").with_message(message_re) }
|
9
|
-
it { should_not create_notify("bool testing").with_message(/true/) }
|
10
|
-
end
|
@@ -1,11 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
if Puppet::PUPPETVERSION !~ /0\.2/
|
4
|
-
describe 'boolean' do
|
5
|
-
let(:title) { 'bool.testing' }
|
6
|
-
let(:params) { { :bool => false } }
|
7
|
-
|
8
|
-
it { should create_notify("bool testing")\
|
9
|
-
.with_message("This will print when \$bool is false.") }
|
10
|
-
end
|
11
|
-
end
|
@@ -1,40 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe 'sysctl::common' do
|
4
|
-
it { should contain_exec('sysctl/reload') \
|
5
|
-
.with_command('/sbin/sysctl -p /etc/sysctl.conf').with_returns([0, 2]) }
|
6
|
-
it { should_not create_augeas('foo') }
|
7
|
-
describe 'when using with to specify a hash of parameters' do
|
8
|
-
it 'should fail if the parameter is not contained in the resource' do
|
9
|
-
expect do
|
10
|
-
subject.should contain_exec('sysctl/reload').with('foo' => 'bar')
|
11
|
-
end.to raise_error(RSpec::Expectations::ExpectationNotMetError)
|
12
|
-
end
|
13
|
-
it 'should pass if the parameters are contained in the resource' do
|
14
|
-
subject.should contain_exec('sysctl/reload').with(
|
15
|
-
'refreshonly' => 'true',
|
16
|
-
'returns' => [0, 2]
|
17
|
-
)
|
18
|
-
end
|
19
|
-
end
|
20
|
-
describe 'when using without to specify parameter name(s)' do
|
21
|
-
it 'should pass if the parameter name is not contained in the resource' do
|
22
|
-
subject.should contain_exec('sysctl/reload').without('foo')
|
23
|
-
end
|
24
|
-
it 'should pass if the parameter names are not contained in the resource' do
|
25
|
-
subject.should contain_exec('sysctl/reload').without(['foo', 'bar'])
|
26
|
-
end
|
27
|
-
it 'should fail if any of the parameter names are contained in the resource' do
|
28
|
-
expect do
|
29
|
-
subject.should contain_exec('sysctl/reload').without(['foo', 'returns'])
|
30
|
-
end.to raise_error(RSpec::Expectations::ExpectationNotMetError)
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
describe 'sysctl::common' do
|
36
|
-
let(:params) { { :test_param => "yes" } }
|
37
|
-
|
38
|
-
it { should create_class("sysctl::common")\
|
39
|
-
.with_test_param("yes") }
|
40
|
-
end
|
@@ -1,26 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe 'sysctl::before' do
|
4
|
-
let(:title) { 'sysctl::before' }
|
5
|
-
let(:params) { { :value => "title" } }
|
6
|
-
|
7
|
-
it "Should raise an error about needing the sysctl::common class" do
|
8
|
-
expect { should create_notify("message-title")\
|
9
|
-
.with_message("This should print if the class is here first.") }\
|
10
|
-
.to raise_error(Puppet::Error, /Could not find resource 'Class\[Sysctl::Common\]/)
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
describe 'sysctl::before' do
|
15
|
-
let(:title) { 'test define' }
|
16
|
-
let(:pre_condition) {
|
17
|
-
[ '# we need sysctl common',
|
18
|
-
'class {"sysctl::common":}' ] }
|
19
|
-
let(:params) { { :value => "title" } }
|
20
|
-
|
21
|
-
it { should create_resource("sysctl::before", 'test define')\
|
22
|
-
.with_param(:value, "title") }
|
23
|
-
|
24
|
-
it { should include_class("sysctl::common") }
|
25
|
-
|
26
|
-
end
|
data/spec/defines/sysctl_spec.rb
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe 'sysctl' do
|
4
|
-
let(:title) { 'vm.swappiness' }
|
5
|
-
let(:params) { {:value => '60'} }
|
6
|
-
|
7
|
-
it { should include_class('sysctl::common') }
|
8
|
-
it { should create_augeas('sysctl/vm.swappiness') \
|
9
|
-
.with_context('/files/etc/sysctl.conf') \
|
10
|
-
.with_changes("set vm.swappiness '60'") \
|
11
|
-
.with_onlyif("match vm.swappiness[.='60'] size == 0") \
|
12
|
-
.with_notify('Exec[sysctl/reload]')\
|
13
|
-
.without_foo }
|
14
|
-
end
|
@@ -1,39 +0,0 @@
|
|
1
|
-
class sysctl::common ($test_param = 'yes') {
|
2
|
-
exec { 'sysctl/reload':
|
3
|
-
command => '/sbin/sysctl -p /etc/sysctl.conf',
|
4
|
-
refreshonly => true,
|
5
|
-
returns => [0, 2],
|
6
|
-
}
|
7
|
-
}
|
8
|
-
|
9
|
-
define sysctl($value) {
|
10
|
-
include sysctl::common
|
11
|
-
|
12
|
-
augeas { "sysctl/${name}":
|
13
|
-
context => '/files/etc/sysctl.conf',
|
14
|
-
changes => "set ${name} '${value}'",
|
15
|
-
onlyif => "match ${name}[.='${value}'] size == 0",
|
16
|
-
notify => Exec['sysctl/reload'],
|
17
|
-
}
|
18
|
-
}
|
19
|
-
|
20
|
-
class boolean($bool) {
|
21
|
-
$real_bool = $bool ? {
|
22
|
-
true => false,
|
23
|
-
false => true,
|
24
|
-
}
|
25
|
-
|
26
|
-
if ($real_bool) {
|
27
|
-
notify {"bool testing":
|
28
|
-
message => "This will print when \$bool is false."
|
29
|
-
}
|
30
|
-
}
|
31
|
-
}
|
32
|
-
|
33
|
-
define sysctl::before($value) {
|
34
|
-
Class['sysctl::common'] -> Sysctl::Before[$name]
|
35
|
-
|
36
|
-
notify {"message-${name}":
|
37
|
-
message => "This should print if the class is here first."
|
38
|
-
}
|
39
|
-
}
|
@@ -1,17 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe 'split' do
|
4
|
-
it { should run.with_params('aoeu', 'o').and_return(['a', 'eu']) }
|
5
|
-
it { should run.with_params('foo').and_raise_error(Puppet::ParseError) }
|
6
|
-
it { should_not run.with_params('foo').and_raise_error(Puppet::DevError) }
|
7
|
-
|
8
|
-
it 'something' do
|
9
|
-
if Integer(Puppet.version.split('.').first) >= 3
|
10
|
-
expected_error = ArgumentError
|
11
|
-
else
|
12
|
-
expected_error = Puppet::ParseError
|
13
|
-
end
|
14
|
-
|
15
|
-
expect { subject.call('foo') }.to raise_error(expected_error)
|
16
|
-
end
|
17
|
-
end
|
data/spec/hosts/foo_spec.rb
DELETED