diff options
author | danielsdeleo <dan@opscode.com> | 2014-01-23 15:45:38 -0800 |
---|---|---|
committer | danielsdeleo <dan@opscode.com> | 2014-01-23 17:14:56 -0800 |
commit | 43d8c8fbe5c69f7ebb9cb462dd7de453bea00f4a (patch) | |
tree | e3887132a7460f4aad6913dd6bec232c42dbfb28 /spec/unit/policy_builder | |
parent | 7ef17a8e4cb03bc37ab345f5dfe85a6110573711 (diff) | |
download | chef-43d8c8fbe5c69f7ebb9cb462dd7de453bea00f4a.tar.gz |
Add public API for expanding run_list in Chef::Client
External projects like chefspec need to do this separately so they can
inject custom behavior before/after.
Diffstat (limited to 'spec/unit/policy_builder')
-rw-r--r-- | spec/unit/policy_builder/expand_node_object_spec.rb | 25 | ||||
-rw-r--r-- | spec/unit/policy_builder/policyfile_spec.rb | 8 |
2 files changed, 33 insertions, 0 deletions
diff --git a/spec/unit/policy_builder/expand_node_object_spec.rb b/spec/unit/policy_builder/expand_node_object_spec.rb index b452f98c80..bca48b0914 100644 --- a/spec/unit/policy_builder/expand_node_object_spec.rb +++ b/spec/unit/policy_builder/expand_node_object_spec.rb @@ -51,6 +51,10 @@ describe Chef::PolicyBuilder::ExpandNodeObject do expect(policy_builder).to respond_to(:run_context) end + it "implements an expand_run_list method" do + expect(policy_builder).to respond_to(:expand_run_list) + end + describe "loading the node" do context "on chef-solo" do @@ -112,6 +116,27 @@ describe Chef::PolicyBuilder::ExpandNodeObject do end + context "once the node has been loaded" do + let(:node) do + node = Chef::Node.new + node.name(node_name) + node.run_list(["recipe[a::default]", "recipe[b::server]"]) + node + end + + before do + Chef::Node.should_receive(:find_or_create).with(node_name).and_return(node) + policy_builder.load_node + end + + it "expands the run_list" do + expect(policy_builder.expand_run_list).to be_a(Chef::RunList::RunListExpansion) + expect(policy_builder.run_list_expansion).to be_a(Chef::RunList::RunListExpansion) + expect(policy_builder.run_list_expansion.recipes).to eq(["a::default", "b::server"]) + end + + end + describe "building the node" do let(:configured_environment) { nil } diff --git a/spec/unit/policy_builder/policyfile_spec.rb b/spec/unit/policy_builder/policyfile_spec.rb index 7e83dce804..aeda1af773 100644 --- a/spec/unit/policy_builder/policyfile_spec.rb +++ b/spec/unit/policy_builder/policyfile_spec.rb @@ -234,6 +234,14 @@ describe Chef::PolicyBuilder::Policyfile do expect(policy_builder.run_list_expansion_ish.recipes).to eq(["example1::default", "example2::server"]) end + it "implements #expand_run_list in a manner compatible with ExpandNodeObject" do + Chef::Node.should_receive(:find_or_create).with(node_name).and_return(node) + policy_builder.load_node + expect(policy_builder.expand_run_list).to respond_to(:recipes) + expect(policy_builder.expand_run_list.recipes).to eq(["example1::default", "example2::server"]) + expect(policy_builder.expand_run_list.roles).to eq([]) + end + describe "validating the Policyfile.lock" do |