Sha256: 6ed2a72417ea2b3cbdb1bdd2661e5725f84697f956bad2ff22b188814f030e38

Contents?: true

Size: 1.71 KB

Versions: 3

Compression:

Stored size: 1.71 KB

Contents

require 'spec_helper'

module Log2mail

  describe ReportFactory do

    subject { ReportFactory.new( build(:valid_config) ) }
    before do

    end

    describe '.reports_from_hit' do
      subject { ReportFactory.new( build(:valid_config) ).reports_from_hit( build(:hit) ) }
      it { is_expected.to be_kind_of(Array) }
      it { is_expected.to all( be_kind_of(Log2mail::Report) ) }
    end

  end

  describe Report do
    describe '#body_from_template' do
      subject { build(:report).send(:body_from_template) }
      it 'should parse the template' do
        expect(subject).to eql(<<-EOS)
From: log2mail
To: recipient@example.org
Subject: matched your pattern: string match

Hello!

We have matched your pattern "string match" in "test.log" %n times:

a line with string match in it

Yours,
log2mail.
        EOS
      end
    end
    describe '#deliver' do
      include Mail::Matchers
      subject { build(:report).deliver }
      it { should have_sent_email }
      # it 'should send the message' do
      #   expect(subject.deliver).to change{Mail::TestMailer.deliveries.length}.by(1)
      # end
    end
    describe '#sendmail_command=' do
      let(:report){ build(:report) }
      it 'parses the sendmail command string with parameters' do
        report.sendmail_command = "/usr/local/sbin/sendmail -oi -t"
        expect(report.sendmail_location).to eql('/usr/local/sbin/sendmail')
        expect(report.sendmail_arguments).to eql('-oi -t')
      end
      it 'parses the sendmail command string without' do
        report.sendmail_command = "/usr/local/sbin/sendmail"
        expect(report.sendmail_location).to eql('/usr/local/sbin/sendmail')
        expect(report.sendmail_arguments).to be(nil)
      end
    end
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
log2mail-0.0.1.pre4 spec/log2mail/report_spec.rb
log2mail-0.0.1.pre3 spec/log2mail/report_spec.rb
log2mail-0.0.1.pre2 spec/log2mail/report_spec.rb