puppet 2.7.13 → 2.7.14

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of puppet might be problematic. Click here for more details.

Files changed (215) hide show
  1. data/CHANGELOG +144 -1
  2. data/conf/osx/preflight +1 -1
  3. data/conf/redhat/puppet.spec +9 -5
  4. data/conf/suse/puppet.spec +4 -1
  5. data/conf/windows/eventlog/Rakefile +32 -0
  6. data/conf/windows/eventlog/puppetres.dll +0 -0
  7. data/conf/windows/eventlog/puppetres.mc +18 -0
  8. data/ext/rack/files/apache2.conf +3 -0
  9. data/install.rb +23 -1
  10. data/lib/puppet.rb +1 -1
  11. data/lib/puppet/agent.rb +1 -14
  12. data/lib/puppet/application/kick.rb +1 -1
  13. data/lib/puppet/application/module.rb +11 -0
  14. data/lib/puppet/daemon.rb +74 -3
  15. data/lib/puppet/defaults.rb +1 -1
  16. data/lib/puppet/face/certificate.rb +1 -1
  17. data/lib/puppet/face/help/man.erb +1 -1
  18. data/lib/puppet/face/module.rb +17 -0
  19. data/lib/puppet/face/module/build.rb +10 -4
  20. data/lib/puppet/face/module/changes.rb +5 -5
  21. data/lib/puppet/face/module/generate.rb +6 -4
  22. data/lib/puppet/face/module/install.rb +122 -32
  23. data/lib/puppet/face/module/list.rb +234 -33
  24. data/lib/puppet/face/module/search.rb +56 -23
  25. data/lib/puppet/face/module/uninstall.rb +33 -38
  26. data/lib/puppet/face/module/upgrade.rb +84 -0
  27. data/lib/puppet/feature/eventlog.rb +6 -0
  28. data/lib/puppet/forge.rb +67 -122
  29. data/lib/puppet/forge/cache.rb +1 -1
  30. data/lib/puppet/forge/repository.rb +6 -25
  31. data/lib/puppet/indirector/facts/network_device.rb +1 -1
  32. data/lib/puppet/interface/action.rb +1 -1
  33. data/lib/puppet/module.rb +79 -28
  34. data/lib/puppet/module_tool.rb +72 -34
  35. data/lib/puppet/module_tool/applications.rb +12 -14
  36. data/lib/puppet/module_tool/applications/application.rb +21 -19
  37. data/lib/puppet/module_tool/applications/builder.rb +4 -4
  38. data/lib/puppet/module_tool/applications/checksummer.rb +12 -3
  39. data/lib/puppet/module_tool/applications/generator.rb +1 -1
  40. data/lib/puppet/module_tool/applications/installer.rb +163 -34
  41. data/lib/puppet/module_tool/applications/searcher.rb +2 -3
  42. data/lib/puppet/module_tool/applications/uninstaller.rb +84 -36
  43. data/lib/puppet/module_tool/applications/unpacker.rb +4 -26
  44. data/lib/puppet/module_tool/applications/upgrader.rb +109 -0
  45. data/lib/puppet/module_tool/checksums.rb +2 -2
  46. data/lib/puppet/module_tool/contents_description.rb +1 -1
  47. data/lib/puppet/module_tool/dependency.rb +2 -2
  48. data/lib/puppet/module_tool/errors.rb +9 -0
  49. data/lib/puppet/module_tool/errors/base.rb +15 -0
  50. data/lib/puppet/module_tool/errors/installer.rb +90 -0
  51. data/lib/puppet/module_tool/errors/shared.rb +115 -0
  52. data/lib/puppet/module_tool/errors/uninstaller.rb +45 -0
  53. data/lib/puppet/module_tool/errors/upgrader.rb +72 -0
  54. data/lib/puppet/module_tool/metadata.rb +2 -2
  55. data/lib/puppet/module_tool/modulefile.rb +7 -7
  56. data/lib/puppet/module_tool/shared_behaviors.rb +161 -0
  57. data/lib/puppet/module_tool/skeleton.rb +1 -1
  58. data/lib/puppet/node/environment.rb +4 -2
  59. data/lib/puppet/parser/ast/leaf.rb +1 -1
  60. data/lib/puppet/parser/functions/create_resources.rb +3 -2
  61. data/lib/puppet/parser/scope.rb +44 -9
  62. data/lib/puppet/provider/augeas/augeas.rb +2 -2
  63. data/lib/puppet/provider/exec.rb +8 -3
  64. data/lib/puppet/provider/exec/shell.rb +1 -2
  65. data/lib/puppet/provider/nameservice/directoryservice.rb +10 -4
  66. data/lib/puppet/provider/package/gem.rb +1 -1
  67. data/lib/puppet/provider/package/pkg.rb +10 -21
  68. data/lib/puppet/provider/selmodule/semodule.rb +1 -2
  69. data/lib/puppet/provider/service/upstart.rb +33 -17
  70. data/lib/puppet/provider/ssh_authorized_key/parsed.rb +1 -1
  71. data/lib/puppet/rails/inventory_node.rb +7 -7
  72. data/lib/puppet/reports/http.rb +4 -1
  73. data/lib/puppet/reports/tagmail.rb +8 -1
  74. data/lib/puppet/resource/type.rb +1 -1
  75. data/lib/puppet/test/test_helper.rb +138 -0
  76. data/lib/puppet/type.rb +9 -1
  77. data/lib/puppet/type/file.rb +18 -10
  78. data/lib/puppet/type/package.rb +13 -9
  79. data/lib/puppet/type/resources.rb +1 -1
  80. data/lib/puppet/type/ssh_authorized_key.rb +3 -4
  81. data/lib/puppet/type/sshkey.rb +4 -4
  82. data/lib/puppet/type/user.rb +1 -0
  83. data/lib/puppet/type/vlan.rb +1 -1
  84. data/lib/puppet/util.rb +31 -14
  85. data/lib/puppet/util/autoload.rb +1 -1
  86. data/lib/puppet/util/command_line.rb +2 -6
  87. data/lib/puppet/util/instrumentation/indirection_probe.rb +1 -1
  88. data/lib/puppet/util/instrumentation/instrumentable.rb +1 -1
  89. data/lib/puppet/util/instrumentation/listeners/log.rb +1 -1
  90. data/lib/puppet/util/instrumentation/listeners/performance.rb +1 -1
  91. data/lib/puppet/util/log.rb +3 -1
  92. data/lib/puppet/util/log/destinations.rb +38 -0
  93. data/lib/puppet/util/monkey_patches.rb +45 -0
  94. data/lib/puppet/util/network_device/base.rb +1 -1
  95. data/lib/puppet/util/network_device/cisco.rb +1 -1
  96. data/lib/puppet/util/network_device/cisco/facts.rb +1 -1
  97. data/lib/puppet/util/network_device/cisco/interface.rb +1 -1
  98. data/lib/puppet/util/network_device/config.rb +1 -1
  99. data/lib/puppet/util/network_device/ipcalc.rb +1 -1
  100. data/lib/puppet/util/network_device/transport.rb +1 -1
  101. data/lib/puppet/util/network_device/transport/base.rb +1 -1
  102. data/lib/puppet/util/network_device/transport/ssh.rb +1 -1
  103. data/lib/puppet/util/settings.rb +2 -11
  104. data/lib/puppet/util/settings/file_setting.rb +3 -5
  105. data/lib/puppet/util/terminal.rb +16 -0
  106. data/lib/puppet/util/zaml.rb +3 -1
  107. data/lib/semver.rb +15 -7
  108. data/spec/fixtures/releases/jamtur01-apache/metadata.json +1 -1
  109. data/spec/fixtures/unit/parser/lexer/arithmetic_expression.pp +1 -1
  110. data/spec/fixtures/unit/provider/package/pkg/dummy +1 -0
  111. data/spec/fixtures/unit/provider/package/pkg/incomplete +1 -0
  112. data/spec/fixtures/unit/provider/package/pkg/publisher +2 -0
  113. data/spec/fixtures/unit/provider/package/pkg/simple +4 -0
  114. data/spec/fixtures/unit/reports/tagmail/tagmail_email.conf +2 -0
  115. data/spec/fixtures/yaml/report0.25.x.yaml +1 -1
  116. data/spec/fixtures/yaml/report2.6.x.yaml +1 -1
  117. data/spec/integration/faces/documentation_spec.rb +1 -1
  118. data/spec/integration/network/rest_authconfig_spec.rb +1 -1
  119. data/spec/lib/puppet_spec/compiler.rb +6 -0
  120. data/spec/lib/puppet_spec/database.rb +30 -0
  121. data/spec/lib/puppet_spec/files.rb +4 -2
  122. data/spec/shared_behaviours/path_parameters.rb +2 -29
  123. data/spec/shared_contexts/platform.rb +43 -0
  124. data/spec/spec_helper.rb +36 -65
  125. data/spec/unit/agent_spec.rb +0 -32
  126. data/spec/unit/application/kick_spec.rb +2 -2
  127. data/spec/unit/daemon_spec.rb +1 -17
  128. data/spec/unit/face/module/install_spec.rb +158 -0
  129. data/spec/unit/face/module/list_spec.rb +182 -0
  130. data/spec/unit/face/module/search_spec.rb +163 -0
  131. data/spec/unit/face/module/uninstall_spec.rb +77 -0
  132. data/spec/unit/face/module/upgrade_spec.rb +26 -0
  133. data/spec/unit/forge/repository_spec.rb +0 -30
  134. data/spec/unit/forge_spec.rb +28 -86
  135. data/spec/unit/indirector/catalog/active_record_spec.rb +45 -65
  136. data/spec/unit/indirector/facts/inventory_active_record_spec.rb +5 -18
  137. data/spec/unit/indirector/resource/active_record_spec.rb +2 -11
  138. data/spec/unit/indirector/resource/ral_spec.rb +7 -2
  139. data/spec/unit/module_spec.rb +240 -107
  140. data/spec/unit/module_tool/application_spec.rb +3 -5
  141. data/spec/unit/module_tool/applications/application_spec.rb +19 -0
  142. data/spec/unit/module_tool/applications/installer_spec.rb +205 -0
  143. data/spec/unit/module_tool/applications/uninstaller_spec.rb +206 -0
  144. data/spec/unit/module_tool/applications/upgrader_spec.rb +37 -0
  145. data/spec/unit/module_tool/metadata_spec.rb +2 -2
  146. data/spec/unit/module_tool_spec.rb +109 -1
  147. data/spec/unit/node/environment_spec.rb +16 -1
  148. data/spec/unit/parser/ast/leaf_spec.rb +16 -1
  149. data/spec/unit/parser/collector_spec.rb +2 -12
  150. data/spec/unit/parser/functions/create_resources_spec.rb +135 -86
  151. data/spec/unit/parser/functions/generate_spec.rb +2 -10
  152. data/spec/unit/parser/scope_spec.rb +345 -16
  153. data/spec/unit/provider/augeas/augeas_spec.rb +19 -0
  154. data/spec/unit/provider/exec/shell_spec.rb +17 -14
  155. data/spec/unit/provider/exec/windows_spec.rb +1 -7
  156. data/spec/unit/provider/exec_spec.rb +35 -0
  157. data/spec/unit/provider/nameservice/directoryservice_spec.rb +10 -0
  158. data/spec/unit/provider/package/dpkg_spec.rb +2 -1
  159. data/spec/unit/provider/package/gem_spec.rb +15 -0
  160. data/spec/unit/provider/package/openbsd_spec.rb +5 -4
  161. data/spec/unit/provider/package/pacman_spec.rb +3 -2
  162. data/spec/unit/provider/package/pkg_spec.rb +56 -33
  163. data/spec/unit/provider/selmodule_spec.rb +11 -4
  164. data/spec/unit/provider/service/redhat_spec.rb +1 -3
  165. data/spec/unit/provider/service/smf_spec.rb +1 -3
  166. data/spec/unit/provider/service/upstart_spec.rb +38 -0
  167. data/spec/unit/provider/ssh_authorized_key/parsed_spec.rb +28 -0
  168. data/spec/unit/rails/host_spec.rb +6 -12
  169. data/spec/unit/rails/param_value_spec.rb +3 -8
  170. data/spec/unit/rails/resource_spec.rb +2 -8
  171. data/spec/unit/reports/http_spec.rb +47 -31
  172. data/spec/unit/reports/tagmail_spec.rb +77 -0
  173. data/spec/unit/resource/type_spec.rb +2 -2
  174. data/spec/unit/resource_spec.rb +18 -20
  175. data/spec/unit/semver_spec.rb +31 -13
  176. data/spec/unit/type/exec_spec.rb +8 -15
  177. data/spec/unit/type/group_spec.rb +0 -9
  178. data/spec/unit/type/package_spec.rb +10 -0
  179. data/spec/unit/type/resources_spec.rb +4 -5
  180. data/spec/unit/type/ssh_authorized_key_spec.rb +4 -15
  181. data/spec/unit/type/sshkey_spec.rb +9 -11
  182. data/spec/unit/type/user_spec.rb +123 -127
  183. data/spec/unit/type_spec.rb +20 -0
  184. data/spec/unit/util/command_line_spec.rb +2 -2
  185. data/spec/unit/util/instrumentation/data_spec.rb +1 -1
  186. data/spec/unit/util/instrumentation/indirection_probe_spec.rb +1 -1
  187. data/spec/unit/util/instrumentation/instrumentable_spec.rb +1 -1
  188. data/spec/unit/util/instrumentation/listener_spec.rb +1 -1
  189. data/spec/unit/util/instrumentation/listeners/log_spec.rb +1 -1
  190. data/spec/unit/util/instrumentation/listeners/performance_spec.rb +1 -1
  191. data/spec/unit/util/instrumentation_spec.rb +1 -1
  192. data/spec/unit/util/log/destinations_spec.rb +4 -8
  193. data/spec/unit/util/log_spec.rb +47 -0
  194. data/spec/unit/util/reference_spec.rb +1 -1
  195. data/spec/unit/util/settings/file_setting_spec.rb +9 -0
  196. data/spec/unit/util/settings_spec.rb +0 -53
  197. data/spec/unit/util/terminal_spec.rb +42 -0
  198. data/spec/unit/util/zaml_spec.rb +7 -0
  199. data/spec/unit/util_spec.rb +63 -20
  200. data/tasks/rake/manpages.rake +1 -1
  201. data/test/data/snippets/arithmetic_expression.pp +1 -1
  202. data/test/other/puppet.rb +0 -1
  203. data/test/util/log.rb +6 -6
  204. metadata +41 -16
  205. data/lib/puppet/external/event-loop.rb +0 -1
  206. data/lib/puppet/external/event-loop/better-definers.rb +0 -367
  207. data/lib/puppet/external/event-loop/event-loop.rb +0 -355
  208. data/lib/puppet/external/event-loop/signal-system.rb +0 -218
  209. data/lib/puppet/face/module/clean.rb +0 -30
  210. data/lib/puppet/module_tool/applications/cleaner.rb +0 -16
  211. data/lib/puppet/module_tool/skeleton/templates/generator/metadata.json +0 -12
  212. data/lib/puppet/module_tool/utils.rb +0 -5
  213. data/lib/puppet/module_tool/utils/interrogation.rb +0 -25
  214. data/spec/integration/module_tool_spec.rb +0 -475
  215. data/spec/unit/module_tool/uninstaller_spec.rb +0 -124
