puppet 3.1.0.rc1 → 3.1.0.rc2

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 (127) hide show
  1. data/COMMITTERS.md +185 -0
  2. data/ext/debian/changelog.erb +6 -0
  3. data/ext/debian/puppet-common.manpages +1 -0
  4. data/ext/debian/puppet.default +3 -1
  5. data/ext/debian/puppetmaster.default +6 -3
  6. data/ext/redhat/puppet.spec.erb +16 -5
  7. data/lib/puppet.rb +3 -5
  8. data/lib/puppet/defaults.rb +6 -5
  9. data/lib/puppet/dsl.rb +3 -7
  10. data/lib/puppet/dsl/resource_api.rb +120 -0
  11. data/lib/puppet/dsl/resource_type_api.rb +34 -0
  12. data/lib/puppet/module_tool.rb +23 -11
  13. data/lib/puppet/network/formats.rb +1 -1
  14. data/lib/puppet/node/environment.rb +1 -3
  15. data/lib/puppet/parser/ast/definition.rb +5 -2
  16. data/lib/puppet/parser/ast/hostclass.rb +3 -2
  17. data/lib/puppet/parser/ast/node.rb +5 -2
  18. data/lib/puppet/parser/ast/resourceparam.rb +1 -1
  19. data/lib/puppet/parser/compiler.rb +0 -10
  20. data/lib/puppet/parser/lexer.rb +50 -39
  21. data/lib/puppet/parser/parser_support.rb +29 -11
  22. data/lib/puppet/parser/scope.rb +2 -2
  23. data/lib/puppet/parser/type_loader.rb +7 -31
  24. data/lib/puppet/provider/package/openbsd.rb +16 -2
  25. data/lib/puppet/provider/package/pip.rb +11 -2
  26. data/lib/puppet/provider/package/portage.rb +29 -12
  27. data/lib/puppet/provider/service/launchd.rb +19 -14
  28. data/lib/puppet/provider/service/upstart.rb +1 -1
  29. data/lib/puppet/provider/user/hpux.rb +37 -2
  30. data/lib/puppet/resource.rb +25 -38
  31. data/lib/puppet/resource/type.rb +6 -14
  32. data/lib/puppet/settings.rb +1 -1
  33. data/lib/puppet/ssl/certificate_authority.rb +4 -1
  34. data/lib/puppet/ssl/certificate_request.rb +3 -1
  35. data/lib/puppet/ssl/certificate_signer.rb +22 -0
  36. data/lib/puppet/type.rb +4 -4
  37. data/lib/puppet/util/methodhelper.rb +0 -19
  38. data/lib/puppet/util/rubygems.rb +3 -1
  39. data/lib/puppet/util/selinux.rb +1 -6
  40. data/lib/puppet/version.rb +1 -1
  41. data/man/man5/puppet.conf.5 +81 -95
  42. data/man/man8/extlookup2hiera.8 +23 -0
  43. data/man/man8/puppet-agent.8 +3 -3
  44. data/man/man8/puppet-apply.8 +2 -6
  45. data/man/man8/puppet-ca.8 +6 -7
  46. data/man/man8/puppet-catalog.8 +6 -7
  47. data/man/man8/puppet-cert.8 +4 -4
  48. data/man/man8/puppet-certificate.8 +6 -7
  49. data/man/man8/puppet-certificate_request.8 +6 -7
  50. data/man/man8/puppet-certificate_revocation_list.8 +6 -7
  51. data/man/man8/puppet-config.8 +4 -8
  52. data/man/man8/puppet-describe.8 +1 -1
  53. data/man/man8/puppet-device.8 +1 -1
  54. data/man/man8/puppet-doc.8 +3 -3
  55. data/man/man8/puppet-facts.8 +4 -8
  56. data/man/man8/puppet-file.8 +6 -7
  57. data/man/man8/puppet-filebucket.8 +1 -1
  58. data/man/man8/puppet-help.8 +2 -6
  59. data/man/man8/puppet-inspect.8 +1 -1
  60. data/man/man8/puppet-instrumentation_data.8 +3 -7
  61. data/man/man8/puppet-instrumentation_listener.8 +3 -7
  62. data/man/man8/puppet-instrumentation_probe.8 +3 -7
  63. data/man/man8/puppet-key.8 +6 -7
  64. data/man/man8/puppet-kick.8 +5 -1
  65. data/man/man8/puppet-man.8 +2 -6
  66. data/man/man8/puppet-master.8 +2 -2
  67. data/man/man8/puppet-module.8 +11 -9
  68. data/man/man8/puppet-node.8 +38 -37
  69. data/man/man8/puppet-parser.8 +2 -6
  70. data/man/man8/puppet-plugin.8 +2 -6
  71. data/man/man8/puppet-queue.8 +1 -1
  72. data/man/man8/puppet-report.8 +3 -7
  73. data/man/man8/puppet-resource.8 +1 -1
  74. data/man/man8/puppet-resource_type.8 +3 -7
  75. data/man/man8/puppet-secret_agent.8 +2 -6
  76. data/man/man8/puppet-status.8 +3 -7
  77. data/man/man8/puppet.8 +1 -1
  78. data/spec/integration/parser/ruby_manifest_spec.rb +128 -0
  79. data/spec/lib/puppet_spec/compiler.rb +0 -11
  80. data/spec/spec_helper.rb +3 -4
  81. data/spec/unit/dsl/resource_api_spec.rb +180 -0
  82. data/spec/unit/dsl/resource_type_api_spec.rb +53 -0
  83. data/spec/unit/module_tool_spec.rb +79 -46
  84. data/spec/unit/network/formats_spec.rb +4 -0
  85. data/spec/unit/node/environment_spec.rb +0 -13
  86. data/spec/unit/parser/compiler_spec.rb +0 -26
  87. data/spec/unit/parser/parser_spec.rb +14 -0
  88. data/spec/unit/parser/type_loader_spec.rb +4 -15
  89. data/spec/unit/provider/package/openbsd_spec.rb +148 -35
  90. data/spec/unit/provider/package/pip_spec.rb +49 -25
  91. data/spec/unit/provider/package/portage_spec.rb +65 -0
  92. data/spec/unit/provider/service/launchd_spec.rb +6 -5
  93. data/spec/unit/provider/user/hpux_spec.rb +39 -11
  94. data/spec/unit/provider/user/useradd_spec.rb +14 -14
  95. data/spec/unit/resource/type_spec.rb +7 -49
  96. data/spec/unit/resource_spec.rb +0 -32
  97. data/spec/unit/ssl/certificate_request_spec.rb +18 -0
  98. data/spec/unit/util/rubygems_spec.rb +1 -1
  99. data/spec/unit/util/selinux_spec.rb +0 -2
  100. metadata +17 -50
  101. data/lib/puppet/dsl/actions.rb +0 -283
  102. data/lib/puppet/dsl/blank_slate.rb +0 -55
  103. data/lib/puppet/dsl/context.rb +0 -393
  104. data/lib/puppet/dsl/parser.rb +0 -57
  105. data/lib/puppet/dsl/resource_decorator.rb +0 -56
  106. data/lib/puppet/dsl/resource_reference.rb +0 -95
  107. data/lib/puppet/dsl/type_reference.rb +0 -102
  108. data/lib/puppet/util/manifest_filetype_helper.rb +0 -22
  109. data/spec/integration/dsl/classes_spec.rb +0 -191
  110. data/spec/integration/dsl/defaults_spec.rb +0 -38
  111. data/spec/integration/dsl/definitions_spec.rb +0 -73
  112. data/spec/integration/dsl/functions_spec.rb +0 -95
  113. data/spec/integration/dsl/nodes_spec.rb +0 -96
  114. data/spec/integration/dsl/params_spec.rb +0 -146
  115. data/spec/integration/dsl/relationships_spec.rb +0 -46
  116. data/spec/integration/dsl/resources_spec.rb +0 -202
  117. data/spec/integration/dsl/type_loading_spec.rb +0 -64
  118. data/spec/lib/matchers/catalog.rb +0 -50
  119. data/spec/lib/puppet_spec/dsl.rb +0 -29
  120. data/spec/unit/dsl/actions_spec.rb +0 -402
  121. data/spec/unit/dsl/blank_slate_spec.rb +0 -27
  122. data/spec/unit/dsl/context_spec.rb +0 -678
  123. data/spec/unit/dsl/parser_spec.rb +0 -56
  124. data/spec/unit/dsl/resource_decorator_spec.rb +0 -94
  125. data/spec/unit/dsl/resource_reference_spec.rb +0 -150
  126. data/spec/unit/dsl/type_reference_spec.rb +0 -164
  127. data/spec/unit/util/manifest_filetype_helper_spec.rb +0 -29
