puppet 2.7.11 → 2.7.12

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 (220) hide show
  1. data/CHANGELOG +188 -0
  2. data/conf/osx/createpackage.sh +1 -0
  3. data/conf/redhat/puppet.spec +12 -9
  4. data/conf/suse/puppet.spec +4 -1
  5. data/install.rb +9 -22
  6. data/lib/puppet.rb +1 -31
  7. data/lib/puppet/agent.rb +3 -5
  8. data/lib/puppet/agent/locker.rb +15 -1
  9. data/lib/puppet/application.rb +7 -4
  10. data/lib/puppet/application/agent.rb +4 -25
  11. data/lib/puppet/application/apply.rb +3 -3
  12. data/lib/puppet/application/device.rb +2 -16
  13. data/lib/puppet/application/doc.rb +2 -2
  14. data/lib/puppet/application/face_base.rb +22 -5
  15. data/lib/puppet/application/filebucket.rb +2 -0
  16. data/lib/puppet/application/inspect.rb +2 -1
  17. data/lib/puppet/application/kick.rb +25 -9
  18. data/lib/puppet/application/queue.rb +0 -23
  19. data/lib/puppet/configurer.rb +1 -0
  20. data/lib/puppet/configurer/downloader.rb +7 -3
  21. data/lib/puppet/defaults.rb +34 -29
  22. data/lib/puppet/face/ca.rb +1 -1
  23. data/lib/puppet/face/catalog.rb +1 -0
  24. data/lib/puppet/face/file/store.rb +1 -1
  25. data/lib/puppet/face/module/list.rb +23 -3
  26. data/lib/puppet/face/module/search.rb +21 -32
  27. data/lib/puppet/face/module/uninstall.rb +56 -15
  28. data/lib/puppet/file_bucket/dipper.rb +2 -2
  29. data/lib/puppet/file_serving/base.rb +6 -5
  30. data/lib/puppet/file_serving/configuration/parser.rb +1 -1
  31. data/lib/puppet/file_serving/content.rb +1 -1
  32. data/lib/puppet/forge.rb +153 -0
  33. data/lib/puppet/{module_tool → forge}/cache.rb +1 -2
  34. data/lib/puppet/{module_tool → forge}/repository.rb +46 -4
  35. data/lib/puppet/indirector/exec.rb +1 -1
  36. data/lib/puppet/indirector/file_bucket_file/file.rb +3 -3
  37. data/lib/puppet/interface/action.rb +6 -2
  38. data/lib/puppet/module.rb +70 -10
  39. data/lib/puppet/module_tool.rb +2 -38
  40. data/lib/puppet/module_tool/applications.rb +15 -11
  41. data/lib/puppet/module_tool/applications/application.rb +2 -5
  42. data/lib/puppet/module_tool/applications/cleaner.rb +1 -1
  43. data/lib/puppet/module_tool/applications/installer.rb +10 -45
  44. data/lib/puppet/module_tool/applications/searcher.rb +2 -26
  45. data/lib/puppet/module_tool/applications/uninstaller.rb +39 -13
  46. data/lib/puppet/module_tool/applications/unpacker.rb +1 -1
  47. data/lib/puppet/module_tool/dependency.rb +1 -1
  48. data/lib/puppet/network/authconfig.rb +1 -1
  49. data/lib/puppet/network/handler/fileserver.rb +1 -1
  50. data/lib/puppet/network/http/handler.rb +4 -1
  51. data/lib/puppet/network/http/webrick.rb +4 -2
  52. data/lib/puppet/node/environment.rb +32 -6
  53. data/lib/puppet/parameter/path.rb +0 -4
  54. data/lib/puppet/parser/ast/relationship.rb +3 -16
  55. data/lib/puppet/parser/collector.rb +5 -3
  56. data/lib/puppet/parser/compiler.rb +2 -1
  57. data/lib/puppet/parser/functions/file.rb +1 -1
  58. data/lib/puppet/parser/functions/generate.rb +8 -2
  59. data/lib/puppet/parser/grammar.ra +16 -15
  60. data/lib/puppet/parser/parser.rb +959 -881
  61. data/lib/puppet/parser/relationship.rb +32 -15
  62. data/lib/puppet/parser/resource.rb +0 -1
  63. data/lib/puppet/parser/type_loader.rb +1 -2
  64. data/lib/puppet/provider/augeas/augeas.rb +17 -29
  65. data/lib/puppet/provider/exec/windows.rb +25 -3
  66. data/lib/puppet/provider/file/posix.rb +1 -1
  67. data/lib/puppet/provider/file/windows.rb +1 -1
  68. data/lib/puppet/provider/group/windows_adsi.rb +1 -1
  69. data/lib/puppet/provider/package/aix.rb +1 -1
  70. data/lib/puppet/provider/package/appdmg.rb +1 -1
  71. data/lib/puppet/provider/package/dpkg.rb +1 -1
  72. data/lib/puppet/provider/package/gem.rb +21 -23
  73. data/lib/puppet/provider/package/macports.rb +1 -1
  74. data/lib/puppet/provider/package/msi.rb +7 -1
  75. data/lib/puppet/provider/package/openbsd.rb +13 -16
  76. data/lib/puppet/provider/package/pacman.rb +1 -1
  77. data/lib/puppet/provider/package/pip.rb +3 -0
  78. data/lib/puppet/provider/package/pkg.rb +1 -1
  79. data/lib/puppet/provider/package/pkgdmg.rb +1 -1
  80. data/lib/puppet/provider/package/pkgutil.rb +1 -1
  81. data/lib/puppet/provider/package/portage.rb +2 -2
  82. data/lib/puppet/provider/package/rpm.rb +1 -1
  83. data/lib/puppet/provider/package/sun.rb +1 -1
  84. data/lib/puppet/provider/package/zypper.rb +35 -3
  85. data/lib/puppet/provider/scheduled_task/win32_taskscheduler.rb +6 -2
  86. data/lib/puppet/provider/selmodule/semodule.rb +2 -2
  87. data/lib/puppet/provider/service/base.rb +1 -1
  88. data/lib/puppet/provider/service/launchd.rb +4 -0
  89. data/lib/puppet/provider/service/src.rb +2 -2
  90. data/lib/puppet/provider/service/upstart.rb +1 -1
  91. data/lib/puppet/provider/service/windows.rb +5 -4
  92. data/lib/puppet/provider/user/aix.rb +3 -3
  93. data/lib/puppet/provider/user/pw.rb +6 -0
  94. data/lib/puppet/provider/user/windows_adsi.rb +1 -1
  95. data/lib/puppet/resource/catalog.rb +6 -6
  96. data/lib/puppet/resource/type.rb +2 -0
  97. data/lib/puppet/ssl/certificate_request.rb +0 -70
  98. data/lib/puppet/transaction.rb +1 -1
  99. data/lib/puppet/transaction/report.rb +3 -2
  100. data/lib/puppet/type.rb +1 -1
  101. data/lib/puppet/type/cron.rb +5 -2
  102. data/lib/puppet/type/exec.rb +8 -0
  103. data/lib/puppet/type/file.rb +27 -18
  104. data/lib/puppet/type/file/checksum.rb +2 -2
  105. data/lib/puppet/type/file/content.rb +14 -9
  106. data/lib/puppet/type/file/ensure.rb +5 -4
  107. data/lib/puppet/type/file/group.rb +10 -2
  108. data/lib/puppet/type/file/mode.rb +46 -18
  109. data/lib/puppet/type/file/owner.rb +10 -2
  110. data/lib/puppet/type/file/source.rb +27 -40
  111. data/lib/puppet/type/file/target.rb +6 -6
  112. data/lib/puppet/type/group.rb +13 -9
  113. data/lib/puppet/type/k5login.rb +1 -1
  114. data/lib/puppet/type/package.rb +24 -8
  115. data/lib/puppet/type/scheduled_task.rb +77 -131
  116. data/lib/puppet/type/service.rb +22 -8
  117. data/lib/puppet/type/user.rb +29 -9
  118. data/lib/puppet/util.rb +24 -33
  119. data/lib/puppet/util/colors.rb +98 -0
  120. data/lib/puppet/util/diff.rb +3 -1
  121. data/lib/puppet/util/log.rb +5 -1
  122. data/lib/puppet/util/log/destinations.rb +37 -44
  123. data/lib/puppet/util/monkey_patches.rb +32 -0
  124. data/lib/puppet/util/pidlock.rb +70 -21
  125. data/lib/puppet/util/rdoc/parser.rb +4 -2
  126. data/lib/puppet/util/selinux.rb +1 -1
  127. data/lib/puppet/util/suidmanager.rb +2 -12
  128. data/lib/puppet/util/windows.rb +2 -0
  129. data/lib/puppet/util/windows/process.rb +33 -0
  130. data/lib/puppet/util/windows/security.rb +6 -4
  131. data/lib/puppet/util/windows/user.rb +44 -0
  132. data/lib/semver.rb +55 -4
  133. data/spec/fixtures/unit/provider/package/openbsd/pkginfo.detail +19 -0
  134. data/spec/fixtures/unit/provider/package/openbsd/pkginfo.list +10 -0
  135. data/spec/fixtures/unit/provider/package/openbsd/pkginfo.query +1 -0
  136. data/spec/fixtures/unit/provider/package/zypper/zypper-list-updates-SLES11sp1.out +369 -0
  137. data/spec/integration/defaults_spec.rb +10 -0
  138. data/spec/integration/indirector/direct_file_server_spec.rb +1 -1
  139. data/spec/integration/module_tool_spec.rb +10 -12
  140. data/spec/integration/parser/compiler_spec.rb +147 -0
  141. data/spec/integration/type/file_spec.rb +1 -1
  142. data/spec/integration/util/windows/user_spec.rb +59 -0
  143. data/spec/lib/puppet/face/basetest.rb +5 -0
  144. data/spec/lib/puppet_spec/modules.rb +26 -0
  145. data/spec/spec_helper.rb +25 -0
  146. data/spec/unit/agent/locker_spec.rb +12 -0
  147. data/spec/unit/agent_backward_compatibility_spec.rb +152 -0
  148. data/spec/unit/agent_spec.rb +28 -8
  149. data/spec/unit/application/agent_spec.rb +4 -36
  150. data/spec/unit/application/device_spec.rb +55 -10
  151. data/spec/unit/application/face_base_spec.rb +32 -10
  152. data/spec/unit/application/filebucket_spec.rb +5 -0
  153. data/spec/unit/application/kick_spec.rb +6 -0
  154. data/spec/unit/application_spec.rb +8 -1
  155. data/spec/unit/configurer/downloader_spec.rb +4 -5
  156. data/spec/unit/face/ca_spec.rb +15 -4
  157. data/spec/unit/file_bucket/dipper_spec.rb +1 -1
  158. data/spec/unit/file_serving/base_spec.rb +60 -42
  159. data/spec/unit/file_serving/configuration/parser_spec.rb +5 -3
  160. data/spec/unit/file_serving/content_spec.rb +26 -27
  161. data/spec/unit/file_serving/metadata_spec.rb +22 -21
  162. data/spec/unit/forge/repository_spec.rb +86 -0
  163. data/spec/unit/forge_spec.rb +114 -0
  164. data/spec/unit/indirector/exec_spec.rb +8 -6
  165. data/spec/unit/indirector/facts/inventory_active_record_spec.rb +0 -1
  166. data/spec/unit/indirector/file_bucket_file/file_spec.rb +1 -1
  167. data/spec/unit/indirector/node/exec_spec.rb +1 -1
  168. data/spec/unit/indirector/resource/active_record_spec.rb +0 -4
  169. data/spec/unit/interface/action_builder_spec.rb +7 -5
  170. data/spec/unit/module_spec.rb +228 -9
  171. data/spec/unit/module_tool/application_spec.rb +3 -3
  172. data/spec/unit/module_tool/uninstaller_spec.rb +107 -27
  173. data/spec/unit/module_tool_spec.rb +0 -33
  174. data/spec/unit/network/authconfig_spec.rb +22 -21
  175. data/spec/unit/network/http/webrick_spec.rb +13 -9
  176. data/spec/unit/node/environment_spec.rb +159 -66
  177. data/spec/unit/parser/collector_spec.rb +16 -8
  178. data/spec/unit/parser/functions/generate_spec.rb +60 -18
  179. data/spec/unit/parser/resource_spec.rb +44 -0
  180. data/spec/unit/provider/augeas/augeas_spec.rb +160 -179
  181. data/spec/unit/provider/confine/feature_spec.rb +3 -5
  182. data/spec/unit/provider/package/dpkg_spec.rb +4 -2
  183. data/spec/unit/provider/package/gem_spec.rb +59 -43
  184. data/spec/unit/provider/package/openbsd_spec.rb +114 -0
  185. data/spec/unit/provider/package/pacman_spec.rb +1 -1
  186. data/spec/unit/provider/package/pip_spec.rb +10 -4
  187. data/spec/unit/provider/package/zypper_spec.rb +56 -14
  188. data/spec/unit/provider/selmodule_spec.rb +3 -3
  189. data/spec/unit/provider/service/launchd_spec.rb +22 -21
  190. data/spec/unit/provider/service/{upstart.rb → upstart_spec.rb} +7 -3
  191. data/spec/unit/provider/user/pw_spec.rb +19 -0
  192. data/spec/unit/resource/catalog_spec.rb +3 -3
  193. data/spec/unit/semver_spec.rb +117 -24
  194. data/spec/unit/transaction/report_spec.rb +11 -1
  195. data/spec/unit/type/cron_spec.rb +200 -213
  196. data/spec/unit/type/exec_spec.rb +7 -0
  197. data/spec/unit/type/file/content_spec.rb +2 -2
  198. data/spec/unit/type/file_spec.rb +12 -9
  199. data/spec/unit/type/package_spec.rb +25 -0
  200. data/spec/unit/type/schedule_spec.rb +31 -31
  201. data/spec/unit/util/diff_spec.rb +30 -0
  202. data/spec/unit/util/execution_stub_spec.rb +1 -2
  203. data/spec/unit/util/log/destinations_spec.rb +51 -0
  204. data/spec/unit/util/log_spec.rb +17 -1
  205. data/spec/unit/util/monkey_patches_spec.rb +119 -0
  206. data/spec/unit/util/rdoc/parser_spec.rb +25 -1
  207. data/spec/unit/util/selinux_spec.rb +2 -2
  208. data/spec/unit/util/suidmanager_spec.rb +6 -51
  209. data/spec/unit/util_spec.rb +82 -24
  210. data/test/lib/puppettest/certificates.rb +16 -0
  211. data/test/lib/puppettest/servertest.rb +4 -0
  212. data/test/util/pidlock.rb +125 -0
  213. metadata +23 -14
  214. data/ext/puppetstoredconfigclean.rb +0 -103
  215. data/lib/puppet/agent/disabler.rb +0 -27
  216. data/lib/puppet/util/anonymous_filelock.rb +0 -36
  217. data/spec/unit/agent/disabler_spec.rb +0 -60
  218. data/spec/unit/module_tool/repository_spec.rb +0 -52
  219. data/spec/unit/util/anonymous_filelock_spec.rb +0 -78
  220. data/spec/unit/util/pidlock_spec.rb +0 -208
