puppet 2.7.18 → 2.7.19

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 (137) hide show
  1. data/CHANGELOG +82 -0
  2. data/CONTRIBUTING.md +114 -171
  3. data/README.md +8 -0
  4. data/README_DEVELOPER.md +38 -3
  5. data/Rakefile +19 -3
  6. data/conf/osx/createpackage.sh +3 -1
  7. data/conf/redhat/logrotate +1 -1
  8. data/conf/redhat/puppet.spec +35 -8
  9. data/lib/puppet.rb +1 -1
  10. data/lib/puppet/application/agent.rb +2 -0
  11. data/lib/puppet/application/master.rb +2 -0
  12. data/lib/puppet/configurer.rb +2 -3
  13. data/lib/puppet/defaults.rb +6 -5
  14. data/lib/puppet/face/module/install.rb +2 -1
  15. data/lib/puppet/file_bucket/dipper.rb +1 -1
  16. data/lib/puppet/indirector/file_content.rb +2 -2
  17. data/lib/puppet/indirector/file_metadata.rb +2 -2
  18. data/lib/puppet/indirector/indirection.rb +3 -4
  19. data/lib/puppet/indirector/rest.rb +12 -6
  20. data/lib/puppet/interface/action_manager.rb +1 -2
  21. data/lib/puppet/module_tool/applications/unpacker.rb +22 -3
  22. data/lib/puppet/network/handler/fileserver.rb +2 -2
  23. data/lib/puppet/parser/ast/resource.rb +9 -2
  24. data/lib/puppet/parser/functions/fqdn_rand.rb +2 -1
  25. data/lib/puppet/parser/functions/md5.rb +2 -2
  26. data/lib/puppet/parser/functions/sha1.rb +2 -2
  27. data/lib/puppet/parser/functions/template.rb +0 -2
  28. data/lib/puppet/parser/type_loader.rb +1 -2
  29. data/lib/puppet/provider/augeas/augeas.rb +19 -1
  30. data/lib/puppet/provider/confine.rb +1 -1
  31. data/lib/puppet/provider/package/msi.rb +97 -51
  32. data/lib/puppet/provider/scheduled_task/win32_taskscheduler.rb +1 -0
  33. data/lib/puppet/provider/service/gentoo.rb +0 -2
  34. data/lib/puppet/provider/service/openrc.rb +69 -0
  35. data/lib/puppet/provider/service/windows.rb +6 -4
  36. data/lib/puppet/provider/user/aix.rb +8 -4
  37. data/lib/puppet/provider/user/useradd.rb +6 -0
  38. data/lib/puppet/rails/benchmark.rb +2 -2
  39. data/lib/puppet/reports/store.rb +9 -9
  40. data/lib/puppet/resource/catalog.rb +2 -1
  41. data/lib/puppet/resource/type_collection.rb +2 -1
  42. data/lib/puppet/ssl/base.rb +1 -2
  43. data/lib/puppet/ssl/certificate_authority/interface.rb +1 -0
  44. data/lib/puppet/test/test_helper.rb +2 -1
  45. data/lib/puppet/type.rb +1 -1
  46. data/lib/puppet/type/augeas.rb +1 -1
  47. data/lib/puppet/type/file.rb +4 -2
  48. data/lib/puppet/type/scheduled_task.rb +8 -10
  49. data/lib/puppet/type/tidy.rb +1 -1
  50. data/lib/puppet/util.rb +63 -25
  51. data/lib/puppet/util/autoload.rb +6 -4
  52. data/lib/puppet/util/checksums.rb +3 -8
  53. data/lib/puppet/util/diff.rb +2 -1
  54. data/lib/puppet/util/filetype.rb +1 -3
  55. data/lib/puppet/util/run_mode.rb +2 -1
  56. data/lib/puppet/util/suidmanager.rb +1 -1
  57. data/lib/puppet/util/windows.rb +1 -0
  58. data/lib/puppet/util/windows/file.rb +27 -0
  59. data/lib/puppet/util/windows/user.rb +1 -2
  60. data/man/man8/puppet-agent.8 +4 -0
  61. data/man/man8/puppet-master.8 +4 -0
  62. data/man/man8/puppetmasterd.8 +4 -0
  63. data/spec/fixtures/unit/provider/augeas/augeas/augeas/lenses/test.aug +13 -0
  64. data/spec/fixtures/unit/provider/augeas/augeas/etc/fstab +10 -0
  65. data/spec/fixtures/unit/provider/augeas/augeas/etc/hosts +6 -0
  66. data/spec/fixtures/unit/provider/augeas/augeas/etc/test +3 -0
  67. data/spec/fixtures/unit/provider/augeas/augeas/test.aug +13 -0
  68. data/spec/fixtures/unit/provider/service/openrc/rcservice_list +8 -0
  69. data/spec/fixtures/unit/provider/service/openrc/rcstatus +43 -0
  70. data/spec/integration/defaults_spec.rb +3 -3
  71. data/spec/integration/network/server/mongrel_spec.rb +8 -6
  72. data/spec/integration/parser/parser_spec.rb +1 -1
  73. data/spec/integration/type/file_spec.rb +49 -12
  74. data/spec/lib/puppet_spec/database.rb +5 -3
  75. data/spec/lib/puppet_spec/files.rb +2 -1
  76. data/spec/monkey_patches/alias_should_to_must.rb +15 -2
  77. data/spec/shared_behaviours/file_serving_model.rb +9 -6
  78. data/spec/shared_behaviours/path_parameters.rb +5 -5
  79. data/spec/shared_behaviours/things_that_declare_options.rb +5 -5
  80. data/spec/unit/application/facts_spec.rb +1 -1
  81. data/spec/unit/application_spec.rb +10 -8
  82. data/spec/unit/configurer_spec.rb +11 -2
  83. data/spec/unit/face/ca_spec.rb +15 -15
  84. data/spec/unit/face/help_spec.rb +5 -5
  85. data/spec/unit/face/module/install_spec.rb +13 -2
  86. data/spec/unit/face/node_spec.rb +7 -6
  87. data/spec/unit/indirector/certificate_request/ca_spec.rb +1 -1
  88. data/spec/unit/indirector/envelope_spec.rb +0 -13
  89. data/spec/unit/indirector/facts/inventory_service_spec.rb +1 -1
  90. data/spec/unit/indirector/queue_spec.rb +3 -3
  91. data/spec/unit/indirector/rest_spec.rb +31 -20
  92. data/spec/unit/indirector_spec.rb +5 -5
  93. data/spec/unit/interface/action_builder_spec.rb +3 -2
  94. data/spec/unit/interface/action_manager_spec.rb +1 -1
  95. data/spec/unit/interface/action_spec.rb +4 -3
  96. data/spec/unit/interface/face_collection_spec.rb +1 -1
  97. data/spec/unit/interface/option_spec.rb +13 -9
  98. data/spec/unit/interface_spec.rb +5 -5
  99. data/spec/unit/module_tool/applications/unpacker_spec.rb +61 -0
  100. data/spec/unit/network/handler/fileserver_spec.rb +3 -3
  101. data/spec/unit/other/transbucket_spec.rb +6 -9
  102. data/spec/unit/parser/ast/resource_spec.rb +27 -0
  103. data/spec/unit/parser/functions/create_resources_spec.rb +12 -12
  104. data/spec/unit/parser/lexer_spec.rb +5 -5
  105. data/spec/unit/provider/augeas/augeas_spec.rb +78 -0
  106. data/spec/unit/provider/nameservice/directoryservice_spec.rb +6 -6
  107. data/spec/unit/provider/package/freebsd_spec.rb +2 -2
  108. data/spec/unit/provider/package/msi_spec.rb +181 -114
  109. data/spec/unit/provider/package/openbsd_spec.rb +1 -0
  110. data/spec/unit/provider/package/pkgdmg_spec.rb +3 -3
  111. data/spec/unit/provider/scheduled_task/win32_taskscheduler_spec.rb +1 -1
  112. data/spec/unit/provider/service/openrc_spec.rb +209 -0
  113. data/spec/unit/provider/service/windows_spec.rb +57 -59
  114. data/spec/unit/provider/user/useradd_spec.rb +7 -0
  115. data/spec/unit/reports/store_spec.rb +13 -13
  116. data/spec/unit/resource/catalog_spec.rb +29 -24
  117. data/spec/unit/resource_spec.rb +13 -13
  118. data/spec/unit/simple_graph_spec.rb +12 -12
  119. data/spec/unit/ssl/certificate_authority/interface_spec.rb +3 -3
  120. data/spec/unit/ssl/certificate_authority_spec.rb +11 -10
  121. data/spec/unit/transaction_spec.rb +3 -3
  122. data/spec/unit/type/cron_spec.rb +171 -171
  123. data/spec/unit/type/exec_spec.rb +29 -27
  124. data/spec/unit/type/file_spec.rb +22 -13
  125. data/spec/unit/type/interface_spec.rb +1 -1
  126. data/spec/unit/type/scheduled_task_spec.rb +15 -14
  127. data/spec/unit/type/tidy_spec.rb +2 -2
  128. data/spec/unit/type/user_spec.rb +15 -15
  129. data/spec/unit/type/vlan_spec.rb +1 -1
  130. data/spec/unit/type_spec.rb +22 -25
  131. data/spec/unit/util/autoload_spec.rb +13 -7
  132. data/spec/unit/util/backups_spec.rb +36 -67
  133. data/spec/unit/util/storage_spec.rb +2 -9
  134. data/spec/unit/util/suidmanager_spec.rb +1 -1
  135. data/spec/unit/util_spec.rb +20 -28
  136. data/test/ral/manager/attributes.rb +1 -1
  137. metadata +1553 -1542
