require 'spec_helper'

# test if the agent is able to find and use an add-on module

describe command("puppet apply --detailed-exitcodes -e \"cron { 'test' : ensure => present, command => '/bin/true', minute => 3 }\"") do
  its(:exit_status) { should eq 2 }
  its(:stdout) { should match %r{/Stage\[main\]/Main/Cron\[test\]/ensure: created} }

  describe cron do
    it { should have_entry '3 * * * * /bin/true' }
  end
end

describe command("puppet apply --detailed-exitcodes -e \"cron { 'test' : ensure => absent }\"") do
  its(:exit_status) { should eq 2 }
  its(:stdout) { should match %r{/Stage\[main\]/Main/Cron\[test\]/ensure: removed} }

  describe cron do
    it { should_not have_entry '3 * * * * /bin/true' }
  end
end

