diff options
author | danielsdeleo <dan@opscode.com> | 2012-10-18 12:03:53 -0700 |
---|---|---|
committer | danielsdeleo <dan@opscode.com> | 2012-10-19 14:16:00 -0700 |
commit | 054fed23f058c3e5e038ab47fc9a88b4796bedb7 (patch) | |
tree | f20230ef1e0f9a12462f58d3193aa2813cba6834 /chef/spec/unit | |
parent | 9394e0082bcbe8b364b5d209a9eb3fee1a02904a (diff) | |
download | chef-054fed23f058c3e5e038ab47fc9a88b4796bedb7.tar.gz |
[CHEF-2992] remove proxy object for evaluating attributes
Although having the DSL go through a purpose-specific object is a better
design, the risk introduced by that change isn't worth it right now.
Diffstat (limited to 'chef/spec/unit')
-rw-r--r-- | chef/spec/unit/dsl/attribute_spec.rb | 32 | ||||
-rw-r--r-- | chef/spec/unit/node_spec.rb | 47 | ||||
-rw-r--r-- | chef/spec/unit/run_context_spec.rb | 4 |
3 files changed, 26 insertions, 57 deletions
diff --git a/chef/spec/unit/dsl/attribute_spec.rb b/chef/spec/unit/dsl/attribute_spec.rb deleted file mode 100644 index c2983eb187..0000000000 --- a/chef/spec/unit/dsl/attribute_spec.rb +++ /dev/null @@ -1,32 +0,0 @@ - - -require 'spec_helper' -require 'chef/dsl/attribute' - -describe Chef::DSL::Attribute do - - before do - @node = Chef::Node.new - - @cookbook_repo = File.expand_path(File.join(CHEF_SPEC_DATA, "cookbooks")) - @cookbook_loader = Chef::CookbookLoader.new(@cookbook_repo) - @cookbook_loader.load_cookbooks - - @cookbook_collection = Chef::CookbookCollection.new(@cookbook_loader.cookbooks_by_name) - - @events = Chef::EventDispatch::Dispatcher.new - @run_context = Chef::RunContext.new(@node, @cookbook_collection, @events) - - @attribute = Chef::DSL::Attribute.new(@node, @run_context) - @attribute.eval_attribute("openldap", "default") - @attribute.eval_attribute("openldap", "smokey") - end - - it "should eval attributes files in cookbooks" do - @node.ldap_server.should eql("ops1prod") - @node.ldap_basedn.should eql("dc=hjksolutions,dc=com") - @node.ldap_replication_password.should eql("forsure") - @node.smokey.should eql("robinson") - end -end - diff --git a/chef/spec/unit/node_spec.rb b/chef/spec/unit/node_spec.rb index 43866a63ad..9741f94bfb 100644 --- a/chef/spec/unit/node_spec.rb +++ b/chef/spec/unit/node_spec.rb @@ -21,7 +21,6 @@ require 'ostruct' describe Chef::Node do before(:each) do - Chef::Config.node_path(File.expand_path(File.join(CHEF_SPEC_DATA, "nodes"))) @node = Chef::Node.new() end @@ -425,28 +424,30 @@ describe Chef::Node do end end - # TODO: timh, cw: 2010-5-19: Node.recipe? deprecated. See node.rb - # describe "recipes" do - # it "should have a RunList of recipes that should be applied" do - # @node.recipes.should be_a_kind_of(Chef::RunList) - # end - # - # it "should allow you to query whether or not it has a recipe applied with recipe?" do - # @node.recipes << "sunrise" - # @node.recipe?("sunrise").should eql(true) - # @node.recipe?("not at home").should eql(false) - # end - # - # it "should return false if a recipe has not been seen" do - # @node.recipe?("snakes").should eql(false) - # end - # - # it "should allow you to set recipes with arguments" do - # @node.recipes "one", "two" - # @node.recipe?("one").should eql(true) - # @node.recipe?("two").should eql(true) - # end - # end + describe "when evaluating attributes files" do + before do + @node = Chef::Node.new + + @cookbook_repo = File.expand_path(File.join(CHEF_SPEC_DATA, "cookbooks")) + @cookbook_loader = Chef::CookbookLoader.new(@cookbook_repo) + @cookbook_loader.load_cookbooks + + @cookbook_collection = Chef::CookbookCollection.new(@cookbook_loader.cookbooks_by_name) + + @events = Chef::EventDispatch::Dispatcher.new + @run_context = Chef::RunContext.new(@node, @cookbook_collection, @events) + + @node.include_attribute("openldap::default") + @node.include_attribute("openldap::smokey") + end + + it "sets attributes from the files" do + @node.ldap_server.should eql("ops1prod") + @node.ldap_basedn.should eql("dc=hjksolutions,dc=com") + @node.ldap_replication_password.should eql("forsure") + @node.smokey.should eql("robinson") + end + end describe "roles" do it "should allow you to query whether or not it has a recipe applied with role?" do diff --git a/chef/spec/unit/run_context_spec.rb b/chef/spec/unit/run_context_spec.rb index c24dd352a8..f90acd15a5 100644 --- a/chef/spec/unit/run_context_spec.rb +++ b/chef/spec/unit/run_context_spec.rb @@ -24,12 +24,12 @@ Chef::Log.level = :debug describe Chef::RunContext do before(:each) do - Chef::Config.node_path(File.expand_path(File.join(CHEF_SPEC_DATA, "run_context", "nodes"))) @chef_repo_path = File.expand_path(File.join(CHEF_SPEC_DATA, "run_context", "cookbooks")) cl = Chef::CookbookLoader.new(@chef_repo_path) cl.load_cookbooks @cookbook_collection = Chef::CookbookCollection.new(cl) @node = Chef::Node.new + @node.run_list << "test" << "test::one" << "test::two" @events = Chef::EventDispatch::Dispatcher.new @run_context = Chef::RunContext.new(@node, @cookbook_collection, @events) end @@ -54,7 +54,7 @@ describe Chef::RunContext do end it "should load all the recipes specified for this node" do - @run_context.resource_collection[0].to_s.should == "cat[einstein]" + @run_context.resource_collection[0].to_s.should == "cat[einstein]" @run_context.resource_collection[1].to_s.should == "cat[loulou]" @run_context.resource_collection[2].to_s.should == "cat[birthday]" @run_context.resource_collection[3].to_s.should == "cat[peanut]" |