@@ -59,17 +59,17 @@ describe Puppet::Type.type(:exec) do
59
59
  end
60
60
 
61
61
  it "should report a failure" do
62
- proc { exec_tester('false', 1).refresh }.
63
- should raise_error(Puppet::Error, /^false returned 1 instead of/)
62
+ expect { exec_tester('false', 1).refresh }.
63
+ to raise_error(Puppet::Error, /^false returned 1 instead of/)
64
64
  end
65
65
 
66
66
  it "should not report a failure if the exit status is specified in a returns array" do
67
- proc { exec_tester("false", 1, :returns => [0, 1]).refresh }.should_not raise_error
67
+ expect { exec_tester("false", 1, :returns => [0, 1]).refresh }.to_not raise_error
68
68
  end
69
69
 
70
70
  it "should report a failure if the exit status is not specified in a returns array" do
71
- proc { exec_tester('false', 1, :returns => [0, 100]).refresh }.
72
- should raise_error(Puppet::Error, /^false returned 1 instead of/)
71
+ expect { exec_tester('false', 1, :returns => [0, 100]).refresh }.
72
+ to raise_error(Puppet::Error, /^false returned 1 instead of/)
73
73
  end
74
74
 
75
75
  it "should log the output on success" do
@@ -84,8 +84,8 @@ describe Puppet::Type.type(:exec) do
84
84
 
