puppet-retrospec 0.5.1 → 0.6.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.
Files changed (32) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +2 -2
  3. data/VERSION +1 -1
  4. data/bin/retrospec +2 -5
  5. data/lib/retrospec.rb +41 -45
  6. data/lib/retrospec/exceptions.rb +4 -0
  7. data/lib/retrospec/puppet_module.rb +163 -0
  8. data/lib/retrospec/resource.rb +2 -3
  9. data/lib/retrospec/spec_object.rb +37 -0
  10. data/lib/retrospec/templates/gemfile.erb +12 -10
  11. data/lib/retrospec/templates/nodesets/centos-66-x64.yml +11 -0
  12. data/lib/retrospec/templates/rakefile.erb +3 -0
  13. data/lib/retrospec/templates/resource_spec_file.erb +3 -3
  14. data/lib/retrospec/templates/spec_helper_file.erb +1 -0
  15. data/lib/retrospec/templates/travis.yml.erb +14 -0
  16. data/lib/retrospec/type_code.rb +14 -2
  17. data/lib/retrospec/variable_store.rb +70 -9
  18. data/lib/retrospec/version.rb +1 -1
  19. data/puppet-retrospec.gemspec +14 -7
  20. data/spec/fixtures/fixture_modules/one_resource_module/manifests/{another_resource_class.pp → another_resource.pp} +4 -3
  21. data/spec/fixtures/fixture_modules/one_resource_module/manifests/inherits_params.pp +8 -0
  22. data/spec/fixtures/fixture_modules/one_resource_module/manifests/params.pp +19 -0
  23. data/spec/integration/retrospec_spec.rb +36 -0
  24. data/spec/unit/conditional_spec.rb +41 -23
  25. data/spec/unit/module_spec.rb +55 -0
  26. data/spec/unit/puppet-retrospec_spec.rb +15 -22
  27. data/spec/unit/resource_spec.rb +46 -38
  28. data/spec/unit/type_code_spec.rb +37 -19
  29. data/spec/unit/variable_store_spec.rb +72 -16
  30. metadata +40 -33
  31. data/lib/retrospec/module_utilities.rb +0 -80
  32. data/lib/retrospec/templates/nodesets/centos-65-x64.yml +0 -10
@@ -0,0 +1,55 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'Utilities::Module' do
4
+
5
+ before :each do
6
+ clean_up_spec_dir(@path)
7
+ @opts = {:module_path => @path, :enable_beaker_tests => false,
8
+ :enable_user_templates => false, :template_dir => nil }
9
+ @module = Utilities::PuppetModule.instance
10
+ @module.module_path = @opts[:module_path]
11
+
12
+ end
13
+
14
+ before :all do
15
+ # enabling the removal of real modules slows down tests, but from time to time we may need to
16
+ FileUtils.rm_rf(fixture_modules_path) if ENV['RETROSPEC_CLEAN_UP_TEST_MODULES'] =~ /true/
17
+ install_module('puppetlabs-tomcat')
18
+ @path = File.join(fixture_modules_path, 'tomcat')
19
+ end
20
+
21
+ it 'should create an instance' do
22
+ expect(@module).to be_instance_of(Utilities::PuppetModule)
23
+ end
24
+
25
+ it 'should create tmp module path' do
26
+ expect(File.exists?(@module.tmp_modules_dir)).to be true
27
+ end
28
+
29
+ it 'should create a temp modules dir' do
30
+ tomcat_path = Utilities::PuppetModule.create_tmp_module_path
31
+ expect(tomcat_path).to match(/modules/)
32
+ end
33
+
34
+ it 'should create a temp modules dir' do
35
+ tomcat_path = @module.create_tmp_module_path(@opts[:module_path])
36
+ expect(tomcat_path).to match(/modules/)
37
+ expect(File.exists?(tomcat_path)).to be true
38
+ end
39
+
40
+ it 'should set the module path' do
41
+ expect(@module.module_path).to eq(@opts[:module_path])
42
+ end
43
+
44
+ it 'should create a link in the temp modules directory' do
45
+ tmp_path = @module.create_tmp_module_path(@opts[:module_path])
46
+ expect(File.exists?(tmp_path)).to eq(true)
47
+ expect(tmp_path).to eq(File.join(@module.tmp_modules_dir, @module.module_name))
48
+ end
49
+
50
+ it 'should find types' do
51
+ expect(@module.types).to be_instance_of(Array)
52
+ expect(@module.types.map {|t| t.name}.length).to eq(14)
53
+ end
54
+
55
+ end
@@ -10,7 +10,7 @@ describe "puppet-retrospec" do
10
10
  end
