puppet-retrospec 0.5.1 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/VERSION +1 -1
- data/bin/retrospec +2 -5
- data/lib/retrospec.rb +41 -45
- data/lib/retrospec/exceptions.rb +4 -0
- data/lib/retrospec/puppet_module.rb +163 -0
- data/lib/retrospec/resource.rb +2 -3
- data/lib/retrospec/spec_object.rb +37 -0
- data/lib/retrospec/templates/gemfile.erb +12 -10
- data/lib/retrospec/templates/nodesets/centos-66-x64.yml +11 -0
- data/lib/retrospec/templates/rakefile.erb +3 -0
- data/lib/retrospec/templates/resource_spec_file.erb +3 -3
- data/lib/retrospec/templates/spec_helper_file.erb +1 -0
- data/lib/retrospec/templates/travis.yml.erb +14 -0
- data/lib/retrospec/type_code.rb +14 -2
- data/lib/retrospec/variable_store.rb +70 -9
- data/lib/retrospec/version.rb +1 -1
- data/puppet-retrospec.gemspec +14 -7
- data/spec/fixtures/fixture_modules/one_resource_module/manifests/{another_resource_class.pp → another_resource.pp} +4 -3
- data/spec/fixtures/fixture_modules/one_resource_module/manifests/inherits_params.pp +8 -0
- data/spec/fixtures/fixture_modules/one_resource_module/manifests/params.pp +19 -0
- data/spec/integration/retrospec_spec.rb +36 -0
- data/spec/unit/conditional_spec.rb +41 -23
- data/spec/unit/module_spec.rb +55 -0
- data/spec/unit/puppet-retrospec_spec.rb +15 -22
- data/spec/unit/resource_spec.rb +46 -38
- data/spec/unit/type_code_spec.rb +37 -19
- data/spec/unit/variable_store_spec.rb +72 -16
- metadata +40 -33
- data/lib/retrospec/module_utilities.rb +0 -80
- data/lib/retrospec/templates/nodesets/centos-65-x64.yml +0 -10
@@ -6,6 +6,9 @@ require 'puppet-syntax/tasks/puppet-syntax'
|
|
6
6
|
# on Travis with --without development
|
7
7
|
begin
|
8
8
|
require 'puppet_blacksmith/rake_tasks'
|
9
|
+
Blacksmith::RakeTask.new do |t|
|
10
|
+
t.tag_pattern = "v%s" # Use a custom pattern with git tag. %s is replaced with the version number.
|
11
|
+
end
|
9
12
|
rescue LoadError
|
10
13
|
end
|
11
14
|
|
@@ -10,7 +10,7 @@ describe '<%= @type.name -%>' do
|
|
10
10
|
#include_context :hiera
|
11
11
|
|
12
12
|
<%- if @type.type == :definition -%>
|
13
|
-
let(:title) { '
|
13
|
+
let(:title) { 'XXreplace_meXX' }
|
14
14
|
<%- end -%>
|
15
15
|
|
16
16
|
# below is the facts hash that gives you the ability to mock
|
@@ -28,7 +28,7 @@ describe '<%= @type.name -%>' do
|
|
28
28
|
<%- if v.nil? -%>
|
29
29
|
<%= ":#{k} => 'place_value_here'," %>
|
30
30
|
<%- else -%>
|
31
|
-
<%= "#:#{k} => #{v}," %>
|
31
|
+
<%= "#:#{k} => #{variable_value(v)}," %>
|
32
32
|
<%- end -%>
|
33
33
|
<%- end -%>
|
34
34
|
}
|
@@ -38,7 +38,7 @@ describe '<%= @type.name -%>' do
|
|
38
38
|
# Puppet::Util::Log.newdestination(:console)
|
39
39
|
<%- @resources.each do |res| -%>
|
40
40
|
it do
|
41
|
-
|
41
|
+
is_expected.to contain_<%= res.type.gsub('::', '__')%>('<%= res.title %>').
|
42
42
|
with(<%= res.parameters.to_s.gsub(/\",/, "\",\n ") %>)
|
43
43
|
end
|
44
44
|
<%- end -%>
|
@@ -0,0 +1,14 @@
|
|
1
|
+
branches:
|
2
|
+
script: "bundle exec rake spec SPEC_OPTS='--format documentation'"
|
3
|
+
bundler_args: --without development
|
4
|
+
|
5
|
+
rvm:
|
6
|
+
- 1.9.3
|
7
|
+
- 2.0.0
|
8
|
+
- 2.1.5
|
9
|
+
- 2.2.0
|
10
|
+
env:
|
11
|
+
matrix:
|
12
|
+
- PUPPET_GEM_VERSION="~> 3.2"
|
13
|
+
- PUPPET_GEM_VERSION="~> 3.7"
|
14
|
+
|
data/lib/retrospec/type_code.rb
CHANGED
@@ -1,12 +1,24 @@
|
|
1
|
+
require 'retrospec/puppet_module'
|
2
|
+
require 'retrospec/variable_store'
|
3
|
+
require 'retrospec/exceptions'
|
4
|
+
|
1
5
|
class TypeCode
|
2
|
-
attr_reader :type, :variables, :scope_name
|
6
|
+
attr_reader :type, :variables, :scope_name, :parent, :name
|
3
7
|
|
4
8
|
#TODO figure out how to store vardef statements that are contained inside conditional blocks
|
5
9
|
def initialize(type)
|
6
|
-
|
10
|
+
raise TypeNotFoundException unless type
|
11
|
+
@scope_name = type.namespace
|
12
|
+
@name = type.name
|
7
13
|
@type = type
|
14
|
+
@parent = type.parent
|
15
|
+
end
|
16
|
+
# need to figure out a way to load the parent or dependent manfifests
|
17
|
+
def has_parent?
|
18
|
+
@parent.nil?
|
8
19
|
end
|
9
20
|
|
21
|
+
# returns a list of variables found in the main code block
|
10
22
|
def variables
|
11
23
|
if @type.code.respond_to?(:find_all)
|
12
24
|
@variables ||= @type.code.find_all {|i| i.instance_of?(Puppet::Parser::AST::VarDef) }
|
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'singleton'
|
2
2
|
require 'retrospec/type_code'
|
3
|
+
require 'logger'
|
3
4
|
|
4
5
|
class VariableStore
|
5
6
|
attr_reader :store
|
@@ -8,6 +9,9 @@ class VariableStore
|
|
8
9
|
|
9
10
|
def initialize
|
10
11
|
@store = {}
|
12
|
+
# a defined type will sometimes use the name variable within other variables
|
13
|
+
# so we need to setup a name to reference
|
14
|
+
@store['$name'] = 'XXreplace_meXX'
|
11
15
|
end
|
12
16
|
|
13
17
|
def self.instance
|
@@ -17,7 +21,13 @@ class VariableStore
|
|
17
21
|
# key should be a variable starting with $
|
18
22
|
# enable_value_conversion converts the value to a string
|
19
23
|
def self.add(key, value, enable_value_conversion=true)
|
20
|
-
|
24
|
+
if key.respond_to?(:value)
|
25
|
+
key = key.value
|
26
|
+
end
|
27
|
+
# the key name must always be the same and look like $key_name or $key_name::other::name
|
28
|
+
key = "#{'$' + key.to_s}" unless key.to_s.start_with?('$')
|
29
|
+
key = key.to_s.gsub('$::', '$') if key.to_s.start_with?('$::') # sometimes variables start with $::
|
30
|
+
#return if instance.store[key] == value
|
21
31
|
if value.instance_of?(String) or value.instance_of?(Puppet::Parser::AST::String)
|
22
32
|
value = value.to_s.gsub("\"",'')
|
23
33
|
end
|
@@ -30,24 +40,36 @@ class VariableStore
|
|
30
40
|
|
31
41
|
# lookup the key in the hash, if we dont' find it lets just return the string representation
|
32
42
|
def self.lookup(key)
|
43
|
+
if key.respond_to?(:value)
|
44
|
+
key = key.value
|
45
|
+
end
|
33
46
|
key = "$#{key.to_s}" unless key.to_s.start_with?('$')
|
47
|
+
key = key.gsub('$::', '$') if key.to_s.start_with?('$::') # sometimes variables start with $::
|
48
|
+
#puts "Looking up: #{key}"
|
34
49
|
begin
|
35
50
|
value = VariableStore.instance.store.fetch(key.to_s)
|
36
51
|
# try and resolve if necessary
|
37
52
|
if [Puppet::Parser::AST::Variable,Puppet::Parser::AST::VarDef].include?(value.class)
|
38
53
|
value = resolve(value)
|
54
|
+
else
|
55
|
+
if captures = value.scan(/(\$[::]?[\w+::]*\w+)/).flatten
|
56
|
+
# produces an array of variables that have not been resolved yet
|
57
|
+
# ["$concat1", "$concat"] = "$concat1/test3183/$concat"
|
58
|
+
captures.each { |c| value.gsub(c, resolve(c))}
|
59
|
+
end
|
39
60
|
end
|
40
61
|
rescue
|
41
62
|
return key
|
42
63
|
end
|
43
64
|
value
|
44
65
|
end
|
45
|
-
|
66
|
+
# the problem is that when it tries to lookup file name pieces it doesn't have the namespace
|
67
|
+
# ie. $file_name/test3183/$some_var
|
46
68
|
def self.variable_resolution(variable)
|
47
69
|
res = nil
|
48
70
|
if variable.instance_of? Puppet::Parser::AST::VarDef
|
49
71
|
res = lookup(variable.name.value)
|
50
|
-
add(variable.name, variable.value,false) unless res.nil?
|
72
|
+
#add(variable.name, variable.value,false) unless res.nil?
|
51
73
|
elsif variable.instance_of?(Puppet::Parser::AST::Variable)
|
52
74
|
res = lookup(variable.value)
|
53
75
|
elsif variable.instance_of?(Puppet::Parser::AST::Concat)
|
@@ -60,10 +82,10 @@ class VariableStore
|
|
60
82
|
# I give up, I can't find the variable value so will just assign the variable name
|
61
83
|
res = variable.to_s
|
62
84
|
end
|
63
|
-
|
85
|
+
unless res.nil?
|
64
86
|
if variable.instance_of?(Puppet::Parser::AST::Variable)
|
65
|
-
|
66
|
-
add(variable, res)
|
87
|
+
unless res = lookup(variable.to_s)
|
88
|
+
#add(variable.to_s, res)
|
67
89
|
end
|
68
90
|
end
|
69
91
|
end
|
@@ -75,8 +97,47 @@ class VariableStore
|
|
75
97
|
res = variable_resolution(variable)
|
76
98
|
end
|
77
99
|
|
78
|
-
# gets all the variables and passes them through the resolve function to populate the variable store
|
79
|
-
|
80
|
-
|
100
|
+
# gets all the variables and parameters and passes them through the resolve function to populate the variable store
|
101
|
+
# we use recursion to evaluate inherited manifests
|
102
|
+
# TODO use the same recursion method to evaluate included manifests
|
103
|
+
def self.populate(type, is_parent=false)
|
104
|
+
if type.parent
|
105
|
+
p = type.parent.gsub(/\A::/, '')
|
106
|
+
parent = type.resource_type_collection.hostclasses[p]
|
107
|
+
else
|
108
|
+
parent = nil
|
109
|
+
end
|
110
|
+
if parent
|
111
|
+
# type has a parent and we want to add the parent variables first so we call populate first
|
112
|
+
# then we load the type's variable
|
113
|
+
populate(parent,true)
|
114
|
+
# we load the local scope and top scope variables because we need access to both
|
115
|
+
# there is a chance some of the local scope variables will be overwritten but by the time that happens
|
116
|
+
# we won't need them anymore.
|
117
|
+
type.arguments.each do |k,v|
|
118
|
+
# store the class params
|
119
|
+
add(k.to_s,resolve(v),true)
|
120
|
+
add(("$#{type.namespace}::" << k.to_s),resolve(v),true)
|
121
|
+
end
|
122
|
+
TypeCode.new(type).variables.each do |v|
|
123
|
+
add(v.name.to_s, resolve(v.value))
|
124
|
+
add(("$#{type.namespace}::" << v.name.to_s), resolve(v.value))
|
125
|
+
end
|
126
|
+
elsif is_parent
|
127
|
+
# if this is the parent we load the variables
|
128
|
+
type.arguments.each {|k,v| add(("$#{type.namespace}::" << k.to_s),resolve(v),true)}
|
129
|
+
TypeCode.new(type).variables.each {|v| add(("$#{type.namespace}::" << v.name.to_s), resolve(v.value))}
|
130
|
+
else
|
131
|
+
# if the type does not have a parent we load the variables
|
132
|
+
type.arguments.each do |k,v|
|
133
|
+
# store the class params
|
134
|
+
add(k.to_s,resolve(v),true)
|
135
|
+
add(("$#{type.namespace}::" << k.to_s),resolve(v),true)
|
136
|
+
end
|
137
|
+
TypeCode.new(type).variables.each do |v|
|
138
|
+
add(v.name.to_s, resolve(v.value))
|
139
|
+
add(("$#{type.namespace}::" << v.name.to_s), resolve(v.value))
|
140
|
+
end
|
141
|
+
end
|
81
142
|
end
|
82
143
|
end
|
data/lib/retrospec/version.rb
CHANGED
data/puppet-retrospec.gemspec
CHANGED
@@ -2,16 +2,16 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: puppet-retrospec 0.
|
5
|
+
# stub: puppet-retrospec 0.6.0 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "puppet-retrospec"
|
9
|
-
s.version = "0.
|
9
|
+
s.version = "0.6.0"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib"]
|
13
13
|
s.authors = ["Corey Osman"]
|
14
|
-
s.date = "2015-
|
14
|
+
s.date = "2015-03-25"
|
15
15
|
s.description = "Retrofits and generates valid puppet rspec test code to existing modules"
|
16
16
|
s.email = "corey@logicminds.biz"
|
17
17
|
s.executables = ["retrospec"]
|
@@ -31,16 +31,18 @@ Gem::Specification.new do |s|
|
|
31
31
|
"bin/retrospec",
|
32
32
|
"lib/retrospec.rb",
|
33
33
|
"lib/retrospec/conditional.rb",
|
34
|
+
"lib/retrospec/exceptions.rb",
|
34
35
|
"lib/retrospec/helpers.rb",
|
35
|
-
"lib/retrospec/
|
36
|
+
"lib/retrospec/puppet_module.rb",
|
36
37
|
"lib/retrospec/resource.rb",
|
38
|
+
"lib/retrospec/spec_object.rb",
|
37
39
|
"lib/retrospec/templates/acceptance_spec_test.erb",
|
38
40
|
"lib/retrospec/templates/fixtures_file.erb",
|
39
41
|
"lib/retrospec/templates/gemfile.erb",
|
40
42
|
"lib/retrospec/templates/nodesets/centos-59-x64.yml",
|
41
43
|
"lib/retrospec/templates/nodesets/centos-64-x64-pe.yml",
|
42
44
|
"lib/retrospec/templates/nodesets/centos-64-x64.yml",
|
43
|
-
"lib/retrospec/templates/nodesets/centos-
|
45
|
+
"lib/retrospec/templates/nodesets/centos-66-x64.yml",
|
44
46
|
"lib/retrospec/templates/nodesets/debian-607-x64.yml",
|
45
47
|
"lib/retrospec/templates/nodesets/debian-70rc1-x64.yml",
|
46
48
|
"lib/retrospec/templates/nodesets/debian-73-i386.yml",
|
@@ -57,18 +59,23 @@ Gem::Specification.new do |s|
|
|
57
59
|
"lib/retrospec/templates/shared_context.erb",
|
58
60
|
"lib/retrospec/templates/spec_helper_acceptance.rb.erb",
|
59
61
|
"lib/retrospec/templates/spec_helper_file.erb",
|
62
|
+
"lib/retrospec/templates/travis.yml.erb",
|
60
63
|
"lib/retrospec/type_code.rb",
|
61
64
|
"lib/retrospec/variable_store.rb",
|
62
65
|
"lib/retrospec/version.rb",
|
63
66
|
"puppet-retrospec.gemspec",
|
64
|
-
"spec/fixtures/fixture_modules/one_resource_module/manifests/
|
67
|
+
"spec/fixtures/fixture_modules/one_resource_module/manifests/another_resource.pp",
|
68
|
+
"spec/fixtures/fixture_modules/one_resource_module/manifests/inherits_params.pp",
|
65
69
|
"spec/fixtures/fixture_modules/one_resource_module/manifests/one_resource_class.pp",
|
70
|
+
"spec/fixtures/fixture_modules/one_resource_module/manifests/params.pp",
|
66
71
|
"spec/fixtures/fixture_modules/zero_resource_module/manifests/empty_class.pp",
|
67
72
|
"spec/fixtures/fixture_modules/zero_resource_module/manifests/not_a_resource_defination.pp",
|
68
73
|
"spec/fixtures/manifests/includes-class.pp",
|
69
74
|
"spec/fixtures/manifests/includes-defines.pp",
|
75
|
+
"spec/integration/retrospec_spec.rb",
|
70
76
|
"spec/spec_helper.rb",
|
71
77
|
"spec/unit/conditional_spec.rb",
|
78
|
+
"spec/unit/module_spec.rb",
|
72
79
|
"spec/unit/puppet-retrospec_spec.rb",
|
73
80
|
"spec/unit/resource_spec.rb",
|
74
81
|
"spec/unit/type_code_spec.rb",
|
@@ -76,7 +83,7 @@ Gem::Specification.new do |s|
|
|
76
83
|
]
|
77
84
|
s.homepage = "http://github.com/logicminds/puppet-retrospec"
|
78
85
|
s.licenses = ["MIT"]
|
79
|
-
s.rubygems_version = "2.4.
|
86
|
+
s.rubygems_version = "2.4.4"
|
80
87
|
s.summary = "Generates puppet rspec test code based on the classes and defines inside the manifests directory. Aims to reduce some of the boilerplate coding with default test patterns."
|
81
88
|
|
82
89
|
if s.respond_to? :specification_version then
|
@@ -2,13 +2,14 @@ class one_resource::another_resource(
|
|
2
2
|
$var1 = 'value1',
|
3
3
|
$var2 = 'value2',
|
4
4
|
$file_name = '/tmp/test3',
|
5
|
-
$config_base_path = '/etc/hammer'
|
5
|
+
$config_base_path = '/etc/hammer',
|
6
|
+
$config_set = $one_resource::params::param1_var1,
|
6
7
|
|
7
|
-
){
|
8
|
+
) inherits one_resource::params {
|
8
9
|
$some_var = "oohhhh"
|
9
10
|
$concat_var = "${file_name}/test3183/${some_var}"
|
10
11
|
$cli_modules = "${config_base_path}/cli.modules.d"
|
11
|
-
|
12
|
+
$inherited_variable = $one_resource::params::var1
|
12
13
|
file{'/tmp/test2':
|
13
14
|
ensure => present,
|
14
15
|
}
|
@@ -0,0 +1,19 @@
|
|
1
|
+
class one_resource::params(
|
2
|
+
$param1_var1 = 'param1_value'
|
3
|
+
){
|
4
|
+
$var1 = 'params_class_value1'
|
5
|
+
$var2 = 'value2'
|
6
|
+
|
7
|
+
case $::osfamily{
|
8
|
+
'windows': {
|
9
|
+
$osfamily_var = 'windows'
|
10
|
+
}
|
11
|
+
'redhat': {
|
12
|
+
$osfamily_var = 'redhat'
|
13
|
+
}
|
14
|
+
default: {
|
15
|
+
$osfamily_var = 'default'
|
16
|
+
}
|
17
|
+
|
18
|
+
}
|
19
|
+
}
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "variable_store" do
|
4
|
+
|
5
|
+
# after :all do
|
6
|
+
# # enabling the removal slows down tests, but from time to time we may need to
|
7
|
+
# FileUtils.rm_rf(fixture_modules_path) if ENV['RETROSPEC_CLEAN_UP_TEST_MODULES'] =~ /true/
|
8
|
+
# end
|
9
|
+
#
|
10
|
+
# before :all do
|
11
|
+
# #enabling the removal of real modules slows down tests, but from time to time we may need to
|
12
|
+
# FileUtils.rm_rf(fixture_modules_path) if ENV['RETROSPEC_CLEAN_UP_TEST_MODULES'] =~ /true/
|
13
|
+
# install_module('puppetlabs-tomcat')
|
14
|
+
# @path = File.join(fixture_modules_path, 'tomcat')
|
15
|
+
# @bin_path = File.expand_path(File.join('/Users/cosman/bodeco/puppet-retrospec', 'bin', 'retrospec'))
|
16
|
+
#
|
17
|
+
# end
|
18
|
+
#
|
19
|
+
# before :each do
|
20
|
+
# clean_up_spec_dir("#{@path}/spec")
|
21
|
+
# @opts = {:module_path => @path, :enable_beaker_tests => false,
|
22
|
+
# :enable_user_templates => false, :template_dir => nil }
|
23
|
+
# end
|
24
|
+
#
|
25
|
+
# it 'should create files without error' do
|
26
|
+
# `#{@bin_path} #{@path}`
|
27
|
+
# expect(File.exists?(File.join(@path, 'Gemfile'))).to eq(true)
|
28
|
+
# expect(File.exists?(File.join(@path, 'Rakefile'))).to eq(true)
|
29
|
+
# expect(File.exists?(File.join(@path, 'spec', 'shared_contexts.rb'))).to eq(true)
|
30
|
+
# expect(File.exists?(File.join(@path, '.fixtures.yml'))).to eq(true)
|
31
|
+
# expect(File.exists?(File.join(@path, 'spec','classes','tomcat_spec.rb'))).to eq(true)
|
32
|
+
# #clean_up_spec_dir(@path)
|
33
|
+
#
|
34
|
+
# end
|
35
|
+
|
36
|
+
end
|
@@ -1,6 +1,10 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe "conditional" do
|
4
|
+
|
5
|
+
|
6
|
+
|
7
|
+
|
4
8
|
after :all do
|
5
9
|
# enabling the removal slows down tests, but from time to time we may need to
|
6
10
|
FileUtils.rm_rf(fixture_modules_path) if ENV['RETROSPEC_CLEAN_UP_TEST_MODULES'] =~ /true/
|
@@ -11,33 +15,47 @@ describe "conditional" do
|
|
11
15
|
FileUtils.rm_rf(fixture_modules_path) if ENV['RETROSPEC_CLEAN_UP_TEST_MODULES'] =~ /true/
|
12
16
|
end
|
13
17
|
|
14
|
-
before :each do
|
15
|
-
my_path = File.expand_path(File.join('spec', 'fixtures', 'fixture_modules', 'one_resource_module'))
|
16
|
-
my_retro = Retrospec.new(my_path)
|
17
|
-
@test_type = my_retro.types.find {|x| x.name == 'one_resource::another_resource'}
|
18
|
-
Resource.all(@test_type)
|
19
|
-
conds = Conditional.find_conditionals(@test_type)
|
20
|
-
@con = Conditional.new(conds.first, @test_type.arguments)
|
21
|
-
end
|
22
18
|
|
23
|
-
|
24
|
-
|
25
|
-
|
19
|
+
describe 'one resource module' do
|
20
|
+
|
21
|
+
let(:instance) {Utilities::PuppetModule.send :new}
|
26
22
|
|
23
|
+
it 'should initialize ' do
|
24
|
+
my_path = File.expand_path(File.join('spec', 'fixtures', 'fixture_modules', 'one_resource_module'))
|
25
|
+
m = instance
|
26
|
+
m.module_path =my_path
|
27
|
+
m.create_tmp_module_path(my_path)
|
28
|
+
test_type = m.types.find {|x| x.name == 'one_resource::another_resource'}
|
29
|
+
Resource.all(test_type)
|
30
|
+
conds = Conditional.find_conditionals(test_type)
|
31
|
+
con = Conditional.new(conds.first, test_type.arguments)
|
32
|
+
expect(con.class).to eq(Conditional)
|
33
|
+
end
|
27
34
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
+
it 'should generate conditional resources' do
|
36
|
+
my_path = File.expand_path(File.join('spec', 'fixtures', 'fixture_modules', 'one_resource_module'))
|
37
|
+
m = instance
|
38
|
+
m.module_path =my_path
|
39
|
+
m.create_tmp_module_path(my_path)
|
40
|
+
test_type = m.types.find {|x| x.name == 'one_resource::another_resource'}
|
41
|
+
VariableStore.populate(test_type)
|
42
|
+
r = Conditional.all(test_type)
|
43
|
+
expect(r.length).to eq(1)
|
44
|
+
expect(r[0].parameters).to eq({"ensure"=>"present"})
|
45
|
+
expect(r[0].title).to eq("/tmp/test3/3")
|
46
|
+
expect(r[0].type).to eq("file")
|
47
|
+
end
|
35
48
|
end
|
36
49
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
50
|
+
describe 'zero module' do
|
51
|
+
let(:instance) {Utilities::PuppetModule.send :new}
|
52
|
+
it 'should respond correctly when class is empty' do
|
53
|
+
my_path = File.expand_path(File.join('spec', 'fixtures', 'fixture_modules', 'zero_resource_module'))
|
54
|
+
m = instance
|
55
|
+
m.module_path = my_path
|
56
|
+
m.create_tmp_module_path(my_path)
|
57
|
+
test_type = m.types.find {|x| x.name == 'empty_class'}
|
58
|
+
expect{Conditional.all(test_type)}.to_not raise_error
|
59
|
+
end
|
42
60
|
end
|
43
61
|
end
|