rack-mail_exception 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (321) hide show
  1. data/.document +5 -0
  2. data/.gitignore +22 -0
  3. data/LICENSE +20 -0
  4. data/README.rdoc +38 -0
  5. data/Rakefile +56 -0
  6. data/VERSION +1 -0
  7. data/lib/rack/mail_exception.rb +103 -0
  8. data/test/helper.rb +13 -0
  9. data/test/test_rack_mail_exception.rb +93 -0
  10. data/vendor/mail/.bundle/config +2 -0
  11. data/vendor/mail/CHANGELOG.rdoc +370 -0
  12. data/vendor/mail/Dependencies.txt +3 -0
  13. data/vendor/mail/Gemfile +17 -0
  14. data/vendor/mail/README.rdoc +572 -0
  15. data/vendor/mail/ROADMAP +92 -0
  16. data/vendor/mail/Rakefile +41 -0
  17. data/vendor/mail/TODO.rdoc +9 -0
  18. data/vendor/mail/lib/mail.rb +76 -0
  19. data/vendor/mail/lib/mail/attachments_list.rb +99 -0
  20. data/vendor/mail/lib/mail/body.rb +287 -0
  21. data/vendor/mail/lib/mail/configuration.rb +67 -0
  22. data/vendor/mail/lib/mail/core_extensions/blank.rb +26 -0
  23. data/vendor/mail/lib/mail/core_extensions/nil.rb +11 -0
  24. data/vendor/mail/lib/mail/core_extensions/string.rb +27 -0
  25. data/vendor/mail/lib/mail/elements.rb +14 -0
  26. data/vendor/mail/lib/mail/elements/address.rb +306 -0
  27. data/vendor/mail/lib/mail/elements/address_list.rb +74 -0
  28. data/vendor/mail/lib/mail/elements/content_disposition_element.rb +30 -0
  29. data/vendor/mail/lib/mail/elements/content_location_element.rb +25 -0
  30. data/vendor/mail/lib/mail/elements/content_transfer_encoding_element.rb +24 -0
  31. data/vendor/mail/lib/mail/elements/content_type_element.rb +35 -0
  32. data/vendor/mail/lib/mail/elements/date_time_element.rb +26 -0
  33. data/vendor/mail/lib/mail/elements/envelope_from_element.rb +34 -0
  34. data/vendor/mail/lib/mail/elements/message_ids_element.rb +29 -0
  35. data/vendor/mail/lib/mail/elements/mime_version_element.rb +26 -0
  36. data/vendor/mail/lib/mail/elements/phrase_list.rb +21 -0
  37. data/vendor/mail/lib/mail/elements/received_element.rb +30 -0
  38. data/vendor/mail/lib/mail/encodings.rb +258 -0
  39. data/vendor/mail/lib/mail/encodings/7bit.rb +31 -0
  40. data/vendor/mail/lib/mail/encodings/8bit.rb +31 -0
  41. data/vendor/mail/lib/mail/encodings/base64.rb +33 -0
  42. data/vendor/mail/lib/mail/encodings/binary.rb +31 -0
  43. data/vendor/mail/lib/mail/encodings/quoted_printable.rb +38 -0
  44. data/vendor/mail/lib/mail/encodings/transfer_encoding.rb +58 -0
  45. data/vendor/mail/lib/mail/envelope.rb +35 -0
  46. data/vendor/mail/lib/mail/field.rb +223 -0
  47. data/vendor/mail/lib/mail/field_list.rb +33 -0
  48. data/vendor/mail/lib/mail/fields.rb +35 -0
  49. data/vendor/mail/lib/mail/fields/bcc_field.rb +56 -0
  50. data/vendor/mail/lib/mail/fields/cc_field.rb +55 -0
  51. data/vendor/mail/lib/mail/fields/comments_field.rb +41 -0
  52. data/vendor/mail/lib/mail/fields/common/address_container.rb +16 -0
  53. data/vendor/mail/lib/mail/fields/common/common_address.rb +125 -0
  54. data/vendor/mail/lib/mail/fields/common/common_date.rb +42 -0
  55. data/vendor/mail/lib/mail/fields/common/common_field.rb +50 -0
  56. data/vendor/mail/lib/mail/fields/common/common_message_id.rb +43 -0
  57. data/vendor/mail/lib/mail/fields/common/parameter_hash.rb +52 -0
  58. data/vendor/mail/lib/mail/fields/content_description_field.rb +19 -0
  59. data/vendor/mail/lib/mail/fields/content_disposition_field.rb +69 -0
  60. data/vendor/mail/lib/mail/fields/content_id_field.rb +63 -0
  61. data/vendor/mail/lib/mail/fields/content_location_field.rb +42 -0
  62. data/vendor/mail/lib/mail/fields/content_transfer_encoding_field.rb +50 -0
  63. data/vendor/mail/lib/mail/fields/content_type_field.rb +185 -0
  64. data/vendor/mail/lib/mail/fields/date_field.rb +55 -0
  65. data/vendor/mail/lib/mail/fields/from_field.rb +55 -0
  66. data/vendor/mail/lib/mail/fields/in_reply_to_field.rb +55 -0
  67. data/vendor/mail/lib/mail/fields/keywords_field.rb +44 -0
  68. data/vendor/mail/lib/mail/fields/message_id_field.rb +83 -0
  69. data/vendor/mail/lib/mail/fields/mime_version_field.rb +53 -0
  70. data/vendor/mail/lib/mail/fields/optional_field.rb +13 -0
  71. data/vendor/mail/lib/mail/fields/received_field.rb +67 -0
  72. data/vendor/mail/lib/mail/fields/references_field.rb +55 -0
  73. data/vendor/mail/lib/mail/fields/reply_to_field.rb +55 -0
  74. data/vendor/mail/lib/mail/fields/resent_bcc_field.rb +55 -0
  75. data/vendor/mail/lib/mail/fields/resent_cc_field.rb +55 -0
  76. data/vendor/mail/lib/mail/fields/resent_date_field.rb +35 -0
  77. data/vendor/mail/lib/mail/fields/resent_from_field.rb +55 -0
  78. data/vendor/mail/lib/mail/fields/resent_message_id_field.rb +34 -0
  79. data/vendor/mail/lib/mail/fields/resent_sender_field.rb +62 -0
  80. data/vendor/mail/lib/mail/fields/resent_to_field.rb +55 -0
  81. data/vendor/mail/lib/mail/fields/return_path_field.rb +64 -0
  82. data/vendor/mail/lib/mail/fields/sender_field.rb +67 -0
  83. data/vendor/mail/lib/mail/fields/structured_field.rb +51 -0
  84. data/vendor/mail/lib/mail/fields/subject_field.rb +16 -0
  85. data/vendor/mail/lib/mail/fields/to_field.rb +55 -0
  86. data/vendor/mail/lib/mail/fields/unstructured_field.rb +166 -0
  87. data/vendor/mail/lib/mail/header.rb +262 -0
  88. data/vendor/mail/lib/mail/mail.rb +234 -0
  89. data/vendor/mail/lib/mail/message.rb +1867 -0
  90. data/vendor/mail/lib/mail/network.rb +9 -0
  91. data/vendor/mail/lib/mail/network/delivery_methods/file_delivery.rb +40 -0
  92. data/vendor/mail/lib/mail/network/delivery_methods/sendmail.rb +62 -0
  93. data/vendor/mail/lib/mail/network/delivery_methods/smtp.rb +110 -0
  94. data/vendor/mail/lib/mail/network/delivery_methods/test_mailer.rb +40 -0
  95. data/vendor/mail/lib/mail/network/retriever_methods/imap.rb +18 -0
  96. data/vendor/mail/lib/mail/network/retriever_methods/pop3.rb +149 -0
  97. data/vendor/mail/lib/mail/parsers/address_lists.rb +64 -0
  98. data/vendor/mail/lib/mail/parsers/address_lists.treetop +19 -0
  99. data/vendor/mail/lib/mail/parsers/content_disposition.rb +387 -0
  100. data/vendor/mail/lib/mail/parsers/content_disposition.treetop +46 -0
  101. data/vendor/mail/lib/mail/parsers/content_location.rb +139 -0
  102. data/vendor/mail/lib/mail/parsers/content_location.treetop +20 -0
  103. data/vendor/mail/lib/mail/parsers/content_transfer_encoding.rb +162 -0
  104. data/vendor/mail/lib/mail/parsers/content_transfer_encoding.treetop +20 -0
  105. data/vendor/mail/lib/mail/parsers/content_type.rb +539 -0
  106. data/vendor/mail/lib/mail/parsers/content_type.treetop +58 -0
  107. data/vendor/mail/lib/mail/parsers/date_time.rb +114 -0
  108. data/vendor/mail/lib/mail/parsers/date_time.treetop +11 -0
  109. data/vendor/mail/lib/mail/parsers/envelope_from.rb +194 -0
  110. data/vendor/mail/lib/mail/parsers/envelope_from.treetop +32 -0
  111. data/vendor/mail/lib/mail/parsers/message_ids.rb +45 -0
  112. data/vendor/mail/lib/mail/parsers/message_ids.treetop +15 -0
  113. data/vendor/mail/lib/mail/parsers/mime_version.rb +144 -0
  114. data/vendor/mail/lib/mail/parsers/mime_version.treetop +19 -0
  115. data/vendor/mail/lib/mail/parsers/phrase_lists.rb +45 -0
  116. data/vendor/mail/lib/mail/parsers/phrase_lists.treetop +15 -0
  117. data/vendor/mail/lib/mail/parsers/received.rb +71 -0
  118. data/vendor/mail/lib/mail/parsers/received.treetop +11 -0
  119. data/vendor/mail/lib/mail/parsers/rfc2045.rb +464 -0
  120. data/vendor/mail/lib/mail/parsers/rfc2045.treetop +36 -0
  121. data/vendor/mail/lib/mail/parsers/rfc2822.rb +5318 -0
  122. data/vendor/mail/lib/mail/parsers/rfc2822.treetop +410 -0
  123. data/vendor/mail/lib/mail/parsers/rfc2822_obsolete.rb +3757 -0
  124. data/vendor/mail/lib/mail/parsers/rfc2822_obsolete.treetop +241 -0
  125. data/vendor/mail/lib/mail/part.rb +102 -0
  126. data/vendor/mail/lib/mail/parts_list.rb +34 -0
  127. data/vendor/mail/lib/mail/patterns.rb +30 -0
  128. data/vendor/mail/lib/mail/utilities.rb +181 -0
  129. data/vendor/mail/lib/mail/version.rb +10 -0
  130. data/vendor/mail/lib/mail/version_specific/ruby_1_8.rb +97 -0
  131. data/vendor/mail/lib/mail/version_specific/ruby_1_9.rb +87 -0
  132. data/vendor/mail/lib/tasks/corpus.rake +125 -0
  133. data/vendor/mail/lib/tasks/treetop.rake +10 -0
  134. data/vendor/mail/mail.gemspec +20 -0
  135. data/vendor/mail/reference/US ASCII Table.txt +130 -0
  136. data/vendor/mail/reference/rfc1035 Domain Implementation and Specification.txt +3083 -0
  137. data/vendor/mail/reference/rfc1049 Content-Type Header Field for Internet Messages.txt +451 -0
  138. data/vendor/mail/reference/rfc1344 Implications of MIME for Internet Mail Gateways.txt +586 -0
  139. data/vendor/mail/reference/rfc1345 Character Mnemonics & Character Sets.txt +5761 -0
  140. data/vendor/mail/reference/rfc1524 A User Agent Configuration Mechanism For Multimedia Mail Format Information.txt +675 -0
  141. data/vendor/mail/reference/rfc1652 SMTP Service Extension for 8bit-MIMEtransport.txt +339 -0
  142. data/vendor/mail/reference/rfc1892 Multipart Report .txt +227 -0
  143. data/vendor/mail/reference/rfc1893 Mail System Status Codes.txt +843 -0
  144. data/vendor/mail/reference/rfc2045 Multipurpose Internet Mail Extensions (1).txt +1739 -0
  145. data/vendor/mail/reference/rfc2046 Multipurpose Internet Mail Extensions (2).txt +2467 -0
  146. data/vendor/mail/reference/rfc2047 Multipurpose Internet Mail Extensions (3).txt +843 -0
  147. data/vendor/mail/reference/rfc2048 Multipurpose Internet Mail Extensions (4).txt +1180 -0
  148. data/vendor/mail/reference/rfc2049 Multipurpose Internet Mail Extensions (5).txt +1347 -0
  149. data/vendor/mail/reference/rfc2111 Content-ID and Message-ID URLs.txt +283 -0
  150. data/vendor/mail/reference/rfc2183 Content-Disposition Header Field.txt +675 -0
  151. data/vendor/mail/reference/rfc2231 MIME Parameter Value and Encoded Word Extensions.txt +563 -0
  152. data/vendor/mail/reference/rfc2387 MIME Multipart-Related Content-type.txt +563 -0
  153. data/vendor/mail/reference/rfc2821 Simple Mail Transfer Protocol.txt +3711 -0
  154. data/vendor/mail/reference/rfc2822 Internet Message Format.txt +2859 -0
  155. data/vendor/mail/reference/rfc3462 Reporting of Mail System Administrative Messages.txt +396 -0
  156. data/vendor/mail/reference/rfc3696 Checking and Transformation of Names.txt +898 -0
  157. data/vendor/mail/reference/rfc4155 The application-mbox Media Type.txt +502 -0
  158. data/vendor/mail/reference/rfc4234 Augmented BNF for Syntax Specifications: ABNF.txt +899 -0
  159. data/vendor/mail/reference/rfc822 Standard for the Format of ARPA Internet Text Messages.txt +2900 -0
  160. data/vendor/mail/spec/environment.rb +15 -0
  161. data/vendor/mail/spec/features/making_a_new_message.feature +14 -0
  162. data/vendor/mail/spec/features/steps/env.rb +6 -0
  163. data/vendor/mail/spec/features/steps/making_a_new_message_steps.rb +11 -0
  164. data/vendor/mail/spec/fixtures/attachments/basic_email.eml +31 -0
  165. data/vendor/mail/spec/fixtures/attachments/test.gif +0 -0
  166. data/vendor/mail/spec/fixtures/attachments/test.jpg +0 -0
  167. data/vendor/mail/spec/fixtures/attachments/test.pdf +0 -0
  168. data/vendor/mail/spec/fixtures/attachments/test.png +0 -0
  169. data/vendor/mail/spec/fixtures/attachments/test.tiff +0 -0
  170. data/vendor/mail/spec/fixtures/attachments/test.zip +0 -0
  171. data/vendor/mail/spec/fixtures/attachments//343/201/246/343/201/231/343/201/250.txt +2 -0
  172. data/vendor/mail/spec/fixtures/emails/attachment_emails/attachment_content_disposition.eml +29 -0
  173. data/vendor/mail/spec/fixtures/emails/attachment_emails/attachment_content_location.eml +32 -0
  174. data/vendor/mail/spec/fixtures/emails/attachment_emails/attachment_message_rfc822.eml +92 -0
  175. data/vendor/mail/spec/fixtures/emails/attachment_emails/attachment_only_email.eml +17 -0
  176. data/vendor/mail/spec/fixtures/emails/attachment_emails/attachment_pdf.eml +70 -0
  177. data/vendor/mail/spec/fixtures/emails/attachment_emails/attachment_with_encoded_name.eml +47 -0
  178. data/vendor/mail/spec/fixtures/emails/attachment_emails/attachment_with_quoted_filename.eml +60 -0
  179. data/vendor/mail/spec/fixtures/emails/error_emails/cant_parse_from.eml +33 -0
  180. data/vendor/mail/spec/fixtures/emails/error_emails/content_transfer_encoding_7-bit.eml +231 -0
  181. data/vendor/mail/spec/fixtures/emails/error_emails/content_transfer_encoding_empty.eml +33 -0
  182. data/vendor/mail/spec/fixtures/emails/error_emails/content_transfer_encoding_plain.eml +148 -0
  183. data/vendor/mail/spec/fixtures/emails/error_emails/content_transfer_encoding_qp_with_space.eml +53 -0
  184. data/vendor/mail/spec/fixtures/emails/error_emails/content_transfer_encoding_spam.eml +44 -0
  185. data/vendor/mail/spec/fixtures/emails/error_emails/content_transfer_encoding_text-html.eml +50 -0
  186. data/vendor/mail/spec/fixtures/emails/error_emails/content_transfer_encoding_with_8bits.eml +770 -0
  187. data/vendor/mail/spec/fixtures/emails/error_emails/content_transfer_encoding_with_semi_colon.eml +269 -0
  188. data/vendor/mail/spec/fixtures/emails/error_emails/content_transfer_encoding_x_uuencode.eml +79 -0
  189. data/vendor/mail/spec/fixtures/emails/error_emails/empty_group_lists.eml +162 -0
  190. data/vendor/mail/spec/fixtures/emails/error_emails/header_fields_with_empty_values.eml +33 -0
  191. data/vendor/mail/spec/fixtures/emails/error_emails/missing_body.eml +16 -0
  192. data/vendor/mail/spec/fixtures/emails/error_emails/missing_content_disposition.eml +43 -0
  193. data/vendor/mail/spec/fixtures/emails/error_emails/multiple_content_types.eml +25 -0
  194. data/vendor/mail/spec/fixtures/emails/mime_emails/raw_email11.eml +34 -0
  195. data/vendor/mail/spec/fixtures/emails/mime_emails/raw_email12.eml +32 -0
  196. data/vendor/mail/spec/fixtures/emails/mime_emails/raw_email2.eml +114 -0
  197. data/vendor/mail/spec/fixtures/emails/mime_emails/raw_email4.eml +59 -0
  198. data/vendor/mail/spec/fixtures/emails/mime_emails/raw_email7.eml +66 -0
  199. data/vendor/mail/spec/fixtures/emails/mime_emails/raw_email_encoded_stack_level_too_deep.eml +53 -0
  200. data/vendor/mail/spec/fixtures/emails/mime_emails/raw_email_with_illegal_boundary.eml +58 -0
  201. data/vendor/mail/spec/fixtures/emails/mime_emails/raw_email_with_mimepart_without_content_type.eml +94 -0
  202. data/vendor/mail/spec/fixtures/emails/mime_emails/raw_email_with_multipart_mixed_quoted_boundary.eml +50 -0
  203. data/vendor/mail/spec/fixtures/emails/mime_emails/raw_email_with_nested_attachment.eml +100 -0
  204. data/vendor/mail/spec/fixtures/emails/mime_emails/raw_email_with_quoted_illegal_boundary.eml +58 -0
  205. data/vendor/mail/spec/fixtures/emails/mime_emails/sig_only_email.eml +29 -0
  206. data/vendor/mail/spec/fixtures/emails/mime_emails/two_from_in_message.eml +42 -0
  207. data/vendor/mail/spec/fixtures/emails/multi_charset/japanese.eml +9 -0
  208. data/vendor/mail/spec/fixtures/emails/multi_charset/japanese_attachment.eml +27 -0
  209. data/vendor/mail/spec/fixtures/emails/multi_charset/japanese_attachment_long_name.eml +44 -0
  210. data/vendor/mail/spec/fixtures/emails/multipart_report_emails/multi_address_bounce1.eml +179 -0
  211. data/vendor/mail/spec/fixtures/emails/multipart_report_emails/multi_address_bounce2.eml +179 -0
  212. data/vendor/mail/spec/fixtures/emails/multipart_report_emails/report_422.eml +98 -0
  213. data/vendor/mail/spec/fixtures/emails/multipart_report_emails/report_530.eml +97 -0
  214. data/vendor/mail/spec/fixtures/emails/plain_emails/basic_email.eml +31 -0
  215. data/vendor/mail/spec/fixtures/emails/plain_emails/raw_email.eml +14 -0
  216. data/vendor/mail/spec/fixtures/emails/plain_emails/raw_email10.eml +20 -0
  217. data/vendor/mail/spec/fixtures/emails/plain_emails/raw_email5.eml +19 -0
  218. data/vendor/mail/spec/fixtures/emails/plain_emails/raw_email6.eml +20 -0
  219. data/vendor/mail/spec/fixtures/emails/plain_emails/raw_email8.eml +47 -0
  220. data/vendor/mail/spec/fixtures/emails/plain_emails/raw_email_bad_time.eml +62 -0
  221. data/vendor/mail/spec/fixtures/emails/plain_emails/raw_email_double_at_in_header.eml +14 -0
  222. data/vendor/mail/spec/fixtures/emails/plain_emails/raw_email_incorrect_header.eml +28 -0
  223. data/vendor/mail/spec/fixtures/emails/plain_emails/raw_email_multiple_from.eml +30 -0
  224. data/vendor/mail/spec/fixtures/emails/plain_emails/raw_email_quoted_with_0d0a.eml +14 -0
  225. data/vendor/mail/spec/fixtures/emails/plain_emails/raw_email_reply.eml +32 -0
  226. data/vendor/mail/spec/fixtures/emails/plain_emails/raw_email_simple.eml +11 -0
  227. data/vendor/mail/spec/fixtures/emails/plain_emails/raw_email_string_in_date_field.eml +17 -0
  228. data/vendor/mail/spec/fixtures/emails/plain_emails/raw_email_trailing_dot.eml +21 -0
  229. data/vendor/mail/spec/fixtures/emails/plain_emails/raw_email_with_bad_date.eml +48 -0
  230. data/vendor/mail/spec/fixtures/emails/plain_emails/raw_email_with_partially_quoted_subject.eml +14 -0
  231. data/vendor/mail/spec/fixtures/emails/rfc2822/example01.eml +8 -0
  232. data/vendor/mail/spec/fixtures/emails/rfc2822/example02.eml +9 -0
  233. data/vendor/mail/spec/fixtures/emails/rfc2822/example03.eml +7 -0
  234. data/vendor/mail/spec/fixtures/emails/rfc2822/example04.eml +7 -0
  235. data/vendor/mail/spec/fixtures/emails/rfc2822/example05.eml +8 -0
  236. data/vendor/mail/spec/fixtures/emails/rfc2822/example06.eml +10 -0
  237. data/vendor/mail/spec/fixtures/emails/rfc2822/example07.eml +9 -0
  238. data/vendor/mail/spec/fixtures/emails/rfc2822/example08.eml +12 -0
  239. data/vendor/mail/spec/fixtures/emails/rfc2822/example09.eml +15 -0
  240. data/vendor/mail/spec/fixtures/emails/rfc2822/example10.eml +15 -0
  241. data/vendor/mail/spec/fixtures/emails/rfc2822/example11.eml +6 -0
  242. data/vendor/mail/spec/fixtures/emails/rfc2822/example12.eml +8 -0
  243. data/vendor/mail/spec/fixtures/emails/rfc2822/example13.eml +10 -0
  244. data/vendor/mail/spec/fixtures/emails/sample_output_multipart +0 -0
  245. data/vendor/mail/spec/mail/attachments_list_spec.rb +214 -0
  246. data/vendor/mail/spec/mail/body_spec.rb +385 -0
  247. data/vendor/mail/spec/mail/configuration_spec.rb +19 -0
  248. data/vendor/mail/spec/mail/core_extensions/string_spec.rb +62 -0
  249. data/vendor/mail/spec/mail/core_extensions_spec.rb +99 -0
  250. data/vendor/mail/spec/mail/elements/address_list_spec.rb +109 -0
  251. data/vendor/mail/spec/mail/elements/address_spec.rb +609 -0
  252. data/vendor/mail/spec/mail/elements/date_time_element_spec.rb +20 -0
  253. data/vendor/mail/spec/mail/elements/envelope_from_element_spec.rb +31 -0
  254. data/vendor/mail/spec/mail/elements/message_ids_element_spec.rb +43 -0
  255. data/vendor/mail/spec/mail/elements/phrase_list_spec.rb +22 -0
  256. data/vendor/mail/spec/mail/elements/received_element_spec.rb +34 -0
  257. data/vendor/mail/spec/mail/encoding_spec.rb +189 -0
  258. data/vendor/mail/spec/mail/encodings/base64_spec.rb +25 -0
  259. data/vendor/mail/spec/mail/encodings/quoted_printable_spec.rb +25 -0
  260. data/vendor/mail/spec/mail/encodings_spec.rb +664 -0
  261. data/vendor/mail/spec/mail/example_emails_spec.rb +303 -0
  262. data/vendor/mail/spec/mail/field_list_spec.rb +33 -0
  263. data/vendor/mail/spec/mail/field_spec.rb +198 -0
  264. data/vendor/mail/spec/mail/fields/bcc_field_spec.rb +89 -0
  265. data/vendor/mail/spec/mail/fields/cc_field_spec.rb +79 -0
  266. data/vendor/mail/spec/mail/fields/comments_field_spec.rb +25 -0
  267. data/vendor/mail/spec/mail/fields/common/address_container_spec.rb +18 -0
  268. data/vendor/mail/spec/mail/fields/common/common_address_spec.rb +132 -0
  269. data/vendor/mail/spec/mail/fields/common/common_date_spec.rb +25 -0
  270. data/vendor/mail/spec/mail/fields/common/common_field_spec.rb +69 -0
  271. data/vendor/mail/spec/mail/fields/common/common_message_id_spec.rb +30 -0
  272. data/vendor/mail/spec/mail/fields/common/parameter_hash_spec.rb +56 -0
  273. data/vendor/mail/spec/mail/fields/content_description_field_spec.rb +39 -0
  274. data/vendor/mail/spec/mail/fields/content_disposition_field_spec.rb +55 -0
  275. data/vendor/mail/spec/mail/fields/content_id_field_spec.rb +117 -0
  276. data/vendor/mail/spec/mail/fields/content_location_field_spec.rb +46 -0
  277. data/vendor/mail/spec/mail/fields/content_transfer_encoding_field_spec.rb +113 -0
  278. data/vendor/mail/spec/mail/fields/content_type_field_spec.rb +678 -0
  279. data/vendor/mail/spec/mail/fields/date_field_spec.rb +73 -0
  280. data/vendor/mail/spec/mail/fields/envelope_spec.rb +48 -0
  281. data/vendor/mail/spec/mail/fields/from_field_spec.rb +89 -0
  282. data/vendor/mail/spec/mail/fields/in_reply_to_field_spec.rb +62 -0
  283. data/vendor/mail/spec/mail/fields/keywords_field_spec.rb +66 -0
  284. data/vendor/mail/spec/mail/fields/message_id_field_spec.rb +147 -0
  285. data/vendor/mail/spec/mail/fields/mime_version_field_spec.rb +166 -0
  286. data/vendor/mail/spec/mail/fields/received_field_spec.rb +44 -0
  287. data/vendor/mail/spec/mail/fields/references_field_spec.rb +35 -0
  288. data/vendor/mail/spec/mail/fields/reply_to_field_spec.rb +67 -0
  289. data/vendor/mail/spec/mail/fields/resent_bcc_field_spec.rb +66 -0
  290. data/vendor/mail/spec/mail/fields/resent_cc_field_spec.rb +66 -0
  291. data/vendor/mail/spec/mail/fields/resent_date_field_spec.rb +39 -0
  292. data/vendor/mail/spec/mail/fields/resent_from_field_spec.rb +66 -0
  293. data/vendor/mail/spec/mail/fields/resent_message_id_field_spec.rb +24 -0
  294. data/vendor/mail/spec/mail/fields/resent_sender_field_spec.rb +58 -0
  295. data/vendor/mail/spec/mail/fields/resent_to_field_spec.rb +66 -0
  296. data/vendor/mail/spec/mail/fields/return_path_field_spec.rb +52 -0
  297. data/vendor/mail/spec/mail/fields/sender_field_spec.rb +58 -0
  298. data/vendor/mail/spec/mail/fields/structured_field_spec.rb +72 -0
  299. data/vendor/mail/spec/mail/fields/to_field_spec.rb +92 -0
  300. data/vendor/mail/spec/mail/fields/unstructured_field_spec.rb +134 -0
  301. data/vendor/mail/spec/mail/header_spec.rb +578 -0
  302. data/vendor/mail/spec/mail/mail_spec.rb +34 -0
  303. data/vendor/mail/spec/mail/message_spec.rb +1409 -0
  304. data/vendor/mail/spec/mail/mime_messages_spec.rb +435 -0
  305. data/vendor/mail/spec/mail/multipart_report_spec.rb +112 -0
  306. data/vendor/mail/spec/mail/network/delivery_methods/file_delivery_spec.rb +79 -0
  307. data/vendor/mail/spec/mail/network/delivery_methods/sendmail_spec.rb +125 -0
  308. data/vendor/mail/spec/mail/network/delivery_methods/smtp_spec.rb +133 -0
  309. data/vendor/mail/spec/mail/network/delivery_methods/test_mailer_spec.rb +57 -0
  310. data/vendor/mail/spec/mail/network/retriever_methods/pop3_spec.rb +180 -0
  311. data/vendor/mail/spec/mail/network_spec.rb +359 -0
  312. data/vendor/mail/spec/mail/parsers/address_lists_parser_spec.rb +15 -0
  313. data/vendor/mail/spec/mail/parsers/content_transfer_encoding_parser_spec.rb +72 -0
  314. data/vendor/mail/spec/mail/part_spec.rb +129 -0
  315. data/vendor/mail/spec/mail/parts_list_spec.rb +12 -0
  316. data/vendor/mail/spec/mail/round_tripping_spec.rb +44 -0
  317. data/vendor/mail/spec/mail/utilities_spec.rb +327 -0
  318. data/vendor/mail/spec/mail/version_specific/escape_paren_1_8_spec.rb +32 -0
  319. data/vendor/mail/spec/matchers/break_down_to.rb +35 -0
  320. data/vendor/mail/spec/spec_helper.rb +163 -0
  321. metadata +442 -0
