fizzgig 0.2.0 → 0.2.1

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.
@@ -1,3 +1,12 @@
1
+ # 0.2.1
2
+
3
+ * Added support for evaluating nodes using Fizzgig.node(hostname)
4
+
5
+ # 0.2.0
6
+
7
+ * Changed function stubs to allow multi-arg functions. This broke
8
+ existing code, since single args need to be wrapped in an Array.
9
+
1
10
  # 0.1.1
2
11
 
3
12
  * fixed bug to allow multiple conditions on a matcher, eg:
data/TODO.org CHANGED
@@ -70,6 +70,9 @@ That's not so cool :(
70
70
 
71
71
  ** DONE Rename
72
72
  ** DONE functions with multiple arguments
73
+ ** DONE nodes
74
+ See govuk_nodes_spec_optional for examples of this.
75
+ the rspec-puppet equivalent is :type => :host
73
76
  ** TODO implementation-independent dependency assertions
74
77
  ** TODO Test standalone puppet modules
75
78
  ** TODO better test output for files with large content
@@ -82,6 +85,3 @@ maybe testing functions more generally?
82
85
  helpful here
83
86
  ** TODO Parameterized classes
84
87
  ** TODO Preconditions (do I actually want this?)
85
- ** TODO nodes
86
- See govuk_nodes_spec_optional for examples of this.
87
- the rspec-puppet equivalent is :type => :host
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'fizzgig'
3
- s.version = '0.2.0'
3
+ s.version = '0.2.1'
4
4
  s.homepage = 'https://github.com/philandstuff/fizzgig'
5
5
  s.summary = 'Tools for writing fast unit tests for Puppet'
6
6
  s.description = 'Tools for writing fast unit tests for Puppet'
@@ -23,8 +23,18 @@ module Fizzgig
23
23
  end
24
24
  end
25
25
 
26
- def self.make_compiler(facts)
27
- node = Puppet::Node.new('localhost')
26
+ def self.node(hostname,options = {})
27
+ LSpace.with(:function_stubs => options[:stubs]) do
28
+ setup_puppet
29
+ Puppet[:code] = '' # we want puppet to import the Puppet[:manifest] file
30
+ compiler = make_compiler(options[:facts], hostname)
31
+ compiler.send :evaluate_ast_node
32
+ compiler.catalog
33
+ end
34
+ end
35
+
36
+ def self.make_compiler(facts,hostname='localhost')
37
+ node = Puppet::Node.new(hostname)
28
38
  node.merge(facts) if facts
29
39
  compiler = Puppet::Parser::Compiler.new(node)
30
40
  compiler.send :set_node_parameters
@@ -50,6 +60,7 @@ module Fizzgig
50
60
  def self.setup_puppet
51
61
  Puppet[:code] = ' ' # hack to suppress puppet from looking at Puppet[:manifest]
52
62
  Puppet[:modulepath] = RSpec.configuration.modulepath
63
+ Puppet[:manifestdir] = RSpec.configuration.manifestdir
53
64
  # stop template() fn from complaining about missing vardir config
54
65
  Puppet[:vardir] ||= ""
55
66
  end
@@ -57,9 +68,9 @@ end
57
68
 
58
69
  RSpec.configure do |c|
59
70
  c.add_setting :modulepath, :default => '/etc/puppet/modules'
71
+ c.add_setting :manifestdir, :default => nil
60
72
 
61
73
  # FIXME: decide if these are needed
62
- #c.add_setting :manifestdir, :default => nil
63
74
  #c.add_setting :manifest, :default => nil
64
75
  #c.add_setting :template_dir, :default => nil
65
76
  #c.add_setting :config, :default => nil
@@ -112,4 +112,11 @@ describe Fizzgig do
112
112
  it { should contain_notify('qualified-fact-test').with_message('cse ungraded in metalwork') }
113
113
  end
114
114
  end
115
+
116
+ describe '#node' do
117
+ subject { Fizzgig.node('foo.com') }
118
+ it {
119
+ # require 'pp'; pp subject
120
+ should contain_nginx__site('foo.com') }
121
+ end
115
122
  end
@@ -0,0 +1,6 @@
1
+ node 'foo.com' {
2
+ nginx::site {'foo.com':}
3
+ }
4
+ node 'default' {
5
+ notify{'oops, default':}
6
+ }
@@ -5,6 +5,7 @@ HERE = File.expand_path(File.dirname(__FILE__))
5
5
 
6
6
  RSpec.configure do |c|
7
7
  c.modulepath = "#{File.join(HERE, 'modules')}:#{File.join(HERE, 'extra_modules')}"
8
+ c.manifestdir = File.join(HERE,'manifests')
8
9
 
9
10
  c.include Fizzgig::CatalogMatchers
10
11
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fizzgig
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -79,6 +79,7 @@ files:
79
79
  - spec/extra_modules/webapp/manifests/init.pp
80
80
  - spec/fizzgig/function_stubs_spec.rb
81
81
  - spec/fizzgig_spec.rb
82
+ - spec/manifests/site.pp
82
83
  - spec/modules/facts/manifests/class_test.pp
83
84
  - spec/modules/facts/manifests/define_test.pp
84
85
  - spec/modules/facts/templates/template-test.erb
@@ -120,6 +121,7 @@ test_files:
120
121
  - spec/extra_modules/webapp/manifests/init.pp
121
122
  - spec/fizzgig/function_stubs_spec.rb
122
123
  - spec/fizzgig_spec.rb
124
+ - spec/manifests/site.pp
123
125
  - spec/modules/facts/manifests/class_test.pp
124
126
  - spec/modules/facts/manifests/define_test.pp
125
127
  - spec/modules/facts/templates/template-test.erb