11
11
 
12
12
  before :all do
13
- # enabling the removal of real modules slows down tests, but from time to time we may need to
13
+ #enabling the removal of real modules slows down tests, but from time to time we may need to
14
14
  FileUtils.rm_rf(fixture_modules_path) if ENV['RETROSPEC_CLEAN_UP_TEST_MODULES'] =~ /true/
15
15
  install_module('puppetlabs-tomcat')
16
16
  @path = File.join(fixture_modules_path, 'tomcat')
@@ -18,15 +18,22 @@ describe "puppet-retrospec" do
18
18
  end
19
19
 
20
20
  before :each do
21
- #clean_up_spec_dir(@path)
21
+ clean_up_spec_dir(@path)
22
22
  @opts = {:module_path => @path, :enable_beaker_tests => false,
23
23
  :enable_user_templates => false, :template_dir => nil }
24
24
  end
25
25
 
26
26
  it 'should run without errors using new' do
27
+ tomcat = Retrospec.new(@opts[:module_path], @opts)
28
+ expect(tomcat).to be_instance_of(Retrospec)
29
+ end
30
+
31
+ it 'should create files without error' do
27
32
  tomcat = Retrospec.new(@opts[:module_path], @opts)
28
33
  expect(tomcat.create_files).to eq(true)
29
34
  expect(File.exists?(File.join(@path, 'Gemfile'))).to eq(true)
35
+ expect(File.exists?(File.join(@path, 'Rakefile'))).to eq(true)
36
+ expect(File.exists?(File.join(@path, 'spec', 'shared_contexts.rb'))).to eq(true)
30
37
  expect(File.exists?(File.join(@path, '.fixtures.yml'))).to eq(true)
31
38
  expect(File.exists?(File.join(@path, 'spec','classes','tomcat_spec.rb'))).to eq(true)
32
39
  end
@@ -116,7 +123,7 @@ describe "puppet-retrospec" do
116
123
  it 'should create proper spec helper file' do
117
124
  tomcat = Retrospec.new(@opts[:module_path], @opts)
118
125
  filepath = File.expand_path(File.join(@path, 'spec', 'spec_helper.rb'))
119
- path = tomcat.create_tmp_module_path(@opts[:module_path])
126
+ path = tomcat.module_path
120
127
  tomcat.safe_create_spec_helper
121
128
  expect(File.exists?(filepath)).to eq(true)
122
129
  end
@@ -124,7 +131,7 @@ describe "puppet-retrospec" do
124
131
  it 'should create proper shared context file' do
125
132
  tomcat = Retrospec.new(@opts[:module_path], @opts)
126
133
  filepath = File.expand_path(File.join(@path, 'spec', 'shared_contexts.rb'))
127
- path = tomcat.create_tmp_module_path(@opts[:module_path])
134
+ path = tomcat.module_path
128
135
  tomcat.safe_make_shared_context
129
136
  expect(File.exists?(filepath)).to eq(true)
130
137
  end
@@ -172,20 +179,6 @@ describe "puppet-retrospec" do
172
179
  Helpers.should_not_receive(:safe_create_file).with(anything,'resource_spec_file.erb')
173
180
  end
174
181
 
