<commit_before>require 'spec_helper'

describe Tricle::Mailer do

  describe '#email' do
    def deliver
      TestMailer.email.deliver
      ActionMailer::Base.deliveries.length.should eq(1)
    end

    let(:message) { ActionMailer::Base.deliveries.last }

    it "should respect all the options in the 'default hash'" do
      deliver
      message.to.should eq(['<EMAIL>', '<EMAIL>'])
      message.from.should eq(['<EMAIL>'])
    end

    it "should set the subject based on the class name" do
      deliver
      message.subject.should eq("Your Test Mailer")
    end

    it "should include the values from the Report in the HTML part" do
      deliver
      source = message.html_part.body.to_s
      source.should include('Test Metric')
      source.should match(/\b62\b/) # last week
      source.should match(/\b787\b/) # total
    end

    it "should link to the Issues page in the text part" do
      deliver<commit_msg>add test for Tricle::Mailer.send_all - fixes #16<commit_after>require 'spec_helper'

describe Tricle::Mailer do
  describe ".send_all" do
    it "should .deliver all defined mailers" do
      Tricle::Mailer.send_all
      ActionMailer::Base.deliveries.length.should eq(1)
    end
  end

  describe '#email' do
    def deliver
      TestMailer.email.deliver
      ActionMailer::Base.deliveries.length.should eq(1)
    end

    let(:message) { ActionMailer::Base.deliveries.last }

    it "should respect all the options in the 'default hash'" do
      deliver
      message.to.should eq(['<EMAIL>', '<EMAIL>'])
      message.from.should eq(['<EMAIL>'])
    end

    it "should set the subject based on the class name" do
      deliver
      message.subject.should eq("Your Test Mailer")
    end

    it "should include the values from the Report in the HTML part" do
      deliver
      source = message.html_part.body.to_s
      source.should include('Test Metric')
      source.should match(/\b62\b/) # last week
      source.should match(/\b787\b/) # total
    end

    it "should link to the Issues page in the text part" do
      deliver
{'fraction_non_alphanumeric': 0.10082006753497347, 'fraction_numerical': 0.00723589001447178, 'mean_word_length': 2.7572463768115942, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '7617299', 'n_tokens_mistral': 645, 'n_tokens_neox': 636, 'n_words': 201}