mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Enumerable#to_h with block and so on
[Feature #15143] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64794 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
e76eebd79b
commit
abe75149d1
16 changed files with 243 additions and 30 deletions
13
spec/ruby/core/env/to_h_spec.rb
vendored
13
spec/ruby/core/env/to_h_spec.rb
vendored
|
@ -3,4 +3,17 @@ require_relative 'shared/to_hash'
|
|||
|
||||
describe "ENV.to_hash" do
|
||||
it_behaves_like :env_to_hash, :to_h
|
||||
|
||||
ruby_version_is "2.6" do
|
||||
it "converts [key, value] pairs returned by the block to a hash" do
|
||||
orig = ENV.to_hash
|
||||
begin
|
||||
ENV.replace "a" => "b", "c" => "d"
|
||||
i = 0
|
||||
ENV.to_h {|k, v| [k.to_sym, v.upcase]}.should == {a:"B", c:"D"}
|
||||
ensure
|
||||
ENV.replace orig
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue