summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2016-11-15 10:46:11 -0800
committerLamont Granquist <lamont@scriptkiddie.org>2016-11-15 10:46:11 -0800
commitc3f75bc59dfbae82ccb249659da898ce49179371 (patch)
tree774b63ed7e856c9fb9c6b9f1a42bbfa72b52bcb7
parent7524f955aea038b45089f56d64bcb0f557cfb26d (diff)
downloadchef-lcg/node-immutable-array-slice.tar.gz
add specs for array slice access to node attributeslcg/node-immutable-array-slice
Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
-rw-r--r--spec/unit/node/immutable_collections_spec.rb5
-rw-r--r--spec/unit/node/vivid_mash_spec.rb11
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 } ]