85
85
  it "should log the output on failure" do
86
86
  output = "output1\noutput2\n"
87
- proc { exec_tester('false', 1, :output => output, :logoutput => true).refresh }.
88
- should raise_error(Puppet::Error)
87
+ expect { exec_tester('false', 1, :output => output, :logoutput => true).refresh }.
88
+ to raise_error(Puppet::Error)
89
89
 
90
90
  output.split("\n").each do |line|
91
91
  log = @logs.shift
@@ -98,8 +98,8 @@ describe Puppet::Type.type(:exec) do
98
98
  describe "when logoutput=>on_failure is set" do
99
99
  it "should log the output on failure" do
100
100
  output = "output1\noutput2\n"
101
- proc { exec_tester('false', 1, :output => output, :logoutput => :on_failure).refresh }.
102
- should raise_error(Puppet::Error, /^false returned 1 instead of/)
101
+ expect { exec_tester('false', 1, :output => output, :logoutput => :on_failure).refresh }.
102
+ to raise_error(Puppet::Error, /^false returned 1 instead of/)
103
103
 
104
104
  output.split("\n").each do |line|
105
105
  log = @logs.shift
@@ -111,10 +111,10 @@ describe Puppet::Type.type(:exec) do
111
111
  it "should log the output on failure when returns is specified as an array" do
112
112
  output = "output1\noutput2\n"
113
113
 
114
- proc {
114
+ expect {
115
115
  exec_tester('false', 1, :output => output, :returns => [0, 100],
116
116
  :logoutput => :on_failure).refresh
117
- }.should raise_error(Puppet::Error, /^false returned 1 instead of/)
117
+ }.to raise_error(Puppet::Error, /^false returned 1 instead of/)
118
118
 
119
119
  output.split("\n").each do |line|
120
120
  log = @logs.shift
@@ -138,7 +138,7 @@ describe Puppet::Type.type(:exec) do
138
138
  it "should repeat the command attempt 'tries' times on failure and produce an error" do
139
139
  tries = 5
140
140
  resource = exec_tester("false", 1, :tries => tries, :try_sleep => 0)
141
- proc { resource.refresh }.should raise_error(Puppet::Error)
141
+ expect { resource.refresh }.to raise_error(Puppet::Error)
142
142
  end
143
143
  end
144
144
  end
@@ -190,8 +190,9 @@ describe Puppet::Type.type(:exec) do
190
190
  describe "on POSIX systems", :as_platform => :posix do
