Skip to content

Commit bbfdf33

Browse files
authored
Merge pull request #568 from segiddins/seg-hash-fetch-tests
Add more tests for HashWithIndifferentAccess#fetch
2 parents 7bb6f63 + c44218b commit bbfdf33

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

spec/core_ext/hash_with_indifferent_access_spec.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,14 @@
1919
expect(@hash.fetch("foo", nil)).to eq("bar")
2020
expect(@hash.fetch(:foo)).to eq("bar")
2121
expect(@hash.fetch(:foo, nil)).to eq("bar")
22+
23+
expect(@hash.fetch("baz")).to eq("bee")
24+
expect(@hash.fetch("baz", nil)).to eq("bee")
25+
expect(@hash.fetch(:baz)).to eq("bee")
26+
expect(@hash.fetch(:baz, nil)).to eq("bee")
27+
28+
expect { @hash.fetch(:missing) }.to raise_error(IndexError)
29+
expect(@hash.fetch(:missing, :found)).to eq(:found)
2230
end
2331

2432
it "has key checkable by either strings or symbols" do

0 commit comments

Comments
 (0)