Skip to content

Instantly share code, notes, and snippets.

@btm
Created January 23, 2009 12:10
Show Gist options
  • Save btm/50991 to your computer and use it in GitHub Desktop.
Save btm/50991 to your computer and use it in GitHub Desktop.
#
# Author:: Bryan McLellan ([email protected])
# Copyright:: Copyright (c) 2009 Bryan McLellan
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
require File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "spec_helper"))
describe Chef::Provider::Cron, "initialize" do
before(:each) do
@node = mock("Chef::Node", :null_object => true)
@new_resource = mock("Chef::Resource", :null_object => true)
end
it "should return a Chef::Provider::Cron object" do
provider = Chef::Provider::Cron.new(@node, @new_resource)
provider.should be_a_kind_of(Chef::Provider::Cron)
end
end
describe Chef::Provider::Cron, "action_create" do
before(:each) do
@node = mock("Chef::Node", :null_object => true)
@new_resource = mock("Chef::Resource::Cron",
:null_object => true,
:name => "foo",
:minute => "30",
:command => "/bin/true"
)
@current_resource = mock("Chef::Resource::Cron",
:null_object => true,
:name => "foo",
:minute => "30",
:command => "/bin/true"
)
@status = mock("Status", :exitstatus => 0)
@provider.stub!(:popen4).and_return(@status)
@stdin = mock("STDIN", :null_object => true)
@stdout = mock("STDOUT", :null_object => true)
@stdout.stub!(:each).and_yield("# Chef Name: foo").
and_yield("* 30 * * * /bin/true")
@stderr = mock("STDERR", :null_object => true)
@pid = mock("PID", :null_object => true)
@provider = Chef::Provider::Cron.new(@node, @new_resource)
@provider.current_resource = @current_resource
end
it "should not add the cronjob if it exists" do
@provider.should_receive(Chef::Log.debug).with("Added cron '#{@new_resource.name}'")
@provider.action_create
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment