diff options
author | Adam Jacob <adam@opscode.com> | 2012-12-12 15:52:06 -0800 |
---|---|---|
committer | Adam Jacob <adam@opscode.com> | 2012-12-12 16:44:08 -0800 |
commit | a19d39a2e7fbeb52ad8b9f713f015781536d5e23 (patch) | |
tree | 6b7817556525cadd3a2b9733500cea46f9cda44b /spec/unit/node | |
parent | e109d6de95ed1e6291e23dab802e8879e4f4d947 (diff) | |
download | chef-a19d39a2e7fbeb52ad8b9f713f015781536d5e23.tar.gz |
CHEF-3688 remove stale attribute read protection
This commit removes stale attribute read protection, as it does more
harm than good. Includes removal of passing "root" around to
immutablize.
Diffstat (limited to 'spec/unit/node')
-rw-r--r-- | spec/unit/node/attribute_spec.rb | 195 | ||||
-rw-r--r-- | spec/unit/node/immutable_collections_spec.rb | 6 |
2 files changed, 2 insertions, 199 deletions
diff --git a/spec/unit/node/attribute_spec.rb b/spec/unit/node/attribute_spec.rb index d568d6fc15..947de76b1d 100644 --- a/spec/unit/node/attribute_spec.rb +++ b/spec/unit/node/attribute_spec.rb @@ -1086,200 +1086,5 @@ describe Chef::Node::Attribute do end - - describe "when reading from a stale sub tree" do - before do - @attributes.default[:sub_tree] = {:key => "old value", :ary => %w[foo bar]} - @sub_tree = @attributes[:sub_tree] - @sub_array = @attributes[:sub_tree][:ary] - @attributes.default[:sub_tree] = {:key => "new value"} - end - - it "detects reads from a no-longer-valid merged attributes sub-tree" do - lambda { @sub_tree[:key] }.should raise_error(Chef::Exceptions::StaleAttributeRead) - end - - it "detects reads from a no-longer-valid array value" do - lambda {@sub_array.first}.should raise_error(Chef::Exceptions::StaleAttributeRead) - end - [ - :[], - :all?, - :any?, - :assoc, - :chunk, - :collect, - :collect_concat, - :count, - :cycle, - :detect, - :drop, - :drop_while, - :each, - :each_cons, - :each_entry, - :each_key, - :each_pair, - :each_slice, - :each_value, - :each_with_index, - :each_with_object, - :empty?, - :entries, - :except, - :fetch, - :find, - :find_all, - :find_index, - :first, - :flat_map, - :flatten, - :grep, - :group_by, - :has_key?, - :has_value?, - :include?, - :index, - :inject, - :invert, - :key, - :key?, - :keys, - :length, - :map, - :max, - :max_by, - :member?, - :merge, - :min, - :min_by, - :minmax, - :minmax_by, - :none?, - :one?, - :partition, - :rassoc, - :reduce, - :reject, - :reverse_each, - :select, - :size, - :slice_before, - :sort, - :sort_by, - :store, - :symbolize_keys, - :take, - :take_while, - :to_a, - :to_hash, - :to_set, - :value?, - :values, - :values_at, - :zip - ].each do |reader| - it "detects dirty reads from a no-longer-valid Mash via Mash##{reader}" do - lambda { @sub_tree.send(:reader) }.should raise_error(Chef::Exceptions::StaleAttributeRead) - end - end - - - [ - :&, - :*, - :+, - :-, - :[], - :all?, - :any?, - :assoc, - :at, - :chunk, - :collect, - :collect_concat, - :combination, - :compact, - :concat, - :count, - :cycle, - :detect, - :drop, - :drop_while, - :each, - :each_cons, - :each_entry, - :each_index, - :each_slice, - :each_with_index, - :each_with_object, - :empty?, - :entries, - :fetch, - :find, - :find_all, - :find_index, - :first, - :flat_map, - :flatten, - :grep, - :group_by, - :include?, - :index, - :inject, - :join, - :last, - :length, - :map, - :max, - :max_by, - :member?, - :min, - :min_by, - :minmax, - :minmax_by, - :none?, - :one?, - :pack, - :partition, - :permutation, - :product, - :rassoc, - :reduce, - :reject, - :repeated_combination, - :repeated_permutation, - :reverse, - :reverse_each, - :rindex, - :rotate, - :sample, - :select, - :shelljoin, - :shuffle, - :size, - :slice, - :slice_before, - :sort, - :sort_by, - :take, - :take_while, - :to_a, - :to_ary, - :to_set, - :transpose, - :uniq, - :values_at, - :zip, - :| - ].each do |reader| - - it "detects dirty reads via Array##{reader}" do - lambda {@sub_array.send(reader)}.should raise_error(Chef::Exceptions::StaleAttributeRead) - end - end - - end - end diff --git a/spec/unit/node/immutable_collections_spec.rb b/spec/unit/node/immutable_collections_spec.rb index 4ad5313415..db4a79f21b 100644 --- a/spec/unit/node/immutable_collections_spec.rb +++ b/spec/unit/node/immutable_collections_spec.rb @@ -21,13 +21,12 @@ require "chef/node/immutable_collections" 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) + @immutable_mash = Chef::Node::ImmutableMash.new(@data_in) end it "element references like regular hash" do @@ -87,8 +86,7 @@ end describe Chef::Node::ImmutableArray do before do - @root = Chef::Node::Attribute.new({}, {}, {}, {}) - @immutable_array = Chef::Node::ImmutableArray.new(@root, %w[foo bar baz]) + @immutable_array = Chef::Node::ImmutableArray.new(%w[foo bar baz]) end ## |