9 class TestMessage < Test::Unit::TestCase
16 def test_normal_headers
17 h = MBox.read_header StringIO.new(<<EOS)
18 From: Bob <bob@bob.com>
19 To: Sally <sally@sally.com>
22 assert_equal "Bob <bob@bob.com>", h["From"]
23 assert_equal "Sally <sally@sally.com>", h["To"]
24 assert_nil h["Message-Id"]
27 ## this is shitty behavior in retrospect, but it's built in now.
28 def test_message_id_stripping
29 h = MBox.read_header StringIO.new("Message-Id: <one@bob.com>\n")
30 assert_equal "one@bob.com", h["Message-Id"]
32 h = MBox.read_header StringIO.new("Message-Id: one@bob.com\n")
33 assert_equal "one@bob.com", h["Message-Id"]
37 h = MBox.read_header StringIO.new(<<EOS)
38 From: Bob <bob@bob.com>
39 Subject: one two three
41 To: Sally <sally@sally.com>
47 assert_equal "one two three four five six", h["Subject"]
48 assert_equal "Sally <sally@sally.com>", h["To"]
49 assert_equal "seven eight", h["References"]
52 def test_ignore_spacing
54 "Subject:one two three end\n",
55 "Subject: one two three end\n",
56 "Subject: one two three end \n",
59 h = MBox.read_header StringIO.new(s)
60 assert_equal "one two three end", h["Subject"]
64 def test_message_id_ignore_spacing
66 "Message-Id: <one@bob.com> \n",
67 "Message-Id: one@bob.com \n",
68 "Message-Id:<one@bob.com> \n",
69 "Message-Id:one@bob.com \n",
72 h = MBox.read_header StringIO.new(s)
73 assert_equal "one@bob.com", h["Message-Id"]
77 def test_ignore_empty_lines
84 h = MBox.read_header StringIO.new(s)
85 assert_nil h["Message-Id"]
89 def test_detect_end_of_headers
90 h = MBox.read_header StringIO.new(<<EOS)
91 From: Bob <bob@bob.com>
95 assert_equal "Bob <bob@bob.com>", h["From"]
98 h = MBox.read_header StringIO.new(<<EOS)
99 From: Bob <bob@bob.com>
103 assert_equal "Bob <bob@bob.com>", h["From"]
106 h = MBox.read_header StringIO.new(<<EOS)
107 From: Bob <bob@bob.com>
111 assert_equal "Bob <bob@bob.com>", h["From"]