@@ -41,11 +41,7 @@ describe "the generate function" do
41
41
  scope.function_generate([command]).should == 'yay'
42
42
  end
43
43
 
44
- describe "on Windows" do
45
- before :each do
46
- Puppet.features.stubs(:microsoft_windows?).returns(true)
47
- end
48
-
44
+ describe "on Windows", :as_platform => :windows do
49
45
  it "should accept lower-case drive letters" do
50
46
  command = 'd:/command/foo'
51
47
  Dir.expects(:chdir).with(File.dirname(command)).returns("yay")
@@ -73,11 +69,7 @@ describe "the generate function" do
73
69
  end
74
70
  end
75
71
 
76
- describe "on non-Windows" do
77
- before :each do
78
- Puppet.features.stubs(:microsoft_windows?).returns(false)
79
- end
80
-
72
+ describe "on non-Windows", :as_platform => :posix do
81
73
  it "should reject backslashes" do
82
74
  lambda { scope.function_generate(['/com\\mand']) }.should raise_error(Puppet::ParseError)
83
75
  end
@@ -1,13 +1,13 @@
1
1
  #!/usr/bin/env rspec
2
2
  require 'spec_helper'
3
+ require 'puppet_spec/compiler'
3
4
 
4
5
  describe Puppet::Parser::Scope do