@@ -29,7 +29,7 @@ describe Puppet::Transaction::Report do
29
29
  end
30
30
 
31
31
  it "should take a 'configuration_version' as an argument" do
32
- Puppet::Transaction::Report.new("inspect", "some configuration version").configuration_version.should == "some configuration version"
32
+ Puppet::Transaction::Report.new("inspect", "some configuration version", "some environment").configuration_version.should == "some configuration version"
33
33
  end
34
34
 
35
35
  it "should be able to set configuration_version" do
@@ -38,6 +38,16 @@ describe Puppet::Transaction::Report do
38
38
  report.configuration_version.should == "some version"
39
39
  end
40
40
 
41
+ it "should take 'environment' as an argument" do
42
+ Puppet::Transaction::Report.new("inspect", "some configuration version", "some environment").environment.should == "some environment"
43
+ end
44
+
45
+ it "should be able to set environment" do
46
+ report = Puppet::Transaction::Report.new("inspect")
47
+ report.environment = "some environment"
48
+ report.environment.should == "some environment"
49
+ end
50
+
41
51
  it "should not include whits" do
42
52
  Puppet::FileBucket::File.indirection.stubs(:save)
43
53
 
@@ -1,490 +1,477 @@
1
1
  #!/usr/bin/env rspec
2
+
2
3
  require 'spec_helper'
3
4
 
4
5
  describe Puppet::Type.type(:cron), :unless => Puppet.features.microsoft_windows? do
