summaryrefslogtreecommitdiff
path: root/spec/ruby/library/openstruct
diff options
context:
space:
mode:
Diffstat (limited to 'spec/ruby/library/openstruct')
-rw-r--r--spec/ruby/library/openstruct/to_h_spec.rb7
1 files changed, 7 insertions, 0 deletions
diff --git a/spec/ruby/library/openstruct/to_h_spec.rb b/spec/ruby/library/openstruct/to_h_spec.rb
index f3e157816b..1a8a87a94d 100644
--- a/spec/ruby/library/openstruct/to_h_spec.rb
+++ b/spec/ruby/library/openstruct/to_h_spec.rb
@@ -26,4 +26,11 @@ describe "OpenStruct#to_h" do
@to_h[:age] = 71
@os.age.should == 70
end
+
+ ruby_version_is "2.6" do
+ it "converts [key, value] pairs returned by the block to a hash" do
+ h = @os.to_h {|key, value| [key.to_s, value * 2]}
+ h.should == {"name" => "John SmithJohn Smith", "age" => 140, "pension" => 600}
+ end
+ end
end