5
6
  before :each do
6
- @topscope = Puppet::Parser::Scope.new
7
- # This is necessary so we don't try to use the compiler to discover our parent.
8
- @topscope.parent = nil
9
7
  @scope = Puppet::Parser::Scope.new
10
8
  @scope.compiler = Puppet::Parser::Compiler.new(Puppet::Node.new("foo"))
9
+ @scope.source = Puppet::Resource::Type.new(:node, :foo)
10
+ @topscope = @scope.compiler.topscope
11
11
  @scope.parent = @topscope
12
12
  end
13
13
 
@@ -92,14 +92,6 @@ describe Puppet::Parser::Scope do
92
92
 
93
93
  Puppet::Parser::Scope.new.singleton_class.ancestors.should be_include(mod)
94
94
  end
95
-
96
- it "should remember if it is dynamic" do
97
- (!!Puppet::Parser::Scope.new(:dynamic => true).dynamic).should == true
98
- end
99
-
100
- it "should assume it is not dynamic" do
101
- (!Puppet::Parser::Scope.new.dynamic).should == true
102
- end
103
95
  end
104
96
 
105
97
  describe "when looking up a variable" do
@@ -128,10 +120,36 @@ describe Puppet::Parser::Scope do
128
120
  @scope.lookupvar("var").should == "childval"