175
- it 'should create a temp modules dir' do
176
- tomcat = Retrospec.new(@opts[:module_path], @opts)
177
- path = tomcat.tmp_modules_dir
178
- path.should =~ /modules/
179
- end
180
-
181
- it 'should create a link in the temp modules directory' do
182
- tomcat = Retrospec.new(@opts[:module_path], @opts)
183
- path = tomcat.tmp_modules_dir
184
- tmp_path = tomcat.create_tmp_module_path(@opts[:module_path])
185
- expect(File.exists?(tmp_path)).to eq(true)
186
- expect(tmp_path).to eq(File.join(path, tomcat.module_name))
187
- end
188
-
189
182
  it 'should create a file from a template' do
190
183
  tomcat = Retrospec.new(@opts[:module_path], @opts)
191
184
  tomcat.safe_create_template_file('.fixtures.yml', 'fixtures_file.erb')
@@ -201,14 +194,14 @@ describe "puppet-retrospec" do
201
194
  allow(type).to receive(:type).and_return(:hostclass)
202
195
  allow(type).to receive(:name).and_return('tomcat::config::server::connector')
203
196
  tomcat = Retrospec.new(@opts[:module_path], @opts)
204
- expect(tomcat.generate_file_path(type, true)).to eq("spec/acceptance/classes/config/server/connector/connector_spec.rb")
197
+ expect(tomcat.generate_file_path(type, true)).to eq("spec/acceptance/classes/config/server/connector_spec.rb")
205
198
  end
206
199
  it 'should generate a normal test path correctly' do
207
200
  type = double("type")
208
201
  allow(type).to receive(:type).and_return(:hostclass)
209
202
  allow(type).to receive(:name).and_return('tomcat::config::server::connector')
210
203
  tomcat = Retrospec.new(@opts[:module_path], @opts)
211
- expect(tomcat.generate_file_path(type, false)).to eq("spec/classes/config/server/connector/connector_spec.rb")
204
+ expect(tomcat.generate_file_path(type, false)).to eq("spec/classes/config/server/connector_spec.rb")
212
205
  end
213
206
  end
214
207
 
@@ -218,7 +211,7 @@ describe "puppet-retrospec" do
218
211
  allow(type).to receive(:type).and_return(:definition)
219
212
  allow(type).to receive(:name).and_return('tomcat::config::server::connector')
220
213
  tomcat = Retrospec.new(@opts[:module_path], @opts)
221
- expect(tomcat.generate_file_path(type, true)).to eq("spec/acceptance/defines/config/server/connector/connector_spec.rb")
214
+ expect(tomcat.generate_file_path(type, true)).to eq("spec/acceptance/defines/config/server/connector_spec.rb")
222
215
  end
223
216
 
224
217
  it 'should generate a normal test path correctly' do
@@ -226,7 +219,7 @@ describe "puppet-retrospec" do
226
219
  allow(type).to receive(:type).and_return(:definition)
227
220
  allow(type).to receive(:name).and_return('tomcat::config::server::connector')
228
221
  tomcat = Retrospec.new(@opts[:module_path], @opts)
229
- expect(tomcat.generate_file_path(type, false)).to eq("spec/defines/config/server/connector/connector_spec.rb")
222
+ expect(tomcat.generate_file_path(type, false)).to eq("spec/defines/config/server/connector_spec.rb")
230
223
  end
231
224
  end
232
225
  end
@@ -11,52 +11,60 @@ describe "resource" do
11
11
  # enabling the removal of real modules slows down tests, but from time to time we may need to
12
12
  FileUtils.rm_rf(fixture_modules_path) if ENV['RETROSPEC_CLEAN_UP_TEST_MODULES'] =~ /true/
13
13
  @path = File.join(fixture_modules_path, 'tomcat')
14
-
15
-
16
14
  end
17
15
 
18
16
  before :each do
19
17
  clean_up_spec_dir(@path)
20
- @opts = {:module_path => @path, :enable_beaker_tests => false,
21
- :enable_user_templates => false, :template_dir => nil }
22
-
23
18
  end
24
19
 
