summaryrefslogtreecommitdiff
path: root/spec/ruby/core/env/to_h_spec.rb
blob: f6c796b4d6e787dc20016a4cd8e2e6717c127076 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
require_relative '../../spec_helper'
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