diff options
author | danielsdeleo <dan@opscode.com> | 2012-10-09 14:19:28 -0700 |
---|---|---|
committer | Bryan McLellan <btm@opscode.com> | 2012-10-15 16:09:34 -0700 |
commit | d2557515361e9f774282e4bc712bf0a51ffbd9b4 (patch) | |
tree | 944ccfcaf84282b8b971f772baba57e0ffa42a42 | |
parent | 0f63d210e6dd4dc7346061c2c6f0b66427b57aa9 (diff) | |
download | chef-d2557515361e9f774282e4bc712bf0a51ffbd9b4.tar.gz |
[CHEF-1804] fix old attribute api usage in tests
32 files changed, 177 insertions, 291 deletions
diff --git a/chef/lib/chef/client.rb b/chef/lib/chef/client.rb index 15462fad24..54788724fd 100644 --- a/chef/lib/chef/client.rb +++ b/chef/lib/chef/client.rb @@ -208,7 +208,7 @@ class Chef Chef::Log.debug("Saving the current state of node #{node_name}") if(@original_runlist) @node.run_list(*@original_runlist) - @node[:runlist_override_history] = {Time.now.to_i => @override_runlist.inspect} + @node.automatic_attrs[:runlist_override_history] = {Time.now.to_i => @override_runlist.inspect} end @node.save end diff --git a/chef/lib/chef/node.rb b/chef/lib/chef/node.rb index af0bb3d822..d0b073d6a3 100644 --- a/chef/lib/chef/node.rb +++ b/chef/lib/chef/node.rb @@ -440,9 +440,8 @@ class Chef self.tags # make sure they're defined - automatic[:recipes] = expansion.recipes - automatic[:roles] = expansion.roles - + automatic_attrs[:recipes] = expansion.recipes + automatic_attrs[:roles] = expansion.roles expansion end diff --git a/chef/lib/chef/node/attribute.rb b/chef/lib/chef/node/attribute.rb index 90477e6dfc..22075533b4 100644 --- a/chef/lib/chef/node/attribute.rb +++ b/chef/lib/chef/node/attribute.rb @@ -158,7 +158,7 @@ class Chef def default=(new_data) reset - @default = new_data + @default = VividMash.new(self, new_data) end def normal @@ -167,7 +167,7 @@ class Chef def normal=(new_data) reset - @normal = new_data + @normal = VividMash.new(self, new_data) end def override @@ -176,7 +176,7 @@ class Chef def override=(new_data) reset - @override = new_data + @override = VividMash.new(self, new_data) end def automatic @@ -185,7 +185,7 @@ class Chef def automatic=(new_data) reset - @automatic = new_data + @automatic = VividMash.new(self, new_data) end def merged_attributes diff --git a/chef/lib/chef/recipe.rb b/chef/lib/chef/recipe.rb index 33dfde787d..258a56e715 100644 --- a/chef/lib/chef/recipe.rb +++ b/chef/lib/chef/recipe.rb @@ -89,7 +89,7 @@ class Chef if tags.length > 0 tags.each do |tag| tag = tag.to_s - run_context.node[:tags] << tag unless run_context.node[:tags].include?(tag) + run_context.node.normal[:tags] << tag unless run_context.node[:tags].include?(tag) end run_context.node[:tags] else @@ -121,7 +121,7 @@ class Chef # tags<Array>:: The current list of run_context.node[:tags] def untag(*tags) tags.each do |tag| - run_context.node[:tags].delete(tag) + run_context.node.normal[:tags].delete(tag) end end diff --git a/chef/spec/functional/resource/template_spec.rb b/chef/spec/functional/resource/template_spec.rb index 462f41b66c..0dfdb17324 100644 --- a/chef/spec/functional/resource/template_spec.rb +++ b/chef/spec/functional/resource/template_spec.rb @@ -27,7 +27,7 @@ describe Chef::Resource::Template do let(:node) do node = Chef::Node.new - node[:slappiness] = "a warm gun" + node.normal[:slappiness] = "a warm gun" node end diff --git a/chef/spec/unit/client_spec.rb b/chef/spec/unit/client_spec.rb index 2182bd654f..699164b2af 100644 --- a/chef/spec/unit/client_spec.rb +++ b/chef/spec/unit/client_spec.rb @@ -35,17 +35,15 @@ shared_examples_for Chef::Client do ohai_data = { :fqdn => @fqdn, :hostname => @hostname, :platform => 'example-platform', - :platform_version => 'example-platform', + :platform_version => 'example-platform-1.0', :data => {} } ohai_data.stub!(:all_plugins).and_return(true) - ohai_data.stub!(:data).and_return(ohai_data[:data]) + ohai_data.stub!(:data).and_return(ohai_data) Ohai::System.stub!(:new).and_return(ohai_data) @node = Chef::Node.new(@hostname) @node.name(@fqdn) @node.chef_environment("_default") - @node[:platform] = "example-platform" - @node[:platform_version] = "example-platform-1.0" @client = Chef::Client.new @client.node = @node @@ -240,8 +238,8 @@ shared_examples_for Chef::Client do @node = Chef::Node.new(@hostname) @node.name(@fqdn) @node.chef_environment("_default") - @node[:platform] = "example-platform" - @node[:platform_version] = "example-platform-1.0" + @node.automatic_attrs[:platform] = "example-platform" + @node.automatic_attrs[:platform_version] = "example-platform-1.0" @client = Chef::Client.new(nil, :override_runlist => 'role[test_role]') @client.node = @node diff --git a/chef/spec/unit/cookbook_manifest_spec.rb b/chef/spec/unit/cookbook_manifest_spec.rb index 255cd7f920..7da87e93a5 100644 --- a/chef/spec/unit/cookbook_manifest_spec.rb +++ b/chef/spec/unit/cookbook_manifest_spec.rb @@ -205,9 +205,9 @@ describe "Chef::CookbookVersion manifest" do it "should return a manifest record based on priority preference: host" do node = Chef::Node.new - node[:platform] = "ubuntu" - node[:platform_version] = "9.10" - node[:fqdn] = "examplehost.example.org" + node.automatic_attrs[:platform] = "ubuntu" + node.automatic_attrs[:platform_version] = "9.10" + node.automatic_attrs[:fqdn] = "examplehost.example.org" manifest_record = @cookbook.preferred_manifest_record(node, :files, "afile.rb") manifest_record.should_not be_nil @@ -216,9 +216,9 @@ describe "Chef::CookbookVersion manifest" do it "should return a manifest record based on priority preference: platform & full version" do node = Chef::Node.new - node[:platform] = "ubuntu" - node[:platform_version] = "9.10" - node[:fqdn] = "differenthost.example.org" + node.automatic_attrs[:platform] = "ubuntu" + node.automatic_attrs[:platform_version] = "9.10" + node.automatic_attrs[:fqdn] = "differenthost.example.org" manifest_record = @cookbook.preferred_manifest_record(node, :files, "afile.rb") manifest_record.should_not be_nil @@ -227,9 +227,9 @@ describe "Chef::CookbookVersion manifest" do it "should return a manifest record based on priority preference: platform & partial version" do node = Chef::Node.new - node[:platform] = "newubuntu" - node[:platform_version] = "9.10" - node[:fqdn] = "differenthost.example.org" + node.automatic_attrs[:platform] = "newubuntu" + node.automatic_attrs[:platform_version] = "9.10" + node.automatic_attrs[:fqdn] = "differenthost.example.org" manifest_record = @cookbook.preferred_manifest_record(node, :files, "afile.rb") manifest_record.should_not be_nil @@ -238,9 +238,9 @@ describe "Chef::CookbookVersion manifest" do it "should return a manifest record based on priority preference: platform only" do node = Chef::Node.new - node[:platform] = "ubuntu" - node[:platform_version] = "1.0" - node[:fqdn] = "differenthost.example.org" + node.automatic_attrs[:platform] = "ubuntu" + node.automatic_attrs[:platform_version] = "1.0" + node.automatic_attrs[:fqdn] = "differenthost.example.org" manifest_record = @cookbook.preferred_manifest_record(node, :files, "afile.rb") manifest_record.should_not be_nil @@ -249,9 +249,9 @@ describe "Chef::CookbookVersion manifest" do it "should return a manifest record based on priority preference: default" do node = Chef::Node.new - node[:platform] = "notubuntu" - node[:platform_version] = "1.0" - node[:fqdn] = "differenthost.example.org" + node.automatic_attrs[:platform] = "notubuntu" + node.automatic_attrs[:platform_version] = "1.0" + node.automatic_attrs[:fqdn] = "differenthost.example.org" manifest_record = @cookbook.preferred_manifest_record(node, :files, "afile.rb") manifest_record.should_not be_nil @@ -260,9 +260,9 @@ describe "Chef::CookbookVersion manifest" do it "should return a manifest record based on priority preference: platform & full version - platform_version variant 1" do node = Chef::Node.new - node[:platform] = "fakeos" - node[:platform_version] = "2.0.rc.1" - node[:fqdn] = "differenthost.example.org" + node.automatic_attrs[:platform] = "fakeos" + node.automatic_attrs[:platform_version] = "2.0.rc.1" + node.automatic_attrs[:fqdn] = "differenthost.example.org" manifest_record = @cookbook.preferred_manifest_record(node, :files, "bfile.rb") manifest_record.should_not be_nil @@ -271,9 +271,9 @@ describe "Chef::CookbookVersion manifest" do it "should return a manifest record based on priority preference: platform & partial version - platform_version variant 1" do node = Chef::Node.new - node[:platform] = "newfakeos" - node[:platform_version] = "2.0.rc.1" - node[:fqdn] = "differenthost.example.org" + node.automatic_attrs[:platform] = "newfakeos" + node.automatic_attrs[:platform_version] = "2.0.rc.1" + node.automatic_attrs[:fqdn] = "differenthost.example.org" manifest_record = @cookbook.preferred_manifest_record(node, :files, "bfile.rb") manifest_record.should_not be_nil @@ -282,9 +282,9 @@ describe "Chef::CookbookVersion manifest" do it "should return a manifest record based on priority preference: platform & full version - platform_version variant 2" do node = Chef::Node.new - node[:platform] = "fakeos" - node[:platform_version] = "maple tree" - node[:fqdn] = "differenthost.example.org" + node.automatic_attrs[:platform] = "fakeos" + node.automatic_attrs[:platform_version] = "maple tree" + node.automatic_attrs[:fqdn] = "differenthost.example.org" manifest_record = @cookbook.preferred_manifest_record(node, :files, "bfile.rb") manifest_record.should_not be_nil @@ -293,9 +293,9 @@ describe "Chef::CookbookVersion manifest" do it "should return a manifest record based on priority preference: platform & full version - platform_version variant 3" do node = Chef::Node.new - node[:platform] = "fakeos" - node[:platform_version] = "1" - node[:fqdn] = "differenthost.example.org" + node.automatic_attrs[:platform] = "fakeos" + node.automatic_attrs[:platform_version] = "1" + node.automatic_attrs[:fqdn] = "differenthost.example.org" manifest_record = @cookbook.preferred_manifest_record(node, :files, "bfile.rb") manifest_record.should_not be_nil @@ -306,9 +306,9 @@ describe "Chef::CookbookVersion manifest" do it "should return a directory of manifest records based on priority preference: host" do node = Chef::Node.new - node[:platform] = "ubuntu" - node[:platform_version] = "9.10" - node[:fqdn] = "examplehost.example.org" + node.automatic_attrs[:platform] = "ubuntu" + node.automatic_attrs[:platform_version] = "9.10" + node.automatic_attrs[:fqdn] = "examplehost.example.org" manifest_records = @cookbook.preferred_manifest_records_for_directory(node, :files, "adirectory") manifest_records.should_not be_nil @@ -320,9 +320,9 @@ describe "Chef::CookbookVersion manifest" do it "should return a directory of manifest records based on priority preference: platform & full version" do node = Chef::Node.new - node[:platform] = "ubuntu" - node[:platform_version] = "9.10" - node[:fqdn] = "differenthost.example.org" + node.automatic_attrs[:platform] = "ubuntu" + node.automatic_attrs[:platform_version] = "9.10" + node.automatic_attrs[:fqdn] = "differenthost.example.org" manifest_records = @cookbook.preferred_manifest_records_for_directory(node, :files, "adirectory") manifest_records.should_not be_nil @@ -334,9 +334,9 @@ describe "Chef::CookbookVersion manifest" do it "should return a directory of manifest records based on priority preference: platform & partial version" do node = Chef::Node.new - node[:platform] = "newubuntu" - node[:platform_version] = "9.10" - node[:fqdn] = "differenthost.example.org" + node.automatic_attrs[:platform] = "newubuntu" + node.automatic_attrs[:platform_version] = "9.10" + node.automatic_attrs[:fqdn] = "differenthost.example.org" manifest_records = @cookbook.preferred_manifest_records_for_directory(node, :files, "adirectory") manifest_records.should_not be_nil @@ -348,9 +348,9 @@ describe "Chef::CookbookVersion manifest" do it "should return a directory of manifest records based on priority preference: platform only" do node = Chef::Node.new - node[:platform] = "ubuntu" - node[:platform_version] = "1.0" - node[:fqdn] = "differenthost.example.org" + node.automatic_attrs[:platform] = "ubuntu" + node.automatic_attrs[:platform_version] = "1.0" + node.automatic_attrs[:fqdn] = "differenthost.example.org" manifest_records = @cookbook.preferred_manifest_records_for_directory(node, :files, "adirectory") manifest_records.should_not be_nil @@ -362,9 +362,9 @@ describe "Chef::CookbookVersion manifest" do it "should return a directory of manifest records based on priority preference: default" do node = Chef::Node.new - node[:platform] = "notubuntu" - node[:platform_version] = "1.0" - node[:fqdn] = "differenthost.example.org" + node.automatic_attrs[:platform] = "notubuntu" + node.automatic_attrs[:platform_version] = "1.0" + node.automatic_attrs[:fqdn] = "differenthost.example.org" manifest_records = @cookbook.preferred_manifest_records_for_directory(node, :files, "adirectory") manifest_records.should_not be_nil @@ -376,9 +376,9 @@ describe "Chef::CookbookVersion manifest" do it "should return a manifest record based on priority preference: platform & full version - platform_version variant 1" do node = Chef::Node.new - node[:platform] = "fakeos" - node[:platform_version] = "2.0.rc.1" - node[:fqdn] = "differenthost.example.org" + node.automatic_attrs[:platform] = "fakeos" + node.automatic_attrs[:platform_version] = "2.0.rc.1" + node.automatic_attrs[:fqdn] = "differenthost.example.org" manifest_records = @cookbook.preferred_manifest_records_for_directory(node, :files, "adirectory") manifest_records.should_not be_nil @@ -390,9 +390,9 @@ describe "Chef::CookbookVersion manifest" do it "should return a manifest record based on priority preference: platform & partial version - platform_version variant 1" do node = Chef::Node.new - node[:platform] = "newfakeos" - node[:platform_version] = "2.0.rc.1" - node[:fqdn] = "differenthost.example.org" + node.automatic_attrs[:platform] = "newfakeos" + node.automatic_attrs[:platform_version] = "2.0.rc.1" + node.automatic_attrs[:fqdn] = "differenthost.example.org" manifest_records = @cookbook.preferred_manifest_records_for_directory(node, :files, "adirectory") manifest_records.should_not be_nil @@ -404,9 +404,9 @@ describe "Chef::CookbookVersion manifest" do it "should return a manifest record based on priority preference: platform & full version - platform_version variant 2" do node = Chef::Node.new - node[:platform] = "fakeos" - node[:platform_version] = "maple tree" - node[:fqdn] = "differenthost.example.org" + node.automatic_attrs[:platform] = "fakeos" + node.automatic_attrs[:platform_version] = "maple tree" + node.automatic_attrs[:fqdn] = "differenthost.example.org" manifest_records = @cookbook.preferred_manifest_records_for_directory(node, :files, "adirectory") manifest_records.should_not be_nil @@ -418,9 +418,9 @@ describe "Chef::CookbookVersion manifest" do it "should return a manifest record based on priority preference: platform & full version - platform_version variant 3" do node = Chef::Node.new - node[:platform] = "fakeos" - node[:platform_version] = "1" - node[:fqdn] = "differenthost.example.org" + node.automatic_attrs[:platform] = "fakeos" + node.automatic_attrs[:platform_version] = "1" + node.automatic_attrs[:fqdn] = "differenthost.example.org" manifest_records = @cookbook.preferred_manifest_records_for_directory(node, :files, "adirectory") manifest_records.should_not be_nil @@ -436,9 +436,9 @@ describe "Chef::CookbookVersion manifest" do describe "when globbing for relative file paths based on filespecificity" do it "should return a list of relative paths based on priority preference: host" do node = Chef::Node.new - node[:platform] = "ubuntu" - node[:platform_version] = "9.10" - node[:fqdn] = "examplehost.example.org" + node.automatic_attrs[:platform] = "ubuntu" + node.automatic_attrs[:platform_version] = "9.10" + node.automatic_attrs[:fqdn] = "examplehost.example.org" filenames = @cookbook.relative_filenames_in_preferred_directory(node, :files, "adirectory") filenames.should_not be_nil @@ -449,9 +449,9 @@ describe "Chef::CookbookVersion manifest" do it "should return a list of relative paths based on priority preference: platform & full version" do node = Chef::Node.new - node[:platform] = "ubuntu" - node[:platform_version] = "9.10" - node[:fqdn] = "differenthost.example.org" + node.automatic_attrs[:platform] = "ubuntu" + node.automatic_attrs[:platform_version] = "9.10" + node.automatic_attrs[:fqdn] = "differenthost.example.org" filenames = @cookbook.relative_filenames_in_preferred_directory(node, :files, "adirectory") filenames.should_not be_nil @@ -462,9 +462,9 @@ describe "Chef::CookbookVersion manifest" do it "should return a list of relative paths based on priority preference: platform & partial version" do node = Chef::Node.new - node[:platform] = "newubuntu" - node[:platform_version] = "9.10" - node[:fqdn] = "differenthost.example.org" + node.automatic_attrs[:platform] = "newubuntu" + node.automatic_attrs[:platform_version] = "9.10" + node.automatic_attrs[:fqdn] = "differenthost.example.org" filenames = @cookbook.relative_filenames_in_preferred_directory(node, :files, "adirectory") filenames.should_not be_nil @@ -475,9 +475,9 @@ describe "Chef::CookbookVersion manifest" do it "should return a list of relative paths based on priority preference: platform only" do node = Chef::Node.new - node[:platform] = "ubuntu" - node[:platform_version] = "1.0" - node[:fqdn] = "differenthost.example.org" + node.automatic_attrs[:platform] = "ubuntu" + node.automatic_attrs[:platform_version] = "1.0" + node.automatic_attrs[:fqdn] = "differenthost.example.org" filenames = @cookbook.relative_filenames_in_preferred_directory(node, :files, "adirectory") filenames.should_not be_nil @@ -488,9 +488,9 @@ describe "Chef::CookbookVersion manifest" do it "should return a list of relative paths based on priority preference: default" do node = Chef::Node.new - node[:platform] = "notubuntu" - node[:platform_version] = "1.0" - node[:fqdn] = "differenthost.example.org" + node.automatic_attrs[:platform] = "notubuntu" + node.automatic_attrs[:platform_version] = "1.0" + node.automatic_attrs[:fqdn] = "differenthost.example.org" filenames = @cookbook.relative_filenames_in_preferred_directory(node, :files, "adirectory") filenames.should_not be_nil @@ -501,9 +501,9 @@ describe "Chef::CookbookVersion manifest" do it "should return a list of relative paths based on priority preference: platform & full version - platform_version variant 1" do node = Chef::Node.new - node[:platform] = "fakeos" - node[:platform_version] = "2.0.rc.1" - node[:fqdn] = "differenthost.example.org" + node.automatic_attrs[:platform] = "fakeos" + node.automatic_attrs[:platform_version] = "2.0.rc.1" + node.automatic_attrs[:fqdn] = "differenthost.example.org" filenames = @cookbook.relative_filenames_in_preferred_directory(node, :files, "adirectory") filenames.should_not be_nil @@ -514,9 +514,9 @@ describe "Chef::CookbookVersion manifest" do it "should return a list of relative paths based on priority preference: platform & partial version - platform_version variant 1" do node = Chef::Node.new - node[:platform] = "newfakeos" - node[:platform_version] = "2.0.rc.1" - node[:fqdn] = "differenthost.example.org" + node.automatic_attrs[:platform] = "newfakeos" + node.automatic_attrs[:platform_version] = "2.0.rc.1" + node.automatic_attrs[:fqdn] = "differenthost.example.org" filenames = @cookbook.relative_filenames_in_preferred_directory(node, :files, "adirectory") filenames.should_not be_nil @@ -527,9 +527,9 @@ describe "Chef::CookbookVersion manifest" do it "should return a list of relative paths based on priority preference: platform & full version - platform_version variant 2" do node = Chef::Node.new - node[:platform] = "fakeos" - node[:platform_version] = "maple tree" - node[:fqdn] = "differenthost.example.org" + node.automatic_attrs[:platform] = "fakeos" + node.automatic_attrs[:platform_version] = "maple tree" + node.automatic_attrs[:fqdn] = "differenthost.example.org" filenames = @cookbook.relative_filenames_in_preferred_directory(node, :files, "adirectory") filenames.should_not be_nil @@ -540,9 +540,9 @@ describe "Chef::CookbookVersion manifest" do it "should return a list of relative paths based on priority preference: platform & full version - platform_version variant 3" do node = Chef::Node.new - node[:platform] = "fakeos" - node[:platform_version] = "1" - node[:fqdn] = "differenthost.example.org" + node.automatic_attrs[:platform] = "fakeos" + node.automatic_attrs[:platform_version] = "1" + node.automatic_attrs[:fqdn] = "differenthost.example.org" filenames = @cookbook.relative_filenames_in_preferred_directory(node, :files, "adirectory") filenames.should_not be_nil diff --git a/chef/spec/unit/cookbook_version_spec.rb b/chef/spec/unit/cookbook_version_spec.rb index 80af5e8fa9..90f411d8b2 100644 --- a/chef/spec/unit/cookbook_version_spec.rb +++ b/chef/spec/unit/cookbook_version_spec.rb @@ -267,7 +267,12 @@ describe Chef::CookbookVersion do describe "raises an error when attempting to load a missing cookbook_file and" do before do - node = Chef::Node.new.tap {|n| n.name("sample.node"); n[:fqdn] = "sample.example.com"; n[:platform] = "ubuntu"; n[:platform_version] = "10.04"} + node = Chef::Node.new.tap do |n| + n.name("sample.node") + n.automatic_attrs[:fqdn] = "sample.example.com" + n.automatic_attrs[:platform] = "ubuntu" + n.automatic_attrs[:platform_version] = "10.04" + end @attempt_to_load_file = lambda { @cookbook_version.preferred_manifest_record(node, :files, "no-such-thing.txt") } end diff --git a/chef/spec/unit/formatters/error_inspectors/resource_failure_inspector_spec.rb b/chef/spec/unit/formatters/error_inspectors/resource_failure_inspector_spec.rb index eb674adb76..fd49cb63bb 100644 --- a/chef/spec/unit/formatters/error_inspectors/resource_failure_inspector_spec.rb +++ b/chef/spec/unit/formatters/error_inspectors/resource_failure_inspector_spec.rb @@ -23,8 +23,8 @@ describe Chef::Formatters::ErrorInspectors::ResourceFailureInspector do def run_context node = Chef::Node.new - node[:platform] = "ubuntu" - node[:platform_version] = "10.04" + node.automatic_attrs[:platform] = "ubuntu" + node.automatic_attrs[:platform_version] = "10.04" Chef::RunContext.new(node, {}, nil) end diff --git a/chef/spec/unit/knife/ssh_spec.rb b/chef/spec/unit/knife/ssh_spec.rb index 77d23d84fa..1fda4b4bd9 100644 --- a/chef/spec/unit/knife/ssh_spec.rb +++ b/chef/spec/unit/knife/ssh_spec.rb @@ -37,11 +37,11 @@ describe Chef::Knife::Ssh do @knife.config.clear @knife.config[:attribute] = "fqdn" @node_foo = Chef::Node.new('foo') - @node_foo[:fqdn] = "foo.example.org" - @node_foo[:ipaddress] = "10.0.0.1" + @node_foo.automatic_attrs[:fqdn] = "foo.example.org" + @node_foo.automatic_attrs[:ipaddress] = "10.0.0.1" @node_bar = Chef::Node.new('bar') - @node_bar[:fqdn] = "bar.example.org" - @node_bar[:ipaddress] = "10.0.0.2" + @node_bar.automatic_attrs[:fqdn] = "bar.example.org" + @node_bar.automatic_attrs[:ipaddress] = "10.0.0.2" end describe "#configure_session" do @@ -84,10 +84,8 @@ describe Chef::Knife::Ssh do context "when cloud hostnames are available" do before do - @node_foo[:cloud] = Mash.new - @node_bar[:cloud] = Mash.new - @node_foo[:cloud][:public_hostname] = "ec2-10-0-0-1.compute-1.amazonaws.com" - @node_bar[:cloud][:public_hostname] = "ec2-10-0-0-2.compute-1.amazonaws.com" + @node_foo.automatic_attrs[:cloud][:public_hostname] = "ec2-10-0-0-1.compute-1.amazonaws.com" + @node_bar.automatic_attrs[:cloud][:public_hostname] = "ec2-10-0-0-2.compute-1.amazonaws.com" end it "returns an array of cloud public hostnames" do diff --git a/chef/spec/unit/knife/status_spec.rb b/chef/spec/unit/knife/status_spec.rb index ae05051188..b009997ab1 100644 --- a/chef/spec/unit/knife/status_spec.rb +++ b/chef/spec/unit/knife/status_spec.rb @@ -22,8 +22,8 @@ require 'highline' describe Chef::Knife::Status do before(:each) do node = Chef::Node.new.tap do |n| - n["fqdn"] = "foobar" - n["ohai_time"] = 1343845969 + n.automatic_attrs["fqdn"] = "foobar" + n.automatic_attrs["ohai_time"] = 1343845969 end query = mock("Chef::Search::Query") query.stub!(:search).and_yield(node) diff --git a/chef/spec/unit/lwrp_spec.rb b/chef/spec/unit/lwrp_spec.rb index 76be6ffa55..76834cf182 100644 --- a/chef/spec/unit/lwrp_spec.rb +++ b/chef/spec/unit/lwrp_spec.rb @@ -95,7 +95,7 @@ describe "LWRP" do it "should have access to the run context and node during class definition" do node = Chef::Node.new(nil) - node[:penguin_name] = "jackass" + node.normal[:penguin_name] = "jackass" run_context = Chef::RunContext.new(node, Chef::CookbookCollection.new, @events) Dir[File.expand_path(File.join(File.dirname(__FILE__), "..", "data", "lwrp", "resources_with_default_attributes", "*"))].each do |file| diff --git a/chef/spec/unit/node/attribute_spec.rb b/chef/spec/unit/node/attribute_spec.rb index d3a98362bd..55dbf72366 100644 --- a/chef/spec/unit/node/attribute_spec.rb +++ b/chef/spec/unit/node/attribute_spec.rb @@ -958,6 +958,12 @@ describe Chef::Node::Attribute do end end + describe "when setting a component attribute to a new value" do + it "converts the imput in to a VividMash tree" do + pending + end + end + describe "when attemping to write without specifying precedence" do it "raises an error when using []=" do lambda { @attributes[:new_key] = "new value" }.should raise_error(Chef::Exceptions::ImmutableAttributeModification) @@ -1166,123 +1172,3 @@ describe Chef::Node::Attribute do end -describe Chef::Node::ImmutableMash do - before do - @root = Chef::Node::Attribute.new({}, {}, {}, {}) - @data_in = {:top => {:second_level => "some value"}, - "top_level_2" => %w[array of values], - :top_level_3 => [{:hash_array => 1, :hash_array_b => 2}], - :top_level_4 => {:level2 => {:key => "value"}} - } - @immutable_mash = Chef::Node::ImmutableMash.new(@root, @data_in) - end - - it "element references like regular hash" do - @immutable_mash[:top][:second_level].should == "some value" - end - - it "elelment references like a regular Mash" do - @immutable_mash[:top_level_2].should == %w[array of values] - end - - it "converts Hash-like inputs into ImmutableMash's" do - @immutable_mash[:top].should be_a(Chef::Node::ImmutableMash) - end - - it "converts array inputs into ImmutableArray's" do - @immutable_mash[:top_level_2].should be_a(Chef::Node::ImmutableArray) - end - - it "converts arrays of hashes to ImmutableArray's of ImmutableMashes" do - @immutable_mash[:top_level_3].first.should be_a(Chef::Node::ImmutableMash) - end - - it "converts nested hashes to ImmutableMashes" do - @immutable_mash[:top_level_4].should be_a(Chef::Node::ImmutableMash) - @immutable_mash[:top_level_4][:level2].should be_a(Chef::Node::ImmutableMash) - end - - - [ - :[]=, - :clear, - :default=, - :default_proc=, - :delete, - :delete_if, - :keep_if, - :merge!, - :update, - :reject!, - :replace, - :select!, - :shift - ].each do |mutator| - it "doesn't allow mutation via `#{mutator}'" do - lambda { @immutable_mash.send(mutator) }.should raise_error(Chef::Exceptions::ImmutableAttributeModification) - end - end - - it "returns a mutable version of itself when duped" do - mutable = @immutable_mash.dup - mutable[:new_key] = :value - mutable[:new_key].should == :value - end - -end - -describe Chef::Node::ImmutableArray do - - before do - @root = Chef::Node::Attribute.new({}, {}, {}, {}) - @immutable_array = Chef::Node::ImmutableArray.new(@root, %w[foo bar baz]) - end - - ## - # Note: other behaviors, such as immutibilizing input data, are tested along - # with ImmutableMash, above - ### - - [ - :<<, - :[]=, - :clear, - :collect!, - :compact!, - :default=, - :default_proc=, - :delete, - :delete_at, - :delete_if, - :fill, - :flatten!, - :insert, - :keep_if, - :map!, - :merge!, - :pop, - :push, - :update, - :reject!, - :reverse!, - :replace, - :select!, - :shift, - :slice!, - :sort!, - :sort_by!, - :uniq!, - :unshift - ].each do |mutator| - it "does not allow mutation via `#{mutator}" do - lambda { @immutable_array.send(mutator)}.should raise_error(Chef::Exceptions::ImmutableAttributeModification) - end - end - - it "returns a mutable version of itself when duped" do - mutable = @immutable_array.dup - mutable[0] = :value - mutable[0].should == :value - end -end - diff --git a/chef/spec/unit/platform_spec.rb b/chef/spec/unit/platform_spec.rb index e45c29274f..95e86e76c8 100644 --- a/chef/spec/unit/platform_spec.rb +++ b/chef/spec/unit/platform_spec.rb @@ -129,8 +129,8 @@ describe Chef::Platform do kitty = Chef::Resource::Cat.new("loulou") node = Chef::Node.new node.name("Intel") - node[:platform] = "mac_os_x" - node[:platform_version] = "9.2.2" + node.automatic_attrs[:platform] = "mac_os_x" + node.automatic_attrs[:platform_version] = "9.2.2" Chef::Platform.find_provider_for_node(node, kitty).should eql("nice") end @@ -139,8 +139,8 @@ describe Chef::Platform do kitty.stub!(:provider).and_return(Chef::Provider::File) node = Chef::Node.new node.name("Intel") - node[:platform] = "mac_os_x" - node[:platform_version] = "9.2.2" + node.automatic_attrs[:platform] = "mac_os_x" + node.automatic_attrs[:platform_version] = "9.2.2" Chef::Platform.find_provider_for_node(node, kitty).should eql(Chef::Provider::File) end @@ -150,15 +150,15 @@ describe Chef::Platform do Chef::Platform.platforms[:default].delete(:cat) node = Chef::Node.new node.name("Intel") - node[:platform] = "mac_os_x" - node[:platform_version] = "8.5" + node.automatic_attrs[:platform] = "mac_os_x" + node.automatic_attrs[:platform_version] = "8.5" Chef::Platform.find_provider_for_node(node, kitty).should eql(Chef::Provider::Cat) end it "returns a provider object given a Chef::Resource object which has a valid run context" do node = Chef::Node.new - node[:platform] = "mac_os_x" - node[:platform_version] = "9.2.2" + node.automatic_attrs[:platform] = "mac_os_x" + node.automatic_attrs[:platform_version] = "9.2.2" run_context = Chef::RunContext.new(node, {}, @events) file = Chef::Resource::File.new("whateva", run_context) provider = Chef::Platform.provider_for_resource(file, :foo) diff --git a/chef/spec/unit/provider/group/usermod_spec.rb b/chef/spec/unit/provider/group/usermod_spec.rb index dbbb75433c..6e6e275a7a 100644 --- a/chef/spec/unit/provider/group/usermod_spec.rb +++ b/chef/spec/unit/provider/group/usermod_spec.rb @@ -64,7 +64,7 @@ describe Chef::Provider::Group::Usermod do platforms.each do |platform, flags| it "should usermod each user when the append option is set on #{platform}" do - @node[:platform] = platform + @node.automatic_attrs[:platform] = platform @new_resource.stub!(:append).and_return(true) @provider.should_receive(:run_command).with({:command => "usermod #{flags} wheel all"}) @provider.should_receive(:run_command).with({:command => "usermod #{flags} wheel your"}) @@ -76,7 +76,7 @@ describe Chef::Provider::Group::Usermod do end describe "when loading the current resource" do - before (:each) do + before(:each) do File.stub!(:exists?).and_return(false) @provider.define_resource_requirements end diff --git a/chef/spec/unit/provider/ifconfig_spec.rb b/chef/spec/unit/provider/ifconfig_spec.rb index e6d57f25e6..1caeb75572 100644 --- a/chef/spec/unit/provider/ifconfig_spec.rb +++ b/chef/spec/unit/provider/ifconfig_spec.rb @@ -183,7 +183,7 @@ describe Chef::Provider::Ifconfig do it "should write network-script for centos" do @provider.stub!(:load_current_resource) - @node[:platform] = "centos" + @node.automatic_attrs[:platform] = "centos" @provider.stub!(:run_command) config_filename = "/etc/sysconfig/network-scripts/ifcfg-#{@new_resource.device}" config_file = StringIO.new @@ -199,7 +199,7 @@ describe Chef::Provider::Ifconfig do describe Chef::Provider::Ifconfig, "delete_config for action_delete" do it "should delete network-script if it exists for centos" do - @node[:platform] = "centos" + @node.automatic_attrs[:platform] = "centos" @current_resource.device "eth0" @provider.stub!(:load_current_resource) @provider.stub!(:run_command) diff --git a/chef/spec/unit/provider/ohai_spec.rb b/chef/spec/unit/provider/ohai_spec.rb index 7bdc648c72..c86ad288eb 100644 --- a/chef/spec/unit/provider/ohai_spec.rb +++ b/chef/spec/unit/provider/ohai_spec.rb @@ -64,7 +64,7 @@ describe Chef::Provider::Ohai do describe "when reloading ohai" do before do - @node[:origdata] = 'somevalue' + @node.automatic_attrs[:origdata] = 'somevalue' end it "applies updated ohai data to the node" do diff --git a/chef/spec/unit/provider/package_spec.rb b/chef/spec/unit/provider/package_spec.rb index a4e21ab26b..6e4cf6fe16 100644 --- a/chef/spec/unit/provider/package_spec.rb +++ b/chef/spec/unit/provider/package_spec.rb @@ -347,8 +347,8 @@ describe Chef::Provider::Package do @cookbook_collection = Chef::CookbookCollection.new(cl) @run_context = Chef::RunContext.new(@node, @cookbook_collection, @events) - @node[:platform] = 'PLATFORM: just testing' - @node[:platform_version] = 'PLATFORM VERSION: just testing' + @node.automatic_attrs[:platform] = 'PLATFORM: just testing' + @node.automatic_attrs[:platform_version] = 'PLATFORM VERSION: just testing' @new_resource.response_file('java.response') @new_resource.cookbook_name = 'java' @@ -384,8 +384,8 @@ describe Chef::Provider::Package do describe "when installing the preseed file to the cache location" do before do - @node[:platform] = :just_testing - @node[:platform_version] = :just_testing + @node.automatic_attrs[:platform] = :just_testing + @node.automatic_attrs[:platform_version] = :just_testing @response_file_destination = Dir.tmpdir + '/preseed--java--java-6.seed' diff --git a/chef/spec/unit/provider/remote_directory_spec.rb b/chef/spec/unit/provider/remote_directory_spec.rb index 22f15baf0f..8eabe31d6a 100644 --- a/chef/spec/unit/provider/remote_directory_spec.rb +++ b/chef/spec/unit/provider/remote_directory_spec.rb @@ -87,8 +87,8 @@ describe Chef::Provider::RemoteDirectory do describe "when creating the remote directory" do before do - @node[:platform] = :just_testing - @node[:platform_version] = :just_testing + @node.automatic_attrs[:platform] = :just_testing + @node.automatic_attrs[:platform_version] = :just_testing @destination_dir = Dir.tmpdir << "/remote_directory_test" @resource.path(@destination_dir) diff --git a/chef/spec/unit/provider/route_spec.rb b/chef/spec/unit/provider/route_spec.rb index 61c7b8e508..3c5db0b7a1 100644 --- a/chef/spec/unit/provider/route_spec.rb +++ b/chef/spec/unit/provider/route_spec.rb @@ -51,7 +51,7 @@ describe Chef::Provider::Route do describe Chef::Provider::Route, "load_current_resource" do context "on linux" do before do - @node[:os] = 'linux' + @node.automatic_attrs[:os] = 'linux' routing_table = "Iface Destination Gateway Flags RefCnt Use Metric Mask MTU Window IRTT\n" + "eth0 0064A8C0 0984A8C0 0003 0 0 0 00FFFFFF 0 0 0\n" route_file = StringIO.new(routing_table) @@ -198,7 +198,7 @@ describe Chef::Provider::Route do describe Chef::Provider::Route, "generate_config method" do %w[ centos redhat fedora ].each do |platform| it "should write a route file on #{platform} platform" do - @node[:platform] = platform + @node.automatic_attrs[:platform] = platform route_file = StringIO.new File.should_receive(:new).with("/etc/sysconfig/network-scripts/route-eth0", "w").and_return(route_file) @@ -211,7 +211,7 @@ describe Chef::Provider::Route do end it "should put all routes for a device in a route config file" do - @node[:platform] = 'centos' + @node.automatic_attrs[:platform] = 'centos' route_file = StringIO.new File.should_receive(:new).and_return(route_file) diff --git a/chef/spec/unit/provider/service/arch_service_spec.rb b/chef/spec/unit/provider/service/arch_service_spec.rb index e49f96869f..a7afa28da1 100644 --- a/chef/spec/unit/provider/service/arch_service_spec.rb +++ b/chef/spec/unit/provider/service/arch_service_spec.rb @@ -27,7 +27,7 @@ require 'ostruct' describe Chef::Provider::Service::Arch, "load_current_resource" do before(:each) do @node = Chef::Node.new - @node[:command] = {:ps => "ps -ef"} + @node.automatic_attrs[:command] = {:ps => "ps -ef"} @events = Chef::EventDispatch::Dispatcher.new @run_context = Chef::RunContext.new(@node, {}, @events) @@ -96,14 +96,14 @@ describe Chef::Provider::Service::Arch, "load_current_resource" do end it "should raise error if the node has a nil ps attribute and no other means to get status" do - @node[:command] = {:ps => nil} + @node.automatic_attrs[:command] = {:ps => nil} @provider.define_resource_requirements @provider.action = :start lambda { @provider.process_resource_requirements }.should raise_error(Chef::Exceptions::Service) end it "should raise error if the node has an empty ps attribute and no other means to get status" do - @node[:command] = {:ps => ""} + @node.automatic_attrs[:command] = {:ps => ""} @provider.define_resource_requirements @provider.action = :start lambda { @provider.process_resource_requirements }.should raise_error(Chef::Exceptions::Service) @@ -130,7 +130,7 @@ DEFAULT_PS @status = mock("Status", :exitstatus => 0, :stdout => @stdout) @provider.stub!(:shell_out!).and_return(@status) - @node[:command] = {:ps => "ps -ef"} + @node.automatic_attrs[:command] = {:ps => "ps -ef"} end it "determines the service is running when it appears in ps" do diff --git a/chef/spec/unit/provider/service/debian_service_spec.rb b/chef/spec/unit/provider/service/debian_service_spec.rb index d32a0068a4..bea9360561 100644 --- a/chef/spec/unit/provider/service/debian_service_spec.rb +++ b/chef/spec/unit/provider/service/debian_service_spec.rb @@ -21,7 +21,7 @@ require 'spec_helper' describe Chef::Provider::Service::Debian, "load_current_resource" do before(:each) do @node = Chef::Node.new - @node[:command] = {:ps => 'fuuuu'} + @node.automatic_attrs[:command] = {:ps => 'fuuuu'} @events = Chef::EventDispatch::Dispatcher.new @run_context = Chef::RunContext.new(@node, {}, @events) diff --git a/chef/spec/unit/provider/service/freebsd_service_spec.rb b/chef/spec/unit/provider/service/freebsd_service_spec.rb index c1f5ab24cb..6dd06bde2c 100644 --- a/chef/spec/unit/provider/service/freebsd_service_spec.rb +++ b/chef/spec/unit/provider/service/freebsd_service_spec.rb @@ -21,7 +21,7 @@ require 'spec_helper' describe Chef::Provider::Service::Freebsd do before do @node = Chef::Node.new - @node[:command] = {:ps => "ps -ax"} + @node.automatic_attrs[:command] = {:ps => "ps -ax"} @events = Chef::EventDispatch::Dispatcher.new @run_context = Chef::RunContext.new(@node, {}, @events) @@ -115,13 +115,13 @@ RC_SAMPLE end it "should raise error if the node has a nil ps attribute and no other means to get status" do - @node[:command] = {:ps => nil} + @node.automatic_attrs[:command] = {:ps => nil} @provider.define_resource_requirements lambda { @provider.process_resource_requirements }.should raise_error(Chef::Exceptions::Service) end it "should raise error if the node has an empty ps attribute and no other means to get status" do - @node[:command] = {:ps => ""} + @node.automatic_attrs[:command] = {:ps => ""} @provider.define_resource_requirements lambda { @provider.process_resource_requirements }.should raise_error(Chef::Exceptions::Service) end @@ -180,7 +180,7 @@ RC_SAMPLE describe "when we have a 'ps' attribute" do before do - @node[:command] = {:ps => "ps -ax"} + @node.automatic_attrs[:command] = {:ps => "ps -ax"} end it "should shell_out! the node's ps command" do diff --git a/chef/spec/unit/provider/service/init_service_spec.rb b/chef/spec/unit/provider/service/init_service_spec.rb index 6016c96a1a..77b22c8cf4 100644 --- a/chef/spec/unit/provider/service/init_service_spec.rb +++ b/chef/spec/unit/provider/service/init_service_spec.rb @@ -21,7 +21,7 @@ require 'spec_helper' describe Chef::Provider::Service::Init, "load_current_resource" do before(:each) do @node = Chef::Node.new - @node[:command] = {:ps => "ps -ef"} + @node.automatic_attrs[:command] = {:ps => "ps -ef"} @events = Chef::EventDispatch::Dispatcher.new @run_context = Chef::RunContext.new(@node, {}, @events) @@ -96,7 +96,7 @@ PS describe "when the node has not specified a ps command" do it "should raise an error if the node has a nil ps attribute" do - @node[:command] = {:ps => nil} + @node.automatic_attrs[:command] = {:ps => nil} @provider.load_current_resource @provider.action = :start @provider.define_resource_requirements @@ -104,7 +104,7 @@ PS end it "should raise an error if the node has an empty ps attribute" do - @node[:command] = {:ps => ""} + @node.automatic_attrs[:command] = {:ps => ""} @provider.load_current_resource @provider.action = :start @provider.define_resource_requirements diff --git a/chef/spec/unit/provider/service/insserv_service_spec.rb b/chef/spec/unit/provider/service/insserv_service_spec.rb index 6a8d3f351c..c823d511b5 100644 --- a/chef/spec/unit/provider/service/insserv_service_spec.rb +++ b/chef/spec/unit/provider/service/insserv_service_spec.rb @@ -23,7 +23,7 @@ describe Chef::Provider::Service::Insserv do @node = Chef::Node.new @events = Chef::EventDispatch::Dispatcher.new @run_context = Chef::RunContext.new(@node, {}, @events) - @node[:command] = {:ps => "ps -ax"} + @node.automatic_attrs[:command] = {:ps => "ps -ax"} @new_resource = Chef::Resource::Service.new("initgrediant") @current_resource = Chef::Resource::Service.new("initgrediant") diff --git a/chef/spec/unit/provider/service/invokercd_service_spec.rb b/chef/spec/unit/provider/service/invokercd_service_spec.rb index 2740858edb..ace2ad24e3 100644 --- a/chef/spec/unit/provider/service/invokercd_service_spec.rb +++ b/chef/spec/unit/provider/service/invokercd_service_spec.rb @@ -21,7 +21,7 @@ require 'spec_helper' describe Chef::Provider::Service::Invokercd, "load_current_resource" do before(:each) do @node = Chef::Node.new - @node[:command] = {:ps => "ps -ef"} + @node.automatic_attrs[:command] = {:ps => "ps -ef"} @events = Chef::EventDispatch::Dispatcher.new @run_context = Chef::RunContext.new(@node, {}, @events) @@ -95,14 +95,14 @@ PS describe "when the node has not specified a ps command" do it "should raise error if the node has a nil ps attribute and no other means to get status" do - @node[:command] = {:ps => nil} + @node.automatic_attrs[:command] = {:ps => nil} @provider.action = :start @provider.define_resource_requirements lambda { @provider.process_resource_requirements }.should raise_error(Chef::Exceptions::Service) end it "should raise error if the node has an empty ps attribute and no other means to get status" do - @node[:command] = {:ps => ""} + @node.automatic_attrs[:command] = {:ps => ""} @provider.action = :start @provider.define_resource_requirements lambda { @provider.process_resource_requirements }.should raise_error(Chef::Exceptions::Service) diff --git a/chef/spec/unit/provider/service/redhat_spec.rb b/chef/spec/unit/provider/service/redhat_spec.rb index 3847ce5ef2..dd874a4f05 100644 --- a/chef/spec/unit/provider/service/redhat_spec.rb +++ b/chef/spec/unit/provider/service/redhat_spec.rb @@ -44,7 +44,7 @@ describe "Chef::Provider::Service::Redhat" do before(:each) do @node = Chef::Node.new - @node[:command] = {:ps => 'foo'} + @node.automatic_attrs[:command] = {:ps => 'foo'} @events = Chef::EventDispatch::Dispatcher.new @run_context = Chef::RunContext.new(@node, {}, @events) diff --git a/chef/spec/unit/provider/service/simple_service_spec.rb b/chef/spec/unit/provider/service/simple_service_spec.rb index 75335a1ee8..cc0173e246 100644 --- a/chef/spec/unit/provider/service/simple_service_spec.rb +++ b/chef/spec/unit/provider/service/simple_service_spec.rb @@ -21,7 +21,7 @@ require 'spec_helper' describe Chef::Provider::Service::Simple, "load_current_resource" do before(:each) do @node = Chef::Node.new - @node[:command] = {:ps => "ps -ef"} + @node.automatic_attrs[:command] = {:ps => "ps -ef"} @events = Chef::EventDispatch::Dispatcher.new @run_context = Chef::RunContext.new(@node, {}, @events) @@ -51,13 +51,13 @@ NOMOCKINGSTRINGSPLZ end it "should raise error if the node has a nil ps attribute and no other means to get status" do - @node[:command] = {:ps => nil} + @node.automatic_attrs[:command] = {:ps => nil} @provider.define_resource_requirements lambda { @provider.process_resource_requirements }.should raise_error(Chef::Exceptions::Service) end it "should raise error if the node has an empty ps attribute and no other means to get status" do - @node[:command] = {:ps => ""} + @node.automatic_attrs[:command] = {:ps => ""} @provider.define_resource_requirements lambda { @provider.process_resource_requirements }.should raise_error(Chef::Exceptions::Service) end diff --git a/chef/spec/unit/provider/service/upstart_service_spec.rb b/chef/spec/unit/provider/service/upstart_service_spec.rb index f6c4606f90..2fc49c7aa2 100644 --- a/chef/spec/unit/provider/service/upstart_service_spec.rb +++ b/chef/spec/unit/provider/service/upstart_service_spec.rb @@ -21,9 +21,9 @@ require 'spec_helper' describe Chef::Provider::Service::Upstart do before(:each) do @node =Chef::Node.new - @node[:name] = 'upstarter' - @node[:platform] = 'ubuntu' - @node[:platform_version] = '9.10' + @node.name('upstarter') + @node.automatic_attrs[:platform] = 'ubuntu' + @node.automatic_attrs[:platform_version] = '9.10' @events = Chef::EventDispatch::Dispatcher.new @run_context = Chef::RunContext.new(@node, {}, @events) @@ -38,7 +38,7 @@ describe Chef::Provider::Service::Upstart do end it "should return /etc/event.d as the upstart job directory when running on Ubuntu 9.04" do - @node[:platform_version] = '9.04' + @node.automatic_attrs[:platform_version] = '9.04' #Chef::Platform.stub!(:find_platform_and_version).and_return([ "ubuntu", "9.04" ]) @provider = Chef::Provider::Service::Upstart.new(@new_resource, @run_context) @provider.instance_variable_get(:@upstart_job_dir).should == "/etc/event.d" @@ -46,14 +46,14 @@ describe Chef::Provider::Service::Upstart do end it "should return /etc/init as the upstart job directory when running on Ubuntu 9.10" do - @node[:platform_version] = '9.10' + @node.automatic_attrs[:platform_version] = '9.10' @provider = Chef::Provider::Service::Upstart.new(@new_resource, @run_context) @provider.instance_variable_get(:@upstart_job_dir).should == "/etc/init" @provider.instance_variable_get(:@upstart_conf_suffix).should == ".conf" end it "should return /etc/init as the upstart job directory by default" do - @node[:platform_version] = '9000' + @node.automatic_attrs[:platform_version] = '9000' @provider = Chef::Provider::Service::Upstart.new(@new_resource, @run_context) @provider.instance_variable_get(:@upstart_job_dir).should == "/etc/init" @provider.instance_variable_get(:@upstart_conf_suffix).should == ".conf" @@ -62,7 +62,7 @@ describe Chef::Provider::Service::Upstart do describe "load_current_resource" do before(:each) do - @node[:command] = {:ps => "ps -ax"} + @node.automatic_attrs[:command] = {:ps => "ps -ax"} @current_resource = Chef::Resource::Service.new("rsyslog") Chef::Resource::Service.stub!(:new).and_return(@current_resource) diff --git a/chef/spec/unit/provider/template_spec.rb b/chef/spec/unit/provider/template_spec.rb index 6b5d6da9c1..6747876d61 100644 --- a/chef/spec/unit/provider/template_spec.rb +++ b/chef/spec/unit/provider/template_spec.rb @@ -89,7 +89,7 @@ describe Chef::Provider::Template do it "creates the template with the rendered content" do @access_controls.stub!(:requires_changes?).and_return(true) @access_controls.should_receive(:set_all!) - @node[:slappiness] = "a warm gun" + @node.normal[:slappiness] = "a warm gun" @provider.should_receive(:backup) @provider.run_action(:create) IO.read(@rendered_file_location).should == "slappiness is a warm gun" @@ -109,7 +109,7 @@ describe Chef::Provider::Template do it "creates the template with the rendered content for the create if missing action" do @access_controls.stub!(:requires_changes?).and_return(true) @access_controls.should_receive(:set_all!) - @node[:slappiness] = "happiness" + @node.normal[:slappiness] = "happiness" @provider.should_receive(:backup) @provider.run_action(:create_if_missing) IO.read(@rendered_file_location).should == "slappiness is happiness" @@ -123,7 +123,7 @@ describe Chef::Provider::Template do end it "overwrites the file with the updated content when the create action is run" do - @node[:slappiness] = "a warm gun" + @node.normal[:slappiness] = "a warm gun" @access_controls.stub!(:requires_changes?).and_return(false) @access_controls.should_receive(:set_all!) @provider.should_receive(:backup) @@ -146,7 +146,7 @@ describe Chef::Provider::Template do it "doesn't overwrite the file when the create if missing action is run" do @access_controls.stub!(:requires_changes?).and_return(false) @access_controls.should_not_receive(:set_all!) - @node[:slappiness] = "a warm gun" + @node.normal[:slappiness] = "a warm gun" @provider.should_not_receive(:backup) @provider.run_action(:create_if_missing) IO.read(@rendered_file_location).should == "blargh" @@ -164,7 +164,7 @@ describe Chef::Provider::Template do end it "does not backup the original or overwrite it" do - @node[:slappiness] = "a warm gun" + @node.normal[:slappiness] = "a warm gun" @access_controls.stub!(:requires_changes?).and_return(false) @provider.should_not_receive(:backup) FileUtils.should_not_receive(:mv) @@ -173,7 +173,7 @@ describe Chef::Provider::Template do end it "does not backup the original or overwrite it on create if missing" do - @node[:slappiness] = "a warm gun" + @node.normal[:slappiness] = "a warm gun" @access_controls.stub!(:requires_changes?).and_return(false) @provider.should_not_receive(:backup) FileUtils.should_not_receive(:mv) diff --git a/chef/spec/unit/recipe_spec.rb b/chef/spec/unit/recipe_spec.rb index 5f94e8fd14..797e566190 100644 --- a/chef/spec/unit/recipe_spec.rb +++ b/chef/spec/unit/recipe_spec.rb @@ -28,7 +28,7 @@ describe Chef::Recipe do 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) @@ -153,7 +153,7 @@ describe Chef::Recipe do end end @run_context.definitions[:crow] = crow_define - @node[:foo] = false + @node.normal[:foo] = false @recipe.crow "mine" do something node[:foo] end diff --git a/chef/spec/unit/resource_spec.rb b/chef/spec/unit/resource_spec.rb index 671a9fa147..71d8a4cccf 100644 --- a/chef/spec/unit/resource_spec.rb +++ b/chef/spec/unit/resource_spec.rb @@ -425,8 +425,8 @@ describe Chef::Resource do before do @resource = Chef::Resource.new("provided", @run_context) @resource.provider = Chef::Provider::SnakeOil - @node[:platform] = "fubuntu" - @node[:platform_version] = '10.04' + @node.automatic_attrs[:platform] = "fubuntu" + @node.automatic_attrs[:platform_version] = '10.04' end it "does not run only_if if no only_if command is given" do |