25
- it 'should initialize with one resource' do
26
- my_path = File.expand_path(File.join('spec', 'fixtures', 'fixture_modules', 'one_resource_module'))
27
- my_retro = Retrospec.new(my_path)
28
- r = Resource.all(my_retro.types.find {|x| x.name == 'one_resource'})
29
- expect(r.length).to eq(1)
30
- expect(r[0].parameters).to eq({"ensure"=>"present"})
31
- expect(r[0].title).to eq("/tmp/test")
32
- expect(r[0].type).to eq("file")
33
- end
20
+ describe 'one resource module' do
21
+ let(:instance) {Utilities::PuppetModule.send :new}
22
+ before :each do
23
+ my_path = File.expand_path(File.join('spec', 'fixtures', 'fixture_modules', 'one_resource_module'))
24
+ @m = instance
25
+ @m.module_path = my_path
26
+ @m.create_tmp_module_path(my_path)
27
+ end
28
+
29
+ it 'should initialize with one resource' do
30
+ r = Resource.all(@m.types.find {|x| x.name == 'one_resource'})
31
+ expect(r.length).to eq(1)
32
+ expect(r[0].parameters).to eq({"ensure"=>"present"})
33
+ expect(r[0].title).to eq("/tmp/test")
34
+ expect(r[0].type).to eq("file")
35
+ end
36
+
37
+ it 'should initialize with two resources' do
38
+ test_type = @m.types.find {|x| x.name == 'one_resource::another_resource'}
39
+ VariableStore.populate(test_type)
40
+ r = Resource.all(test_type)
41
+ expect(r.length).to eq(2)
42
+ expect(r[0].parameters).to eq({"ensure"=>"present"})
43
+ expect(r[0].title).to eq("/tmp/test2")
44
+ expect(r[0].type).to eq("file")
45
+ expect(r[1].parameters).to eq({"ensure"=>"present","content" => "/tmp/test3/test3183/oohhhh"})
46
+ expect(r[1].title).to eq("/tmp/test3")
47
+ expect(r[1].type).to eq("file")
48
+ end
34
49
 
35
- it 'should initialize with two resources' do
36
- my_path = File.expand_path(File.join('spec', 'fixtures', 'fixture_modules', 'one_resource_module'))
37
- my_retro = Retrospec.new(my_path)
38
- test_type = my_retro.types.find {|x| x.name == 'one_resource::another_resource'}
39
- VariableStore.populate(test_type)
40
- r = Resource.all(test_type)
41
- expect(r.length).to eq(2)
42
- expect(r[0].parameters).to eq({"ensure"=>"present"})
43
- expect(r[0].title).to eq("/tmp/test2")
44
- expect(r[0].type).to eq("file")
45
- expect(r[1].parameters).to eq({"ensure"=>"present","content" => "/tmp/test3/test3183/oohhhh"})
46
- expect(r[1].title).to eq("/tmp/test3")
47
- expect(r[1].type).to eq("file")
48
- end
49
50
 
50
- it 'should return resources' do
51
- test_module = Retrospec.new(@opts[:module_path], @opts)
52
- test_type = test_module.types[0]
53
- expect(Resource.all(test_type.code)).to eq([])
54
- end
55
51
 
56
- it 'can process an empty class' do
57
- my_path = File.expand_path(File.join('spec', 'fixtures', 'fixture_modules', 'zero_resource_module'))
58
- my_retro = Retrospec.new(my_path)
59
- r = Resource.all(my_retro.types.find {|x| x.name == 'empty_class'})
60
- expect(r.size).to eq(0)
52
+ it 'should return resources' do
53
+ test_type = @m.types.find {|x| x.name == 'one_resource::another_resource'}
54
+ expect(Resource.all(test_type.code).length).to eq(2)
55
+ end
56
+
57
+ end
58
+ describe 'zero module' do
59
+ let(:instance) {Utilities::PuppetModule.send :new}
60
+ it 'can process an empty class' do
61
+ my_path = File.expand_path(File.join('spec', 'fixtures', 'fixture_modules', 'zero_resource_module'))
62
+ m = instance
63
+ m.module_path = my_path
64
+ m.create_tmp_module_path(my_path)
65
+ test_type = m.types.find {|x| x.name == 'empty_class'}
66
+ r = Resource.all(test_type)
67
+ expect(r.size).to eq(0)
68
+ end
61
69
  end
