Skip to content

Commit f319619

Browse files
committed
New spec for Array#to_h
1 parent 00b0956 commit f319619

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

spec/ruby/core/array/to_h_spec.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@
3535
lambda { [].to_h(:a, :b) }.should raise_error(ArgumentError)
3636
end
3737

38+
it "produces a hash that returns nil for a missing element" do
39+
[[:a, 1], [:b, 2]].to_h[:c].should be_nil
40+
end
41+
3842
ruby_version_is "2.6" do
3943
context "with block" do
4044
it "converts [key, value] pairs returned by the block to a Hash" do

spec/tags/core/array/to_h_tags.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
fails:Array#to_h produces a hash that returns nil for a missing element

0 commit comments

Comments
 (0)