<commit_before>require 'rack/test'
require 'rack/logs'

describe 'running `Rack::Logs` via `Rack::Builder`', type: :integration do
  include Rack::Test::Methods

  context 'running with defaults' do
    let(:app) { Rack::Builder.app { run Rack::Logs } }

    before { get '/' }

    example 'returns a 200 response code' do
      expect(last_response).to be_ok
    end
    example 'returns no logs because there are no files' do
      expect(last_response.body).to eq ''
    end
  end
end<commit_msg>basic behaviour<commit_after>require 'rack/test'
require 'rack/logs'

describe 'running `Rack::Logs` via `Rack::Builder`', type: :integration do
  include Rack::Test::Methods

  context 'running with defaults' do
    let(:app) { Rack::Builder.app { run Rack::Logs } }

    before { get '/' }

    example 'returns a 200 response code' do
      expect(last_response).to be_ok
    end
    example 'returns no logs because there are no files' do
      expect(last_response.body).to eq ''
    end
  end

  context 'given a log in a configured directory' do
    let(:app) do
      Rack::Builder.app do
        logs = Rack::Logs.configure do |config|
          config.log_dir = './tmp'
        end
        run logs
      end
    end

    before do
      File.open('./tmp/my_log_file.log','w') do |f|
        f.write "LOG ENTRY 1234"
      end
      get '/'
    end

    example 'returns a 200 response code' do
      expect(last_response).to be_ok
    end

    example 'accessing the log returns log contents' do
      expect(last_response.body).to match 'LOG ENTRY 1234'
    end
  end
end
{'fraction_non_alphanumeric': 0.10675931775110549, 'fraction_numerical': 0.010739102969046115, 'mean_word_length': 2.7270588235294118, 'pattern_counts': {'":': 0, '<': 3, '<?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': '4147933', 'n_tokens_mistral': 527, 'n_tokens_neox': 492, 'n_words': 161}