Change regexp to allow cron environment => "MAILTO="
Signed-off-by: Jesse Wolfe <[email protected]>
---
lib/puppet/type/cron.rb | 2 +-
spec/unit/type/cron.rb | 33 +++++++++++++++++++++++++++++++++
2 files changed, 34 insertions(+), 1 deletions(-)
create mode 100755 spec/unit/type/cron.rb
diff --git a/lib/puppet/type/cron.rb b/lib/puppet/type/cron.rb
index 1269f38..1cdd561 100755
--- a/lib/puppet/type/cron.rb
+++ b/lib/puppet/type/cron.rb
@@ -312,7 +312,7 @@ Puppet::Type.newtype(:cron) do
the crontab, e.g., ``PATH=/bin:/usr/bin:/usr/sbin``."
validate do |value|
- unless value =~ /^\s*(\w+)\s*=\s*(.+)\s*$/ or value == :absent or
value == "absent"
+ unless value =~ /^\s*(\w+)\s*=\s*(.*)\s*$/ or value == :absent or
value == "absent"
raise ArgumentError, "Invalid environment setting %s" %
value.inspect
end
diff --git a/spec/unit/type/cron.rb b/spec/unit/type/cron.rb
new file mode 100755
index 0000000..6951077
--- /dev/null
+++ b/spec/unit/type/cron.rb
@@ -0,0 +1,33 @@
+#!/usr/bin/env ruby
+
+Dir.chdir(File.dirname(__FILE__)) { (s = lambda { |f| File.exist?(f) ?
require(f) : Dir.chdir("..") { s.call(f) } }).call("spec/spec_helper.rb") }
+
+describe Puppet::Type.type(:cron) do
+ before do
+ @cron = Puppet::Type.type(:cron).new( :name => "foo" )
+ end
+
+ it "it should accept an :environment that looks like a path" do
+ lambda do
+ @cron[:environment] = 'PATH=/bin:/usr/bin:/usr/sbin'
+ end.should_not raise_error
+ end
+
+ it "should not accept environment variables that do not contain '='" do
+ lambda do
+ @cron[:environment] = "INVALID"
+ end.should raise_error(Puppet::Error)
+ end
+
+ it "should accept empty environment variables that do not contain '='" do
+ lambda do
+ @cron[:environment] = "MAILTO="
+ end.should_not raise_error(Puppet::Error)
+ end
+
+ it "should accept 'absent'" do
+ lambda do
+ @cron[:environment] = 'absent'
+ end.should_not raise_error(Puppet::Error)
+ end
+end
--
1.6.3.3
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Puppet Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/puppet-dev?hl=en
-~----------~----~----~----~------~----~------~--~---