191
191
  it "should fail if we are not root" do
192
192
  Puppet.features.stubs(:root?).returns(false)
193
- expect { Puppet::Type.type(:exec).new(:name => '/bin/true whatever', :user => 'input') }.
194
- should raise_error Puppet::Error, /Parameter user failed/
193
+ expect {
194
+ Puppet::Type.type(:exec).new(:name => '/bin/true whatever', :user => 'input')
195
+ }.to raise_error Puppet::Error, /Parameter user failed/
195
196
  end
196
197
 
197
198
  ['one', 2, 'root', 4294967295, 4294967296].each do |value|
@@ -209,8 +210,9 @@ describe Puppet::Type.type(:exec) do
209
210
  end
210
211
 
211
212
  it "should reject user parameter" do
212
- expect { Puppet::Type.type(:exec).new(:name => 'c:\windows\notepad.exe', :user => 'input') }.
213
- should raise_error Puppet::Error, /Unable to execute commands as other users on Windows/
213
+ expect {
214
+ Puppet::Type.type(:exec).new(:name => 'c:\windows\notepad.exe', :user => 'input')
215
+ }.to raise_error Puppet::Error, /Unable to execute commands as other users on Windows/
214
216
  end
215
217
  end
216
218
  end
@@ -267,12 +269,12 @@ describe Puppet::Type.type(:exec) do
267
269
  end
268
270
 
269
271
  it "should work if the provider calls the command valid" do
270
- expect { test(command, true) }.should_not raise_error
272
+ expect { test(command, true) }.to_not raise_error
271
273
  end
272
274
 
273
275
  it "should fail if the provider calls the command invalid" do
274
276
  expect { test(command, false) }.
275
- should raise_error Puppet::Error, /Parameter #{@param} failed: from a stub/
277
+ to raise_error Puppet::Error, /Parameter #{@param} failed: from a stub/
276
278
  end
277
279
  end
278
280
  end
@@ -335,7 +337,7 @@ describe Puppet::Type.type(:exec) do
335
337
  }.each do |name, data|
336
338
  it "should reject #{name} without assignment" do
337
339
  expect { @exec[:environment] = data }.
338
- should raise_error Puppet::Error, /Invalid environment setting/
340
+ to raise_error Puppet::Error, /Invalid environment setting/
339
341
  end
340
342
  end
341
343
  end
@@ -356,12 +358,12 @@ describe Puppet::Type.type(:exec) do
356
358
  ['1/2', '', 'foo', '5foo'].each do |invalid|
357
359
  it "should reject '#{invalid}' as invalid" do
358
360
  expect { @exec[:timeout] = invalid }.
359
- should raise_error Puppet::Error, /The timeout must be a number/
361
+ to raise_error Puppet::Error, /The timeout must be a number/
360
362
  end
361
363
 
362
364
  it "should reject '#{invalid}' in an array as invalid" do
363
365
  expect { @exec[:timeout] = [invalid] }.
364
- should raise_error Puppet::Error, /The timeout must be a number/
366
+ to raise_error Puppet::Error, /The timeout must be a number/
365
367
  end
366
368
  end
367
369
 
@@ -376,7 +378,7 @@ describe Puppet::Type.type(:exec) do
376
378
  FileTest.stubs(:executable?).with(File.expand_path('/bin/sleep')).returns(true)
377
379
  sleep_exec = Puppet::Type.type(:exec).new(:name => 'sleep 1', :path => [File.expand_path('/bin')], :timeout => '0.2')
378
380
 
379
- lambda { sleep_exec.refresh }.should raise_error Puppet::Error, "Command exceeded timeout"
381
+ expect { sleep_exec.refresh }.to raise_error Puppet::Error, "Command exceeded timeout"
380
382
  end
381
383
 
382
384
  it "should convert timeout to a float" do
@@ -413,14 +415,14 @@ describe Puppet::Type.type(:exec) do
413
415
  [-3.5, -1, 0, 0.2, '1/2', '1_000_000', '+12', '', 'foo'].each do |invalid|
414
416
  it "should reject '#{invalid}' as invalid" do
415
417
  expect { @exec[:tries] = invalid }.
416
- should raise_error Puppet::Error, /Tries must be an integer/
418
+ to raise_error Puppet::Error, /Tries must be an integer/
417
419
  end
418
420
 
419
421
  if "REVISIT: too much test log spam" == "a good thing" then
420
422
  it "should reject '#{invalid}' in an array as invalid" do
