diff options
author | marcandre <marcandre@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-12-22 17:05:03 +0000 |
---|---|---|
committer | marcandre <marcandre@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-12-22 17:05:03 +0000 |
commit | 1e30df6f77c79b07d1c65e450b0167861c180473 (patch) | |
tree | 68ad1f210e24af5733e27ed086bf9796fb6777a3 /spec/ruby/library/openstruct | |
parent | 8ef2aae2d0350506fb1b12eb0afd56b5b1f51b89 (diff) |
ostruct.rb: Accept block for to_h [#15451].
Patch by Shuji Kobayashi.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66496 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'spec/ruby/library/openstruct')
-rw-r--r-- | spec/ruby/library/openstruct/to_h_spec.rb | 7 |
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 |