62
70
  end
@@ -10,30 +10,48 @@ describe "type_code" do
10
10
  before :all do
11
11
  # enabling the removal of real modules slows down tests, but from time to time we may need to
12
12
  FileUtils.rm_rf(fixture_modules_path) if ENV['RETROSPEC_CLEAN_UP_TEST_MODULES'] =~ /true/
13
- @path = File.join(fixture_modules_path, 'tomcat')
14
-
15
-
16
13
  end
17
14
 
18
- before :each do
19
- my_path = File.expand_path(File.join('spec', 'fixtures', 'fixture_modules', 'one_resource_module'))
20
- @my_retro = Retrospec.new(my_path)
21
- @test_type = @my_retro.types.find {|x| x.name == 'one_resource::another_resource'}
22
15
 
23
- end
24
- it 'should initialize correctly scope name' do
25
- expect(TypeCode.new(@test_type).scope_name).to eq('one_resource::another_resource')
26
- expect(TypeCode.new(@test_type).type).to eq(@test_type)
16
+ describe 'one resource module' do
17
+ before :all do
18
+ @path = File.expand_path(File.join('spec', 'fixtures', 'fixture_modules', 'one_resource_module'))
19
+ end
20
+
21
+ before :each do
22
+ @opts = {:module_path => @path, :enable_beaker_tests => false,
23
+ :enable_user_templates => false, :template_dir => nil }
24
+ end
25
+ let(:instance) {Utilities::PuppetModule.send :new}
26
+
27
+ it 'should initialize correctly scope name' do
28
+ m = instance
29
+ m.module_path = @opts[:module_path]
30
+ m.create_tmp_module_path(@opts[:module_path])
31
+ test_type = m.types.find {|x| x.name == 'one_resource::another_resource'}
32
+ expect(TypeCode.new(test_type).scope_name).to eq('one_resource::another_resource')
33
+ expect(TypeCode.new(test_type).type).to eq(test_type)
34
+ end
35
+
36
+ it 'should find all the variables' do
37
+ m = instance
38
+ m.module_path = @opts[:module_path]
39
+ m.create_tmp_module_path(@opts[:module_path])
40
+ test_type = m.types.find {|x| x.name == 'one_resource::another_resource'}
41
+ expect(TypeCode.new(test_type).variables.size).to eq(4)
42
+ end
27
43
  end
28
44
 
29
- it 'should find all the variables' do
30
- expect(TypeCode.new(@test_type).variables.size).to eq(3)
45
+ describe 'zero module' do
46
+ let(:instance) {Utilities::PuppetModule.send :new}
47
+ it 'should respond correctly when class is empty' do
48
+ my_path = File.expand_path(File.join('spec', 'fixtures', 'fixture_modules', 'zero_resource_module'))
49
+ m = instance
50
+ m.module_path = my_path
51
+ m.create_tmp_module_path(my_path)
52
+ test_type = m.types.find {|x| x.name == 'empty_class'}
53
+ expect{TypeCode.new(test_type).variables}.to_not raise_error
54
+ end
31
55
  end
32
56
 
33
- it 'should respond correctly when class is empty' do
34
- my_path = File.expand_path(File.join('spec', 'fixtures', 'fixture_modules', 'zero_resource_module'))
35
- my_retro = Retrospec.new(my_path)
36
- test_type = my_retro.types.find {|x| x.name == 'empty_class'}
37
- expect{TypeCode.new(test_type).variables}.to_not raise_error
38
- end
39
57
  end
@@ -1,18 +1,25 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe "variable_store" do
4
+ let(:instance) {Utilities::PuppetModule.send :new}
5
+
4
6
  after :all do
5
7
  # enabling the removal slows down tests, but from time to time we may need to
6
8
  FileUtils.rm_rf(fixture_modules_path) if ENV['RETROSPEC_CLEAN_UP_TEST_MODULES'] =~ /true/