5
6
  before do
6
- @class = Puppet::Type.type(:cron)
7
-
8
- # Init a fake provider
9
- @provider_class = stub 'provider_class', :ancestors => [], :name => 'fake', :suitable? => true, :supports_parameter? => true
10
- @class.stubs(:defaultprovider).returns @provider_class
11
- @class.stubs(:provider).returns @provider_class
12
-
13
- @provider = stub 'provider', :class => @provider_class, :clean => nil
14
- @provider.stubs(:is_a?).returns false
15
- @provider_class.stubs(:new).returns @provider
16
-
17
- @cron = @class.new( :name => "foo" )
7
+ @provider_class = described_class.provide(:simple) { mk_resource_methods }
8
+ @provider_class.stubs(:suitable?).returns true
9
+ described_class.stubs(:defaultprovider).returns @provider_class
18
10
  end
19
11
 
20
12
  it "should have :name be its namevar" do
21
- @class.key_attributes.should == [:name]
13
+ described_class.key_attributes.should == [:name]
22
14
  end
23
15
 
24
16
  describe "when validating attributes" do
25
-
26
17
  [:name, :provider].each do |param|
27
18
  it "should have a #{param} parameter" do
28
- @class.attrtype(param).should == :param
19
+ described_class.attrtype(param).should == :param
29
20
  end
30
21
  end
31
22
 
32
23
  [:command, :special, :minute, :hour, :weekday, :month, :monthday, :environment, :user, :target].each do |property|
33
24
  it "should have a #{property} property" do
34
- @class.attrtype(property).should == :property
25
+ described_class.attrtype(property).should == :property
35
26
  end
36
27
  end
37
28
 
38
29
  [:command, :minute, :hour, :weekday, :month, :monthday].each do |cronparam|
39
30
  it "should have #{cronparam} of type CronParam" do
40
- @class.attrclass(cronparam).ancestors.should include CronParam
31
+ described_class.attrclass(cronparam).ancestors.should include CronParam
41
32
  end
42
33
  end
43
-
44
34
  end
45
35
 
46
36
 
47
37
  describe "when validating attribute" do
48
-
49
38
  describe "ensure" do
50
39
  it "should support present as a value for ensure" do
51
- proc { @class.new(:name => 'foo', :ensure => :present) }.should_not raise_error
40
+ proc { described_class.new(:name => 'foo', :ensure => :present) }.should_not raise_error
52
41
  end
53
42
 
54
43
  it "should support absent as a value for ensure" do
55
- proc { @class.new(:name => 'foo', :ensure => :present) }.should_not raise_error
44
+ proc { described_class.new(:name => 'foo', :ensure => :present) }.should_not raise_error
45
+ end
46
+
47
+ it "should not support other values" do
48
+ proc { described_class.new(:name => 'foo', :ensure => :foo) }.should raise_error(Puppet::Error, /Invalid value/)
56
49
  end
57
50
  end
58
51
 
59
52
  describe "minute" do
60
-
61
53
  it "should support absent" do
62
- proc { @class.new(:name => 'foo', :minute => 'absent') }.should_not raise_error
54
+ proc { described_class.new(:name => 'foo', :minute => 'absent') }.should_not raise_error
63
55
  end
64
56
 
65
57
  it "should support *" do
66
- proc { @class.new(:name => 'foo', :minute => '*') }.should_not raise_error
58
+ proc { described_class.new(:name => 'foo', :minute => '*') }.should_not raise_error
67
59
  end
68
60
 
69
61
  it "should translate absent to :absent" do
70
- @class.new(:name => 'foo', :minute => 'absent')[:minute].should == :absent
62
+ described_class.new(:name => 'foo', :minute => 'absent')[:minute].should == :absent
71
63
  end
72
64
 
73
65
  it "should translate * to :absent" do
74
- @class.new(:name => 'foo', :minute => '*')[:minute].should == :absent
66
+ described_class.new(:name => 'foo', :minute => '*')[:minute].should == :absent
75
67
  end
76
68
 
77
69
  it "should support valid single values" do
78
- proc { @class.new(:name => 'foo', :minute => '0') }.should_not raise_error
79
- proc { @class.new(:name => 'foo', :minute => '1') }.should_not raise_error
80
- proc { @class.new(:name => 'foo', :minute => '59') }.should_not raise_error
70
+ proc { described_class.new(:name => 'foo', :minute => '0') }.should_not raise_error
71
+ proc { described_class.new(:name => 'foo', :minute => '1') }.should_not raise_error
72
+ proc { described_class.new(:name => 'foo', :minute => '59') }.should_not raise_error
81
73
  end
82
74
 
83
75
  it "should not support non numeric characters" do
84
- proc { @class.new(:name => 'foo', :minute => 'z59') }.should raise_error(Puppet::Error)
85
- proc { @class.new(:name => 'foo', :minute => '5z9') }.should raise_error(Puppet::Error)
86
- proc { @class.new(:name => 'foo', :minute => '59z') }.should raise_error(Puppet::Error)
76
+ proc { described_class.new(:name => 'foo', :minute => 'z59') }.should raise_error(Puppet::Error, /z59 is not a valid minute/)
77
+ proc { described_class.new(:name => 'foo', :minute => '5z9') }.should raise_error(Puppet::Error, /5z9 is not a valid minute/)
78
+ proc { described_class.new(:name => 'foo', :minute => '59z') }.should raise_error(Puppet::Error, /59z is not a valid minute/)
87
79
  end
88
80
 
89
81
  it "should not support single values out of range" do
90
82
 
91
- proc { @class.new(:name => 'foo', :minute => '-1') }.should raise_error(Puppet::Error)
92
- proc { @class.new(:name => 'foo', :minute => '60') }.should raise_error(Puppet::Error)
93
- proc { @class.new(:name => 'foo', :minute => '61') }.should raise_error(Puppet::Error)
94
- proc { @class.new(:name => 'foo', :minute => '120') }.should raise_error(Puppet::Error)
83
+ proc { described_class.new(:name => 'foo', :minute => '-1') }.should raise_error(Puppet::Error, /-1 is not a valid minute/)
84
+ proc { described_class.new(:name => 'foo', :minute => '60') }.should raise_error(Puppet::Error, /60 is not a valid minute/)
85
+ proc { described_class.new(:name => 'foo', :minute => '61') }.should raise_error(Puppet::Error, /61 is not a valid minute/)
86
+ proc { described_class.new(:name => 'foo', :minute => '120') }.should raise_error(Puppet::Error, /120 is not a valid minute/)
95
87
  end
96
88
 
97
89
  it "should support valid multiple values" do
98
- proc { @class.new(:name => 'foo', :minute => ['0','1','59'] ) }.should_not raise_error
99
- proc { @class.new(:name => 'foo', :minute => ['40','30','20'] ) }.should_not raise_error
100
- proc { @class.new(:name => 'foo', :minute => ['10','30','20'] ) }.should_not raise_error
90
+ proc { described_class.new(:name => 'foo', :minute => ['0','1','59'] ) }.should_not raise_error
91
+ proc { described_class.new(:name => 'foo', :minute => ['40','30','20'] ) }.should_not raise_error
92
+ proc { described_class.new(:name => 'foo', :minute => ['10','30','20'] ) }.should_not raise_error
101
93
  end
102
94
 
103
95
  it "should not support multiple values if at least one is invalid" do
104
96
  # one invalid
105
- proc { @class.new(:name => 'foo', :minute => ['0','1','60'] ) }.should raise_error(Puppet::Error)
106
- proc { @class.new(:name => 'foo', :minute => ['0','120','59'] ) }.should raise_error(Puppet::Error)
107
- proc { @class.new(:name => 'foo', :minute => ['-1','1','59'] ) }.should raise_error(Puppet::Error)
97
+ proc { described_class.new(:name => 'foo', :minute => ['0','1','60'] ) }.should raise_error(Puppet::Error, /60 is not a valid minute/)
98
+ proc { described_class.new(:name => 'foo', :minute => ['0','120','59'] ) }.should raise_error(Puppet::Error, /120 is not a valid minute/)
99
+ proc { described_class.new(:name => 'foo', :minute => ['-1','1','59'] ) }.should raise_error(Puppet::Error, /-1 is not a valid minute/)
108
100
  # two invalid