421
423
  pending "inconsistent, but this is not supporting arrays, unlike timeout"
422
424
  expect { @exec[:tries] = [invalid] }.
423
- should raise_error Puppet::Error, /Tries must be an integer/
425
+ to raise_error Puppet::Error, /Tries must be an integer/
424
426
  end
425
427
  end
426
428
  end
@@ -452,14 +454,14 @@ describe Puppet::Type.type(:exec) do
452
454
  }.each do |invalid, error|
453
455
  it "should reject '#{invalid}' as invalid" do
454
456
  expect { @exec[:try_sleep] = invalid }.
455
- should raise_error Puppet::Error, /try_sleep #{error}/
457
+ to raise_error Puppet::Error, /try_sleep #{error}/
456
458
  end
457
459
 
458
460
  if "REVISIT: too much test log spam" == "a good thing" then
459
461
  it "should reject '#{invalid}' in an array as invalid" do
460
462
  pending "inconsistent, but this is not supporting arrays, unlike timeout"
461
463
  expect { @exec[:try_sleep] = [invalid] }.
462
- should raise_error Puppet::Error, /try_sleep #{error}/
464
+ to raise_error Puppet::Error, /try_sleep #{error}/
463
465
  end
464
466
  end
465
467
  end
@@ -476,7 +478,7 @@ describe Puppet::Type.type(:exec) do
476
478
  [1, 0, "1", "0", "yes", "y", "no", "n"].each do |value|
477
479
  it "should reject '#{value}'" do
478
480
  expect { @exec[:refreshonly] = value }.
479
- should raise_error(Puppet::Error,
481
+ to raise_error(Puppet::Error,
480
482
  /Invalid value #{value.inspect}\. Valid values are true, false/
481
483
  )
482
484
  end
@@ -42,7 +42,7 @@ describe Puppet::Type.type(:file) do
42
42
  # REVISIT: This should be wrong, later. See the next test.
43
43
  # --daniel 2011-01-31
44
44
  file[:path].should == '/tmp/xxx'
45
- }.should_not raise_error
45
+ }.to_not raise_error
46
46
  end
47
47
 
48
48
  # REVISIT: This is pending, because I don't want to try and audit the
@@ -76,7 +76,7 @@ describe Puppet::Type.type(:file) do
76
76
  end
77
77
 
78
78
  it "should not accept a drive letter without a slash", :'fails_on_ruby_1.9.2' => true do
79
- lambda { file[:path] = "X:" }.should raise_error(/File paths must be fully qualified/)
79
+ expect { file[:path] = "X:" }.to raise_error(/File paths must be fully qualified/)
80
80
  end
81
81
 
82
82
  describe "when using UNC filenames", :if => Puppet.features.microsoft_windows?, :'fails_on_ruby_1.9.2' => true do
@@ -433,7 +433,7 @@ describe Puppet::Type.type(:file) do
433
433
 
434
434
  it "should set a desired 'ensure' value if none is set and 'target' is set" do
435
435
  file = described_class.new(:path => path, :target => File.expand_path(__FILE__))
436
- file[:ensure].should == :symlink
436
+ file[:ensure].should == :link
437
437
  end
438
438
  end
439
439
 
@@ -465,7 +465,7 @@ describe Puppet::Type.type(:file) do
465
465
  it "should create a new resource relative to the parent" do
466
466
  child = file.newchild('bar')
467
467
 
468
- child.should be_a(described_class)
468
+ child.must be_a(described_class)
469
469
  child[:path].should == File.join(file[:path], 'bar')
470
470
  end
471
471
 
@@ -1112,6 +1112,15 @@ describe Puppet::Type.type(:file) do
1112
1112
  File.chmod(0777, dir)
1113
1113
  end
1114
1114
 
1115
+ it "should return nil if parts of path are no directories" do
1116
+ regular_file = tmpfile('ENOTDIR_test')
1117
+ FileUtils.touch(regular_file)
1118
+ impossible_child = File.join(regular_file, 'some_file')
1119
+
1120
+ file[:path] = impossible_child
1121
+ file.stat.should be_nil
1122
+ end
1123
+
1115
1124
  it "should return the stat instance" do
1116
1125
  file.stat.should be_a(File::Stat)
1117
1126
  end
@@ -1133,7 +1142,7 @@ describe Puppet::Type.type(:file) do
1133
1142
  property = stub('content_property', :actual_content => "something", :length => "something".length)
1134
1143
  file.stubs(:property).with(:content).returns(property)
1135
1144
 
