<commit_before>require 'duffel'

describe Duffel do
  it 'should not raise an error' do
    expect { subject }.to_not raise_error
  end

  describe '.not_an_existing_method' do
    context 'without a matching environment variable' do
      it 'should raise an error if nothing exists in the environment' do
        expect { subject.not_an_existing_method }.to raise_error(KeyError)
      end

      context 'with a fallback passed' do
        it 'should return the fallback' do
          expect(
            subject.another_non_existing_method(fallback: 'blah')
          ).to eq 'blah'
        end

        context 'fallback is nil' do
          it 'should return nil' do
            expect(
              subject.yet_another_non_existing_method(fallback: nil)
            ).to eq nil
          end
        end
      end
    end

    context 'with a matching environment variable' do
      before { expect(ENV).to receive(:fetch).with('AN_EXISTING_METHOD').and_return(response) }
      let(:response) { 'response' }

      it 'should return the env variable' do
        expect(subject.an_existing_method).to eq response
      end
    end
  end
end<commit_msg>Make tests compatible with older rubies.<commit_after>require 'duffel'

describe Duffel do
  it 'should not raise an error' do
    expect { subject }.to_not raise_error
  end

  describe '.not_an_existing_method' do
    context 'without a matching environment variable' do
      it 'should raise an error if nothing exists in the environment' do
        expect { subject.not_an_existing_method }.to raise_error(KeyError)
      end

      context 'with a fallback passed' do
        it 'should return the fallback' do
          expect(
            subject.another_non_existing_method(:fallback => 'blah')
          ).to eq 'blah'
        end

        context 'fallback is nil' do
          it 'should return nil' do
            expect(
              subject.yet_another_non_existing_method(:fallback => nil)
            ).to eq nil
          end
        end
      end
    end

    context 'with a matching environment variable' do
      before { expect(ENV).to receive(:fetch).with('AN_EXISTING_METHOD').and_return(response) }
      let(:response) { 'response' }

      it 'should return the env variable' do
        expect(subject.an_existing_method).to eq response
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.07012324691882703, 'fraction_numerical': 0.0, 'mean_word_length': 2.34850640113798, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '5595226', 'n_tokens_mistral': 665, 'n_tokens_neox': 646, 'n_words': 222}