109
- proc { @class.new(:name => 'foo', :minute => ['0','61','62'] ) }.should raise_error(Puppet::Error)
101
+ proc { described_class.new(:name => 'foo', :minute => ['0','61','62'] ) }.should raise_error(Puppet::Error, /(61|62) is not a valid minute/)
110
102
  # all invalid
111
- proc { @class.new(:name => 'foo', :minute => ['-1','61','62'] ) }.should raise_error(Puppet::Error)
103
+ proc { described_class.new(:name => 'foo', :minute => ['-1','61','62'] ) }.should raise_error(Puppet::Error, /(-1|61|62) is not a valid minute/)
112
104
  end
113
105
 
114
106
  it "should support valid step syntax" do
115
- proc { @class.new(:name => 'foo', :minute => '*/2' ) }.should_not raise_error
116
- proc { @class.new(:name => 'foo', :minute => '10-16/2' ) }.should_not raise_error
107
+ proc { described_class.new(:name => 'foo', :minute => '*/2' ) }.should_not raise_error
108
+ proc { described_class.new(:name => 'foo', :minute => '10-16/2' ) }.should_not raise_error
117
109
  end
118
110
 
119
111
  it "should not support invalid steps" do
120
- proc { @class.new(:name => 'foo', :minute => '*/A' ) }.should raise_error(Puppet::Error)
121
- proc { @class.new(:name => 'foo', :minute => '*/2A' ) }.should raise_error(Puppet::Error)
112
+ proc { described_class.new(:name => 'foo', :minute => '*/A' ) }.should raise_error(Puppet::Error, /\*\/A is not a valid minute/)
113
+ proc { described_class.new(:name => 'foo', :minute => '*/2A' ) }.should raise_error(Puppet::Error, /\*\/2A is not a valid minute/)
122
114
  # As it turns out cron does not complaining about steps that exceed the valid range
123
- # proc { @class.new(:name => 'foo', :minute => '*/120' ) }.should raise_error(Puppet::Error)
115
+ # proc { described_class.new(:name => 'foo', :minute => '*/120' ) }.should raise_error(Puppet::Error, /is not a valid minute/)
124
116
  end
125
-
126
117
  end
127
118
 
128
119
  describe "hour" do
129
-
130
- it "should support absent" do
131
- proc { @class.new(:name => 'foo', :hour => 'absent') }.should_not raise_error
120
+ it "should support absent" do
121
+ proc { described_class.new(:name => 'foo', :hour => 'absent') }.should_not raise_error
132
122
  end
133
123
 
134
124
  it "should support *" do
135
- proc { @class.new(:name => 'foo', :hour => '*') }.should_not raise_error
125
+ proc { described_class.new(:name => 'foo', :hour => '*') }.should_not raise_error
136
126
  end
137
127
 
138
128
  it "should translate absent to :absent" do
139
- @class.new(:name => 'foo', :hour => 'absent')[:hour].should == :absent
129
+ described_class.new(:name => 'foo', :hour => 'absent')[:hour].should == :absent
140
130
  end
141
131
 
142
132
  it "should translate * to :absent" do
143
- @class.new(:name => 'foo', :hour => '*')[:hour].should == :absent
133
+ described_class.new(:name => 'foo', :hour => '*')[:hour].should == :absent
144
134
  end
145
135
 
146
136
  it "should support valid single values" do
147
- proc { @class.new(:name => 'foo', :hour => '0') }.should_not raise_error
148
- proc { @class.new(:name => 'foo', :hour => '11') }.should_not raise_error
149
- proc { @class.new(:name => 'foo', :hour => '12') }.should_not raise_error
150
- proc { @class.new(:name => 'foo', :hour => '13') }.should_not raise_error
151
- proc { @class.new(:name => 'foo', :hour => '23') }.should_not raise_error
137
+ proc { described_class.new(:name => 'foo', :hour => '0') }.should_not raise_error
138
+ proc { described_class.new(:name => 'foo', :hour => '11') }.should_not raise_error
139
+ proc { described_class.new(:name => 'foo', :hour => '12') }.should_not raise_error
140
+ proc { described_class.new(:name => 'foo', :hour => '13') }.should_not raise_error
141
+ proc { described_class.new(:name => 'foo', :hour => '23') }.should_not raise_error
152
142
  end
153
143
 
154
144
  it "should not support non numeric characters" do
155
- proc { @class.new(:name => 'foo', :hour => 'z15') }.should raise_error(Puppet::Error)
156
- proc { @class.new(:name => 'foo', :hour => '1z5') }.should raise_error(Puppet::Error)
157
- proc { @class.new(:name => 'foo', :hour => '15z') }.should raise_error(Puppet::Error)
145
+ proc { described_class.new(:name => 'foo', :hour => 'z15') }.should raise_error(Puppet::Error, /z15 is not a valid hour/)
146
+ proc { described_class.new(:name => 'foo', :hour => '1z5') }.should raise_error(Puppet::Error, /1z5 is not a valid hour/)
147
+ proc { described_class.new(:name => 'foo', :hour => '15z') }.should raise_error(Puppet::Error, /15z is not a valid hour/)
158
148
  end
159
149
 
160
150
  it "should not support single values out of range" do
161
- proc { @class.new(:name => 'foo', :hour => '-1') }.should raise_error(Puppet::Error)
162
- proc { @class.new(:name => 'foo', :hour => '24') }.should raise_error(Puppet::Error)
163
- proc { @class.new(:name => 'foo', :hour => '120') }.should raise_error(Puppet::Error)
151
+ proc { described_class.new(:name => 'foo', :hour => '-1') }.should raise_error(Puppet::Error, /-1 is not a valid hour/)
152
+ proc { described_class.new(:name => 'foo', :hour => '24') }.should raise_error(Puppet::Error, /24 is not a valid hour/)
153
+ proc { described_class.new(:name => 'foo', :hour => '120') }.should raise_error(Puppet::Error, /120 is not a valid hour/)
164
154
  end
165
155
 
166
156
  it "should support valid multiple values" do
167
- proc { @class.new(:name => 'foo', :hour => ['0','1','23'] ) }.should_not raise_error
168
- proc { @class.new(:name => 'foo', :hour => ['5','16','14'] ) }.should_not raise_error
169
- proc { @class.new(:name => 'foo', :hour => ['16','13','9'] ) }.should_not raise_error
157
+ proc { described_class.new(:name => 'foo', :hour => ['0','1','23'] ) }.should_not raise_error
158
+ proc { described_class.new(:name => 'foo', :hour => ['5','16','14'] ) }.should_not raise_error
159
+ proc { described_class.new(:name => 'foo', :hour => ['16','13','9'] ) }.should_not raise_error
170
160
  end
171
161
 
172
162
  it "should not support multiple values if at least one is invalid" do
173
163
  # one invalid
174
- proc { @class.new(:name => 'foo', :hour => ['0','1','24'] ) }.should raise_error(Puppet::Error)
175
- proc { @class.new(:name => 'foo', :hour => ['0','-1','5'] ) }.should raise_error(Puppet::Error)
176
- proc { @class.new(:name => 'foo', :hour => ['-1','1','23'] ) }.should raise_error(Puppet::Error)
164
+ proc { described_class.new(:name => 'foo', :hour => ['0','1','24'] ) }.should raise_error(Puppet::Error, /24 is not a valid hour/)
165
+ proc { described_class.new(:name => 'foo', :hour => ['0','-1','5'] ) }.should raise_error(Puppet::Error, /-1 is not a valid hour/)
166
+ proc { described_class.new(:name => 'foo', :hour => ['-1','1','23'] ) }.should raise_error(Puppet::Error, /-1 is not a valid hour/)
177
167
  # two invalid
178
- proc { @class.new(:name => 'foo', :hour => ['0','25','26'] ) }.should raise_error(Puppet::Error)
168
+ proc { described_class.new(:name => 'foo', :hour => ['0','25','26'] ) }.should raise_error(Puppet::Error, /(25|26) is not a valid hour/)
179
169
  # all invalid
180
- proc { @class.new(:name => 'foo', :hour => ['-1','24','120'] ) }.should raise_error(Puppet::Error)
170
+ proc { described_class.new(:name => 'foo', :hour => ['-1','24','120'] ) }.should raise_error(Puppet::Error, /(-1|24|120) is not a valid hour/)
181
171
  end
182
172
 
183
173
  it "should support valid step syntax" do
