<commit_before>require 'spec_helper'

RSpec.describe AspectedMessagesController do
  let(:logger_service) { double }

  describe '#perform' do
    it 'logs to file' do
      allow_any_instance_of(described_class)
        .to receive(:sleep)
        .with(10)

      expect(LoggerService)
        .to receive(:new)
        .and_return(logger_service)

      expect(logger_service)
        .to receive(:write_to_file)

      subject.perform
    end
  end

  describe '#after_failure' do
    it 'clears log file' do
      expect(LoggerService)
        .to receive(:new)
        .and_return(logger_service)

      expect(logger_service)
        .to receive(:clear_file)

      subject.after_failure
    end
  end

  describe '#check_params' do
    before do
      subject.params = { 'message' => '45' }
    end
    it 'returns true if message is higher than 30' do
      expect(subject.send(:check_params)).to be_truthy
    end
  end
end
<commit_msg>Params lazy loading in karafka<commit_after>require 'spec_helper'

RSpec.describe AspectedMessagesController do
  let(:logger_service) { double }

  describe '#perform' do
    it 'logs to file' do
      allow_any_instance_of(described_class)
        .to receive(:sleep)
        .with(10)

      expect(LoggerService)
        .to receive(:new)
        .and_return(logger_service)

      expect(logger_service)
        .to receive(:write_to_file)

      subject.perform
    end
  end

  describe '#after_failure' do
    it 'clears log file' do
      expect(LoggerService)
        .to receive(:new)
        .and_return(logger_service)

      expect(logger_service)
        .to receive(:clear_file)

      subject.after_failure
    end
  end

  describe '#check_params' do
    before do
      subject.params = Karafka::Connection::Message.new('topic', { 'message' => '45' })
    end
    it 'returns true if message is higher than 30' do
      expect(subject.send(:check_params)).to be_truthy
    end
  end
end

{'fraction_non_alphanumeric': 0.09118852459016394, 'fraction_numerical': 0.006147540983606557, 'mean_word_length': 2.650467289719626, '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': '931513', 'n_tokens_mistral': 617, 'n_tokens_neox': 588, 'n_words': 147}