7
9
  end
8
10
 
9
11
  before :all do
12
+ @path = File.expand_path(File.join('spec', 'fixtures', 'fixture_modules', 'one_resource_module'))
10
13
  # enabling the removal of real modules slows down tests, but from time to time we may need to
11
14
  FileUtils.rm_rf(fixture_modules_path) if ENV['RETROSPEC_CLEAN_UP_TEST_MODULES'] =~ /true/
12
15
  end
13
16
 
14
17
  before :each do
15
- @my_path = File.expand_path(File.join('spec', 'fixtures', 'fixture_modules', 'one_resource_module'))
18
+ @opts = {:module_path => @path, :enable_beaker_tests => false,
19
+ :enable_user_templates => false, :template_dir => nil }
20
+ @module = instance
21
+ @module.module_path = @opts[:module_path]
22
+ @module.create_tmp_module_path(@opts[:module_path])
16
23
  end
17
24
 
18
25
  it 'should initialize' do
@@ -20,40 +27,36 @@ describe "variable_store" do
20
27
  end
21
28
 
22
29
  it 'should resolve a string' do
23
- my_retro = Retrospec.new(@my_path)
24
- test_type = my_retro.types.find {|x| x.name == 'one_resource::another_resource'}
30
+ test_type = @module.types.find {|x| x.name == 'one_resource::another_resource'}
25
31
  r = Resource.all(test_type).first
26
32
  string1 = ObjectSpace.each_object(Puppet::Parser::AST::String).find {|x| x.to_s == "\"value1\"" }
27
33
  expect(VariableStore.resolve(string1)).to eq("\"value1\"")
28
34
  end
29
35
 
30
36
  it 'should resolve a variable' do
31
- my_retro = Retrospec.new(@my_path)
32
- test_type = my_retro.types.find {|x| x.name == 'one_resource::another_resource'}
37
+ test_type = @module.types.find {|x| x.name == 'one_resource::another_resource'}
33
38
  r = Resource.all(test_type).first
34
39
  var1 = ObjectSpace.each_object(Puppet::Parser::AST::Variable).find {|x| x.to_s == '$file_name' }
40
+ VariableStore.add(var1,'/tmp/test3')
35
41
  expect(VariableStore.resolve(var1)).to eq("/tmp/test3")
36
42
  end
37
43
 
38
44
  it 'should resolve a basic vardef type' do
39
- my_retro = Retrospec.new(@my_path)
40
- test_type = my_retro.types.find {|x| x.name == 'one_resource::another_resource'}
45
+ test_type = @module.types.find {|x| x.name == 'one_resource::another_resource'}
41
46
  VariableStore.populate(test_type)
42
- vardef1 = ObjectSpace.each_object(Puppet::Parser::AST::VarDef).find {|x| x.name.value == 'some_var'}
47
+ vardef1 = ObjectSpace.each_object(Puppet::Parser::AST::VarDef).find {|x| x.name.value == 'some_var'}
43
48
  expect(VariableStore.resolve(vardef1)).to eq("oohhhh")
44
49
  end
45
50
 
46
51
  it 'should resolve a concat vardef type' do
47
- my_retro = Retrospec.new(@my_path)
48
- test_type = my_retro.types.find {|x| x.name == 'one_resource::another_resource'}
52
+ test_type = @module.types.find {|x| x.name == 'one_resource::another_resource'}
49
53
  VariableStore.populate(test_type)
50
54
  vardef2 = ObjectSpace.each_object(Puppet::Parser::AST::VarDef).find {|x| x.name.value == 'concat_var'}
51
55
  expect(VariableStore.resolve(vardef2)).to eq("/tmp/test3/test3183/oohhhh")
52
56
  end
53
57
 
54
58
  it 'should resolve vardef/concat with parameter value' do
55
- my_retro = Retrospec.new(@my_path)
56
- test_type = my_retro.types.find {|x| x.name == 'one_resource::another_resource'}
59
+ test_type = @module.types.find {|x| x.name == 'one_resource::another_resource'}
57
60
  VariableStore.populate(test_type)