184
- proc { @class.new(:name => 'foo', :hour => '*/2' ) }.should_not raise_error
185
- proc { @class.new(:name => 'foo', :hour => '10-18/4' ) }.should_not raise_error
174
+ proc { described_class.new(:name => 'foo', :hour => '*/2' ) }.should_not raise_error
175
+ proc { described_class.new(:name => 'foo', :hour => '10-18/4' ) }.should_not raise_error
186
176
  end
187
177
 
188
178
  it "should not support invalid steps" do
189
- proc { @class.new(:name => 'foo', :hour => '*/A' ) }.should raise_error(Puppet::Error)
190
- proc { @class.new(:name => 'foo', :hour => '*/2A' ) }.should raise_error(Puppet::Error)
179
+ proc { described_class.new(:name => 'foo', :hour => '*/A' ) }.should raise_error(Puppet::Error, /\*\/A is not a valid hour/)
180
+ proc { described_class.new(:name => 'foo', :hour => '*/2A' ) }.should raise_error(Puppet::Error, /\*\/2A is not a valid hour/)
191
181
  # As it turns out cron does not complaining about steps that exceed the valid range
192
- # proc { @class.new(:name => 'foo', :hour => '*/26' ) }.should raise_error(Puppet::Error)
182
+ # proc { described_class.new(:name => 'foo', :hour => '*/26' ) }.should raise_error(Puppet::Error, /is not a valid hour/)
193
183
  end
194
-
195
184
  end
196
185
 
197
- describe "weekday" do
198
-
186
+ describe "weekday" do
199
187
  it "should support absent" do
200
- proc { @class.new(:name => 'foo', :weekday => 'absent') }.should_not raise_error
188
+ proc { described_class.new(:name => 'foo', :weekday => 'absent') }.should_not raise_error
201
189
  end
202
190
 
203
191
  it "should support *" do
204
- proc { @class.new(:name => 'foo', :weekday => '*') }.should_not raise_error
192
+ proc { described_class.new(:name => 'foo', :weekday => '*') }.should_not raise_error
205
193
  end
206
194
 
207
195
  it "should translate absent to :absent" do
208
- @class.new(:name => 'foo', :weekday => 'absent')[:weekday].should == :absent
196
+ described_class.new(:name => 'foo', :weekday => 'absent')[:weekday].should == :absent
209
197
  end
210
198
 
211
199
  it "should translate * to :absent" do
212
- @class.new(:name => 'foo', :weekday => '*')[:weekday].should == :absent
200
+ described_class.new(:name => 'foo', :weekday => '*')[:weekday].should == :absent
213
201
  end
214
202
 
215
203
  it "should support valid numeric weekdays" do
216
- proc { @class.new(:name => 'foo', :weekday => '0') }.should_not raise_error
217
- proc { @class.new(:name => 'foo', :weekday => '1') }.should_not raise_error
218
- proc { @class.new(:name => 'foo', :weekday => '6') }.should_not raise_error
204
+ proc { described_class.new(:name => 'foo', :weekday => '0') }.should_not raise_error
205
+ proc { described_class.new(:name => 'foo', :weekday => '1') }.should_not raise_error
206
+ proc { described_class.new(:name => 'foo', :weekday => '6') }.should_not raise_error
219
207
  # According to http://www.manpagez.com/man/5/crontab 7 is also valid (Sunday)
220
- proc { @class.new(:name => 'foo', :weekday => '7') }.should_not raise_error
208
+ proc { described_class.new(:name => 'foo', :weekday => '7') }.should_not raise_error
221
209
  end
222
210
 
223
- it "should support valid weekdays as words (3 character version)" do
224
- proc { @class.new(:name => 'foo', :weekday => 'Monday') }.should_not raise_error
225
- proc { @class.new(:name => 'foo', :weekday => 'Tuesday') }.should_not raise_error
226
- proc { @class.new(:name => 'foo', :weekday => 'Wednesday') }.should_not raise_error
227
- proc { @class.new(:name => 'foo', :weekday => 'Thursday') }.should_not raise_error
228
- proc { @class.new(:name => 'foo', :weekday => 'Friday') }.should_not raise_error
229
- proc { @class.new(:name => 'foo', :weekday => 'Saturday') }.should_not raise_error
230
- proc { @class.new(:name => 'foo', :weekday => 'Sunday') }.should_not raise_error
211
+ it "should support valid weekdays as words (long version)" do
212
+ proc { described_class.new(:name => 'foo', :weekday => 'Monday') }.should_not raise_error
213
+ proc { described_class.new(:name => 'foo', :weekday => 'Tuesday') }.should_not raise_error
214
+ proc { described_class.new(:name => 'foo', :weekday => 'Wednesday') }.should_not raise_error
215
+ proc { described_class.new(:name => 'foo', :weekday => 'Thursday') }.should_not raise_error
216
+ proc { described_class.new(:name => 'foo', :weekday => 'Friday') }.should_not raise_error
217
+ proc { described_class.new(:name => 'foo', :weekday => 'Saturday') }.should_not raise_error
218
+ proc { described_class.new(:name => 'foo', :weekday => 'Sunday') }.should_not raise_error
231
219
  end
232
220
 
233
221
  it "should support valid weekdays as words (3 character version)" do
234
- proc { @class.new(:name => 'foo', :weekday => 'Mon') }.should_not raise_error
235
- proc { @class.new(:name => 'foo', :weekday => 'Tue') }.should_not raise_error
236
- proc { @class.new(:name => 'foo', :weekday => 'Wed') }.should_not raise_error
237
- proc { @class.new(:name => 'foo', :weekday => 'Thu') }.should_not raise_error
238
- proc { @class.new(:name => 'foo', :weekday => 'Fri') }.should_not raise_error
239
- proc { @class.new(:name => 'foo', :weekday => 'Sat') }.should_not raise_error
240
- proc { @class.new(:name => 'foo', :weekday => 'Sun') }.should_not raise_error
222
+ proc { described_class.new(:name => 'foo', :weekday => 'Mon') }.should_not raise_error
223
+ proc { described_class.new(:name => 'foo', :weekday => 'Tue') }.should_not raise_error
224
+ proc { described_class.new(:name => 'foo', :weekday => 'Wed') }.should_not raise_error
225
+ proc { described_class.new(:name => 'foo', :weekday => 'Thu') }.should_not raise_error
226
+ proc { described_class.new(:name => 'foo', :weekday => 'Fri') }.should_not raise_error
227
+ proc { described_class.new(:name => 'foo', :weekday => 'Sat') }.should_not raise_error
228
+ proc { described_class.new(:name => 'foo', :weekday => 'Sun') }.should_not raise_error
241
229
  end
242
230
 
243
231
  it "should not support numeric values out of range" do
244
- proc { @class.new(:name => 'foo', :weekday => '-1') }.should raise_error(Puppet::Error)
245
- proc { @class.new(:name => 'foo', :weekday => '8') }.should raise_error(Puppet::Error)
232
+ proc { described_class.new(:name => 'foo', :weekday => '-1') }.should raise_error(Puppet::Error, /-1 is not a valid weekday/)
233
+ proc { described_class.new(:name => 'foo', :weekday => '8') }.should raise_error(Puppet::Error, /8 is not a valid weekday/)
246
234
  end
247
235
 
248
236
  it "should not support invalid weekday names" do
249
- proc { @class.new(:name => 'foo', :weekday => 'Sar') }.should raise_error(Puppet::Error)
237
+ proc { described_class.new(:name => 'foo', :weekday => 'Sar') }.should raise_error(Puppet::Error, /Sar is not a valid weekday/)
250
238
  end
251
239
 
252
240
  it "should support valid multiple values" do
253
- proc { @class.new(:name => 'foo', :weekday => ['0','1','6'] ) }.should_not raise_error
254
- proc { @class.new(:name => 'foo', :weekday => ['Mon','Wed','Friday'] ) }.should_not raise_error
241
+ proc { described_class.new(:name => 'foo', :weekday => ['0','1','6'] ) }.should_not raise_error
242
+ proc { described_class.new(:name => 'foo', :weekday => ['Mon','Wed','Friday'] ) }.should_not raise_error
255
243
  end
256
244
 
257
245
  it "should not support multiple values if at least one is invalid" do
258
246
  # one invalid
