rspec-puppet 0.1.1 → 0.1.2

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.
data/README.md CHANGED
@@ -28,8 +28,12 @@ structure and naming convention.
28
28
  | +-- <define_name>_spec.rb
29
29
  |
30
30
  +-- functions
31
+ | |
32
+ | +-- <function_name>_spec.rb
33
+ |
34
+ +-- hosts
31
35
  |
32
- +-- <function_name>_spec.rb
36
+ +-- <host_name>_spec.rb
33
37
 
34
38
  ## Example groups
35
39
 
@@ -49,6 +53,10 @@ end
49
53
  describe 'myfunction', :type => :puppet_function do
50
54
  ...
51
55
  end
56
+
57
+ describe 'myhost.example.com', :type => :host do
58
+ ...
59
+ end
52
60
  ```
53
61
 
54
62
  ## Defined Types & Classes
@@ -2,6 +2,7 @@ require 'rspec-puppet/support'
2
2
  require 'rspec-puppet/example/define_example_group'
3
3
  require 'rspec-puppet/example/class_example_group'
4
4
  require 'rspec-puppet/example/function_example_group'
5
+ require 'rspec-puppet/example/host_example_group'
5
6
 
6
7
  RSpec::configure do |c|
7
8
  def c.escaped_path(*parts)
@@ -19,4 +20,8 @@ RSpec::configure do |c|
19
20
  c.include RSpec::Puppet::FunctionExampleGroup, :type => :puppet_function, :example_group => {
20
21
  :file_path => c.escaped_path(%w[spec functions])
21
22
  }
23
+
24
+ c.include RSpec::Puppet::HostExampleGroup, :type => :host, :example_group => {
25
+ :file_path => c.escaped_path(%w[spec hosts])
26
+ }
22
27
  end
@@ -0,0 +1,29 @@
1
+ module RSpec::Puppet
2
+ module HostExampleGroup
3
+ include RSpec::Puppet::ManifestMatchers
4
+ include RSpec::Puppet::Support
5
+
6
+ def subject
7
+ @catalogue ||= catalogue
8
+ end
9
+
10
+ def catalogue
11
+ Puppet[:modulepath] = self.respond_to?(:module_path) ? module_path : RSpec.configuration.module_path
12
+ Puppet[:manifestdir] = self.respond_to?(:manifest_dir) ? manifest_dir : RSpec.configuration.manifest_dir
13
+ Puppet[:manifest] = self.respond_to?(:manifest) ? manifest : RSpec.configuration.manifest
14
+ Puppet[:templatedir] = self.respond_to?(:template_dir) ? template_dir : RSpec.configuration.template_dir
15
+ Puppet[:code] = ""
16
+
17
+ nodename = self.class.top_level_description.downcase
18
+
19
+ facts_val = {
20
+ 'hostname' => nodename.split('.').first,
21
+ 'fqdn' => nodename,
22
+ 'domain' => nodename.split('.').last,
23
+ }
24
+ facts_val.merge!(munge_facts(facts)) if self.respond_to?(:facts)
25
+
26
+ build_catalog(nodename, facts_val)
27
+ end
28
+ end
29
+ end
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'rspec-puppet'
3
- s.version = '0.1.1'
3
+ s.version = '0.1.2'
4
4
  s.homepage = 'https://github.com/rodjek/rspec-puppet/'
5
5
  s.summary = 'RSpec tests for your Puppet manifests'
6
6
  s.description = 'RSpec tests for your Puppet manifests'
@@ -9,6 +9,7 @@ Gem::Specification.new do |s|
9
9
  'lib/rspec-puppet/example/class_example_group.rb',
10
10
  'lib/rspec-puppet/example/define_example_group.rb',
11
11
  'lib/rspec-puppet/example/function_example_group.rb',
12
+ 'lib/rspec-puppet/example/host_example_group.rb',
12
13
  'lib/rspec-puppet/example.rb',
13
14
  'lib/rspec-puppet/matchers/create_generic.rb',
14
15
  'lib/rspec-puppet/matchers/create_resource.rb',
@@ -26,8 +27,11 @@ Gem::Specification.new do |s|
26
27
  'spec/classes/sysctl_common_spec.rb',
27
28
  'spec/defines/sysctl_before_spec.rb',
28
29
  'spec/defines/sysctl_spec.rb',
29
- 'spec/fixtures/boolean/manifests/init.pp',
30
- 'spec/fixtures/sysctl/manifests/init.pp',
30
+ 'spec/hosts/foo_spec.rb',
31
+ 'spec/hosts/testhost_spec.rb',
32
+ 'spec/fixtures/manifests/site.pp',
33
+ 'spec/fixtures/modules/boolean/manifests/init.pp',
34
+ 'spec/fixtures/modules/sysctl/manifests/init.pp',
31
35
  'spec/functions/split_spec.rb',
32
36
  'spec/spec_helper.rb',
33
37
  ]
@@ -0,0 +1,7 @@
1
+ node default {
2
+ notify { 'test': }
3
+ }
4
+
5
+ node /testhost/ {
6
+ include sysctl::common
7
+ }
@@ -0,0 +1,6 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'foo.example.com' do
4
+ it { should_not include_class('sysctl::common') }
5
+ it { should contain_notify('test') }
6
+ end
@@ -0,0 +1,5 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'testhost' do
4
+ it { should include_class('sysctl::common') }
5
+ end
@@ -1,5 +1,6 @@
1
1
  require 'rspec-puppet'
2
2
 
3
3
  RSpec.configure do |c|
4
- c.module_path = File.join(File.dirname(File.expand_path(__FILE__)), 'fixtures')
4
+ c.module_path = File.join(File.dirname(File.expand_path(__FILE__)), 'fixtures', 'modules')
5
+ c.manifest_dir = File.join(File.dirname(File.expand_path(__FILE__)), 'fixtures', 'manifests')
5
6
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec-puppet
3
3
  version: !ruby/object:Gem::Version
4
- hash: 25
4
+ hash: 31
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 1
10
- version: 0.1.1
9
+ - 2
10
+ version: 0.1.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Tim Sharpe
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-01-20 00:00:00 Z
18
+ date: 2012-02-15 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: rspec
@@ -43,6 +43,7 @@ files:
43
43
  - lib/rspec-puppet/example/class_example_group.rb
44
44
  - lib/rspec-puppet/example/define_example_group.rb
45
45
  - lib/rspec-puppet/example/function_example_group.rb
46
+ - lib/rspec-puppet/example/host_example_group.rb
46
47
  - lib/rspec-puppet/example.rb
47
48
  - lib/rspec-puppet/matchers/create_generic.rb
48
49
  - lib/rspec-puppet/matchers/create_resource.rb
@@ -60,8 +61,11 @@ files:
60
61
  - spec/classes/sysctl_common_spec.rb
61
62
  - spec/defines/sysctl_before_spec.rb
62
63
  - spec/defines/sysctl_spec.rb
63
- - spec/fixtures/boolean/manifests/init.pp
64
- - spec/fixtures/sysctl/manifests/init.pp
64
+ - spec/hosts/foo_spec.rb
65
+ - spec/hosts/testhost_spec.rb
66
+ - spec/fixtures/manifests/site.pp
67
+ - spec/fixtures/modules/boolean/manifests/init.pp
68
+ - spec/fixtures/modules/sysctl/manifests/init.pp
65
69
  - spec/functions/split_spec.rb
66
70
  - spec/spec_helper.rb
67
71
  homepage: https://github.com/rodjek/rspec-puppet/