Sha256: 7dbe7af9bda68d024401cf2079d202ebda961fee9cc7d517082a1100bcdbb947

Contents?: true

Size: 1.96 KB

Versions: 9

Compression:

Stored size: 1.96 KB

Contents

require File.expand_path(File.dirname(__FILE__) + '/spec_helper')

describe MultiMail do
  describe '#setup' do
    before :all do
      MultiMail.setup do |config|
        config.autoresponse_pattern = /^Out of Office AutoReply:/i
      end
    end

    it 'should set the autoresponse pattern' do
      MultiMail.autoresponse_pattern.should == /^Out of Office AutoReply:/i
    end
  end

  describe '#autoresponse?' do
    before :each do
      @message = Mail.new
    end

    it 'should return false if the message is not an autoresponse' do
      MultiMail.autoresponse?(@message).should == false
    end

    it 'should return true if an autoresponder header is found' do
      @message['X-Autogenerated'] = 'value'
      MultiMail.autoresponse?(@message).should == true
    end

    it 'should return true if an autoresponder value is found' do
      @message['Return-Path'] = '<>'
      MultiMail.autoresponse?(@message).should == true
    end

    it 'should return true if Auto-Submitted is not "no"' do
      @message['Auto-Submitted'] = 'auto-replied'
      MultiMail.autoresponse?(@message).should == true
    end

    it 'should return false if Auto-Submitted is "no"' do
      @message['Auto-Submitted'] = 'no'
      MultiMail.autoresponse?(@message).should == false
    end

    context 'without an autoresponse pattern' do
      before :all do
        MultiMail.autoresponse_pattern = nil
      end

      it 'should not match the subject against the autoresponse pattern' do
        @message.subject = 'Out of Office AutoReply: Subject'
        MultiMail.autoresponse?(@message).should == false
      end
    end

    context 'with an autoresponse pattern' do
      before :all do
        MultiMail.autoresponse_pattern = /^Out of Office AutoReply:/i
      end

      it 'should return true if the subject matches the autoresponse pattern' do
        @message.subject = 'Out of Office AutoReply: Subject'
        MultiMail.autoresponse?(@message).should == true
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
multi_mail-0.1.7 spec/multi_mail_spec.rb
multi_mail-0.1.6 spec/multi_mail_spec.rb
multi_mail-0.1.5 spec/multi_mail_spec.rb
multi_mail-0.1.4 spec/multi_mail_spec.rb
multi_mail-0.1.3 spec/multi_mail_spec.rb
multi_mail-0.1.2 spec/multi_mail_spec.rb
multi_mail-0.1.1 spec/multi_mail_spec.rb
multi_mail-0.1.0 spec/multi_mail_spec.rb
multi_mail-0.0.2 spec/multi_mail_spec.rb