1136
- lambda { file.write(:content) }.should raise_error(Puppet::Error)
1145
+ expect { file.write(:content) }.to raise_error(Puppet::Error)
1137
1146
  end
1138
1147
 
1139
1148
  it "should delegate writing to the content property" do
@@ -1161,7 +1170,7 @@ describe Puppet::Type.type(:file) do
1161
1170
  property = stub('content_property', :actual_content => "something", :length => "something".length, :write => 'checksum_a')
1162
1171
  file.stubs(:property).with(:content).returns(property)
1163
1172
 
1164
- lambda { file.write :NOTUSED }.should raise_error(Puppet::Error)
1173
+ expect { file.write :NOTUSED }.to raise_error(Puppet::Error)
1165
1174
  end
1166
1175
  end
1167
1176
 
@@ -1175,7 +1184,7 @@ describe Puppet::Type.type(:file) do
1175
1184
  property = stub('content_property', :actual_content => "something", :length => "something".length, :write => 'checksum_a')
1176
1185
  file.stubs(:property).with(:content).returns(property)
1177
1186
 
1178
- lambda { file.write :NOTUSED }.should_not raise_error(Puppet::Error)
1187
+ expect { file.write :NOTUSED }.to_not raise_error(Puppet::Error)
1179
1188
  end
1180
1189
  end
1181
1190
  end
@@ -1260,7 +1269,7 @@ describe Puppet::Type.type(:file) do
1260
1269
  describe "target" do
1261
1270
  it "should require file resource when specified with the target property" do
1262
1271
  file = described_class.new(:path => File.expand_path("/foo"), :ensure => :directory)
1263
- link = described_class.new(:path => File.expand_path("/bar"), :ensure => :symlink, :target => File.expand_path("/foo"))
1272
+ link = described_class.new(:path => File.expand_path("/bar"), :ensure => :link, :target => File.expand_path("/foo"))
1264
1273
  catalog.add_resource file
1265
1274
  catalog.add_resource link
1266
1275
  reqs = link.autorequire
@@ -1281,7 +1290,7 @@ describe Puppet::Type.type(:file) do
1281
1290
  end
1282
1291
 
1283
1292
  it "should not require target if target is not managed" do
1284
- link = described_class.new(:path => File.expand_path('/foo'), :ensure => :symlink, :target => '/bar')
1293
+ link = described_class.new(:path => File.expand_path('/foo'), :ensure => :link, :target => '/bar')
1285
1294
  catalog.add_resource link
1286
1295
  link.autorequire.size.should == 0
1287
1296
  end
@@ -1420,7 +1429,7 @@ describe Puppet::Type.type(:file) do
1420
1429
 
1421
1430
  it 'should validate' do
1422
1431
 
1423
- lambda { file.validate }.should_not raise_error
1432
+ expect { file.validate }.to_not raise_error
1424
1433
  end
1425
1434
  end
1426
1435
  end
@@ -1431,7 +1440,7 @@ describe Puppet::Type.type(:file) do
1431
1440
  end
1432
1441
 
1433
1442
  it 'should raise an exception when validating' do
1434
- lambda { file.validate }.should raise_error(/You cannot specify source when using checksum 'none'/)
1443
+ expect { file.validate }.to raise_error(/You cannot specify source when using checksum 'none'/)
1435
1444
  end
1436
1445
  end
1437
1446
  end
@@ -1448,7 +1457,7 @@ describe Puppet::Type.type(:file) do
1448
1457
  end
1449
1458
 
1450
1459
  it 'should validate' do
1451
- lambda { file.validate }.should_not raise_error
1460
+ expect { file.validate }.to_not raise_error
1452
1461
  end
1453
1462
  end
1454
1463
  end
@@ -1458,7 +1467,7 @@ describe Puppet::Type.type(:file) do
1458
1467
  it 'should raise an exception when validating' do
1459
1468
  file[:checksum] = checksum_type
1460
1469
 
1461
- lambda { file.validate }.should raise_error(/You cannot specify content when using checksum '#{checksum_type}'/)
1470
+ expect { file.validate }.to raise_error(/You cannot specify content when using checksum '#{checksum_type}'/)
1462
1471
  end
1463
1472
  end
1464
1473
  end
@@ -16,7 +16,7 @@ describe Puppet::Type.type(:interface) do
16
16
  end
17
17
 
18
18
  it "should be applied on device" do
19
- Puppet::Type.type(:interface).new(:name => "FastEthernet 0/1").should be_appliable_to_device
19
+ Puppet::Type.type(:interface).new(:name => "FastEthernet 0/1").must be_appliable_to_device
20
20
  end
