summaryrefslogtreecommitdiffstats
path: root/spec/unit/type/cron_spec.rb
blob: 03817d20ed5539bd4a75a051e95fac6131c8e532 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
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