~ubuntu-branches/ubuntu/wily/puppet/wily

« back to all changes in this revision

Viewing changes to spec/unit/type/cron_spec.rb

  • Committer: Package Import Robot
  • Author(s): Stig Sandbeck Mathisen
  • Date: 2014-04-17 14:50:28 UTC
  • mfrom: (3.1.59 sid)
  • Revision ID: package-import@ubuntu.com-20140417145028-j3p3dwvp8ggpzvaf
Tags: 3.5.1-1
ImportedĀ upstreamĀ releaseĀ 3.5.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
require 'spec_helper'
4
4
 
5
5
describe Puppet::Type.type(:cron), :unless => Puppet.features.microsoft_windows? do
6
 
  before do
 
6
  before :all do
7
7
    @provider_class = described_class.provide(:simple) { mk_resource_methods }
8
8
    @provider_class.stubs(:suitable?).returns true
9
9
    described_class.stubs(:defaultprovider).returns @provider_class
10
10
  end
11
11
 
 
12
  after :all do
 
13
    described_class.unprovide(:simple)
 
14
  end
 
15
 
12
16
  it "should have :name be its namevar" do
13
17
    described_class.key_attributes.should == [:name]
14
18
  end
441
445
      end
442
446
    end
443
447
 
 
448
    describe "special" do
 
449
      %w(reboot yearly annually monthly weekly daily midnight hourly).each do |value|
 
450
        it "should support the value '#{value}'" do
 
451
          expect { described_class.new(:name => 'foo', :special => value ) }.to_not raise_error(Puppet::Error, /cannot specify both a special schedule and a value/)
 
452
        end
 
453
      end
 
454
 
 
455
      context "when combined with numeric schedule fields" do
 
456
        context "which are 'absent'" do
 
457
          [ %w(reboot yearly annually monthly weekly daily midnight hourly), :absent ].flatten.each { |value|
 
458
            it "should accept the value '#{value}' for special" do
 
459
              expect {
 
460
                described_class.new(:name => 'foo', :minute => :absent, :special => value )
 
461
              }.to_not raise_error(Puppet::Error, /cannot specify both a special schedule and a value/)
 
462
            end
 
463
          }
 
464
        end
 
465
        context "which are not absent" do
 
466
          %w(reboot yearly annually monthly weekly daily midnight hourly).each { |value|
 
467
            it "should not accept the value '#{value}' for special" do
 
468
              expect {
 
469
                described_class.new(:name => 'foo', :minute => "1", :special => value )
 
470
              }.to raise_error(Puppet::Error, /cannot specify both a special schedule and a value/)
 
471
            end
 
472
          }
 
473
          it "should accept the 'absent' value for special" do
 
474
            expect {
 
475
              described_class.new(:name => 'foo', :minute => "1", :special => :absent )
 
476
            }.to_not raise_error(Puppet::Error, /cannot specify both a special schedule and a value/)
 
477
          end
 
478
        end
 
479
      end
 
480
    end
 
481
 
444
482
    describe "environment" do
445
483
      it "it should accept an :environment that looks like a path" do
446
484
        expect do