@@ -1,27 +0,0 @@
1
- require 'spec_helper'
2
- require 'puppet/dsl/blank_slate'
3
-
4
- describe Puppet::DSL::BlankSlate do
5
-
6
- it "should have only few methods defined" do
7
- # List of methods implemented in BasicObject in Ruby 1.9
8
- [:==, :equal?, :instance_eval, :instance_exec, :__send__, :__id__].each do |m|
9
- lambda do
10
- Puppet::DSL::BlankSlate.new.__send__ m
11
- end.should_not raise_error NoMethodError
12
- end
13
- end
14
-
15
- describe "private methods" do
16
-
17
- it "should be able to define singleton methods" do
18
- lambda do
19
- Puppet::DSL::BlankSlate.new.__send__ :define_singleton_method, :foobarbaz do
20
- raise ::NameError
21
- end.foobarbaz
22
- end.should raise_error NameError
23
- end
24
- end
25
-
26
- end
27
-
@@ -1,678 +0,0 @@
1
- require 'spec_helper'
2
- require 'puppet_spec/dsl'
3
-
4
- require 'puppet/dsl/parser'
5
- require 'puppet/dsl/context'
6
-
7
- include PuppetSpec::DSL
8
-
9
- describe Puppet::DSL::Context do
10
- prepare_compiler_and_scope_for_evaluation
11
-
12
- context "when creating resources" do
13
-
14
- it "should raise a InvalidTypeError when trying to create a resource with invalid type" do
15
- lambda do
16
- evaluate_in_context do
17
- create_resource :foobar, "test"
18
- end
19
- end.should raise_error NoMethodError
20
- end
21
-
22
- it "should raise NoMethodError when creating resources in a imported file on top level scope" do
23
- lambda do
24
- scope = mock
25
- scope.stubs(:nil?).returns true
26
- scope.stubs(:known_resource_types).returns nil
27
-
28
- evaluate_in_context :scope => scope do
29
- create_resource :foobar, "test"
30
- end
31
- end.should raise_error NoMethodError
32
- end
33
-
34
- it "should create a resource" do
35
- evaluate_in_context do
36
- create_resource :file, "/tmp/test"
37
- end
38
- compiler.resources.map {|r| r.name}.should include "/tmp/test"
39
- end
40
-
41
- it "should return an array of created resources" do
42
- evaluate_in_context do
43
- create_resource :file, "/tmp/test"
44
- end.each do |r|
45
- r.should be_a Puppet::Parser::Resource
46
- end
47
- end
48
-
49
- it "should set proper title" do
50
- title = "/tmp/test"
51
- evaluate_in_context do
52
- create_resource :file, title
53
- end.first.title.should == title
54
- end
55
-
56
- it "converts title to string" do
57
- title = :foobarbaz
58
- evaluate_in_context do
59
- notify title
60
- end.first.title.should == title.to_s
61
- end
62
-
63
- it "sets resource parameters with stringified values" do
64
- parameters = {:ensure => :present, :mode => "0666"}
65
- res = evaluate_in_context do
66
- create_resource :file, "/tmp/test", parameters
67
- end.first
68
-
69
- parameters.each do |k, v|
70
- res[k].should == v.to_s
71
- end
72
- end
73
-
74
- it "should allow block syntax for creating resources" do
75
- res = evaluate_in_context do
76
- create_resource :file, "/tmp/test" do |r|
77
- r.ensure = :present
78
- r.mode = "0666"
79
- end
80
- end.first
81
-
82
- res[:ensure].should == "present"
83
- res[:mode].should == "0666"
84
- end
85
-
86
- it "should allow both block and a hash; block overwrites hash" do
87
- res = evaluate_in_context do
88
- create_resource :file, "/tmp/test", :mode => "0600" do |r|
89
- r.mode = "0666"
90
- end
91
- end.first[:mode].should == "0666"
92
- end
93
-
94
- it "should mark resource as virtual when virtualizing? is set" do
95
- evaluate_in_context do
96
- virtual do
97
- create_resource :notify, "foo"
98
- end
99
- end.first.virtual.should be true
100
- end
101
-
102
- it "should mark resource as exported when exporting? is set" do
103
- evaluate_in_context do
104
- export do
105
- create_resource :notify, "foo"
106
- end
107
- end.first.exported.should be true
108
- end
109
-
110
- it "should mark resource as exported when options[:export] is set" do
111
- evaluate_in_context do
112
- create_resource :notify, "foo", :export => true
113
- end.first.exported.should be true
114
- end
115
-
116
- it "should assign resource as a parameter if one exists" do
117
- evaluate_in_context do
118
- create_resource :file, "asdf"
119
- create_resource :file, "test", :require => type("file")["asdf"]
120
- end.last.parameters.map {|_, v| v.value.class }.should include(Puppet::Parser::Resource)
121
- end
122
-
123
- it "should assign value as a parameter if given resource doesn't exist" do
124
- ["foobar", :asdf, 3, 3.14].each do |i|
125
- evaluate_in_context do
126
- create_resource :notify, "test-#{i}", :message => i
127
- end.last.parameters.map {|_, v| v.value }.should include(i.to_s)
128
- end
129
- end
130
-
131
- context "with method_missing" do
132
- it "should work" do
133
- evaluate_in_context do
134
- file "/tmp/test"
135
- end
136
- end
137
-
138
- it "should create cached method for future use" do
139
- evaluate_in_context do
140
- file "/tmp/foo"
141
- file "/tmp/bar"
142
- end
143
- end
144
-
145
- it "should fail with NoMethodError when resource type doesn't exist" do
146
- lambda do; evaluate_it_context do
147
- self.foobarbaz "/tmp/test"
148
- end; end.should raise_error NoMethodError
149
- end
150
-
151
- end
152
- end
153
-
154
- context "when calling a function" do
155
- it "raises NoMethodError when calling functions in a imported file on top level scope" do
156
- lambda do
157
- scope = mock
158
- scope.stubs(:nil?).returns true
159
- scope.stubs :known_resource_types
160
- evaluate_in_context :scope => scope do
161
- call_function :foobar
162
- end
163
- end.should raise_error NoMethodError
164
- end
165
-
166
- it "should call function with passed arguments" do
167
- Puppet::Parser::Functions.stubs(:function).returns true
168
- scope.expects(:foobar).with(1, 2, 3)
169
- evaluate_in_context do
170
- call_function :foobar, 1, 2, 3
171
- end
172
- end
173
-
174
- context "with method_missing" do
175
- it "should work" do
176
- scope.expects :notice
177
- evaluate_in_context do
178
- notice
179
- end
180
- end
181
-
182
- it "should create cached version of the method" do
183
- evaluate_in_context do
184
- notice "foo"
185
- notice "bar"
186
- end
187
- end
188
-
189
- it "should fail with NoMethodError when the function doesn't exist" do
190
- lambda do; evaluate_in_context do
191
- self.foobar
192
- end; end.should raise_error NoMethodError
193
- end
194
-
195
- end
196
- end
197
-
198
- context "when creating definition" do
199
-
200
- it "should add a new type" do
201
- evaluate_in_context do
202
- define(:foo) {}
203
- end.should == known_resource_types.definition(:foo)
204
- end
205
-
206
- it "converts the name to string" do
207
- name = :foo
208
- evaluate_in_context do
209
- define(name) {}
210
- end.name.should == name.to_s
211
- end
212
-
213
- it "should call the block when evaluating type" do
214
- expected = nil
215
- evaluate_in_context do
216
- define :foo do
217
- expected = true
218
- end
219
- end.ruby_code.each {|c| c.evaluate scope, scope.known_resource_types}
220
-
221
- expected.should be true
222
- end
223
-
224
- it "should return Puppet::Resource::Type" do
225
- evaluate_in_context do
226
- define(:foo) {}
227
- end.should be_a Puppet::Resource::Type
228
- end
229
-
230
- it "should create a definition" do
231
- evaluate_in_context do
232
- define(:foo) {}
233
- end.type.should == :definition
234
- end
235
-
236
- it "should set proper name" do
237
- evaluate_in_context do
238
- define(:foo) {}
239
- end.name.should == "foo"
240
- end
241
-
242
- it "should raise NoMethodError when the nesting is invalid" do
243
- lambda do
244
- evaluate_in_context :nesting => 1 do
245
- define(:foo) {}
246
- end
247
- end.should raise_error NoMethodError
248
- end
249
-
250
- it "should raise ArgumentError when no block is given" do
251
- lambda do
252
- evaluate_in_context do
253
- define :foo
254
- end
255
- end.should raise_error ArgumentError
256
- end
257
-
258
- it "should assign arguments" do
259
- args = {"myparam" => "myvalue"}
260
- evaluate_in_context do
261
- define :foo, :arguments => args do
262
- end
263
- end.arguments.should == args
264
- end
265
-
266
- it "converts argument keys to strings" do
267
- args = {:answer => 42}
268
- evaluate_in_context do
269
- define :foo, :arguments => args do
270
- end
271
- end.arguments.should == {"answer" => 42}
272
- end
273
-
274
- it "should fail when passing invalid options" do
275
- lambda do; evaluate_in_context do
276
- define(:foo, :bar => "asdf") {}
277
- end; end.should raise_error ArgumentError
278
- end
279
-
280
- it "should be able to use created definition" do
281
- evaluate_in_context do
282
- define(:foo) { notify params[:name] }
283
- foo "bar"
284
- end
285
- compiler.findresource("Foo[bar]").should_not be nil
286
- end
287
-
288
-
289
- end
290
-
291
- context "when creating a node" do
292
-
293
- it "should add a new type" do
294
- evaluate_in_context do
295
- node("foo") {}
296
- end.should == known_resource_types.node(:foo)
297
- end
298
-
299
- it "converts the name to string unless it's a regexp" do
300
- name = :foo
301
- evaluate_in_context do
302
- node(name) {}
303
- end.name.should == name.to_s
304
- end
305
-
306
- it "doesn't convert the name to string when it's a regexp" do
307
- evaluate_in_context do
308
- node(/foo/) {}
309
- end.name_is_regex?.should be true
310
- end
311
-
312
- it "should set proper name" do
313
- evaluate_in_context do
314
- node("foo") {}
315
- end.name.should == "foo"
316
- end
317
-
318
- it "should return Puppet::Resource::Type" do
319
- evaluate_in_context do
320
- node("foo") {}
321
- end.should be_a Puppet::Resource::Type
322
- end
323
-
324
- it "should call the block when evaluating type" do
325
- expected = nil
326
- evaluate_in_context do
327
- node "foo" do
328
- expected = true
329
- end
330
- end.ruby_code.each {|c| c.evaluate scope, scope.known_resource_types}
331
-
332
- expected.should be true
333
- end
334
-
335
- it "should raise NoMethodError when the nesting is invalid" do
336
- lambda do
337
- evaluate_in_context :nesting => 1 do
338
- node("foo") {}
339
- end
340
- end.should raise_error NoMethodError
341
- end
342
-
343
- it "should raise ArgumentError when there is no block given" do
344
- lambda do
345
- evaluate_in_context do
346
- node "foo"
347
- end
348
- end.should raise_error ArgumentError
349
- end
350
-
351
- it "allows to assign a parent" do
352
- evaluate_in_context do
353
- node "foo", :inherits => "bar" do
354
- end
355
- end.parent.should == "bar"
356
- end
357
-
358
- it "converts name of the parent to string unless it's a regexp" do
359
- parent = :bar
360
- evaluate_in_context do
361
- node :foo, :inherits => parent do
362
- end
363
- end.parent.should == parent.to_s
364
- end
365
-
366
- it "should support passing a name as regex" do
367
- evaluate_in_context do
368
- node(/mac/) {}
369
- end.name_is_regex?.should be true
370
- end
371
-
372
- it "should fail when passing invalid options" do
373
- lambda do; evaluate_in_context do
374
- node("foo", :bar => :baz) {}
375
- end; end.should raise_error ArgumentError
376
- end
377
-
378
- end
379
-
380
- describe "when defining a class" do
381
-
382
- it "adds a new type" do
383
- evaluate_in_context do
384
- hostclass(:foo) {}
385
- end.should == known_resource_types.hostclass(:foo)
386
- end
387
-
388
- it "converts the name to string" do
389
- name = :foo
390
- evaluate_in_context do
391
- hostclass(name) {}
392
- end.name.should == name.to_s
393
- end
394
-
395
- it "calls the block when evaluating type" do
396
- expected = nil
397
- evaluate_in_context do
398
- hostclass :foo do
399
- expected = true
400
- end
401
- end.ruby_code.each {|c| c.evaluate scope, scope.known_resource_types}
402
-
403
- expected.should be true
404
- end
405
-
406
- it "should return Puppet::Resource::Type object" do
407
- evaluate_in_context do
408
- hostclass(:foo) {}
409
- end.should be_a Puppet::Resource::Type
410
- end
411
-
412
- it "should set proper name" do
413
- evaluate_in_context do
414
- hostclass(:foo) {}
415
- end.name.should == "foo"
416
- end
417
-
418
- it "should create a hostclass" do
419
- evaluate_in_context do
420
- hostclass(:foo) {}
421
- end.type.should == :hostclass
422
- end
423
-
424
- it "should raise NoMethodError when called in invalid nesting" do
425
- lambda do
426
- evaluate_in_context :nesting => 1 do
427
- hostclass(:foo) {}
428
- end
429
- end.should raise_error NoMethodError
430
- end
431
-
432
- it "should raise ArgumentError when no block is given" do
433
- lambda do
434
- evaluate_in_context do
435
- hostclass :foo
436
- end
437
- end.should raise_error ArgumentError
438
- end
439
-
440
- it "should set arguments" do
441
- args = {"myparam" => "foo"}
442
- evaluate_in_context do
443
- hostclass(:foo, :arguments => args) {}
444
- end.arguments.should == args
445
- end
446
-
447
- it "should stringify keys of the arguments" do
448
- args = {:my => 4}
449
- evaluate_in_context do
450
- hostclass(:foo, :arguments => args) {}
451
- end.arguments.should == {"my" => 4}
452
-
453
- end
454
-
455
- it "should set parent type" do
456
- parent = "parent"
457
- evaluate_in_context do
458
- hostclass(:foo, :inherits => parent) {}
459
- end.parent.should == parent
460
- end
461
-
462
- it "converts parent's name to string" do
463
- parent = :parent
464
- evaluate_in_context do
465
- hostclass(:foo, :inherits => parent) {}
466
- end.parent.should == parent.to_s
467
- end
468
-
469
- it "should fail when passing invalid options" do
470
- lambda do; evaluate_in_context do
471
- hostclass(:foo, :bar => :baz) {}
472
- end; end.should raise_error ArgumentError
473
- end
474
-
475
- it "should be able to use created class" do
476
- evaluate_in_context do
477
- hostclass(:foo) { notify params[:name] }
478
- use :foo
479
- end
480
- compiler.findresource("Class[foo]").should_not be nil
481
- end
482
-
483
- end
484
-
485
- context "when referencing type" do
486
- it "should return a type reference when accessing constant" do
487
- evaluate_in_context do
488
- # Full name needs to be used to trigger const_missing
489
- Puppet::DSL::Context::Notify
490
- end.should be_a Puppet::DSL::TypeReference
491
- end
492
-
493
- it "should return a type reference using `type' method" do
494
- evaluate_in_context do
495
- type "notify"
496
- end.should be_a Puppet::DSL::TypeReference
497
- end
498
-
499
- it "should raise NameError when there is no valid type" do
500
- lambda do
501
- evaluate_in_context do
502
- Puppet::DSL::Context::Foobar
503
- end
504
- end.should raise_error NameError
505
- end
506
-
507
- it "should return type reference for a given type" do
508
- evaluate_in_context do
509
- Puppet::DSL::Context::Notify
510
- end.type_name.should == "Notify"
511
- end
512
- end
513
-
514
- describe "utility methods" do
515
-
516
- describe "#raise" do
517
- it "should proxy raise to Object" do
518
- Object.expects :raise
519
- evaluate_in_context do
520
- raise
521
- end
522
- end
523
- end
524
-
525
- describe "#params" do
526
- it "should return current scope" do
527
- evaluate_in_context do
528
- params
529
- end.should be_a Puppet::Parser::Scope
530
- end
531
- end
532
-
533
- describe "#exporting?" do
534
- it "should return true when called from the export block" do
535
- evaluate_in_context do
536
- export do
537
- exporting?.should == true
538
- end
539
- end
540
- end
541
-
542
- it "should return false when called outside export block" do
543
- evaluate_in_context do
544
- exporting?.should == false
545
- end
546
- end
547
- end
548
-
549
- describe "#virtualizing?" do
550
- it "should return true when called from the virtual block" do
551
- evaluate_in_context do
552
- virtual do
553
- virtualizing?.should == true
554
- end
555
- end
556
- end
557
-
558
- it "should return false when called outside virtual block" do
559
- evaluate_in_context do
560
- virtualizing?.should == false
561
- end
562
- end
563
- end
564
-
565
- describe "#export" do
566
- it "should mark resources created in block as exported" do
567
- evaluate_in_context do
568
- export do
569
- file "foo"
570
- end
571
- end.first.exported.should be true
572
- end
573
-
574
- it "should mark resources as exported" do
575
- evaluate_in_context do
576
- export file "foo"
577
- end.first.exported.should be true
578
- end
579
-
580
- it "should mark referenced resources as exported" do
581
- evaluate_in_context do
582
- file "foo"
583
- export type("file")["foo"]
584
- end.first.resource.exported.should be true
585
- end
586
-
587
- it "should mark string references of resources as exported" do
588
- evaluate_in_context do
589
- resource = file "foo"
590
- export "File[foo]"
591
- resource
592
- end.first.exported.should be true
593
- end
594
- end
595
-
596
- describe "#virtual" do
597
- it "should mark resources created in block as virtual" do
598
- evaluate_in_context do
599
- virtual do
600
- file "foo"
601
- end
602
- end.first.virtual.should be true
603
- end
604
-
605
- it "should mark resources as virtual" do
606
- evaluate_in_context do
607
- virtual file "foo"
608
- end.first.virtual.should be true
609
- end
610
-
611
- it "should mark referenced resources as virtual" do
612
- evaluate_in_context do
613
- file "foo"
614
- virtual type("file")["foo"]
615
- end.first.resource.virtual.should be true
616
- end
617
-
618
- it "should mark string references of resources as virtual" do
619
- evaluate_in_context do
620
- resource = file "foo"
621
- virtual "File[foo]"
622
- resource
623
- end.first.virtual.should be true
624
- end
625
- end
626
-
627
- describe "#respond_to?" do
628
- it "should return true when function is defined" do
629
- evaluate_in_context do
630
- respond_to?(:notice).should == true
631
- end
632
- end
633
-
634
- it "should return true when resource type is defined" do
635
- evaluate_in_context do
636
- respond_to?(:file).should == true
637
- end
638
- end
639
-
640
- it "should fail otherwise" do
641
- evaluate_in_context do
642
- respond_to?(:asdf).should == false
643
- end
644
- end
645
- end
646
-
647
- describe "#ruby_eval" do
648
- it "should fail when called without block" do
649
- lambda do; evaluate_in_context do
650
- ruby_eval
651
- end; end.should raise_error
652
- end
653
-
654
- it "should be able to call methods from Object in the block" do
655
- Object.any_instance.expects(:puts).with "hello world"
656
- evaluate_in_context do
657
- ruby_eval { puts "hello world" }
658
- end
659
- end
660
- end
661
-
662
- describe "#inspect" do
663
- it "returns manifest filename if it is set" do
664
- filename = "foo.rb"
665
- evaluate_in_context(:filename => filename) {
666
- inspect
667
- }.should == filename.inspect
668
- end
669
-
670
- it "returns 'dsl_main' when no filename is set" do
671
- evaluate_in_context { inspect }.should == "dsl_main".inspect
672
- end
673
-
674
- end
675
-
676
- end
677
- end
678
-