129
121
  end
130
122
 
123
+ it "should be able to look up intermediary variables in parent scopes (DEPRECATED)" do
124
+ topscope_value = "parentval"
125
+ dynamic_value = "childval"
126
+
127
+ Puppet.expects(:deprecation_warning).with("Dynamic lookup of $var2 is deprecated. For more information, see http://docs.puppetlabs.com/guides/scope_and_puppet.html. To see the change in behavior, use the --debug flag.")
128
+ Puppet.expects(:debug).with("Currently $var2 is #{dynamic_value.inspect}")
129
+ Puppet.expects(:debug).with("In the future $var2 will be #{topscope_value.inspect}")
130
+
131
+ thirdscope = Puppet::Parser::Scope.new(:parent => @scope, :source => Puppet::Resource::Type.new(:hostclass, :foo, :module_name => "foo"))
132
+
133
+ @topscope.setvar("var2", topscope_value)
134
+ @scope.setvar("var2", dynamic_value)
135
+ thirdscope.lookupvar("var2").should == dynamic_value
136
+ end
137
+
138
+ it "should call out when the new variable lookup will not find a value (DEPRECATED)" do
139
+ dynamic_value = "childval"
140
+
141
+ Puppet.expects(:deprecation_warning).with("Dynamic lookup of $var2 is deprecated. For more information, see http://docs.puppetlabs.com/guides/scope_and_puppet.html. To see the change in behavior, use the --debug flag.")
142
+ Puppet.expects(:debug).with("Currently $var2 is #{dynamic_value.inspect}")
143
+ Puppet.expects(:debug).with("In the future $var2 will be undefined")
144
+
145
+ thirdscope = Puppet::Parser::Scope.new(:parent => @scope, :source => Puppet::Resource::Type.new(:hostclass, :foo, :module_name => "foo"))
146
+
147
+ @scope.setvar("var2", dynamic_value)
148
+ thirdscope.lookupvar("var2").should == dynamic_value
149
+ end
150
+
131
151
  describe "and the variable is qualified" do