259
- proc { @class.new(:name => 'foo', :weekday => ['0','1','8'] ) }.should raise_error(Puppet::Error)
260
- proc { @class.new(:name => 'foo', :weekday => ['Mon','Fii','Sat'] ) }.should raise_error(Puppet::Error)
247
+ proc { described_class.new(:name => 'foo', :weekday => ['0','1','8'] ) }.should raise_error(Puppet::Error, /8 is not a valid weekday/)
248
+ proc { described_class.new(:name => 'foo', :weekday => ['Mon','Fii','Sat'] ) }.should raise_error(Puppet::Error, /Fii is not a valid weekday/)
261
249
  # two invalid
262
- proc { @class.new(:name => 'foo', :weekday => ['Mos','Fii','Sat'] ) }.should raise_error(Puppet::Error)
250
+ proc { described_class.new(:name => 'foo', :weekday => ['Mos','Fii','Sat'] ) }.should raise_error(Puppet::Error, /(Mos|Fii) is not a valid weekday/)
263
251
  # all invalid
264
- proc { @class.new(:name => 'foo', :weekday => ['Mos','Fii','Saa'] ) }.should raise_error(Puppet::Error)
265
- proc { @class.new(:name => 'foo', :weekday => ['-1','8','11'] ) }.should raise_error(Puppet::Error)
252
+ proc { described_class.new(:name => 'foo', :weekday => ['Mos','Fii','Saa'] ) }.should raise_error(Puppet::Error, /(Mos|Fii|Saa) is not a valid weekday/)
253
+ proc { described_class.new(:name => 'foo', :weekday => ['-1','8','11'] ) }.should raise_error(Puppet::Error, /(-1|8|11) is not a valid weekday/)
266
254
  end
267
255
 
268
256
  it "should support valid step syntax" do
269
- proc { @class.new(:name => 'foo', :weekday => '*/2' ) }.should_not raise_error
270
- proc { @class.new(:name => 'foo', :weekday => '0-4/2' ) }.should_not raise_error
257
+ proc { described_class.new(:name => 'foo', :weekday => '*/2' ) }.should_not raise_error
258
+ proc { described_class.new(:name => 'foo', :weekday => '0-4/2' ) }.should_not raise_error
271
259
  end
272
260
 
273
261
  it "should not support invalid steps" do
274
- proc { @class.new(:name => 'foo', :weekday => '*/A' ) }.should raise_error(Puppet::Error)
275
- proc { @class.new(:name => 'foo', :weekday => '*/2A' ) }.should raise_error(Puppet::Error)
262
+ proc { described_class.new(:name => 'foo', :weekday => '*/A' ) }.should raise_error(Puppet::Error, /\*\/A is not a valid weekday/)
263
+ proc { described_class.new(:name => 'foo', :weekday => '*/2A' ) }.should raise_error(Puppet::Error, /\*\/2A is not a valid weekday/)
276
264
  # As it turns out cron does not complaining about steps that exceed the valid range
277
- # proc { @class.new(:name => 'foo', :weekday => '*/9' ) }.should raise_error(Puppet::Error)
265
+ # proc { described_class.new(:name => 'foo', :weekday => '*/9' ) }.should raise_error(Puppet::Error, /is not a valid weekday/)
278
266
  end
279
-
280
267
  end
281
268
 
282
269
  describe "month" do
283
-
284
270
  it "should support absent" do
285
- proc { @class.new(:name => 'foo', :month => 'absent') }.should_not raise_error
271
+ proc { described_class.new(:name => 'foo', :month => 'absent') }.should_not raise_error
286
272
  end
287
273
 
288
274
  it "should support *" do
289
- proc { @class.new(:name => 'foo', :month => '*') }.should_not raise_error
275
+ proc { described_class.new(:name => 'foo', :month => '*') }.should_not raise_error
290
276
  end
291
277
 
292
278
  it "should translate absent to :absent" do
293
- @class.new(:name => 'foo', :month => 'absent')[:month].should == :absent
279
+ described_class.new(:name => 'foo', :month => 'absent')[:month].should == :absent
294
280
  end
295
281
 
296
282
  it "should translate * to :absent" do
297
- @class.new(:name => 'foo', :month => '*')[:month].should == :absent
283
+ described_class.new(:name => 'foo', :month => '*')[:month].should == :absent
298
284
  end
299
285
 
300
286
  it "should support valid numeric values" do
301
- proc { @class.new(:name => 'foo', :month => '1') }.should_not raise_error
302
- proc { @class.new(:name => 'foo', :month => '12') }.should_not raise_error
287
+ proc { described_class.new(:name => 'foo', :month => '1') }.should_not raise_error
288
+ proc { described_class.new(:name => 'foo', :month => '12') }.should_not raise_error
303
289
  end
304
290
 
305
291
  it "should support valid months as words" do
306
- proc { @class.new(:name => 'foo', :month => 'January') }.should_not raise_error
307
- proc { @class.new(:name => 'foo', :month => 'February') }.should_not raise_error
308
- proc { @class.new(:name => 'foo', :month => 'March') }.should_not raise_error
309
- proc { @class.new(:name => 'foo', :month => 'April') }.should_not raise_error
310
- proc { @class.new(:name => 'foo', :month => 'May') }.should_not raise_error
311
- proc { @class.new(:name => 'foo', :month => 'June') }.should_not raise_error
312
- proc { @class.new(:name => 'foo', :month => 'July') }.should_not raise_error
313
- proc { @class.new(:name => 'foo', :month => 'August') }.should_not raise_error
314
- proc { @class.new(:name => 'foo', :month => 'September') }.should_not raise_error
315
- proc { @class.new(:name => 'foo', :month => 'October') }.should_not raise_error
316
- proc { @class.new(:name => 'foo', :month => 'November') }.should_not raise_error
317
- proc { @class.new(:name => 'foo', :month => 'December') }.should_not raise_error
292
+ proc { described_class.new(:name => 'foo', :month => 'January') }.should_not raise_error
293
+ proc { described_class.new(:name => 'foo', :month => 'February') }.should_not raise_error
294
+ proc { described_class.new(:name => 'foo', :month => 'March') }.should_not raise_error
295
+ proc { described_class.new(:name => 'foo', :month => 'April') }.should_not raise_error
296
+ proc { described_class.new(:name => 'foo', :month => 'May') }.should_not raise_error
297
+ proc { described_class.new(:name => 'foo', :month => 'June') }.should_not raise_error
298
+ proc { described_class.new(:name => 'foo', :month => 'July') }.should_not raise_error
299
+ proc { described_class.new(:name => 'foo', :month => 'August') }.should_not raise_error
300
+ proc { described_class.new(:name => 'foo', :month => 'September') }.should_not raise_error
301
+ proc { described_class.new(:name => 'foo', :month => 'October') }.should_not raise_error
302
+ proc { described_class.new(:name => 'foo', :month => 'November') }.should_not raise_error
303
+ proc { described_class.new(:name => 'foo', :month => 'December') }.should_not raise_error
318
304
  end
319
305
 
320
306
  it "should support valid months as words (3 character short version)" do
321
- proc { @class.new(:name => 'foo', :month => 'Jan') }.should_not raise_error
322
- proc { @class.new(:name => 'foo', :month => 'Feb') }.should_not raise_error
323
- proc { @class.new(:name => 'foo', :month => 'Mar') }.should_not raise_error
324
- proc { @class.new(:name => 'foo', :month => 'Apr') }.should_not raise_error
325
- proc { @class.new(:name => 'foo', :month => 'May') }.should_not raise_error
326
- proc { @class.new(:name => 'foo', :month => 'Jun') }.should_not raise_error
327
- proc { @class.new(:name => 'foo', :month => 'Jul') }.should_not raise_error
328
- proc { @class.new(:name => 'foo', :month => 'Aug') }.should_not raise_error
329
- proc { @class.new(:name => 'foo', :month => 'Sep') }.should_not raise_error
330
- proc { @class.new(:name => 'foo', :month => 'Oct') }.should_not raise_error
331
- proc { @class.new(:name => 'foo', :month => 'Nov') }.should_not raise_error
332
- proc { @class.new(:name => 'foo', :month => 'Dec') }.should_not raise_error
307
+ proc { described_class.new(:name => 'foo', :month => 'Jan') }.should_not raise_error
308
+ proc { described_class.new(:name => 'foo', :month => 'Feb') }.should_not raise_error
309
+ proc { described_class.new(:name => 'foo', :month => 'Mar') }.should_not raise_error
310
+ proc { described_class.new(:name => 'foo', :month => 'Apr') }.should_not raise_error
311
+ proc { described_class.new(:name => 'foo', :month => 'May') }.should_not raise_error
312
+ proc { described_class.new(:name => 'foo', :month => 'Jun') }.should_not raise_error
313
+ proc { described_class.new(:name => 'foo', :month => 'Jul') }.should_not raise_error
314
+ proc { described_class.new(:name => 'foo', :month => 'Aug') }.should_not raise_error
315
+ proc { described_class.new(:name => 'foo', :month => 'Sep') }.should_not raise_error
316
+ proc { described_class.new(:name => 'foo', :month => 'Oct') }.should_not raise_error
317
+ proc { described_class.new(:name => 'foo', :month => 'Nov') }.should_not raise_error
318
+ proc { described_class.new(:name => 'foo', :month => 'Dec') }.should_not raise_error
333
319
  end
