spec/unit/recipe_spec.rb in chef-10.34.6 vs spec/unit/recipe_spec.rb in chef-11.0.0.beta.0
- old
+ new
@@ -22,18 +22,20 @@
require 'spec_helper'
describe Chef::Recipe do
before(:each) do
@cookbook_repo = File.expand_path(File.join(File.dirname(__FILE__), "..", "data", "cookbooks"))
- @cookbook_collection = Chef::CookbookCollection.new(Chef::CookbookLoader.new(@cookbook_repo))
+ cl = Chef::CookbookLoader.new(@cookbook_repo)
+ cl.load_cookbooks
+ @cookbook_collection = Chef::CookbookCollection.new(cl)
@node = Chef::Node.new
- @node[:tags] = Array.new
+ @node.normal[:tags] = Array.new
@events = Chef::EventDispatch::Dispatcher.new
@run_context = Chef::RunContext.new(@node, @cookbook_collection, @events)
@recipe = Chef::Recipe.new("hjk", "test", @run_context)
- # Shef/ext.rb is on the run path, and it defines
+ # Shell/ext.rb is on the run path, and it defines
# Chef::Recipe#resources to call pp, which we don't want when
# we're running tests.
@recipe.stub!(:pp)
end
@@ -106,12 +108,12 @@
describe "should locate platform mapped resources" do
it "locate resource for particular platform" do
Object.const_set('ShaunTheSheep', Class.new(Chef::Resource){ provides :laughter, :on_platforms => ["television"] })
- @node.platform("television")
- @node.platform_version("123")
+ @node.automatic[:platform] = "television"
+ @node.automatic[:platform_version] = "123"
res = @recipe.laughter "timmy"
res.name.should eql("timmy")
res.kind_of?(ShaunTheSheep)
end
@@ -149,11 +151,11 @@
peace params[:peace]
something params[:something]
end
end
@run_context.definitions[:crow] = crow_define
- @node[:foo] = false
+ @node.normal[:foo] = false
@recipe.crow "mine" do
something node[:foo]
end
@recipe.resources(:zen_master => "lao tzu").something.should eql(false)
end
@@ -202,12 +204,12 @@
res = @run_context.resource_collection.resources(:cat => "blanket")
res.name.should eql("blanket")
res.pretty_kitty.should eql(true)
end
- it "should store that it has seen a recipe in node.run_state[:seen_recipes]" do
+ it "should store that it has seen a recipe in the run_context" do
@run_context.include_recipe "openldap"
- @node.run_state[:seen_recipes].should have_key("openldap")
+ @run_context.loaded_recipe?("openldap").should be_true
end
it "should not include the same recipe twice" do
@cookbook_collection[:openldap].should_receive(:load_recipe).with("default", @run_context)
@recipe.include_recipe "openldap"