132
- before do
133
- @compiler = Puppet::Parser::Compiler.new(Puppet::Node.new("foonode"))
134
- @scope.compiler = @compiler
152
+ before :each do
135
153
  @known_resource_types = @scope.known_resource_types
136
154
  end
137
155
 
@@ -151,6 +169,7 @@ describe Puppet::Parser::Scope do
151
169
  end
152
170
 
153
171
  it "should be able to look up explicitly fully qualified variables from main" do
172
+ Puppet.expects(:deprecation_warning).never
154
173
  other_scope = create_class_scope("")
155
174
 
156
175
  other_scope.setvar("othervar", "otherval")
@@ -159,6 +178,7 @@ describe Puppet::Parser::Scope do
159
178
  end
160
179
 
161
180
  it "should be able to look up explicitly fully qualified variables from other scopes" do
181
+ Puppet.expects(:deprecation_warning).never
162
182
  other_scope = create_class_scope("other")
163
183
 
164
184
  other_scope.setvar("var", "otherval")
@@ -167,6 +187,7 @@ describe Puppet::Parser::Scope do
167
187
  end
168
188
 
169
189
  it "should be able to look up deeply qualified variables" do
190
+ Puppet.expects(:deprecation_warning).never
170
191
  other_scope = create_class_scope("other::deep::klass")