334
320
 
335
321
  it "should not support numeric values out of range" do
336
- proc { @class.new(:name => 'foo', :month => '-1') }.should raise_error(Puppet::Error)
337
- proc { @class.new(:name => 'foo', :month => '0') }.should raise_error(Puppet::Error)
338
- proc { @class.new(:name => 'foo', :month => '13') }.should raise_error(Puppet::Error)
322
+ proc { described_class.new(:name => 'foo', :month => '-1') }.should raise_error(Puppet::Error, /-1 is not a valid month/)
323
+ proc { described_class.new(:name => 'foo', :month => '0') }.should raise_error(Puppet::Error, /0 is not a valid month/)
324
+ proc { described_class.new(:name => 'foo', :month => '13') }.should raise_error(Puppet::Error, /13 is not a valid month/)
339
325
  end
340
326
 
341
327
  it "should not support words that are not valid months" do
342
- proc { @class.new(:name => 'foo', :month => 'Jal') }.should raise_error(Puppet::Error)
328
+ proc { described_class.new(:name => 'foo', :month => 'Jal') }.should raise_error(Puppet::Error, /Jal is not a valid month/)
343
329
  end
344
330
 
345
331
  it "should not support single values out of range" do
346
332
 
347
- proc { @class.new(:name => 'foo', :month => '-1') }.should raise_error(Puppet::Error)
348
- proc { @class.new(:name => 'foo', :month => '60') }.should raise_error(Puppet::Error)
349
- proc { @class.new(:name => 'foo', :month => '61') }.should raise_error(Puppet::Error)
350
- proc { @class.new(:name => 'foo', :month => '120') }.should raise_error(Puppet::Error)
333
+ proc { described_class.new(:name => 'foo', :month => '-1') }.should raise_error(Puppet::Error, /-1 is not a valid month/)
334
+ proc { described_class.new(:name => 'foo', :month => '60') }.should raise_error(Puppet::Error, /60 is not a valid month/)
335
+ proc { described_class.new(:name => 'foo', :month => '61') }.should raise_error(Puppet::Error, /61 is not a valid month/)
336
+ proc { described_class.new(:name => 'foo', :month => '120') }.should raise_error(Puppet::Error, /120 is not a valid month/)
351
337
  end
352
338
 
353
339
  it "should support valid multiple values" do
354
- proc { @class.new(:name => 'foo', :month => ['1','9','12'] ) }.should_not raise_error
355
- proc { @class.new(:name => 'foo', :month => ['Jan','March','Jul'] ) }.should_not raise_error
340
+ proc { described_class.new(:name => 'foo', :month => ['1','9','12'] ) }.should_not raise_error
341
+ proc { described_class.new(:name => 'foo', :month => ['Jan','March','Jul'] ) }.should_not raise_error
356
342
  end
357
343
 
358
344
  it "should not support multiple values if at least one is invalid" do
359
345
  # one invalid
360
- proc { @class.new(:name => 'foo', :month => ['0','1','12'] ) }.should raise_error(Puppet::Error)
361
- proc { @class.new(:name => 'foo', :month => ['1','13','10'] ) }.should raise_error(Puppet::Error)
362
- proc { @class.new(:name => 'foo', :month => ['Jan','Feb','Jxx'] ) }.should raise_error(Puppet::Error)
346
+ proc { described_class.new(:name => 'foo', :month => ['0','1','12'] ) }.should raise_error(Puppet::Error, /0 is not a valid month/)
347
+ proc { described_class.new(:name => 'foo', :month => ['1','13','10'] ) }.should raise_error(Puppet::Error, /13 is not a valid month/)
348
+ proc { described_class.new(:name => 'foo', :month => ['Jan','Feb','Jxx'] ) }.should raise_error(Puppet::Error, /Jxx is not a valid month/)
363
349
  # two invalid
364
- proc { @class.new(:name => 'foo', :month => ['Jan','Fex','Jux'] ) }.should raise_error(Puppet::Error)
350
+ proc { described_class.new(:name => 'foo', :month => ['Jan','Fex','Jux'] ) }.should raise_error(Puppet::Error, /(Fex|Jux) is not a valid month/)
365
351
  # all invalid
366
- proc { @class.new(:name => 'foo', :month => ['-1','0','13'] ) }.should raise_error(Puppet::Error)
367
- proc { @class.new(:name => 'foo', :month => ['Jax','Fex','Aux'] ) }.should raise_error(Puppet::Error)
352
+ proc { described_class.new(:name => 'foo', :month => ['-1','0','13'] ) }.should raise_error(Puppet::Error, /(-1|0|13) is not a valid month/)
353
+ proc { described_class.new(:name => 'foo', :month => ['Jax','Fex','Aux'] ) }.should raise_error(Puppet::Error, /(Jax|Fex|Aux) is not a valid month/)
368
354
  end
369
355
 
370
356
  it "should support valid step syntax" do
371
- proc { @class.new(:name => 'foo', :month => '*/2' ) }.should_not raise_error
372
- proc { @class.new(:name => 'foo', :month => '1-12/3' ) }.should_not raise_error
357
+ proc { described_class.new(:name => 'foo', :month => '*/2' ) }.should_not raise_error
358
+ proc { described_class.new(:name => 'foo', :month => '1-12/3' ) }.should_not raise_error
373
359
  end
374
360
 
375
361
  it "should not support invalid steps" do
376
- proc { @class.new(:name => 'foo', :month => '*/A' ) }.should raise_error(Puppet::Error)
377
- proc { @class.new(:name => 'foo', :month => '*/2A' ) }.should raise_error(Puppet::Error)
362
+ proc { described_class.new(:name => 'foo', :month => '*/A' ) }.should raise_error(Puppet::Error, /\*\/A is not a valid month/)
363
+ proc { described_class.new(:name => 'foo', :month => '*/2A' ) }.should raise_error(Puppet::Error, /\*\/2A is not a valid month/)
378
364
  # As it turns out cron does not complaining about steps that exceed the valid range
379
- # proc { @class.new(:name => 'foo', :month => '*/13' ) }.should raise_error(Puppet::Error)
365
+ # proc { described_class.new(:name => 'foo', :month => '*/13' ) }.should raise_error(Puppet::Error, /is not a valid month/)
380
366
  end
381
-
382
367
  end
383
368
 
384
369
  describe "monthday" do
385
-
386
370
  it "should support absent" do
387
- proc { @class.new(:name => 'foo', :monthday => 'absent') }.should_not raise_error
371
+ proc { described_class.new(:name => 'foo', :monthday => 'absent') }.should_not raise_error
388
372
  end
389
373
 
390
374
  it "should support *" do
391
- proc { @class.new(:name => 'foo', :monthday => '*') }.should_not raise_error
375
+ proc { described_class.new(:name => 'foo', :monthday => '*') }.should_not raise_error
392
376
  end
393
377
 
394
378
  it "should translate absent to :absent" do
395
- @class.new(:name => 'foo', :monthday => 'absent')[:monthday].should == :absent
379
+ described_class.new(:name => 'foo', :monthday => 'absent')[:monthday].should == :absent
396
380
  end
397
381
 
398
382
  it "should translate * to :absent" do
399
- @class.new(:name => 'foo', :monthday => '*')[:monthday].should == :absent
383
+ described_class.new(:name => 'foo', :monthday => '*')[:monthday].should == :absent
400
384
  end
401
385
 
402
386
  it "should support valid single values" do
403
- proc { @class.new(:name => 'foo', :monthday => '1') }.should_not raise_error
404
- proc { @class.new(:name => 'foo', :monthday => '30') }.should_not raise_error
405
- proc { @class.new(:name => 'foo', :monthday => '31') }.should_not raise_error
387
+ proc { described_class.new(:name => 'foo', :monthday => '1') }.should_not raise_error
388
+ proc { described_class.new(:name => 'foo', :monthday => '30') }.should_not raise_error
389
+ proc { described_class.new(:name => 'foo', :monthday => '31') }.should_not raise_error
406
390
  end