21
21
 
22
22
  [:description, :speed, :duplex, :native_vlan, :encapsulation, :mode, :allowed_trunk_vlans, :etherchannel, :ipaddress].each do |p|
@@ -15,6 +15,20 @@ describe Puppet::Type.type(:scheduled_task), :if => Puppet.features.microsoft_wi
15
15
  described_class.new(:name => 'Test Task', :command => 'C:\Windows\System32\notepad.exe')[:command].should == 'C:\Windows\System32\notepad.exe'
16
16
  end
17
17
 
18
+ it 'should convert forward slashes to backslashes' do
19
+ described_class.new(
20
+ :name => 'Test Task',
21
+ :command => 'C:/Windows/System32/notepad.exe'
22
+ )[:command].should == 'C:\Windows\System32\notepad.exe'
23
+ end
24
+
25
+ it 'should normalize backslashes' do
26
+ described_class.new(
27
+ :name => 'Test Task',
28
+ :command => 'C:\Windows\\System32\\\\notepad.exe'
29
+ )[:command].should == 'C:\Windows\System32\notepad.exe'
30
+ end
31
+
18
32
  it 'should fail if the path to the command is not absolute' do
19
33
  expect {
20
34
  described_class.new(:name => 'Test Task', :command => 'notepad.exe')
@@ -26,25 +40,12 @@ describe Puppet::Type.type(:scheduled_task), :if => Puppet.features.microsoft_wi
26
40
  end
27
41
 
28
42
  describe 'when setting the command arguments' do
29
- it 'should fail if provided an array' do
30
- expect {
31
- described_class.new(
32
- :name => 'Test Task',
33
- :command => 'C:\Windows\System32\notepad.exe',
34
- :arguments => ['/a', '/b', '/c']
35
- )
36
- }.to raise_error(
37
- Puppet::Error,
38
- /Parameter arguments failed: Must be specified as a single string/
39
- )
40
- end
41
-
42
43
  it 'should accept a string' do
43
44
  described_class.new(
44
45
  :name => 'Test Task',
45
46
  :command => 'C:\Windows\System32\notepad.exe',
46
47
  :arguments => '/a /b /c'
47
- )[:arguments].should == ['/a /b /c']
48
+ )[:arguments].should == '/a /b /c'
48
49
  end
49
50
 
50
51
  it 'should allow not specifying any command arguments' do
@@ -372,7 +372,7 @@ describe tidy do
372
372
 
373
373
  @tidy.parameter(:size).stubs(:tidy?).returns true
374
374
  @tidy.parameter(:age).stubs(:tidy?).returns false
375
- @tidy.should be_tidy(@basepath)
375
+ @tidy.must be_tidy(@basepath)
376
376
  end
377
377
 
378
378
  it "should tidy a file if age and size are set but only age matches" do
@@ -381,7 +381,7 @@ describe tidy do
381
381
 
382
382
  @tidy.parameter(:size).stubs(:tidy?).returns false
383
383
  @tidy.parameter(:age).stubs(:tidy?).returns true
384
- @tidy.should be_tidy(@basepath)
384
+ @tidy.must be_tidy(@basepath)
385
385
  end
386
386
 
387
387
  it "should tidy all files if neither age nor size is set" do
@@ -111,11 +111,11 @@ describe Puppet::Type.type(:user) do
111
111
 
112
112
  describe "when managing the ensure property" do
113
113
  it "should support a :present value" do
114
- lambda { described_class.new(:name => 'foo', :ensure => :present) }.should_not raise_error
114
+ expect { described_class.new(:name => 'foo', :ensure => :present) }.to_not raise_error
115
115
  end
116
116
 
117
117
  it "should support an :absent value" do
118
- lambda { described_class.new(:name => 'foo', :ensure => :absent) }.should_not raise_error
118
+ expect { described_class.new(:name => 'foo', :ensure => :absent) }.to_not raise_error
119
119
  end
120
120
 
121
121
  it "should call :create on the provider when asked to sync to the :present state" do
@@ -212,20 +212,20 @@ describe Puppet::Type.type(:user) do
212
212
 
213
213
  describe "when managing groups" do
214
214
  it "should support a singe group" do
215
- lambda { described_class.new(:name => 'foo', :groups => 'bar') }.should_not raise_error
215
+ expect { described_class.new(:name => 'foo', :groups => 'bar') }.to_not raise_error
216
216
  end
217
217
 
218
218
  it "should support multiple groups as an array" do