171
192
 
172
193
  other_scope.setvar("var", "otherval")
@@ -175,28 +196,33 @@ describe Puppet::Parser::Scope do
175
196
  end
176
197
 
177
198
  it "should return ':undefined' for qualified variables that cannot be found in other classes" do
199
+ Puppet.expects(:deprecation_warning).never
178
200
  other_scope = create_class_scope("other::deep::klass")
179
201
 
180
202
  @scope.lookupvar("other::deep::klass::var").should == :undefined
181
203
  end
182
204
 
183
205
  it "should warn and return ':undefined' for qualified variables whose classes have not been evaluated" do
206
+ Puppet.expects(:deprecation_warning).never
184
207
  klass = newclass("other::deep::klass")
185
- @scope.expects(:warning)
208
+ @scope.expects(:warning).at_least_once
186
209
  @scope.lookupvar("other::deep::klass::var").should == :undefined
187
210
  end
188
211
 
189
212
  it "should warn and return ':undefined' for qualified variables whose classes do not exist" do
190
- @scope.expects(:warning)
213
+ Puppet.expects(:deprecation_warning).never
214
+ @scope.expects(:warning).at_least_once
191
215
  @scope.lookupvar("other::deep::klass::var").should == :undefined
192
216
  end
193
217
 
194
218
  it "should return ':undefined' when asked for a non-string qualified variable from a class that does not exist" do
219
+ Puppet.expects(:deprecation_warning).never
195
220
  @scope.stubs(:warning)
196
221
  @scope.lookupvar("other::deep::klass::var").should == :undefined
197
222
  end
198
223
 
199
224
  it "should return ':undefined' when asked for a non-string qualified variable from a class that has not been evaluated" do
225
+ Puppet.expects(:deprecation_warning).never
200
226
  @scope.stubs(:warning)
201
227
  klass = newclass("other::deep::klass")
202
228
  @scope.lookupvar("other::deep::klass::var").should == :undefined
@@ -204,6 +230,309 @@ describe Puppet::Parser::Scope do
204
230
  end
205
231
  end
206
232
 
