<commit_before># encoding: utf-8

require "rbitter"

describe Rbitter do
  it 'has env_reset function and clears Rbitter.env,' do
    Rbitter.env_reset
    expect(Rbitter.env).to be_a(Hash)
    expect(Rbitter.env.length).to be(0)
  end

  context 'when config.json is not installed,' do
    it 'fails on loading' do
      expect{Rbitter.config_initialize}.to raise_error(Rbitter::ConfigFileError)
    end
  end

  context 'when path to config.json is invalid,' do
    it 'fals on loading' do
      expect{Rbitter.config_initialize("/silly/dummy/.")}.to raise_error(Rbitter::ConfigFileError)
    end
  end


  context 'when default config.json is installed,' do
    before(:all) do
      Rbitter.bootstrap(['configure'])
      expect(File.file?('config.json')).to be(true)
    end

    it 'loads configuration successfully with autodetection' do
      expect{Rbitter.config_initialize}.to_not raise_error
      expect(Rbitter.env.length > 0).to be(true)
    end

    it 'loads configuration successfully with given config.json path' do
      expect{Rbitter.config_initialize('config.json')}.to_not raise_error
      expect(Rbitter.env.length > 0).to be(true)
    end

    it 'checks that Rbitter.env returns Hash' do
      expect(Rbitter.env).to be_a(Hash)
    end

    it 'checks that Rbitter[] works' do
      expect(Rbitter["twitter"]).to be_a(Hash)
    end<commit_msg>Fix env_spec.rb test to initiate @@env before testing<commit_after># encoding: utf-8

require "rbitter"

describe Rbitter do
  it 'has env_reset function and clears Rbitter.env,' do
    Rbitter.env_reset
    expect(Rbitter.env).to be_a(Hash)
    expect(Rbitter.env.length).to be(0)
  end

  context 'when config.json is not installed,' do
    it 'fails on loading' do
      expect{Rbitter.config_initialize}.to raise_error(Rbitter::ConfigFileError)
    end
  end

  context 'when path to config.json is invalid,' do
    it 'fals on loading' do
      expect{Rbitter.config_initialize("/silly/dummy/.")}.to raise_error(Rbitter::ConfigFileError)
    end
  end


  context 'when default config.json is installed,' do
    before(:all) do
      Rbitter.bootstrap(['configure'])
      expect(File.file?('config.json')).to be(true)
    end

    it 'loads configuration successfully with autodetection' do
      expect{Rbitter.config_initialize}.to_not raise_error
      expect(Rbitter.env.length > 0).to be(true)
    end

    it 'loads configuration successfully with given config.json path' do
      expect{Rbitter.config_initialize('config.json')}.to_not raise_error
      expect(Rbitter.env.length > 0).to be(true)
    end

    it 'checks that Rbitter.env returns Hash' do
      expect{Rbitter.config_initialize}.to_not raise_error
      expect(Rbitter.env).to be_a(Hash)
    end

    it 'checks that Rbitter[] works' do
      expect{Rbitter.config_initialize}.to_not raise_error
      expect(Rbitter["twitter"]).to be_a(Hash)
    end
{'fraction_non_alphanumeric': 0.10310344827586207, 'fraction_numerical': 0.002758620689655172, 'mean_word_length': 3.511664074650078, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '4859085', 'n_tokens_mistral': 963, 'n_tokens_neox': 946, 'n_words': 240}