summaryrefslogtreecommitdiff
path: root/spec/unit/runner_spec.rb
diff options
context:
space:
mode:
authorEzra Zygmuntowicz <ez@engineyard.com>2008-10-08 14:19:52 -0700
committerEzra Zygmuntowicz <ez@engineyard.com>2008-10-08 14:19:52 -0700
commitc5d33c1298834ce40b8fbf344f281045771b5371 (patch)
tree1f0d4c7eab1eb379b544282a7ce48052acf719a5 /spec/unit/runner_spec.rb
parent3d14601aea23dee3899d097324875274da419d84 (diff)
downloadchef-c5d33c1298834ce40b8fbf344f281045771b5371.tar.gz
big refactor of the repo layout. move to a chef gem and a chef-server gem all with proper deps
Diffstat (limited to 'spec/unit/runner_spec.rb')
-rw-r--r--spec/unit/runner_spec.rb103
1 files changed, 0 insertions, 103 deletions
diff --git a/spec/unit/runner_spec.rb b/spec/unit/runner_spec.rb
deleted file mode 100644
index f73d5efb22..0000000000
--- a/spec/unit/runner_spec.rb
+++ /dev/null
@@ -1,103 +0,0 @@
-#
-# Author:: Adam Jacob (<adam@hjksolutions.com>)
-# Copyright:: Copyright (c) 2008 HJK Solutions, LLC
-# 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::Runner do
- before(:each) do
- @mock_node = mock("Node", :null_object => true)
- @mock_collection = mock("Resource Collection", :null_object => true)
- @mock_provider = mock("Provider", :null_object => true)
- @mock_resource = mock("Resource", :null_object => true)
- new_runner
- end
-
- it "should require a Node and a ResourceCollection" do
- @mock_node.should_receive(:kind_of?).once.and_return(true)
- @mock_collection.should_receive(:kind_of?).once.and_return(true)
- runner = Chef::Runner.new(@mock_node, @mock_collection)
- runner.should be_a_kind_of(Chef::Runner)
- end
-
- it "should raise an exception if you pass the wrong kind of object to new" do
- @mock_node.stub!(:kind_of?).and_return(false)
- @mock_collecton.stub!(:kind_of?).and_return(false)
- lambda { Chef::Runner.new(@mock_node, @mock_collection) }.should raise_error(ArgumentError)
- end
-
- it "should pass each resource in the collection to a provider" do
- @collection.should_receive(:each).once
- @runner.converge
- end
-
- it "should use the provider specified by the resource (if it has one)" do
- provider = Chef::Provider::Easy.new(@node, @collection[0])
- @collection[0].should_receive(:provider).once.and_return(Chef::Provider::Easy)
- Chef::Provider::Easy.should_receive(:new).once.and_return(provider)
- @runner.converge
- end
-
- it "should use the platform provider if it has one" do
- Chef::Platform.should_receive(:find_provider_for_node).once.and_return(Chef::Provider::SnakeOil)
- @runner.converge
- end
-
- it "should run the action for each resource" do
- Chef::Platform.should_receive(:find_provider_for_node).once.and_return(Chef::Provider::SnakeOil)
- provider = Chef::Provider::SnakeOil.new(@node, @collection[0])
- provider.should_receive(:action_sell).once.and_return(true)
- Chef::Provider::SnakeOil.should_receive(:new).once.and_return(provider)
- @runner.converge
- end
-
- it "should execute immediate actions on changed resources" do
- Chef::Platform.should_receive(:find_provider_for_node).exactly(3).times.and_return(Chef::Provider::SnakeOil)
- provider = Chef::Provider::SnakeOil.new(@node, @collection[0])
- Chef::Provider::SnakeOil.should_receive(:new).exactly(3).times.and_return(provider)
- @collection << Chef::Resource::Cat.new("peanut", @collection)
- @collection[1].notifies :buy, @collection[0], :immediately
- @collection[1].updated = true
- provider.should_receive(:action_buy).once.and_return(true)
- @runner.converge
- end
-
- it "should execute delayed actions on changed resources" do
- Chef::Platform.should_receive(:find_provider_for_node).exactly(3).times.and_return(Chef::Provider::SnakeOil)
- provider = Chef::Provider::SnakeOil.new(@node, @collection[0])
- Chef::Provider::SnakeOil.should_receive(:new).exactly(3).times.and_return(provider)
- @collection << Chef::Resource::Cat.new("peanut", @collection)
- @collection[1].notifies :buy, @collection[0], :delayed
- @collection[1].updated = true
- provider.should_receive(:action_buy).once.and_return(true)
- @runner.converge
- end
-
- def new_runner
- @node = Chef::Node.new
- @node.name "latte"
- @node.operatingsystem "mac_os_x"
- @node.operatingsystemversion "10.5.1"
- @collection = Chef::ResourceCollection.new()
- @collection << Chef::Resource::Cat.new("loulou", @collection)
- Chef::Platform.set(
- :resource => :cat,
- :provider => Chef::Provider::SnakeOil
- )
- @runner = Chef::Runner.new(@node, @collection)
- end
-end \ No newline at end of file