233
+ describe "when mixing inheritence and inclusion" do
234
+ include PuppetSpec::Compiler
235
+
236
+ def expect_the_message_to_be(message)
237
+ catalog = compile_to_catalog(yield)
238
+ catalog.resource('Notify', 'something')[:message].should == message
239
+ end
240
+
241
+ context "deprecated scoping" do
242
+ before :each do
243
+ Puppet.expects(:deprecation_warning)
244
+ end
245
+
246
+ it "prefers values in its included scope over those from the node (DEPRECATED)" do
247
+ expect_the_message_to_be('baz_msg') do <<-MANIFEST
248
+ node default {
249
+ $var = "node_msg"
250
+ include foo
251
+ }
252
+ class baz {
253
+ $var = "baz_msg"
254
+ include bar
255
+ }
256
+ class foo inherits baz {
257
+ }
258
+ class bar {
259
+ notify { 'something': message => $var, }
260
+ }
261
+ MANIFEST
262
+ end
263
+ end
264
+
265
+ it "finds values in its included scope (DEPRECATED)" do
266
+ expect_the_message_to_be('baz_msg') do <<-MANIFEST
267
+ node default {
268
+ include baz
269
+ }
270
+ class foo {
271
+ }
272
+ class bar inherits foo {
273
+ notify { 'something': message => $var, }
274
+ }
275
+ class baz {
276
+ $var = "baz_msg"
277
+ include bar
278
+ }
279
+ MANIFEST
280
+ end
281
+ end
282
+
283
+ it "recognizes a dynamically scoped boolean (DEPRECATED)" do
284
+ expect_the_message_to_be(true) do <<-MANIFEST
285
+ node default {
286
+ $var = false
287
+ include baz
288
+ }
289
+ class foo {
290
+ }
291
+ class bar inherits foo {
292
+ notify { 'something': message => $var, }
293
+ }
294
+ class baz {
295
+ $var = true
296
+ include bar
297
+ }
298
+ MANIFEST
299
+ end
300
+ end
301
+ end
302
+
303
+ context "supported scoping" do
304
+ before :each do
305
+ Puppet.expects(:deprecation_warning).never
306
+ end
307
+
308
+ it "finds value define in the inherited node" do
309
+ expect_the_message_to_be('parent_msg') do <<-MANIFEST
310
+ $var = "top_msg"
311
+ node parent {
312
+ $var = "parent_msg"
313
+ }
314
+ node default inherits parent {
315
+ include foo
316
+ }
317
+ class foo {
318
+ notify { 'something': message => $var, }
319
+ }
320
+ MANIFEST
321
+ end
322
+ end
323
+
324
+ it "finds top scope when the class is included before the node defines the var" do
325
+ expect_the_message_to_be('top_msg') do <<-MANIFEST
326
+ $var = "top_msg"
327
+ node parent {
328
+ include foo
329
+ }
330
+ node default inherits parent {
331
+ $var = "default_msg"
332
+ }
333
+ class foo {
334
+ notify { 'something': message => $var, }
335
+ }
336
+ MANIFEST
337
+ end
338
+ end
339
+
340
+ it "finds top scope when the class is included before the node defines the var" do
341
+ expect_the_message_to_be('top_msg') do <<-MANIFEST
342
+ $var = "top_msg"
343
+ node parent {
344
+ include foo
345
+ }
346
+ node default inherits parent {
347
+ $var = "default_msg"
348
+ }
349
+ class foo {
350
+ notify { 'something': message => $var, }
351
+ }
352
+ MANIFEST
353
+ end
354
+ end
355
+
356
+
357
+ it "should find values in its local scope" do
358
+ expect_the_message_to_be('local_msg') do <<-MANIFEST
359
+ node default {
360
+ include baz
361
+ }
362
+ class foo {
363
+ }
364
+ class bar inherits foo {
365
+ $var = "local_msg"
366
+ notify { 'something': message => $var, }
367
+ }
368
+ class baz {
369
+ include bar
370
+ }
371
+ MANIFEST
372
+ end
373
+ end
374
+
375
+ it "should find values in its inherited scope" do
376
+ expect_the_message_to_be('foo_msg') do <<-MANIFEST
377
+ node default {
378
+ include baz
379
+ }
380
+ class foo {
381
+ $var = "foo_msg"
382
+ }
383
+ class bar inherits foo {
384
+ notify { 'something': message => $var, }
385
+ }
386
+ class baz {
387
+ include bar
388
+ }
389
+ MANIFEST
390
+ end
391
+ end
392
+
393
+ it "prefers values in its inherited scope over those in the node (with intermediate inclusion)" do
394
+ expect_the_message_to_be('foo_msg') do <<-MANIFEST
395
+ node default {
396
+ $var = "node_msg"
397
+ include baz
398
+ }
399
+ class foo {
400
+ $var = "foo_msg"
401
+ }
402
+ class bar inherits foo {
403
+ notify { 'something': message => $var, }
404
+ }
405
+ class baz {
406
+ include bar
407
+ }
408
+ MANIFEST
409
+ end
410
+ end
411
+
412
+ it "prefers values in its inherited scope over those in the node (without intermediate inclusion)" do
413
+ expect_the_message_to_be('foo_msg') do <<-MANIFEST
414
+ node default {
415
+ $var = "node_msg"
416
+ include bar
417
+ }
418
+ class foo {
419
+ $var = "foo_msg"
420
+ }
421
+ class bar inherits foo {
422
+ notify { 'something': message => $var, }
423
+ }
424
+ MANIFEST
425
+ end
426
+ end
427
+
428
+ it "prefers values in its inherited scope over those from where it is included" do
429
+ expect_the_message_to_be('foo_msg') do <<-MANIFEST
430
+ node default {
431
+ include baz
432
+ }
433
+ class foo {
434
+ $var = "foo_msg"
435
+ }
436
+ class bar inherits foo {
437
+ notify { 'something': message => $var, }
438
+ }
439
+ class baz {
440
+ $var = "baz_msg"
441
+ include bar
442
+ }
443
+ MANIFEST
444
+ end
445
+ end
446
+
447
+ it "does not used variables from classes included in the inherited scope" do
448
+ expect_the_message_to_be('node_msg') do <<-MANIFEST
449
+ node default {
450
+ $var = "node_msg"
451
+ include bar
452
+ }
453
+ class quux {
454
+ $var = "quux_msg"
455
+ }
456
+ class foo inherits quux {
457
+ }
458
+ class baz {
459
+ include foo
460
+ }
461
+ class bar inherits baz {
462
+ notify { 'something': message => $var, }
463
+ }
464
+ MANIFEST
465
+ end
466
+ end
467
+
468
+ it "does not use a variable from a scope lexically enclosing it" do
469
+ expect_the_message_to_be('node_msg') do <<-MANIFEST
470
+ node default {
471
+ $var = "node_msg"
472
+ include other::bar
473
+ }
474
+ class other {
475
+ $var = "other_msg"
476
+ class bar {
477
+ notify { 'something': message => $var, }
478
+ }
479
+ }
480
+ MANIFEST
481
+ end
482
+ end
483
+
484
+ it "finds values in its node scope" do
485
+ expect_the_message_to_be('node_msg') do <<-MANIFEST
486
+ node default {
487
+ $var = "node_msg"
488
+ include baz
489
+ }
490
+ class foo {
491
+ }
492
+ class bar inherits foo {
493
+ notify { 'something': message => $var, }
494
+ }
495
+ class baz {
496
+ include bar
497
+ }
498
+ MANIFEST
499
+ end
500
+ end
501
+
502
+ it "finds values in its top scope" do
503
+ expect_the_message_to_be('top_msg') do <<-MANIFEST
504
+ $var = "top_msg"
505
+ node default {
506
+ include baz
507
+ }
508
+ class foo {
509
+ }
510
+ class bar inherits foo {
511
+ notify { 'something': message => $var, }
512
+ }
513
+ class baz {
514
+ include bar
515
+ }
516
+ MANIFEST
517
+ end
518
+ end
519
+
520
+ it "prefers variables from the node over those in the top scope" do
521
+ expect_the_message_to_be('node_msg') do <<-MANIFEST
522
+ $var = "top_msg"
523
+ node default {
524
+ $var = "node_msg"
525
+ include foo
526
+ }
527
+ class foo {
528
+ notify { 'something': message => $var, }
529
+ }
530
+ MANIFEST
531
+ end
532
+ end
533
+ end
534
+ end
535
+
207
536
  describe "when setvar is called with append=true" do
208
537
  it "should raise error if the variable is already defined in this scope" do
209
538
  @scope.setvar("var","1", :append => false)