Class: IMAPToRSS::TestCase

Inherits:
MiniTest::Unit::TestCase
  • Object
show all
Defined in:
lib/imap_to_rss/test_case.rb

Overview

Test case for IMAPToRSS handlers

Instance Method Summary collapse

Instance Method Details

#setup(handler) ⇒ Object

Sets this test case up with handler. Provides instance variables @itor and @handler



27
28
29
30
31
# File 'lib/imap_to_rss/test_case.rb', line 27

def setup(handler)
  @itor = IMAPToRSS.new
  @handler = handler
  @handler.setup @itor
end

#util_mail(options = {}) ⇒ Object

Returns a new TMail::Mail from options. Defaults are:

from

[email protected]

date

Time.at 0

to

[email protected]

subject

subject for this mail

body

Hi! I’m a body!

The mail body will be normalized to rn line breaks.



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/imap_to_rss/test_case.rb', line 44

def util_mail(options = {})
  options = {
    :from => '[email protected]',
    :date => Time.at(0),
    :to => '[email protected]',
    :subject => 'subject for this mail',
    :body => 'Hi! I\'m a body!'
  }.merge options

  body = options[:body].split(/\r?\n/).join "\r\n"

  TMail::Mail.parse <<-MAIL
From: #{options[:from]}\r
Date: #{options[:date].rfc2822}\r
To: #{options[:to]}\r
Subject: #{options[:subject]}\r
\r
#{body}
  MAIL
end