<commit_before>require File.dirname(__FILE__) + '/../../spec_helper'

describe "ENV.each_key" do

  it "returns each key" do
    e = []
    orig = ENV.to_hash
    begin
      ENV.clear
      ENV["1"] = "3"
      ENV["2"] = "4"
      ENV.each_key { |k| e << k }
      e.should include("1")
      e.should include("2")
    ensure
      ENV.replace orig
    end
  end

  ruby_version_is "" ... "1.8.7" do
    it "raises LocalJumpError if no block given" do
      lambda { ENV.each_key }.should raise_error(LocalJumpError)
    end
  end

  ruby_version_is "1.8.7" do
    it "returns an Enumerator if called without a block" do
      ENV.each_key.should be_kind_of(enumerator_class)
    end
  end

end<commit_msg>ENV.each_key: Uses locale encoding as of 1.9<commit_after>require File.dirname(__FILE__) + '/../../spec_helper'

describe "ENV.each_key" do

  it "returns each key" do
    e = []
    orig = ENV.to_hash
    begin
      ENV.clear
      ENV["1"] = "3"
      ENV["2"] = "4"
      ENV.each_key { |k| e << k }
      e.should include("1")
      e.should include("2")
    ensure
      ENV.replace orig
    end
  end

  ruby_version_is "" ... "1.8.7" do
    it "raises LocalJumpError if no block given" do
      lambda { ENV.each_key }.should raise_error(LocalJumpError)
    end
  end

  ruby_version_is "1.8.7" do
    it "returns an Enumerator if called without a block" do
      ENV.each_key.should be_kind_of(enumerator_class)
    end
  end

  ruby_version_is "1.9" do
    it "returns keys in the locale encoding" do
      ENV.each_key do |key|
        key.encoding.should == Encoding.find('locale')
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.11786372007366483, 'fraction_numerical': 0.017188459177409455, 'mean_word_length': 2.326530612244898, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6057171', 'n_tokens_mistral': 612, 'n_tokens_neox': 583, 'n_words': 160}