diff options
-rw-r--r-- | spec/unit/node/immutable_collections_spec.rb | 5 | ||||
-rw-r--r-- | spec/unit/node/vivid_mash_spec.rb | 11 |
2 files changed, 16 insertions, 0 deletions
diff --git a/spec/unit/node/immutable_collections_spec.rb b/spec/unit/node/immutable_collections_spec.rb index fe4e50d1bd..81dd771df3 100644 --- a/spec/unit/node/immutable_collections_spec.rb +++ b/spec/unit/node/immutable_collections_spec.rb @@ -198,4 +198,9 @@ describe Chef::Node::ImmutableArray do end end + describe "#[]" do + it "works with array slices" do + expect(@immutable_array[1, 2]).to eql(%w{bar baz}) + end + end end diff --git a/spec/unit/node/vivid_mash_spec.rb b/spec/unit/node/vivid_mash_spec.rb index 017e6206fc..4898c22380 100644 --- a/spec/unit/node/vivid_mash_spec.rb +++ b/spec/unit/node/vivid_mash_spec.rb @@ -47,7 +47,18 @@ describe Chef::Node::VividMash do end end + context "#[]" do + it "works with array slices" do + expect(vivid["array"][1, 2]).to eql([1, 2]) + end + end + context "#[]=" do + it "works with array slices" do + vivid["array"][3, 2] = [ 3, 4 ] + expect(vivid["array"]).to eql([0, 1, 2, 3, 4]) + end + it "deep converts values through arrays" do expect(root).to receive(:reset_cache).with("foo") vivid["foo"] = [ { :bar => true } ] |