9 class TestMBoxParsing < 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"]
78 h = MBox.read_header StringIO.new("")
79 assert_equal nil, h["Message-Id"]
82 def test_empty_headers
88 h = MBox.read_header StringIO.new(s)
89 assert_equal "", h["Message-Id"]
93 def test_detect_end_of_headers
94 h = MBox.read_header StringIO.new(<<EOS)
95 From: Bob <bob@bob.com>
99 assert_equal "Bob <bob@bob.com>", h["From"]
102 h = MBox.read_header StringIO.new(<<EOS)
103 From: Bob <bob@bob.com>
107 assert_equal "Bob <bob@bob.com>", h["From"]
110 h = MBox.read_header StringIO.new(<<EOS)
111 From: Bob <bob@bob.com>
115 assert_equal "Bob <bob@bob.com>", h["From"]