58
61
  vardef3 = ObjectSpace.each_object(Puppet::Parser::AST::VarDef).find {|x| x.name.value == 'cli_modules'}
59
62
  expect(VariableStore.resolve(vardef3)).to eq("/etc/hammer/cli.modules.d")
@@ -61,8 +64,7 @@ describe "variable_store" do
61
64
 
62
65
  describe '#add' do
63
66
  it 'should store the value correctly' do
64
- my_retro = Retrospec.new(@my_path)
65
- test_type = my_retro.types.find {|x| x.name == 'one_resource::another_resource'}
67
+ test_type = @module.types.find {|x| x.name == 'one_resource::another_resource'}
66
68
  string1 = ObjectSpace.each_object(Puppet::Parser::AST::String).find {|x| x.to_s == "\"value1\"" }
67
69
  expect(VariableStore.add(string1, 'blah')).to eq("blah")
68
70
  expect(VariableStore.lookup(string1)).to eq('blah')
@@ -74,9 +76,63 @@ describe "variable_store" do
74
76
  end
75
77
 
76
78
  it 'should store vardef as is' do
77
- my_retro = Retrospec.new(@my_path)
78
- test_type = my_retro.types.find {|x| x.name == 'one_resource::another_resource'}
79
+ test_type = @module.types.find {|x| x.name == 'one_resource::another_resource'}
80
+ VariableStore.populate(test_type)
81
+ end
82
+ end
83
+
84
+ describe 'populate' do
85
+ let(:instance) {Utilities::PuppetModule.send :new}
86
+
87
+ before :each do
88
+
89
+ end
90
+ it 'should load an resolve vars from the parent type' do
91
+ m = instance
92
+ m.module_path = @opts[:module_path]
93
+ m.create_tmp_module_path(@opts[:module_path])
94
+ test_type = m.types.find {|x| x.name == 'one_resource::another_resource'}
95
+ VariableStore.populate(test_type)
96
+ vars = {"$var1"=>"value1",
97
+ "$var2"=>"value2",
98
+ "$file_name"=>"/tmp/test3",
99
+ "$config_base_path"=>"/etc/hammer",
100
+ "$config_set"=>"param1_value",
101
+ "$concat_var"=>"/tmp/test3/test3183/oohhhh",
102
+ "$one_resource::params::param1_var1"=>"param1_value",
103
+ "$one_resource::params::var1"=>"params_class_value1",
104
+ "$one_resource::params::var2"=>"value2",
105
+ "$some_var"=>"oohhhh",
106
+ "$cli_modules"=>"/etc/hammer/cli.modules.d",
107
+ "$inherited_variable"=>"params_class_value1",
108
+ }
109
+ vars.each do |k,v|
110
+ expect(VariableStore.instance.store.keys.include?(k)).to be true
111
+ expect(VariableStore.instance.store[k]).to eq(v)
112
+ end
113
+ end
114
+
115
+ xit 'should resolve a fact' do
116
+ #test_type = @module.types.find {|x| x.name == 'one_resource::inherits_params'}
117
+ end
118
+
119
+ it 'should resolve a parent parameter' do
120
+ m = instance
121
+ m.module_path = @opts[:module_path]
122
+ m.create_tmp_module_path(@opts[:module_path])
123
+ test_type = m.types.find {|x| x.name == 'one_resource::another_resource'}
124
+ VariableStore.populate(test_type)
125
+ expect(VariableStore.instance.store['$config_set']).to eq('param1_value')
126
+
127
+ end
128
+
129
+ it 'should resolve a parent variable' do
130
+ m = instance
131
+ m.module_path = @opts[:module_path]
132
+ m.create_tmp_module_path(@opts[:module_path])
133
+ test_type = m.types.find {|x| x.name == 'one_resource::another_resource'}
79
134
  VariableStore.populate(test_type)
135
+ expect(VariableStore.instance.store['$inherited_variable']).to eq('params_class_value1')
80
136
  end
81
137
  end
82
138
  end