219
- lambda { described_class.new(:name => 'foo', :groups => [ 'bar' ]) }.should_not raise_error
220
- lambda { described_class.new(:name => 'foo', :groups => [ 'bar', 'baz' ]) }.should_not raise_error
219
+ expect { described_class.new(:name => 'foo', :groups => [ 'bar' ]) }.to_not raise_error
220
+ expect { described_class.new(:name => 'foo', :groups => [ 'bar', 'baz' ]) }.to_not raise_error
221
221
  end
222
222
 
223
223
  it "should not support a comma separated list" do
224
- lambda { described_class.new(:name => 'foo', :groups => 'bar,baz') }.should raise_error(Puppet::Error, /Group names must be provided as an array/)
224
+ expect { described_class.new(:name => 'foo', :groups => 'bar,baz') }.to raise_error(Puppet::Error, /Group names must be provided as an array/)
225
225
  end
226
226
 
227
227
  it "should not support an empty string" do
228
- lambda { described_class.new(:name => 'foo', :groups => '') }.should raise_error(Puppet::Error, /Group names must not be empty/)
228
+ expect { described_class.new(:name => 'foo', :groups => '') }.to raise_error(Puppet::Error, /Group names must not be empty/)
229
229
  end
230
230
 
231
231
  describe "when testing is in sync" do
@@ -262,27 +262,27 @@ describe Puppet::Type.type(:user) do
262
262
 
263
263
  describe "when managing expiry" do
264
264
  it "should fail if given an invalid date" do
265
- lambda { described_class.new(:name => 'foo', :expiry => "200-20-20") }.should raise_error(Puppet::Error, /Expiry dates must be YYYY-MM-DD/)
265
+ expect { described_class.new(:name => 'foo', :expiry => "200-20-20") }.to raise_error(Puppet::Error, /Expiry dates must be YYYY-MM-DD/)
266
266
  end
267
267
  end
268
268
 
269
269
  describe "when managing minimum password age" do
270
270
  it "should accept a negative minimum age" do
271
- expect { described_class.new(:name => 'foo', :password_min_age => '-1') }.should_not raise_error
271
+ expect { described_class.new(:name => 'foo', :password_min_age => '-1') }.to_not raise_error
272
272
  end
273
273
 
274
274
  it "should fail with an empty minimum age" do
275
- expect { described_class.new(:name => 'foo', :password_min_age => '') }.should raise_error(Puppet::Error, /minimum age must be provided as a number/)
275
+ expect { described_class.new(:name => 'foo', :password_min_age => '') }.to raise_error(Puppet::Error, /minimum age must be provided as a number/)
276
276
  end
277
277
  end
278
278
 
279
279
  describe "when managing maximum password age" do
280
280
  it "should accept a negative maximum age" do
281
- expect { described_class.new(:name => 'foo', :password_max_age => '-1') }.should_not raise_error
281
+ expect { described_class.new(:name => 'foo', :password_max_age => '-1') }.to_not raise_error
282
282
  end
283
283
 
284
284
  it "should fail with an empty maximum age" do
285
- expect { described_class.new(:name => 'foo', :password_max_age => '') }.should raise_error(Puppet::Error, /maximum age must be provided as a number/)
285
+ expect { described_class.new(:name => 'foo', :password_max_age => '') }.to raise_error(Puppet::Error, /maximum age must be provided as a number/)
286
286
  end
287
287
  end
288
288
 
@@ -308,17 +308,17 @@ describe Puppet::Type.type(:user) do
308
308
  end
309
309
 
310
310
  it "should fail if a ':' is included in the password" do
311
- lambda { described_class.new(:name => 'foo', :password => "some:thing") }.should raise_error(Puppet::Error, /Passwords cannot include ':'/)
311
+ expect { described_class.new(:name => 'foo', :password => "some:thing") }.to raise_error(Puppet::Error, /Passwords cannot include ':'/)
312
312
  end
313
313
 
314
314
  it "should allow the value to be set to :absent" do
315
- lambda { described_class.new(:name => 'foo', :password => :absent) }.should_not raise_error
315
+ expect { described_class.new(:name => 'foo', :password => :absent) }.to_not raise_error
316
316
  end
317
317
  end
318
318
 
319
319
  describe "when manages_solaris_rbac is enabled" do
320
320
  it "should support a :role value for ensure" do
321
- lambda { described_class.new(:name => 'foo', :ensure => :role) }.should_not raise_error
321
+ expect { described_class.new(:name => 'foo', :ensure => :role) }.to_not raise_error
322
322
  end
323
323
  end
324
324