diff options
Diffstat (limited to 'chef/spec/unit')
-rw-r--r-- | chef/spec/unit/node_spec.rb | 3 | ||||
-rw-r--r-- | chef/spec/unit/run_list/run_list_expansion_spec.rb | 18 | ||||
-rw-r--r-- | chef/spec/unit/run_list_spec.rb | 32 |
3 files changed, 34 insertions, 19 deletions
diff --git a/chef/spec/unit/node_spec.rb b/chef/spec/unit/node_spec.rb index c626420f67..9163bc1e0f 100644 --- a/chef/spec/unit/node_spec.rb +++ b/chef/spec/unit/node_spec.rb @@ -285,7 +285,8 @@ describe Chef::Node do end it "saves non-runlist json attrs for later" do - @node.run_list.stub!(:expand).and_return([[], {}, {}]) + expansion = Chef::RunList::RunListExpansion.new([]) + @node.run_list.stub!(:expand).and_return(expansion) @node.prepare_for_run(@ohai_data, {"foo" => "bar"}) @node.expand! @node.normal_attrs.should == {"foo" => "bar", "tags" => []} diff --git a/chef/spec/unit/run_list/run_list_expansion_spec.rb b/chef/spec/unit/run_list/run_list_expansion_spec.rb index 53573c6684..13a964feb9 100644 --- a/chef/spec/unit/run_list/run_list_expansion_spec.rb +++ b/chef/spec/unit/run_list/run_list_expansion_spec.rb @@ -80,4 +80,22 @@ describe Chef::RunList::RunListExpansion do @expansion.override_attrs.should == {'baz' => 'qux'} end end + + describe "after expanding a run list with a non existant role" do + before do + @expansion.stub!(:fetch_role) { @expansion.role_not_found('crabrevenge') } + @expansion.expand + end + + it "is invalid" do + @expansion.should be_invalid + @expansion.errors?.should be_true # aliases + end + + it "has a list of invalid role names" do + @expansion.errors.should include('crabrevenge') + end + + end + end diff --git a/chef/spec/unit/run_list_spec.rb b/chef/spec/unit/run_list_spec.rb index 8b552f09ec..05e52ed768 100644 --- a/chef/spec/unit/run_list_spec.rb +++ b/chef/spec/unit/run_list_spec.rb @@ -182,19 +182,19 @@ describe Chef::RunList do end it "should return the list of expanded recipes" do - recipes, default, override = @run_list.expand - recipes[0].should == "one" - recipes[1].should == "two" + expansion = @run_list.expand + expansion.recipes[0].should == "one" + expansion.recipes[1].should == "two" end it "should return the list of default attributes" do - recipes, default, override = @run_list.expand - default[:one].should == :two + expansion = @run_list.expand + expansion.default_attrs[:one].should == :two end it "should return the list of override attributes" do - recipes, default, override = @run_list.expand - override[:three].should == :four + expansion = @run_list.expand + expansion.override_attrs[:three].should == :four end it "should recurse into a child role" do @@ -206,9 +206,9 @@ describe Chef::RunList do Chef::Role.stub!(:from_disk).with("stubby").and_return(@role) Chef::Role.stub!(:from_disk).with("dog").and_return(dog) - recipes, default, override = @run_list.expand('disk') - recipes[2].should == "three" - default[:seven].should == :nine + expansion = @run_list.expand('disk') + expansion.recipes[2].should == "three" + expansion.default_attrs[:seven].should == :nine end it "should not recurse infinitely" do @@ -220,14 +220,10 @@ describe Chef::RunList do Chef::Role.stub!(:from_disk).with("stubby").and_return(@role) Chef::Role.should_receive(:from_disk).with("dog").once.and_return(dog) - recipes, default, override = @run_list.expand('disk') - recipes[2].should == "three" - recipes[3].should == "kitty" - default[:seven].should == :nine - end - - it "propagates the couchdb used as the data source when expanding" do - pending("FIXME: this is the cause of the sharding bug on opscode platform :/") + expansion = @run_list.expand('disk') + expansion.recipes[2].should == "three" + expansion.recipes[3].should == "kitty" + expansion.default_attrs[:seven].should == :nine end end |