summaryrefslogtreecommitdiff
path: root/spec/ruby/core/array
diff options
context:
space:
mode:
Diffstat (limited to 'spec/ruby/core/array')
-rw-r--r--spec/ruby/core/array/to_h_spec.rb7
1 files changed, 7 insertions, 0 deletions
diff --git a/spec/ruby/core/array/to_h_spec.rb b/spec/ruby/core/array/to_h_spec.rb
index 9104aed301..e845d2c950 100644
--- a/spec/ruby/core/array/to_h_spec.rb
+++ b/spec/ruby/core/array/to_h_spec.rb
@@ -34,4 +34,11 @@ describe "Array#to_h" do
it "does not accept arguments" do
lambda { [].to_h(:a, :b) }.should raise_error(ArgumentError)
end
+
+ ruby_version_is "2.6" do
+ it "converts [key, value] pairs returned by the block to a hash" do
+ i = 0
+ [:a, :b].to_h {|k| [k, i += 1]}.should == { a: 1, b: 2 }
+ end
+ end
end