<commit_before>require "rails_helper"

RSpec.describe TaskMailer, type: :mailer do
  fixtures :tasks, :responsibilities

  describe "when task has turns" do

    let(:task)  { tasks(:weekly) }

    it "should build the email" do
      email = TaskMailer.notification(task)

      expect(email.to).to match_array(task.turns.first.emails)
      expect(email.cc).to include(task.email)
      expect(email.subject).to include(task.turns.first.groups.first.name)
      expect(email.text_part.body.to_s).to include(task.turns.first.groups.first.name)
    end
  end

  describe "when task has no turns" do

    let(:task)  { tasks(:monthly) }

    it "should build the email" do
      email = TaskMailer.notification(task)

      expect(email.to).to include(task.email)
      expect(email.subject).to eq(task.notification_subject)
      expect(email.text_part.body.to_s).to include(task.notification_body)
    end
  end
end
<commit_msg>Split task_mailer expectations in their own examples<commit_after>require "rails_helper"

RSpec.describe TaskMailer, type: :mailer do
  fixtures :tasks, :responsibilities

  describe "when task has turns" do

    let(:task)  { tasks(:weekly) }
    let(:email) { TaskMailer.notification(task) }

    it 'the email has the valid TO' do
      expect(email.to).to match_array(task.turns.first.emails)
    end

    it 'the email has the valid CC' do
      expect(email.cc).to include(task.email)
    end

    it 'the email has the valid subject' do
      expect(email.subject).to include(task.turns.first.groups.first.name)
    end

    it 'the email has the valid text_part' do
      expect(email.text_part.body.to_s)
        .to include(task.turns.first.groups.first.name)
    end
  end

  describe "when task has no turns" do

    let(:task)  { tasks(:monthly) }
    let(:email) { TaskMailer.notification(task) }

    it 'the email has the valid TO' do
      expect(email.to).to include(task.email)
    end

    it 'the email has the valid subject' do
      expect(email.subject).to eq(task.notification_subject)
    end

    it 'the email has the valid text_part' do
      expect(email.text_part.body.to_s).to include(task.notification_body)
    end
  end
end

{'fraction_non_alphanumeric': 0.10603290676416818, 'fraction_numerical': 0.0, 'mean_word_length': 3.242248062015504, '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': '4717419', 'n_tokens_mistral': 725, 'n_tokens_neox': 701, 'n_words': 180}