407
391
 
408
392
  it "should not support non numeric characters" do
409
- proc { @class.new(:name => 'foo', :monthday => 'z23') }.should raise_error(Puppet::Error)
410
- proc { @class.new(:name => 'foo', :monthday => '2z3') }.should raise_error(Puppet::Error)
411
- proc { @class.new(:name => 'foo', :monthday => '23z') }.should raise_error(Puppet::Error)
393
+ proc { described_class.new(:name => 'foo', :monthday => 'z23') }.should raise_error(Puppet::Error, /z23 is not a valid monthday/)
394
+ proc { described_class.new(:name => 'foo', :monthday => '2z3') }.should raise_error(Puppet::Error, /2z3 is not a valid monthday/)
395
+ proc { described_class.new(:name => 'foo', :monthday => '23z') }.should raise_error(Puppet::Error, /23z is not a valid monthday/)
412
396
  end
413
397
 
414
398
  it "should not support single values out of range" do
415
- proc { @class.new(:name => 'foo', :monthday => '-1') }.should raise_error(Puppet::Error)
416
- proc { @class.new(:name => 'foo', :monthday => '0') }.should raise_error(Puppet::Error)
417
- proc { @class.new(:name => 'foo', :monthday => '32') }.should raise_error(Puppet::Error)
399
+ proc { described_class.new(:name => 'foo', :monthday => '-1') }.should raise_error(Puppet::Error, /-1 is not a valid monthday/)
400
+ proc { described_class.new(:name => 'foo', :monthday => '0') }.should raise_error(Puppet::Error, /0 is not a valid monthday/)
401
+ proc { described_class.new(:name => 'foo', :monthday => '32') }.should raise_error(Puppet::Error, /32 is not a valid monthday/)
418
402
  end
419
403
 
420
404
  it "should support valid multiple values" do
421
- proc { @class.new(:name => 'foo', :monthday => ['1','23','31'] ) }.should_not raise_error
422
- proc { @class.new(:name => 'foo', :monthday => ['31','23','1'] ) }.should_not raise_error
423
- proc { @class.new(:name => 'foo', :monthday => ['1','31','23'] ) }.should_not raise_error
405
+ proc { described_class.new(:name => 'foo', :monthday => ['1','23','31'] ) }.should_not raise_error
406
+ proc { described_class.new(:name => 'foo', :monthday => ['31','23','1'] ) }.should_not raise_error
407
+ proc { described_class.new(:name => 'foo', :monthday => ['1','31','23'] ) }.should_not raise_error
424
408
  end
425
409
 
426
410
  it "should not support multiple values if at least one is invalid" do
427
411
  # one invalid
428
- proc { @class.new(:name => 'foo', :monthday => ['1','23','32'] ) }.should raise_error(Puppet::Error)
429
- proc { @class.new(:name => 'foo', :monthday => ['-1','12','23'] ) }.should raise_error(Puppet::Error)
430
- proc { @class.new(:name => 'foo', :monthday => ['13','32','30'] ) }.should raise_error(Puppet::Error)
412
+ proc { described_class.new(:name => 'foo', :monthday => ['1','23','32'] ) }.should raise_error(Puppet::Error, /32 is not a valid monthday/)
413
+ proc { described_class.new(:name => 'foo', :monthday => ['-1','12','23'] ) }.should raise_error(Puppet::Error, /-1 is not a valid monthday/)
414
+ proc { described_class.new(:name => 'foo', :monthday => ['13','32','30'] ) }.should raise_error(Puppet::Error, /32 is not a valid monthday/)
431
415
  # two invalid
432
- proc { @class.new(:name => 'foo', :monthday => ['-1','0','23'] ) }.should raise_error(Puppet::Error)
416
+ proc { described_class.new(:name => 'foo', :monthday => ['-1','0','23'] ) }.should raise_error(Puppet::Error, /(-1|0) is not a valid monthday/)
433
417
  # all invalid
434
- proc { @class.new(:name => 'foo', :monthday => ['-1','0','32'] ) }.should raise_error(Puppet::Error)
418
+ proc { described_class.new(:name => 'foo', :monthday => ['-1','0','32'] ) }.should raise_error(Puppet::Error, /(-1|0|32) is not a valid monthday/)
435
419
  end
436
420
 
437
421
  it "should support valid step syntax" do
438
- proc { @class.new(:name => 'foo', :monthday => '*/2' ) }.should_not raise_error
439
- proc { @class.new(:name => 'foo', :monthday => '10-16/2' ) }.should_not raise_error
422
+ proc { described_class.new(:name => 'foo', :monthday => '*/2' ) }.should_not raise_error
423
+ proc { described_class.new(:name => 'foo', :monthday => '10-16/2' ) }.should_not raise_error
440
424
  end
441
425
 
442
426
  it "should not support invalid steps" do
443
- proc { @class.new(:name => 'foo', :monthday => '*/A' ) }.should raise_error(Puppet::Error)
444
- proc { @class.new(:name => 'foo', :monthday => '*/2A' ) }.should raise_error(Puppet::Error)
427
+ proc { described_class.new(:name => 'foo', :monthday => '*/A' ) }.should raise_error(Puppet::Error, /\*\/A is not a valid monthday/)
428
+ proc { described_class.new(:name => 'foo', :monthday => '*/2A' ) }.should raise_error(Puppet::Error, /\*\/2A is not a valid monthday/)
445
429
  # As it turns out cron does not complaining about steps that exceed the valid range
446
- # proc { @class.new(:name => 'foo', :monthday => '*/32' ) }.should raise_error(Puppet::Error)
430
+ # proc { described_class.new(:name => 'foo', :monthday => '*/32' ) }.should raise_error(Puppet::Error, /is not a valid monthday/)
447
431
  end
448
-
449
432
  end
450
433
 
451
434
  describe "environment" do
452
-
453
435
  it "it should accept an :environment that looks like a path" do
454
436
  lambda do
455
- @cron[:environment] = 'PATH=/bin:/usr/bin:/usr/sbin'
437
+ described_class.new(:name => 'foo',:environment => 'PATH=/bin:/usr/bin:/usr/sbin')
456
438
  end.should_not raise_error
457
439
  end
458
440
 
459
441
  it "should not accept environment variables that do not contain '='" do
460
442
  lambda do
461
- @cron[:environment] = "INVALID"
462
- end.should raise_error(Puppet::Error)
443
+ described_class.new(:name => 'foo',:environment => 'INVALID')
444
+ end.should raise_error(Puppet::Error, /Invalid environment setting "INVALID"/)
463
445
  end
464
446
 
465
447
  it "should accept empty environment variables that do not contain '='" do
466
448
  lambda do
467
- @cron[:environment] = "MAILTO="
449
+ described_class.new(:name => 'foo',:environment => 'MAILTO=')
468
450
  end.should_not raise_error(Puppet::Error)
469
451
  end
470
452
 
471
453
  it "should accept 'absent'" do
472
454
  lambda do
473
- @cron[:environment] = 'absent'
455
+ described_class.new(:name => 'foo',:environment => 'absent')
474
456
  end.should_not raise_error(Puppet::Error)
475
457
  end
476
458
 
477
459
  end
478
-
479
460
  end
480
461
 
481
462
  it "should require a command when adding an entry" do
482
- entry = @class.new(:name => "test_entry", :ensure => :present)
483
- expect { entry.value(:command) }.should raise_error(/No command/)
463
+ entry = described_class.new(:name => "test_entry", :ensure => :present)
464
+ expect { entry.value(:command) }.should raise_error(Puppet::Error, /No command/)
484
465
  end
485
466
 
486
467
  it "should not require a command when removing an entry" do
487
- entry = @class.new(:name => "test_entry", :ensure => :absent)
468
+ entry = described_class.new(:name => "test_entry", :ensure => :absent)
488
469
  entry.value(:command).should == nil
489
470
  end
471
+
472
+ it "should default to user => root if Etc.getpwuid(Process.uid) returns nil (#12357)" do
473
+ Etc.expects(:getpwuid).returns(nil)
474
+ entry = described_class.new(:name => "test_entry", :ensure => :present)
475
+ entry.value(:user).should eql "root"
476
+ end
490
477
  end