@@ -0,0 +1,303 @@
1
+ # encoding: utf-8
2
+ require 'spec_helper'
3
+
4
+ describe "Test emails" do
5
+
6
+ describe "from RFC2822" do
7
+
8
+ # From RFC 2822:
9
+ # This could be called a canonical message. It has a single author,
10
+ # John Doe, a single recipient, Mary Smith, a subject, the date, a
11
+ # message identifier, and a textual message in the body.
12
+ it "should handle the basic test email" do
13
+ mail = Mail.read(fixture('emails', 'rfc2822', 'example01.eml'))
14
+ mail.from.should == ["jdoe@machine.example"]
15
+ mail.to.should == ['mary@example.net']
16
+ mail.message_id.should == '1234@local.machine.example'
17
+ mail.date.should == ::DateTime.parse('21 Nov 1997 09:55:06 -0600')
18
+ mail.subject.should == 'Saying Hello'
19
+ end
20
+
21
+ # From RFC 2822:
22
+ # If John's secretary Michael actually sent the message, though John
23
+ # was the author and replies to this message should go back to him, the
24
+ # sender field would be used:
25
+ it "should handle the sender test email" do
26
+ mail = Mail.read(fixture('emails', 'rfc2822', 'example02.eml'))
27
+ mail.from.should == ['jdoe@machine.example']
28
+ mail.sender.should == 'mjones@machine.example'
29
+ mail.to.should == ['mary@example.net']
30
+ mail.message_id.should == '1234@local.machine.example'
31
+ mail.date.should == ::DateTime.parse('21 Nov 1997 09:55:06 -0600')
32
+ mail.subject.should == 'Saying Hello'
33
+ end
34
+
35
+ # From RFC 2822:
36
+ # This message includes multiple addresses in the destination fields
37
+ # and also uses several different forms of addresses.
38
+ #
39
+ # Note that the display names for Joe Q. Public and Giant; "Big" Box
40
+ # needed to be enclosed in double-quotes because the former contains
41
+ # the period and the latter contains both semicolon and double-quote
42
+ # characters (the double-quote characters appearing as quoted-pair
43
+ # construct). Conversely, the display name for Who? could appear
44
+ # without them because the question mark is legal in an atom. Notice
45
+ # also that jdoe@example.org and boss@nil.test have no display names
46
+ # associated with them at all, and jdoe@example.org uses the simpler
47
+ # address form without the angle brackets.
48
+ #
49
+ # "Giant; \"Big\" Box" <sysservices@example.net>
50
+ it "should handle multiple recipients test email" do
51
+ mail = Mail.read(fixture('emails', 'rfc2822', 'example03.eml'))
52
+ mail.from.should == ['john.q.public@example.com']
53
+ mail.to.should == ['mary@x.test', 'jdoe@example.org', 'one@y.test']
54
+ mail.cc.should == ['boss@nil.test', "sysservices@example.net"]
55
+ mail.message_id.should == '5678.21-Nov-1997@example.com'
56
+ mail.date.should == ::DateTime.parse('1 Jul 2003 10:52:37 +0200')
57
+ end
58
+
59
+ # From RFC 2822:
60
+ # A.1.3. Group addresses
61
+ # In this message, the "To:" field has a single group recipient named A
62
+ # Group which contains 3 addresses, and a "Cc:" field with an empty
63
+ # group recipient named Undisclosed recipients.
64
+ it "should handle group address email test" do
65
+ mail = Mail.read(fixture('emails', 'rfc2822', 'example04.eml'))
66
+ mail.from.should == ['pete@silly.example']
67
+ mail.to.should == ['c@a.test', 'joe@where.test', 'jdoe@one.test']
68
+ mail[:cc].group_names.should == ['Undisclosed recipients']
69
+ mail.message_id.should == 'testabcd.1234@silly.example'
70
+ mail.date.should == ::DateTime.parse('Thu, 13 Feb 1969 23:32:54 -0330')
71
+ end
72
+
73
+
74
+ # From RFC 2822:
75
+ # A.2. Reply messages
76
+ # The following is a series of three messages that make up a
77
+ # conversation thread between John and Mary. John firsts sends a
78
+ # message to Mary, Mary then replies to John's message, and then John
79
+ # replies to Mary's reply message.
80
+ #
81
+ # Note especially the "Message-ID:", "References:", and "In-Reply-To:"
82
+ # fields in each message.
83
+ it "should handle reply messages" do
84
+ mail = Mail.read(fixture('emails', 'rfc2822', 'example05.eml'))
85
+ mail.from.should == ["jdoe@machine.example"]
86
+ mail.to.should == ['mary@example.net']
87
+ mail.subject.should == 'Saying Hello'
88
+ mail.message_id.should == '1234@local.machine.example'
89
+ mail.date.should == ::DateTime.parse('Fri, 21 Nov 1997 09:55:06 -0600')
90
+ end
91
+
92
+ # From RFC 2822:
93
+ # When sending replies, the Subject field is often retained, though
94
+ # prepended with "Re: " as described in section 3.6.5.
95
+ # Note the "Reply-To:" field in the below message. When John replies
96
+ # to Mary's message above, the reply should go to the address in the
97
+ # "Reply-To:" field instead of the address in the "From:" field.
98
+ it "should handle reply message 2" do
99
+ mail = Mail.read(fixture('emails', 'rfc2822', 'example06.eml'))
100
+ mail.from.should == ['mary@example.net']
101
+ mail.to.should == ['jdoe@machine.example']
102
+ mail.reply_to.should == ['smith@home.example']
103
+ mail.subject.should == 'Re: Saying Hello'
104
+ mail.message_id.should == '3456@example.net'
105
+ mail[:in_reply_to].message_ids.should == ['1234@local.machine.example']
106
+ mail[:references].message_ids.should == ['1234@local.machine.example']
107
+ mail.date.should == ::DateTime.parse('Fri, 21 Nov 1997 10:01:10 -0600')
108
+ end
109
+
110
+ # From RFC 2822:
111
+ # Final reply message
112
+ it "should handle the final reply message" do
113
+ mail = Mail.read(fixture('emails', 'rfc2822', 'example07.eml'))
114
+ mail.to.should == ['smith@home.example']
115
+ mail.from.should == ['jdoe@machine.example']
116
+ mail.subject.should == 'Re: Saying Hello'
117
+ mail.date.should == ::DateTime.parse('Fri, 21 Nov 1997 11:00:00 -0600')
118
+ mail.message_id.should == 'abcd.1234@local.machine.tld'
119
+ mail.in_reply_to.should == '3456@example.net'
120
+ mail[:references].message_ids.should == ['1234@local.machine.example', '3456@example.net']
121
+ end
122
+
123
+ # From RFC2822
124
+ # A.3. Resent messages
125
+ # Say that Mary, upon receiving this message, wishes to send a copy of
126
+ # the message to Jane such that (a) the message would appear to have
127
+ # come straight from John; (b) if Jane replies to the message, the
128
+ # reply should go back to John; and (c) all of the original
129
+ # information, like the date the message was originally sent to Mary,
130
+ # the message identifier, and the original addressee, is preserved. In
131
+ # this case, resent fields are prepended to the message:
132
+ #
133
+ # If Jane, in turn, wished to resend this message to another person,
134
+ # she would prepend her own set of resent header fields to the above
135
+ # and send that.
136
+ it "should handle the rfc resent example email" do
137
+ mail = Mail.read(fixture('emails', 'rfc2822', 'example08.eml'))
138
+ mail.resent_from.should == ['mary@example.net']
139
+ mail.resent_to.should == ['j-brown@other.example']
140
+ mail.resent_date.should == ::DateTime.parse('Mon, 24 Nov 1997 14:22:01 -0800')
141
+ mail.resent_message_id.should == '78910@example.net'
142
+ mail.from.should == ['jdoe@machine.example']
143
+ mail.to.should == ['mary@example.net']
144
+ mail.subject.should == 'Saying Hello'
145
+ mail.date.should == ::DateTime.parse('Fri, 21 Nov 1997 09:55:06 -0600')
146
+ mail.message_id.should == '1234@local.machine.example'
147
+ end
148
+
149
+ # A.4. Messages with trace fields
150
+ # As messages are sent through the transport system as described in
151
+ # [RFC2821], trace fields are prepended to the message. The following
152
+ # is an example of what those trace fields might look like. Note that
153
+ # there is some folding white space in the first one since these lines
154
+ # can be long.
155
+ it "should handle the RFC trace example email" do
156
+ mail = Mail.read(fixture('emails', 'rfc2822', 'example09.eml'))
157
+ mail.received[0].info.should == 'from x.y.test by example.net via TCP with ESMTP id ABC12345 for <mary@example.net>'
158
+ mail.received[0].date_time.should == ::DateTime.parse('21 Nov 1997 10:05:43 -0600')
159
+ mail.received[1].info.should == 'from machine.example by x.y.test'
160
+ mail.received[1].date_time.should == ::DateTime.parse('21 Nov 1997 10:01:22 -0600')
161
+ mail.from.should == ['jdoe@machine.example']
162
+ mail.to.should == ['mary@example.net']
163
+ mail.subject.should == 'Saying Hello'
164
+ mail.date.should == ::DateTime.parse('Fri, 21 Nov 1997 09:55:06 -0600')
165
+ mail.message_id.should == '1234@local.machine.example'
166
+ end
167
+
168
+ # A.5. White space, comments, and other oddities
169
+ # White space, including folding white space, and comments can be
170
+ # inserted between many of the tokens of fields. Taking the example
171
+ # from A.1.3, white space and comments can be inserted into all of the
172
+ # fields.
173
+ #
174
+ # The below example is aesthetically displeasing, but perfectly legal.
175
+ # Note particularly (1) the comments in the "From:" field (including
176
+ # one that has a ")" character appearing as part of a quoted-pair); (2)
177
+ # the white space absent after the ":" in the "To:" field as well as
178
+ # the comment and folding white space after the group name, the special
179
+ # character (".") in the comment in Chris Jones's address, and the
180
+ # folding white space before and after "joe@example.org,"; (3) the
181
+ # multiple and nested comments in the "Cc:" field as well as the
182
+ # comment immediately following the ":" after "Cc"; (4) the folding
183
+ # white space (but no comments except at the end) and the missing
184
+ # seconds in the time of the date field; and (5) the white space before
185
+ # (but not within) the identifier in the "Message-ID:" field.
186
+
187
+ it "should handle the rfc whitespace test email" do
188
+ mail = Mail.read(fixture('emails', 'rfc2822', 'example10.eml'))
189
+ mail.from.should == ["pete(his account)@silly.test"]
190
+ mail.to.should == ["c@(Chris's host.)public.example", "joe@example.org", "jdoe@one.test"]
191
+ mail[:cc].group_names.should == ['(Empty list)(start)Undisclosed recipients ']
192
+ mail.date.should == ::DateTime.parse('Thu, 13 Feb 1969 23:32 -0330')
193
+ mail.message_id.should == 'testabcd.1234@silly.test'
194
+ end
195
+
196
+ # A.6. Obsoleted forms
197
+ # The following are examples of obsolete (that is, the "MUST NOT
198
+ # generate") syntactic elements described in section 4 of this
199
+ # document.
200
+ # A.6.1. Obsolete addressing
201
+ # Note in the below example the lack of quotes around Joe Q. Public,
202
+ # the route that appears in the address for Mary Smith, the two commas
203
+ # that appear in the "To:" field, and the spaces that appear around the
204
+ # "." in the jdoe address.
205
+ it "should handle the rfc obsolete addressing" do
206
+ pending
207
+ mail = Mail.read(fixture('emails', 'rfc2822', 'example11.eml'))
208
+ mail[:from].addresses.should == ['john.q.public@example.com']
209
+ mail.from.should == '"Joe Q. Public" <john.q.public@example.com>'
210
+ mail.to.should == ["@machine.tld:mary@example.net", 'jdoe@test.example']
211
+ mail.date.should == ::DateTime.parse('Tue, 1 Jul 2003 10:52:37 +0200')
212
+ mail.message_id.should == '5678.21-Nov-1997@example.com'
213
+ end
214
+
215
+ # A.6.2. Obsolete dates
216
+ #
217
+ # The following message uses an obsolete date format, including a non-
218
+ # numeric time zone and a two digit year. Note that although the
219
+ # day-of-week is missing, that is not specific to the obsolete syntax;
220
+ # it is optional in the current syntax as well.
221
+ it "should handle the rfc obsolete dates" do
222
+ pending
223
+ mail = Mail.read(fixture('emails', 'rfc2822', 'example12.eml'))
224
+ mail.from.should == 'jdoe@machine.example'
225
+ mail.to.should == 'mary@example.net'
226
+ mail.date.should == ::DateTime.parse('21 Nov 97 09:55:06 GMT')
227
+ mail.message_id.should == '1234@local.machine.example'
228
+ end
229
+
230
+ # A.6.3. Obsolete white space and comments
231
+ #
232
+ # White space and comments can appear between many more elements than
233
+ # in the current syntax. Also, folding lines that are made up entirely
234
+ # of white space are legal.
235
+ #
236
+ # Note especially the second line of the "To:" field. It starts with
237
+ # two space characters. (Note that "__" represent blank spaces.)
238
+ # Therefore, it is considered part of the folding as described in
239
+ # section 4.2. Also, the comments and white space throughout
240
+ # addresses, dates, and message identifiers are all part of the
241
+ # obsolete syntax.
242
+ it "should handle the rfc obsolete whitespace email" do
243
+ pending
244
+ mail = Mail.read(fixture('emails', 'rfc2822', 'example13.eml'))
245
+ mail.from.should == 'John Doe <jdoe@machine(comment).example>'
246
+ mail.to.should == 'Mary Smith <mary@example.net>'
247
+ mail.date.should == ::DateTime.parse('Fri, 21 Nov 1997 09:55:06 -0600')
248
+ mail.message_id.should == '1234@local(blah).machine.example'
249
+ doing { Mail::Message.new(email) }.should_not raise_error
250
+ end
251
+
252
+ end
253
+
254
+ describe "from the wild" do
255
+
256
+ describe "raw_email_encoded_stack_level_too_deep.eml" do
257
+ before(:each) do
258
+ @message = Mail::Message.new(File.read(fixture('emails', 'mime_emails', 'raw_email_encoded_stack_level_too_deep.eml')))
259
+ end
260
+
261
+ it "should return an 'encoded' version without raising a SystemStackError" do
262
+ doing { @message.encoded }.should_not raise_error
263
+ end
264
+
265
+ it "should have two parts" do
266
+ @message.parts.length.should == 2
267
+ end
268
+
269
+ end
270
+
271
+ describe "sig_only_email.eml" do
272
+ before(:each) do
273
+ @message = Mail::Message.new(File.read(fixture('emails', 'mime_emails', 'sig_only_email.eml')))
274
+ end
275
+
276
+ it "should not error on multiart/signed emails" do
277
+ doing { @message.encoded }.should_not raise_error
278
+ end
279
+
280
+ it "should have one attachment called signature.asc" do
281
+ @message.attachments.length.should == 1
282
+ @message.attachments.first.filename.should == 'signature.asc'
283
+ end
284
+
285
+ end
286
+
287
+ describe "handling invalid group lists" do
288
+ before(:each) do
289
+ @message = Mail::Message.new(File.read(fixture('emails', 'error_emails', 'empty_group_lists.eml')))
290
+ end
291
+
292
+ it "should parse the email and encode without crashing" do
293
+ doing { @message.encoded }.should_not raise_error
294
+ end
295
+
296
+ it "should return an empty groups list" do
297
+ @message[:to].group_addresses.should == []
298
+ end
299
+ end
300
+
301
+ end
302
+
303
+ end
@@ -0,0 +1,33 @@
1
+ require 'spec_helper'
2
+
3
+ describe Mail::FieldList do
4
+ it "should be able to add new fields" do
5
+ fl = Mail::FieldList.new
6
+ fl << Mail::Field.new("To: mikel@me.com")
7
+ fl << Mail::Field.new("From: mikel@me.com")
8
+ fl.length.should == 2
9
+ end
10
+
11
+ it "should be able to add new fields in the right order" do
12
+ fl = Mail::FieldList.new
13
+ fl << Mail::Field.new("To: mikel@me.com")
14
+ fl << Mail::Field.new("From: mikel@me.com")
15
+ fl << Mail::Field.new("Received: from xxx.xxxx.xxx by xxx.xxxx.xxx with ESMTP id 6AAEE3B4D23 for <xxx@xxxx.xxx>; Sun, 8 May 2005 12:30:23 -0500")
16
+ fl << Mail::Field.new("Return-Path: mikel@me.com")
17
+ fl[0].field.class.should == Mail::ReturnPathField
18
+ fl[1].field.class.should == Mail::ReceivedField
19
+ fl[2].field.class.should == Mail::FromField
20
+ fl[3].field.class.should == Mail::ToField
21
+ end
22
+
23
+ it "should add new Received items after the existing ones" do
24
+ fl = Mail::FieldList.new
25
+ fl << Mail::Field.new("To: mikel@me.com")
26
+ fl << Mail::Field.new("From: mikel@me.com")
27
+ fl << Mail::Field.new("Received: from xxx.xxxx.xxx by xxx.xxxx.xxx with ESMTP id 6AAEE3B4D23 for <xxx@xxxx.xxx>; Sun, 8 May 2005 12:30:23 -0500")
28
+ fl << Mail::Field.new("Return-Path: mikel@me.com")
29
+ fl << Mail::Field.new("Received: from 123.xxxx.xxx by xxx.xxxx.xxx with ESMTP id 6AAEE3B4D23 for <xxx@xxxx.xxx>; Sun, 8 May 2005 12:30:23 -0500")
30
+ fl[2].field.value.should == 'from 123.xxxx.xxx by xxx.xxxx.xxx with ESMTP id 6AAEE3B4D23 for <xxx@xxxx.xxx>; Sun, 8 May 2005 12:30:23 -0500'
31
+ end
32
+
33
+ end
@@ -0,0 +1,198 @@
1
+ # encoding: utf-8
2
+ require 'spec_helper'
3
+
4
+ describe Mail::Field do
5
+
6
+ describe "initialization" do
7
+
8
+ it "should be instantiated" do
9
+ doing {Mail::Field.new('To: Mikel')}.should_not raise_error
10
+ Mail::Field.new('To: Mikel').field.class.should == Mail::ToField
11
+ end
12
+
13
+ it "should allow you to init on an array" do
14
+ field = Mail::Field.new("To", ['test1@lindsaar.net', 'Mikel <test2@lindsaar.net>'])
15
+ field.addresses.should == ["test1@lindsaar.net", "test2@lindsaar.net"]
16
+ end
17
+
18
+ it "should allow us to pass an empty value" do
19
+ doing {Mail::Field.new('To')}.should_not raise_error
20
+ Mail::Field.new('To').field.class.should == Mail::ToField
21
+ end
22
+
23
+ it "should allow us to pass a value" do
24
+ doing {Mail::Field.new('To', 'Mikel')}.should_not raise_error
25
+ Mail::Field.new('To', 'Mikel').field.class.should == Mail::ToField
26
+ end
27
+
28
+ it "should match up fields to class names" do
29
+ structured_fields = %w[ Date From Sender Reply-To To Cc Bcc Message-ID In-Reply-To
30
+ References Keywords Resent-Date Resent-From Resent-Sender
31
+ Resent-To Resent-Cc Resent-Bcc Resent-Message-ID
32
+ Return-Path Received Subject Comments Mime-Version
33
+ Content-Transfer-Encoding Content-Description
34
+ Content-Disposition Content-Type ]
35
+ structured_fields.each do |sf|
36
+ words = sf.split("-").map { |a| a.capitalize }
37
+ klass = "#{words.join}Field"
38
+ Mail::Field.new("#{sf}: ").field.class.should == Mail.const_get(klass)
39
+ end
40
+ end
41
+
42
+ it "should match up fields to class names regardless of case" do
43
+ structured_fields = %w[ dATE fROM sENDER REPLY-TO TO CC BCC MESSAGE-ID IN-REPLY-TO
44
+ REFERENCES KEYWORDS resent-date resent-from rESENT-sENDER
45
+ rESENT-tO rESent-cc resent-bcc reSent-MESSAGE-iD
46
+ rEtURN-pAtH rEcEiVeD Subject Comments Mime-VeRSIOn
47
+ cOntenT-transfer-EnCoDiNg Content-Description
48
+ Content-Disposition cOnTENt-TyPe ]
49
+ structured_fields.each do |sf|
50
+ words = sf.split("-").map { |a| a.capitalize }
51
+ klass = "#{words.join}Field"
52
+ Mail::Field.new("#{sf}: ").field.class.should == Mail.const_get(klass)
53
+ end
54
+ end
55
+
56
+ it "should say anything that is not a known field is an optional field" do
57
+ unstructured_fields = %w[ Too Becc bccc Random X-Mail MySpecialField ]
58
+ unstructured_fields.each do |sf|
59
+ Mail::Field.new("#{sf}: Value").field.class.should == Mail::OptionalField
60
+ end
61
+ end
62
+
63
+ it "should split the name and values out of the raw field passed in" do
64
+ field = Mail::Field.new('To: Bob')
65
+ field.name.should == 'To'
66
+ field.value.should == 'Bob'
67
+ end
68
+
69
+ it "should split the name and values out of the raw field passed in if missing whitespace" do
70
+ field = Mail::Field.new('To:Bob')
71
+ field.name.should == 'To'
72
+ field.value.should == 'Bob'
73
+ end
74
+
75
+ it "should split the name and values out of the raw field passed in if having added inapplicable whitespace" do
76
+ field = Mail::Field.new('To : Bob ')
77
+ field.name.should == 'To'
78
+ field.value.should == 'Bob'
79
+ end
80
+
81
+ it "should return an unstuctured field if the structured field parsing raises an error" do
82
+ Mail::ToField.should_receive(:new).and_raise(Mail::Field::ParseError)
83
+ field = Mail::Field.new('To: Bob, ,,, Frank, Smith')
84
+ field.field.class.should == Mail::UnstructuredField
85
+ field.name.should == 'To'
86
+ field.value.should == 'Bob, ,,, Frank, Smith'
87
+ end
88
+
89
+ it "should call to_s on it's field when sent to_s" do
90
+ @field = Mail::SubjectField.new('Subject: Hello bob')
91
+ Mail::SubjectField.should_receive(:new).and_return(@field)
92
+ @field.should_receive(:to_s).once
93
+ Mail::Field.new('Subject: Hello bob').to_s
94
+ end
95
+
96
+ it "should pass missing methods to it's instantiated field class" do
97
+ field = Mail::Field.new('To: Bob')
98
+ field.field.should_receive(:addresses).once
99
+ field.addresses
100
+ end
101
+
102
+ it "should change it's type if you change the name" do
103
+ field = Mail::Field.new("To: mikel@me.com")
104
+ field.field.class.should == Mail::ToField
105
+ field.value = "bob@me.com"
106
+ field.field.class.should == Mail::ToField
107
+ end
108
+
109
+ it "should create a field without trying to parse if given a symbol" do
110
+ field = Mail::Field.new('Message-ID')
111
+ field.field.class.should == Mail::MessageIdField
112
+ end
113
+
114
+ end
115
+
116
+ describe "error handling" do
117
+ it "should populate the errors array if it finds a field it can't deal with" do
118
+ field = Mail::Field.new('Content-Transfer-Encoding: bit')
119
+ field.field.errors[0][0].should == 'Content-Transfer-Encoding'
120
+ field.field.errors[0][1].should == 'bit'
121
+ field.field.errors[0][2].to_s.should =~ /ContentTransferEncodingElement can not parse |17-bit|/
122
+ end
123
+ end
124
+
125
+ describe "helper methods" do
126
+ it "should reply if it is responsible for a field name as a capitalized string - structured field" do
127
+ field = Mail::Field.new("To: mikel@test.lindsaar.net")
128
+ field.responsible_for?("To").should be_true
129
+ end
130
+
131
+ it "should reply if it is responsible for a field as a lower case string - structured field" do
132
+ field = Mail::Field.new("To: mikel@test.lindsaar.net")
133
+ field.responsible_for?("to").should be_true
134
+ end
135
+
136
+ it "should reply if it is responsible for a field as a symbol - structured field" do
137
+ field = Mail::Field.new("To: mikel@test.lindsaar.net")
138
+ field.responsible_for?(:to).should be_true
139
+ end
140
+
141
+ it "should say it is == to another if their field names match" do
142
+ Mail::Field.new("To: mikel").same(Mail::Field.new("To: bob")).should be_true
143
+ end
144
+
145
+ it "should say it is not == to another if their field names do not match" do
146
+ Mail::Field.new("From: mikel").should_not == Mail::Field.new("To: bob")
147
+ end
148
+
149
+ it "should sort according to the field order" do
150
+ list = [Mail::Field.new("To: mikel"), Mail::Field.new("Return-Path: bob")]
151
+ list.sort[0].name.should == "Return-Path"
152
+ end
153
+
154
+ end
155
+
156
+ describe "passing an encoding" do
157
+ it "should allow you to send in unencoded strings to fields and encode them" do
158
+ subject = Mail::SubjectField.new("This is あ string", 'utf-8')
159
+ subject.encoded.should == "Subject: This =?UTF-8?Q?is_=E3=81=82=?= string\r\n"
160
+ subject.decoded.should == "This is あ string"
161
+ end
162
+
163
+ it "should allow you to send in unencoded strings to address fields and encode them" do
164
+ to = Mail::ToField.new('"Mikel Lindsああr" <mikel@test.lindsaar.net>', 'utf-8')
165
+ to.encoded.should == "To: =?UTF-8?B?TWlrZWwgTGluZHPjgYLjgYJy?= <mikel@test.lindsaar.net>\r\n"
166
+ end
167
+
168
+ it "should allow you to send in unencoded strings without quotes to address fields and encode them" do
169
+ to = Mail::ToField.new('Mikel Lindsああr <mikel@test.lindsaar.net>', 'utf-8')
170
+ to.encoded.should == "To: Mikel =?UTF-8?B?TGluZHPjgYLjgYJy?= <mikel@test.lindsaar.net>\r\n"
171
+ end
172
+
173
+ it "should allow you to send in unencoded strings to address fields and encode them" do
174
+ to = Mail::ToField.new("あdあ <ada@test.lindsaar.net>", 'utf-8')
175
+ to.encoded.should == "To: =?UTF-8?B?44GCZOOBgg==?= <ada@test.lindsaar.net>\r\n"
176
+ end
177
+
178
+ it "should allow you to send in multiple unencoded strings to address fields and encode them" do
179
+ to = Mail::ToField.new(["Mikel Lindsああr <mikel@test.lindsaar.net>", "あdあ <ada@test.lindsaar.net>"], 'utf-8')
180
+ to.encoded.should == "To: Mikel =?UTF-8?B?TGluZHPjgYLjgYJy?= <mikel@test.lindsaar.net>, \r\n\t=?UTF-8?B?44GCZOOBgg==?= <ada@test.lindsaar.net>\r\n"
181
+ end
182
+
183
+ it "should allow you to send in multiple unencoded strings to any address field" do
184
+ mail = Mail.new
185
+ mail.charset = 'utf-8'
186
+ array = ["Mikel Lindsああr <mikel@test.lindsaar.net>", "あdあ <ada@test.lindsaar.net>"]
187
+ field = Mail::ToField.new(array, 'utf-8')
188
+ field.encoded.should == "#{Mail::ToField::CAPITALIZED_FIELD}: Mikel =?UTF-8?B?TGluZHPjgYLjgYJy?= <mikel@test.lindsaar.net>, \r\n\t=?UTF-8?B?44GCZOOBgg==?= <ada@test.lindsaar.net>\r\n"
189
+ field = Mail::FromField.new(array, 'utf-8')
190
+ field.encoded.should == "#{Mail::FromField::CAPITALIZED_FIELD}: Mikel =?UTF-8?B?TGluZHPjgYLjgYJy?= <mikel@test.lindsaar.net>, \r\n\t=?UTF-8?B?44GCZOOBgg==?= <ada@test.lindsaar.net>\r\n"
191
+ field = Mail::CcField.new(array, 'utf-8')
192
+ field.encoded.should == "#{Mail::CcField::CAPITALIZED_FIELD}: Mikel =?UTF-8?B?TGluZHPjgYLjgYJy?= <mikel@test.lindsaar.net>, \r\n\t=?UTF-8?B?44GCZOOBgg==?= <ada@test.lindsaar.net>\r\n"
193
+ field = Mail::ReplyToField.new(array, 'utf-8')
194
+ field.encoded.should == "#{Mail::ReplyToField::CAPITALIZED_FIELD}: Mikel =?UTF-8?B?TGluZHPjgYLjgYJy?= <mikel@test.lindsaar.net>, \r\n\t=?UTF-8?B?44GCZOOBgg==?= <ada@test.lindsaar.net>\r\n"
195
+ end
196
+ end
197
+
198
+ end