Skip to content

Commit b7a672b

Browse files
shuuuuunrafaelfranca
authored andcommitted
Specs for HashWithIndifferentAccess#slice
1 parent c3f77d5 commit b7a672b

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

spec/core_ext/hash_with_indifferent_access_spec.rb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,20 @@
4040
expect(@hash.fetch(:missing, :found)).to eq(:found)
4141
end
4242

43+
it "supports slice" do
44+
expect(@hash.slice("foo")).to eq({"foo" => "bar"})
45+
expect(@hash.slice(:foo)).to eq({"foo" => "bar"})
46+
47+
expect(@hash.slice("baz")).to eq({"baz" => "bee"})
48+
expect(@hash.slice(:baz)).to eq({"baz" => "bee"})
49+
50+
expect(@hash.slice("foo", "baz")).to eq({"foo" => "bar", "baz" => "bee"})
51+
expect(@hash.slice(:foo, :baz)).to eq({"foo" => "bar", "baz" => "bee"})
52+
53+
expect(@hash.slice("missing")).to eq({})
54+
expect(@hash.slice(:missing)).to eq({})
55+
end
56+
4357
it "has key checkable by either strings or symbols" do
4458
expect(@hash.key?("foo")).to be true
4559
expect(@hash.key?(:foo)).to be true

0 commit comments

Comments
 (0)