<commit_before>module EmailHelpers
  def sent_to_user?(user, recipients = nil)
    recipients ||= ActionMailer::Base.deliveries.flat_map(&:to)

    recipients.count(user.email) == 1
  end

  def reset_delivered_emails!
    ActionMailer::Base.deliveries.clear
  end

  def should_only_email(*users)
    recipients = ActionMailer::Base.deliveries.flat_map(&:to)

    users.each { |user| should_email(user, recipients) }

    expect(recipients.count).to eq(users.count)
  end

  def should_email(user, recipients = nil)
    expect(sent_to_user?(user, recipients)).to be_truthy
  end

  def should_not_email(user, recipients = nil)
    expect(sent_to_user?(user, recipients)).to be_falsey
  end

  def should_email_no_one
    expect(ActionMailer::Base.deliveries).to be_empty
  end
end<commit_msg>Introduce email_recipients and use include? Feedback:<commit_after>module EmailHelpers
  def sent_to_user?(user, recipients = email_recipients)
    recipients.include?(user.email)
  end

  def reset_delivered_emails!
    ActionMailer::Base.deliveries.clear
  end

  def should_only_email(*users)
    recipients = email_recipients

    users.each { |user| should_email(user, recipients) }

    expect(recipients.count).to eq(users.count)
  end

  def should_email(user, recipients = email_recipients)
    expect(sent_to_user?(user, recipients)).to be_truthy
  end

  def should_not_email(user, recipients = email_recipients)
    expect(sent_to_user?(user, recipients)).to be_falsey
  end

  def should_email_no_one
    expect(ActionMailer::Base.deliveries).to be_empty
  end

  def email_recipients
    ActionMailer::Base.deliveries.flat_map(&:to)
  end
end
{'fraction_non_alphanumeric': 0.09702850212249849, 'fraction_numerical': 0.0006064281382656155, 'mean_word_length': 4.7894736842105265, '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': '7531836', 'n_tokens_mistral': 590, 'n_tokens_neox': 558, 'n_words': 101}