<commit_before>require 'spec_helper'

module Adjust
  module Core
    describe Configuration do
      let(:path) { 'spec/fixtures/config/adjust.yml' }
      subject(:config) { Configuration.new }

      context 'with an explicit environment' do
        subject(:load!) { config.load(path, environment: 'test') }
        before { expect { load! }.to_not raise_error }

        describe '#load' do
          it 'sets an environment' do
            expect(config.environment).to eq 'test'
          end
        end

        describe '#configurations' do
          it 'caches the configurations' do
            expect(config.configurations).to include 'test'
          end
        end

        describe '#active' do
          it 'contains the configuration for current env' do
            expect(config.active).to include 'test_app'
          end
        end

        describe '#active_environment' do
          it 'returns the adjust environment for current env' do
            expect(config.active_environment).to eq 'sandbox'
          end
        end

        describe '#active_tokens' do
          it 'returns arguments if app was not matched' do
            expect(config.tokens('foo', 'bar')).to eq \
              app_token: 'foo',
              event_token: 'bar'
          end

          it 'returns app_token if app matched and event not matched' do
            expect(config.tokens('test_app', 'bar')).to eq \
              app_token: 'app_token',
              event_token: 'bar'
          end

          it 'returns tokens if app matched and event matched' do
            expect(config.tokens('test_app', 'event1')).to eq \
              app_token: 'app_token',
              event_token: '<PASSWORD>'
          end
        end
      end

      context 'with an implicit environment' do
        subject(:load!) { config.load(path) }

        describe '#environment' do
          after do
            ENV.delete('RACK_ENV')
            ENV.delete('RAILS_ENV')
          end

          it 'defaults to development' do
            load!

            expect(config.environment).to eq 'development'
          end

          it 'defaults to rack env if defined' do
            ENV['RACK_ENV'] = 'staging'

            load!

            expect(config.environment).to eq 'staging'
          end

          it 'defaults to rails env if defined' do
            ENV['RAILS_ENV'] = 'production'

            load!

            expect(config.environment).to eq 'production'
          end
        end

        describe '#active' do
          it 'loads the development configs' do
            load!

            expect(config.active).to include 'dev_app'
          end
        end
      end
    end
  end
end<commit_msg>Getting rid of Travis hostile tests<commit_after>require 'spec_helper'

module Adjust
  module Core
    describe Configuration do
      let(:path) { 'spec/fixtures/config/adjust.yml' }
      subject(:config) { Configuration.new }

      context 'with an explicit environment' do
        subject(:load!) { config.load(path, environment: 'test') }
        before { expect { load! }.to_not raise_error }

        describe '#load' do
          it 'sets an environment' do
            expect(config.environment).to eq 'test'
          end
        end

        describe '#configurations' do
          it 'caches the configurations' do
            expect(config.configurations).to include 'test'
          end
        end

        describe '#active' do
          it 'contains the configuration for current env' do
            expect(config.active).to include 'test_app'
          end
        end

        describe '#active_environment' do
          it 'returns the adjust environment for current env' do
            expect(config.active_environment).to eq 'sandbox'
          end
        end

        describe '#active_tokens' do
          it 'returns arguments if app was not matched' do
            expect(config.tokens('foo', 'bar')).to eq \
              app_token: 'foo',
              event_token: 'bar'
          end

          it 'returns app_token if app matched and event not matched' do
            expect(config.tokens('test_app', 'bar')).to eq \
              app_token: 'app_token',
              event_token: 'bar'
          end

          it 'returns tokens if app matched and event matched' do
            expect(config.tokens('test_app', 'event1')).to eq \
              app_token: 'app_token',
              event_token: 'event_token'
          end
        end
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.08525243578387955, 'fraction_numerical': 0.0004428697962798937, 'mean_word_length': 1.7080335731414868, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, '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': '7225764', 'n_tokens_mistral': 1179, 'n_tokens_neox': 1143, 'n_words': 375}