rack-mail_exception 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.document +5 -0
- data/.gitignore +22 -0
- data/LICENSE +20 -0
- data/README.rdoc +38 -0
- data/Rakefile +56 -0
- data/VERSION +1 -0
- data/lib/rack/mail_exception.rb +103 -0
- data/test/helper.rb +13 -0
- data/test/test_rack_mail_exception.rb +93 -0
- data/vendor/mail/.bundle/config +2 -0
- data/vendor/mail/CHANGELOG.rdoc +370 -0
- data/vendor/mail/Dependencies.txt +3 -0
- data/vendor/mail/Gemfile +17 -0
- data/vendor/mail/README.rdoc +572 -0
- data/vendor/mail/ROADMAP +92 -0
- data/vendor/mail/Rakefile +41 -0
- data/vendor/mail/TODO.rdoc +9 -0
- data/vendor/mail/lib/mail.rb +76 -0
- data/vendor/mail/lib/mail/attachments_list.rb +99 -0
- data/vendor/mail/lib/mail/body.rb +287 -0
- data/vendor/mail/lib/mail/configuration.rb +67 -0
- data/vendor/mail/lib/mail/core_extensions/blank.rb +26 -0
- data/vendor/mail/lib/mail/core_extensions/nil.rb +11 -0
- data/vendor/mail/lib/mail/core_extensions/string.rb +27 -0
- data/vendor/mail/lib/mail/elements.rb +14 -0
- data/vendor/mail/lib/mail/elements/address.rb +306 -0
- data/vendor/mail/lib/mail/elements/address_list.rb +74 -0
- data/vendor/mail/lib/mail/elements/content_disposition_element.rb +30 -0
- data/vendor/mail/lib/mail/elements/content_location_element.rb +25 -0
- data/vendor/mail/lib/mail/elements/content_transfer_encoding_element.rb +24 -0
- data/vendor/mail/lib/mail/elements/content_type_element.rb +35 -0
- data/vendor/mail/lib/mail/elements/date_time_element.rb +26 -0
- data/vendor/mail/lib/mail/elements/envelope_from_element.rb +34 -0
- data/vendor/mail/lib/mail/elements/message_ids_element.rb +29 -0
- data/vendor/mail/lib/mail/elements/mime_version_element.rb +26 -0
- data/vendor/mail/lib/mail/elements/phrase_list.rb +21 -0
- data/vendor/mail/lib/mail/elements/received_element.rb +30 -0
- data/vendor/mail/lib/mail/encodings.rb +258 -0
- data/vendor/mail/lib/mail/encodings/7bit.rb +31 -0
- data/vendor/mail/lib/mail/encodings/8bit.rb +31 -0
- data/vendor/mail/lib/mail/encodings/base64.rb +33 -0
- data/vendor/mail/lib/mail/encodings/binary.rb +31 -0
- data/vendor/mail/lib/mail/encodings/quoted_printable.rb +38 -0
- data/vendor/mail/lib/mail/encodings/transfer_encoding.rb +58 -0
- data/vendor/mail/lib/mail/envelope.rb +35 -0
- data/vendor/mail/lib/mail/field.rb +223 -0
- data/vendor/mail/lib/mail/field_list.rb +33 -0
- data/vendor/mail/lib/mail/fields.rb +35 -0
- data/vendor/mail/lib/mail/fields/bcc_field.rb +56 -0
- data/vendor/mail/lib/mail/fields/cc_field.rb +55 -0
- data/vendor/mail/lib/mail/fields/comments_field.rb +41 -0
- data/vendor/mail/lib/mail/fields/common/address_container.rb +16 -0
- data/vendor/mail/lib/mail/fields/common/common_address.rb +125 -0
- data/vendor/mail/lib/mail/fields/common/common_date.rb +42 -0
- data/vendor/mail/lib/mail/fields/common/common_field.rb +50 -0
- data/vendor/mail/lib/mail/fields/common/common_message_id.rb +43 -0
- data/vendor/mail/lib/mail/fields/common/parameter_hash.rb +52 -0
- data/vendor/mail/lib/mail/fields/content_description_field.rb +19 -0
- data/vendor/mail/lib/mail/fields/content_disposition_field.rb +69 -0
- data/vendor/mail/lib/mail/fields/content_id_field.rb +63 -0
- data/vendor/mail/lib/mail/fields/content_location_field.rb +42 -0
- data/vendor/mail/lib/mail/fields/content_transfer_encoding_field.rb +50 -0
- data/vendor/mail/lib/mail/fields/content_type_field.rb +185 -0
- data/vendor/mail/lib/mail/fields/date_field.rb +55 -0
- data/vendor/mail/lib/mail/fields/from_field.rb +55 -0
- data/vendor/mail/lib/mail/fields/in_reply_to_field.rb +55 -0
- data/vendor/mail/lib/mail/fields/keywords_field.rb +44 -0
- data/vendor/mail/lib/mail/fields/message_id_field.rb +83 -0
- data/vendor/mail/lib/mail/fields/mime_version_field.rb +53 -0
- data/vendor/mail/lib/mail/fields/optional_field.rb +13 -0
- data/vendor/mail/lib/mail/fields/received_field.rb +67 -0
- data/vendor/mail/lib/mail/fields/references_field.rb +55 -0
- data/vendor/mail/lib/mail/fields/reply_to_field.rb +55 -0
- data/vendor/mail/lib/mail/fields/resent_bcc_field.rb +55 -0
- data/vendor/mail/lib/mail/fields/resent_cc_field.rb +55 -0
- data/vendor/mail/lib/mail/fields/resent_date_field.rb +35 -0
- data/vendor/mail/lib/mail/fields/resent_from_field.rb +55 -0
- data/vendor/mail/lib/mail/fields/resent_message_id_field.rb +34 -0
- data/vendor/mail/lib/mail/fields/resent_sender_field.rb +62 -0
- data/vendor/mail/lib/mail/fields/resent_to_field.rb +55 -0
- data/vendor/mail/lib/mail/fields/return_path_field.rb +64 -0
- data/vendor/mail/lib/mail/fields/sender_field.rb +67 -0
- data/vendor/mail/lib/mail/fields/structured_field.rb +51 -0
- data/vendor/mail/lib/mail/fields/subject_field.rb +16 -0
- data/vendor/mail/lib/mail/fields/to_field.rb +55 -0
- data/vendor/mail/lib/mail/fields/unstructured_field.rb +166 -0
- data/vendor/mail/lib/mail/header.rb +262 -0
- data/vendor/mail/lib/mail/mail.rb +234 -0
- data/vendor/mail/lib/mail/message.rb +1867 -0
- data/vendor/mail/lib/mail/network.rb +9 -0
- data/vendor/mail/lib/mail/network/delivery_methods/file_delivery.rb +40 -0
- data/vendor/mail/lib/mail/network/delivery_methods/sendmail.rb +62 -0
- data/vendor/mail/lib/mail/network/delivery_methods/smtp.rb +110 -0
- data/vendor/mail/lib/mail/network/delivery_methods/test_mailer.rb +40 -0
- data/vendor/mail/lib/mail/network/retriever_methods/imap.rb +18 -0
- data/vendor/mail/lib/mail/network/retriever_methods/pop3.rb +149 -0
- data/vendor/mail/lib/mail/parsers/address_lists.rb +64 -0
- data/vendor/mail/lib/mail/parsers/address_lists.treetop +19 -0
- data/vendor/mail/lib/mail/parsers/content_disposition.rb +387 -0
- data/vendor/mail/lib/mail/parsers/content_disposition.treetop +46 -0
- data/vendor/mail/lib/mail/parsers/content_location.rb +139 -0
- data/vendor/mail/lib/mail/parsers/content_location.treetop +20 -0
- data/vendor/mail/lib/mail/parsers/content_transfer_encoding.rb +162 -0
- data/vendor/mail/lib/mail/parsers/content_transfer_encoding.treetop +20 -0
- data/vendor/mail/lib/mail/parsers/content_type.rb +539 -0
- data/vendor/mail/lib/mail/parsers/content_type.treetop +58 -0
- data/vendor/mail/lib/mail/parsers/date_time.rb +114 -0
- data/vendor/mail/lib/mail/parsers/date_time.treetop +11 -0
- data/vendor/mail/lib/mail/parsers/envelope_from.rb +194 -0
- data/vendor/mail/lib/mail/parsers/envelope_from.treetop +32 -0
- data/vendor/mail/lib/mail/parsers/message_ids.rb +45 -0
- data/vendor/mail/lib/mail/parsers/message_ids.treetop +15 -0
- data/vendor/mail/lib/mail/parsers/mime_version.rb +144 -0
- data/vendor/mail/lib/mail/parsers/mime_version.treetop +19 -0
- data/vendor/mail/lib/mail/parsers/phrase_lists.rb +45 -0
- data/vendor/mail/lib/mail/parsers/phrase_lists.treetop +15 -0
- data/vendor/mail/lib/mail/parsers/received.rb +71 -0
- data/vendor/mail/lib/mail/parsers/received.treetop +11 -0
- data/vendor/mail/lib/mail/parsers/rfc2045.rb +464 -0
- data/vendor/mail/lib/mail/parsers/rfc2045.treetop +36 -0
- data/vendor/mail/lib/mail/parsers/rfc2822.rb +5318 -0
- data/vendor/mail/lib/mail/parsers/rfc2822.treetop +410 -0
- data/vendor/mail/lib/mail/parsers/rfc2822_obsolete.rb +3757 -0
- data/vendor/mail/lib/mail/parsers/rfc2822_obsolete.treetop +241 -0
- data/vendor/mail/lib/mail/part.rb +102 -0
- data/vendor/mail/lib/mail/parts_list.rb +34 -0
- data/vendor/mail/lib/mail/patterns.rb +30 -0
- data/vendor/mail/lib/mail/utilities.rb +181 -0
- data/vendor/mail/lib/mail/version.rb +10 -0
- data/vendor/mail/lib/mail/version_specific/ruby_1_8.rb +97 -0
- data/vendor/mail/lib/mail/version_specific/ruby_1_9.rb +87 -0
- data/vendor/mail/lib/tasks/corpus.rake +125 -0
- data/vendor/mail/lib/tasks/treetop.rake +10 -0
- data/vendor/mail/mail.gemspec +20 -0
- data/vendor/mail/reference/US ASCII Table.txt +130 -0
- data/vendor/mail/reference/rfc1035 Domain Implementation and Specification.txt +3083 -0
- data/vendor/mail/reference/rfc1049 Content-Type Header Field for Internet Messages.txt +451 -0
- data/vendor/mail/reference/rfc1344 Implications of MIME for Internet Mail Gateways.txt +586 -0
- data/vendor/mail/reference/rfc1345 Character Mnemonics & Character Sets.txt +5761 -0
- data/vendor/mail/reference/rfc1524 A User Agent Configuration Mechanism For Multimedia Mail Format Information.txt +675 -0
- data/vendor/mail/reference/rfc1652 SMTP Service Extension for 8bit-MIMEtransport.txt +339 -0
- data/vendor/mail/reference/rfc1892 Multipart Report .txt +227 -0
- data/vendor/mail/reference/rfc1893 Mail System Status Codes.txt +843 -0
- data/vendor/mail/reference/rfc2045 Multipurpose Internet Mail Extensions (1).txt +1739 -0
- data/vendor/mail/reference/rfc2046 Multipurpose Internet Mail Extensions (2).txt +2467 -0
- data/vendor/mail/reference/rfc2047 Multipurpose Internet Mail Extensions (3).txt +843 -0
- data/vendor/mail/reference/rfc2048 Multipurpose Internet Mail Extensions (4).txt +1180 -0
- data/vendor/mail/reference/rfc2049 Multipurpose Internet Mail Extensions (5).txt +1347 -0
- data/vendor/mail/reference/rfc2111 Content-ID and Message-ID URLs.txt +283 -0
- data/vendor/mail/reference/rfc2183 Content-Disposition Header Field.txt +675 -0
- data/vendor/mail/reference/rfc2231 MIME Parameter Value and Encoded Word Extensions.txt +563 -0
- data/vendor/mail/reference/rfc2387 MIME Multipart-Related Content-type.txt +563 -0
- data/vendor/mail/reference/rfc2821 Simple Mail Transfer Protocol.txt +3711 -0
- data/vendor/mail/reference/rfc2822 Internet Message Format.txt +2859 -0
- data/vendor/mail/reference/rfc3462 Reporting of Mail System Administrative Messages.txt +396 -0
- data/vendor/mail/reference/rfc3696 Checking and Transformation of Names.txt +898 -0
- data/vendor/mail/reference/rfc4155 The application-mbox Media Type.txt +502 -0
- data/vendor/mail/reference/rfc4234 Augmented BNF for Syntax Specifications: ABNF.txt +899 -0
- data/vendor/mail/reference/rfc822 Standard for the Format of ARPA Internet Text Messages.txt +2900 -0
- data/vendor/mail/spec/environment.rb +15 -0
- data/vendor/mail/spec/features/making_a_new_message.feature +14 -0
- data/vendor/mail/spec/features/steps/env.rb +6 -0
- data/vendor/mail/spec/features/steps/making_a_new_message_steps.rb +11 -0
- data/vendor/mail/spec/fixtures/attachments/basic_email.eml +31 -0
- data/vendor/mail/spec/fixtures/attachments/test.gif +0 -0
- data/vendor/mail/spec/fixtures/attachments/test.jpg +0 -0
- data/vendor/mail/spec/fixtures/attachments/test.pdf +0 -0
- data/vendor/mail/spec/fixtures/attachments/test.png +0 -0
- data/vendor/mail/spec/fixtures/attachments/test.tiff +0 -0
- data/vendor/mail/spec/fixtures/attachments/test.zip +0 -0
- data/vendor/mail/spec/fixtures/attachments//343/201/246/343/201/231/343/201/250.txt +2 -0
- data/vendor/mail/spec/fixtures/emails/attachment_emails/attachment_content_disposition.eml +29 -0
- data/vendor/mail/spec/fixtures/emails/attachment_emails/attachment_content_location.eml +32 -0
- data/vendor/mail/spec/fixtures/emails/attachment_emails/attachment_message_rfc822.eml +92 -0
- data/vendor/mail/spec/fixtures/emails/attachment_emails/attachment_only_email.eml +17 -0
- data/vendor/mail/spec/fixtures/emails/attachment_emails/attachment_pdf.eml +70 -0
- data/vendor/mail/spec/fixtures/emails/attachment_emails/attachment_with_encoded_name.eml +47 -0
- data/vendor/mail/spec/fixtures/emails/attachment_emails/attachment_with_quoted_filename.eml +60 -0
- data/vendor/mail/spec/fixtures/emails/error_emails/cant_parse_from.eml +33 -0
- data/vendor/mail/spec/fixtures/emails/error_emails/content_transfer_encoding_7-bit.eml +231 -0
- data/vendor/mail/spec/fixtures/emails/error_emails/content_transfer_encoding_empty.eml +33 -0
- data/vendor/mail/spec/fixtures/emails/error_emails/content_transfer_encoding_plain.eml +148 -0
- data/vendor/mail/spec/fixtures/emails/error_emails/content_transfer_encoding_qp_with_space.eml +53 -0
- data/vendor/mail/spec/fixtures/emails/error_emails/content_transfer_encoding_spam.eml +44 -0
- data/vendor/mail/spec/fixtures/emails/error_emails/content_transfer_encoding_text-html.eml +50 -0
- data/vendor/mail/spec/fixtures/emails/error_emails/content_transfer_encoding_with_8bits.eml +770 -0
- data/vendor/mail/spec/fixtures/emails/error_emails/content_transfer_encoding_with_semi_colon.eml +269 -0
- data/vendor/mail/spec/fixtures/emails/error_emails/content_transfer_encoding_x_uuencode.eml +79 -0
- data/vendor/mail/spec/fixtures/emails/error_emails/empty_group_lists.eml +162 -0
- data/vendor/mail/spec/fixtures/emails/error_emails/header_fields_with_empty_values.eml +33 -0
- data/vendor/mail/spec/fixtures/emails/error_emails/missing_body.eml +16 -0
- data/vendor/mail/spec/fixtures/emails/error_emails/missing_content_disposition.eml +43 -0
- data/vendor/mail/spec/fixtures/emails/error_emails/multiple_content_types.eml +25 -0
- data/vendor/mail/spec/fixtures/emails/mime_emails/raw_email11.eml +34 -0
- data/vendor/mail/spec/fixtures/emails/mime_emails/raw_email12.eml +32 -0
- data/vendor/mail/spec/fixtures/emails/mime_emails/raw_email2.eml +114 -0
- data/vendor/mail/spec/fixtures/emails/mime_emails/raw_email4.eml +59 -0
- data/vendor/mail/spec/fixtures/emails/mime_emails/raw_email7.eml +66 -0
- data/vendor/mail/spec/fixtures/emails/mime_emails/raw_email_encoded_stack_level_too_deep.eml +53 -0
- data/vendor/mail/spec/fixtures/emails/mime_emails/raw_email_with_illegal_boundary.eml +58 -0
- data/vendor/mail/spec/fixtures/emails/mime_emails/raw_email_with_mimepart_without_content_type.eml +94 -0
- data/vendor/mail/spec/fixtures/emails/mime_emails/raw_email_with_multipart_mixed_quoted_boundary.eml +50 -0
- data/vendor/mail/spec/fixtures/emails/mime_emails/raw_email_with_nested_attachment.eml +100 -0
- data/vendor/mail/spec/fixtures/emails/mime_emails/raw_email_with_quoted_illegal_boundary.eml +58 -0
- data/vendor/mail/spec/fixtures/emails/mime_emails/sig_only_email.eml +29 -0
- data/vendor/mail/spec/fixtures/emails/mime_emails/two_from_in_message.eml +42 -0
- data/vendor/mail/spec/fixtures/emails/multi_charset/japanese.eml +9 -0
- data/vendor/mail/spec/fixtures/emails/multi_charset/japanese_attachment.eml +27 -0
- data/vendor/mail/spec/fixtures/emails/multi_charset/japanese_attachment_long_name.eml +44 -0
- data/vendor/mail/spec/fixtures/emails/multipart_report_emails/multi_address_bounce1.eml +179 -0
- data/vendor/mail/spec/fixtures/emails/multipart_report_emails/multi_address_bounce2.eml +179 -0
- data/vendor/mail/spec/fixtures/emails/multipart_report_emails/report_422.eml +98 -0
- data/vendor/mail/spec/fixtures/emails/multipart_report_emails/report_530.eml +97 -0
- data/vendor/mail/spec/fixtures/emails/plain_emails/basic_email.eml +31 -0
- data/vendor/mail/spec/fixtures/emails/plain_emails/raw_email.eml +14 -0
- data/vendor/mail/spec/fixtures/emails/plain_emails/raw_email10.eml +20 -0
- data/vendor/mail/spec/fixtures/emails/plain_emails/raw_email5.eml +19 -0
- data/vendor/mail/spec/fixtures/emails/plain_emails/raw_email6.eml +20 -0
- data/vendor/mail/spec/fixtures/emails/plain_emails/raw_email8.eml +47 -0
- data/vendor/mail/spec/fixtures/emails/plain_emails/raw_email_bad_time.eml +62 -0
- data/vendor/mail/spec/fixtures/emails/plain_emails/raw_email_double_at_in_header.eml +14 -0
- data/vendor/mail/spec/fixtures/emails/plain_emails/raw_email_incorrect_header.eml +28 -0
- data/vendor/mail/spec/fixtures/emails/plain_emails/raw_email_multiple_from.eml +30 -0
- data/vendor/mail/spec/fixtures/emails/plain_emails/raw_email_quoted_with_0d0a.eml +14 -0
- data/vendor/mail/spec/fixtures/emails/plain_emails/raw_email_reply.eml +32 -0
- data/vendor/mail/spec/fixtures/emails/plain_emails/raw_email_simple.eml +11 -0
- data/vendor/mail/spec/fixtures/emails/plain_emails/raw_email_string_in_date_field.eml +17 -0
- data/vendor/mail/spec/fixtures/emails/plain_emails/raw_email_trailing_dot.eml +21 -0
- data/vendor/mail/spec/fixtures/emails/plain_emails/raw_email_with_bad_date.eml +48 -0
- data/vendor/mail/spec/fixtures/emails/plain_emails/raw_email_with_partially_quoted_subject.eml +14 -0
- data/vendor/mail/spec/fixtures/emails/rfc2822/example01.eml +8 -0
- data/vendor/mail/spec/fixtures/emails/rfc2822/example02.eml +9 -0
- data/vendor/mail/spec/fixtures/emails/rfc2822/example03.eml +7 -0
- data/vendor/mail/spec/fixtures/emails/rfc2822/example04.eml +7 -0
- data/vendor/mail/spec/fixtures/emails/rfc2822/example05.eml +8 -0
- data/vendor/mail/spec/fixtures/emails/rfc2822/example06.eml +10 -0
- data/vendor/mail/spec/fixtures/emails/rfc2822/example07.eml +9 -0
- data/vendor/mail/spec/fixtures/emails/rfc2822/example08.eml +12 -0
- data/vendor/mail/spec/fixtures/emails/rfc2822/example09.eml +15 -0
- data/vendor/mail/spec/fixtures/emails/rfc2822/example10.eml +15 -0
- data/vendor/mail/spec/fixtures/emails/rfc2822/example11.eml +6 -0
- data/vendor/mail/spec/fixtures/emails/rfc2822/example12.eml +8 -0
- data/vendor/mail/spec/fixtures/emails/rfc2822/example13.eml +10 -0
- data/vendor/mail/spec/fixtures/emails/sample_output_multipart +0 -0
- data/vendor/mail/spec/mail/attachments_list_spec.rb +214 -0
- data/vendor/mail/spec/mail/body_spec.rb +385 -0
- data/vendor/mail/spec/mail/configuration_spec.rb +19 -0
- data/vendor/mail/spec/mail/core_extensions/string_spec.rb +62 -0
- data/vendor/mail/spec/mail/core_extensions_spec.rb +99 -0
- data/vendor/mail/spec/mail/elements/address_list_spec.rb +109 -0
- data/vendor/mail/spec/mail/elements/address_spec.rb +609 -0
- data/vendor/mail/spec/mail/elements/date_time_element_spec.rb +20 -0
- data/vendor/mail/spec/mail/elements/envelope_from_element_spec.rb +31 -0
- data/vendor/mail/spec/mail/elements/message_ids_element_spec.rb +43 -0
- data/vendor/mail/spec/mail/elements/phrase_list_spec.rb +22 -0
- data/vendor/mail/spec/mail/elements/received_element_spec.rb +34 -0
- data/vendor/mail/spec/mail/encoding_spec.rb +189 -0
- data/vendor/mail/spec/mail/encodings/base64_spec.rb +25 -0
- data/vendor/mail/spec/mail/encodings/quoted_printable_spec.rb +25 -0
- data/vendor/mail/spec/mail/encodings_spec.rb +664 -0
- data/vendor/mail/spec/mail/example_emails_spec.rb +303 -0
- data/vendor/mail/spec/mail/field_list_spec.rb +33 -0
- data/vendor/mail/spec/mail/field_spec.rb +198 -0
- data/vendor/mail/spec/mail/fields/bcc_field_spec.rb +89 -0
- data/vendor/mail/spec/mail/fields/cc_field_spec.rb +79 -0
- data/vendor/mail/spec/mail/fields/comments_field_spec.rb +25 -0
- data/vendor/mail/spec/mail/fields/common/address_container_spec.rb +18 -0
- data/vendor/mail/spec/mail/fields/common/common_address_spec.rb +132 -0
- data/vendor/mail/spec/mail/fields/common/common_date_spec.rb +25 -0
- data/vendor/mail/spec/mail/fields/common/common_field_spec.rb +69 -0
- data/vendor/mail/spec/mail/fields/common/common_message_id_spec.rb +30 -0
- data/vendor/mail/spec/mail/fields/common/parameter_hash_spec.rb +56 -0
- data/vendor/mail/spec/mail/fields/content_description_field_spec.rb +39 -0
- data/vendor/mail/spec/mail/fields/content_disposition_field_spec.rb +55 -0
- data/vendor/mail/spec/mail/fields/content_id_field_spec.rb +117 -0
- data/vendor/mail/spec/mail/fields/content_location_field_spec.rb +46 -0
- data/vendor/mail/spec/mail/fields/content_transfer_encoding_field_spec.rb +113 -0
- data/vendor/mail/spec/mail/fields/content_type_field_spec.rb +678 -0
- data/vendor/mail/spec/mail/fields/date_field_spec.rb +73 -0
- data/vendor/mail/spec/mail/fields/envelope_spec.rb +48 -0
- data/vendor/mail/spec/mail/fields/from_field_spec.rb +89 -0
- data/vendor/mail/spec/mail/fields/in_reply_to_field_spec.rb +62 -0
- data/vendor/mail/spec/mail/fields/keywords_field_spec.rb +66 -0
- data/vendor/mail/spec/mail/fields/message_id_field_spec.rb +147 -0
- data/vendor/mail/spec/mail/fields/mime_version_field_spec.rb +166 -0
- data/vendor/mail/spec/mail/fields/received_field_spec.rb +44 -0
- data/vendor/mail/spec/mail/fields/references_field_spec.rb +35 -0
- data/vendor/mail/spec/mail/fields/reply_to_field_spec.rb +67 -0
- data/vendor/mail/spec/mail/fields/resent_bcc_field_spec.rb +66 -0
- data/vendor/mail/spec/mail/fields/resent_cc_field_spec.rb +66 -0
- data/vendor/mail/spec/mail/fields/resent_date_field_spec.rb +39 -0
- data/vendor/mail/spec/mail/fields/resent_from_field_spec.rb +66 -0
- data/vendor/mail/spec/mail/fields/resent_message_id_field_spec.rb +24 -0
- data/vendor/mail/spec/mail/fields/resent_sender_field_spec.rb +58 -0
- data/vendor/mail/spec/mail/fields/resent_to_field_spec.rb +66 -0
- data/vendor/mail/spec/mail/fields/return_path_field_spec.rb +52 -0
- data/vendor/mail/spec/mail/fields/sender_field_spec.rb +58 -0
- data/vendor/mail/spec/mail/fields/structured_field_spec.rb +72 -0
- data/vendor/mail/spec/mail/fields/to_field_spec.rb +92 -0
- data/vendor/mail/spec/mail/fields/unstructured_field_spec.rb +134 -0
- data/vendor/mail/spec/mail/header_spec.rb +578 -0
- data/vendor/mail/spec/mail/mail_spec.rb +34 -0
- data/vendor/mail/spec/mail/message_spec.rb +1409 -0
- data/vendor/mail/spec/mail/mime_messages_spec.rb +435 -0
- data/vendor/mail/spec/mail/multipart_report_spec.rb +112 -0
- data/vendor/mail/spec/mail/network/delivery_methods/file_delivery_spec.rb +79 -0
- data/vendor/mail/spec/mail/network/delivery_methods/sendmail_spec.rb +125 -0
- data/vendor/mail/spec/mail/network/delivery_methods/smtp_spec.rb +133 -0
- data/vendor/mail/spec/mail/network/delivery_methods/test_mailer_spec.rb +57 -0
- data/vendor/mail/spec/mail/network/retriever_methods/pop3_spec.rb +180 -0
- data/vendor/mail/spec/mail/network_spec.rb +359 -0
- data/vendor/mail/spec/mail/parsers/address_lists_parser_spec.rb +15 -0
- data/vendor/mail/spec/mail/parsers/content_transfer_encoding_parser_spec.rb +72 -0
- data/vendor/mail/spec/mail/part_spec.rb +129 -0
- data/vendor/mail/spec/mail/parts_list_spec.rb +12 -0
- data/vendor/mail/spec/mail/round_tripping_spec.rb +44 -0
- data/vendor/mail/spec/mail/utilities_spec.rb +327 -0
- data/vendor/mail/spec/mail/version_specific/escape_paren_1_8_spec.rb +32 -0
- data/vendor/mail/spec/matchers/break_down_to.rb +35 -0
- data/vendor/mail/spec/spec_helper.rb +163 -0
- metadata +442 -0
@@ -0,0 +1,79 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe "SMTP Delivery Method" do
|
5
|
+
|
6
|
+
before(:each) do
|
7
|
+
# Reset all defaults back to an original state
|
8
|
+
Mail.defaults do
|
9
|
+
delivery_method :smtp, { :address => "localhost",
|
10
|
+
:port => 25,
|
11
|
+
:domain => 'localhost.localdomain',
|
12
|
+
:user_name => nil,
|
13
|
+
:password => nil,
|
14
|
+
:authentication => nil,
|
15
|
+
:enable_starttls_auto => true }
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
after(:each) do
|
20
|
+
files = Dir.glob(File.join(Mail.delivery_method.settings[:location], '*'))
|
21
|
+
files.each do |file|
|
22
|
+
File.delete(file)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
describe "general usage" do
|
27
|
+
tmpdir = File.expand_path('../../../../tmp/mail', __FILE__)
|
28
|
+
|
29
|
+
it "should send an email to a file" do
|
30
|
+
Mail.defaults do
|
31
|
+
delivery_method :file, :location => tmpdir
|
32
|
+
end
|
33
|
+
|
34
|
+
mail = Mail.deliver do
|
35
|
+
from 'roger@moore.com'
|
36
|
+
to 'marcel@amont.com'
|
37
|
+
subject 'invalid RFC2822'
|
38
|
+
end
|
39
|
+
|
40
|
+
delivery = File.join(Mail.delivery_method.settings[:location], 'marcel@amont.com')
|
41
|
+
|
42
|
+
File.read(delivery).should == mail.encoded
|
43
|
+
end
|
44
|
+
|
45
|
+
it "should send multiple emails to multiple files" do
|
46
|
+
Mail.defaults do
|
47
|
+
delivery_method :file, :location => tmpdir
|
48
|
+
end
|
49
|
+
|
50
|
+
mail = Mail.deliver do
|
51
|
+
from 'roger@moore.com'
|
52
|
+
to 'marcel@amont.com, bob@me.com'
|
53
|
+
subject 'invalid RFC2822'
|
54
|
+
end
|
55
|
+
|
56
|
+
delivery_one = File.join(Mail.delivery_method.settings[:location], 'marcel@amont.com')
|
57
|
+
delivery_two = File.join(Mail.delivery_method.settings[:location], 'bob@me.com')
|
58
|
+
|
59
|
+
File.read(delivery_one).should == mail.encoded
|
60
|
+
File.read(delivery_two).should == mail.encoded
|
61
|
+
end
|
62
|
+
|
63
|
+
it "should only create files based on the addr_spec of the destination" do
|
64
|
+
Mail.defaults do
|
65
|
+
delivery_method :file, :location => tmpdir
|
66
|
+
end
|
67
|
+
|
68
|
+
mail = Mail.deliver do
|
69
|
+
from 'roger@moore.com'
|
70
|
+
to '"Long, stupid email address" <mikel@test.lindsaar.net>'
|
71
|
+
subject 'invalid RFC2822'
|
72
|
+
end
|
73
|
+
delivery = File.join(Mail.delivery_method.settings[:location], 'mikel@test.lindsaar.net')
|
74
|
+
File.exists?(delivery).should be_true
|
75
|
+
end
|
76
|
+
|
77
|
+
end
|
78
|
+
|
79
|
+
end
|
@@ -0,0 +1,125 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe "sendmail delivery agent" do
|
5
|
+
|
6
|
+
before(:each) do
|
7
|
+
# Reset all defaults back to original state
|
8
|
+
Mail.defaults do
|
9
|
+
delivery_method :smtp, { :address => "localhost",
|
10
|
+
:port => 25,
|
11
|
+
:domain => 'localhost.localdomain',
|
12
|
+
:user_name => nil,
|
13
|
+
:password => nil,
|
14
|
+
:authentication => nil,
|
15
|
+
:enable_starttls_auto => true }
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should send an email using sendmail" do
|
20
|
+
Mail.defaults do
|
21
|
+
delivery_method :sendmail
|
22
|
+
end
|
23
|
+
|
24
|
+
mail = Mail.new do
|
25
|
+
from 'roger@test.lindsaar.net'
|
26
|
+
to 'marcel@test.lindsaar.net, bob@test.lindsaar.net'
|
27
|
+
subject 'invalid RFC2822'
|
28
|
+
end
|
29
|
+
|
30
|
+
Mail::Sendmail.should_receive(:call).with('/usr/sbin/sendmail',
|
31
|
+
'-i -t -f "roger@test.lindsaar.net"',
|
32
|
+
'marcel@test.lindsaar.net bob@test.lindsaar.net',
|
33
|
+
mail)
|
34
|
+
mail.deliver!
|
35
|
+
end
|
36
|
+
|
37
|
+
describe "return path" do
|
38
|
+
|
39
|
+
it "should send an email with a return-path using sendmail" do
|
40
|
+
Mail.defaults do
|
41
|
+
delivery_method :sendmail
|
42
|
+
end
|
43
|
+
|
44
|
+
mail = Mail.new do
|
45
|
+
to "to@test.lindsaar.net"
|
46
|
+
from "from@test.lindsaar.net"
|
47
|
+
sender "sender@test.lindsaar.net"
|
48
|
+
subject "Can't set the return-path"
|
49
|
+
return_path "return@test.lindsaar.net"
|
50
|
+
message_id "<1234@test.lindsaar.net>"
|
51
|
+
body "body"
|
52
|
+
end
|
53
|
+
|
54
|
+
Mail::Sendmail.should_receive(:call).with('/usr/sbin/sendmail',
|
55
|
+
'-i -t -f "return@test.lindsaar.net"',
|
56
|
+
'to@test.lindsaar.net',
|
57
|
+
mail)
|
58
|
+
|
59
|
+
mail.deliver
|
60
|
+
|
61
|
+
end
|
62
|
+
|
63
|
+
it "should use the sender address is no return path is specified" do
|
64
|
+
Mail.defaults do
|
65
|
+
delivery_method :sendmail
|
66
|
+
end
|
67
|
+
|
68
|
+
mail = Mail.new do
|
69
|
+
to "to@test.lindsaar.net"
|
70
|
+
from "from@test.lindsaar.net"
|
71
|
+
sender "sender@test.lindsaar.net"
|
72
|
+
subject "Can't set the return-path"
|
73
|
+
message_id "<1234@test.lindsaar.net>"
|
74
|
+
body "body"
|
75
|
+
end
|
76
|
+
|
77
|
+
Mail::Sendmail.should_receive(:call).with('/usr/sbin/sendmail',
|
78
|
+
'-i -t -f "sender@test.lindsaar.net"',
|
79
|
+
'to@test.lindsaar.net',
|
80
|
+
mail)
|
81
|
+
|
82
|
+
mail.deliver
|
83
|
+
end
|
84
|
+
|
85
|
+
it "should use the from address is no return path or sender are specified" do
|
86
|
+
Mail.defaults do
|
87
|
+
delivery_method :sendmail
|
88
|
+
end
|
89
|
+
|
90
|
+
mail = Mail.new do
|
91
|
+
to "to@test.lindsaar.net"
|
92
|
+
from "from@test.lindsaar.net"
|
93
|
+
subject "Can't set the return-path"
|
94
|
+
message_id "<1234@test.lindsaar.net>"
|
95
|
+
body "body"
|
96
|
+
end
|
97
|
+
|
98
|
+
Mail::Sendmail.should_receive(:call).with('/usr/sbin/sendmail',
|
99
|
+
'-i -t -f "from@test.lindsaar.net"',
|
100
|
+
'to@test.lindsaar.net',
|
101
|
+
mail)
|
102
|
+
mail.deliver
|
103
|
+
end
|
104
|
+
|
105
|
+
end
|
106
|
+
|
107
|
+
|
108
|
+
it "should still send an email if the settings have been set to nil" do
|
109
|
+
Mail.defaults do
|
110
|
+
delivery_method :sendmail, :arguments => nil
|
111
|
+
end
|
112
|
+
|
113
|
+
mail = Mail.new do
|
114
|
+
from 'from@test.lindsaar.net'
|
115
|
+
to 'marcel@test.lindsaar.net, bob@test.lindsaar.net'
|
116
|
+
subject 'invalid RFC2822'
|
117
|
+
end
|
118
|
+
|
119
|
+
Mail::Sendmail.should_receive(:call).with('/usr/sbin/sendmail',
|
120
|
+
'-f "from@test.lindsaar.net"',
|
121
|
+
'marcel@test.lindsaar.net bob@test.lindsaar.net',
|
122
|
+
mail)
|
123
|
+
mail.deliver!
|
124
|
+
end
|
125
|
+
end
|
@@ -0,0 +1,133 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe "SMTP Delivery Method" do
|
5
|
+
|
6
|
+
before(:each) do
|
7
|
+
# Reset all defaults back to original state
|
8
|
+
Mail.defaults do
|
9
|
+
delivery_method :smtp, { :address => "localhost",
|
10
|
+
:port => 25,
|
11
|
+
:domain => 'localhost.localdomain',
|
12
|
+
:user_name => nil,
|
13
|
+
:password => nil,
|
14
|
+
:authentication => nil,
|
15
|
+
:enable_starttls_auto => true }
|
16
|
+
end
|
17
|
+
MockSMTP.clear_deliveries
|
18
|
+
end
|
19
|
+
|
20
|
+
describe "general usage" do
|
21
|
+
|
22
|
+
it "should send emails from given settings" do
|
23
|
+
|
24
|
+
mail = Mail.deliver do
|
25
|
+
from 'roger@moore.com'
|
26
|
+
to 'marcel@amont.com'
|
27
|
+
subject 'invalid RFC2822'
|
28
|
+
end
|
29
|
+
|
30
|
+
MockSMTP.deliveries[0][0].should == mail.encoded
|
31
|
+
MockSMTP.deliveries[0][1].should == mail.from[0]
|
32
|
+
MockSMTP.deliveries[0][2].should == mail.destinations
|
33
|
+
end
|
34
|
+
|
35
|
+
it "should be able to send itself" do
|
36
|
+
mail = Mail.deliver do
|
37
|
+
from 'roger@moore.com'
|
38
|
+
to 'marcel@amont.com'
|
39
|
+
subject 'invalid RFC2822'
|
40
|
+
end
|
41
|
+
|
42
|
+
mail.deliver!
|
43
|
+
|
44
|
+
MockSMTP.deliveries[0][0].should == mail.encoded
|
45
|
+
MockSMTP.deliveries[0][1].should == mail.from[0]
|
46
|
+
MockSMTP.deliveries[0][2].should == mail.destinations
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
|
51
|
+
describe "enabling tls" do
|
52
|
+
|
53
|
+
def redefine_verify_none(new_value)
|
54
|
+
OpenSSL::SSL.send(:remove_const, :VERIFY_NONE)
|
55
|
+
OpenSSL::SSL.send(:const_set, :VERIFY_NONE, new_value)
|
56
|
+
end
|
57
|
+
|
58
|
+
it "should use OpenSSL::SSL::VERIFY_NONE if a context" do
|
59
|
+
|
60
|
+
# config can't be setup until redefined
|
61
|
+
redefine_verify_none(OpenSSL::SSL::SSLContext.new)
|
62
|
+
Mail.defaults do
|
63
|
+
delivery_method :smtp, :address => 'smtp.mockup.com', :port => 587
|
64
|
+
end
|
65
|
+
|
66
|
+
mail = Mail.deliver do
|
67
|
+
from 'roger@moore.com'
|
68
|
+
to 'marcel@amont.com'
|
69
|
+
subject 'invalid RFC2822'
|
70
|
+
end
|
71
|
+
|
72
|
+
doing { mail.deliver! }.should_not raise_error(TypeError)
|
73
|
+
end
|
74
|
+
|
75
|
+
it "should ignore OpenSSL::SSL::VERIFY_NONE if it is 0" do
|
76
|
+
|
77
|
+
# config can't be setup until redefined
|
78
|
+
redefine_verify_none(0)
|
79
|
+
Mail.defaults do
|
80
|
+
delivery_method :smtp, :address => 'smtp.mockup.com', :port => 587
|
81
|
+
end
|
82
|
+
|
83
|
+
mail = Mail.deliver do
|
84
|
+
from 'roger@moore.com'
|
85
|
+
to 'marcel@amont.com'
|
86
|
+
subject 'invalid RFC2822'
|
87
|
+
end
|
88
|
+
|
89
|
+
doing { mail.deliver! }.should_not raise_error(TypeError)
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
describe "return path" do
|
94
|
+
|
95
|
+
it "should use the return path if specified" do
|
96
|
+
mail = Mail.deliver do
|
97
|
+
to "to@someemail.com"
|
98
|
+
from "from@someemail.com"
|
99
|
+
sender "sender@test.lindsaar.net"
|
100
|
+
subject "Can't set the return-path"
|
101
|
+
return_path "bounce@someemail.com"
|
102
|
+
message_id "<1234@someemail.com>"
|
103
|
+
body "body"
|
104
|
+
end
|
105
|
+
MockSMTP.deliveries[0][1].should == "bounce@someemail.com"
|
106
|
+
end
|
107
|
+
|
108
|
+
it "should use the sender address is no return path is specified" do
|
109
|
+
mail = Mail.deliver do
|
110
|
+
to "to@someemail.com"
|
111
|
+
from "from@someemail.com"
|
112
|
+
sender "sender@test.lindsaar.net"
|
113
|
+
subject "Can't set the return-path"
|
114
|
+
message_id "<1234@someemail.com>"
|
115
|
+
body "body"
|
116
|
+
end
|
117
|
+
MockSMTP.deliveries[0][1].should == "sender@test.lindsaar.net"
|
118
|
+
end
|
119
|
+
|
120
|
+
it "should use the from address is no return path or sender is specified" do
|
121
|
+
mail = Mail.deliver do
|
122
|
+
to "to@someemail.com"
|
123
|
+
from "from@someemail.com"
|
124
|
+
subject "Can't set the return-path"
|
125
|
+
message_id "<1234@someemail.com>"
|
126
|
+
body "body"
|
127
|
+
end
|
128
|
+
MockSMTP.deliveries[0][1].should == "from@someemail.com"
|
129
|
+
end
|
130
|
+
|
131
|
+
end
|
132
|
+
|
133
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe "Mail::TestMailer" do
|
5
|
+
before(:each) do
|
6
|
+
# Reset all defaults back to original state
|
7
|
+
Mail.defaults do
|
8
|
+
delivery_method :smtp, { :address => "localhost",
|
9
|
+
:port => 25,
|
10
|
+
:domain => 'localhost.localdomain',
|
11
|
+
:user_name => nil,
|
12
|
+
:password => nil,
|
13
|
+
:authentication => nil,
|
14
|
+
:enable_starttls_auto => true }
|
15
|
+
Mail::TestMailer.deliveries.clear
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should have no deliveries when first initiated" do
|
20
|
+
Mail.defaults do
|
21
|
+
delivery_method :test
|
22
|
+
end
|
23
|
+
Mail::TestMailer.deliveries.should be_empty
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should deliver an email to the Mail::TestMailer.deliveries array" do
|
27
|
+
Mail.defaults do
|
28
|
+
delivery_method :test
|
29
|
+
end
|
30
|
+
mail = Mail.new do
|
31
|
+
to 'mikel@me.com'
|
32
|
+
from 'you@you.com'
|
33
|
+
subject 'testing'
|
34
|
+
body 'hello'
|
35
|
+
end
|
36
|
+
mail.deliver
|
37
|
+
Mail::TestMailer.deliveries.length.should == 1
|
38
|
+
Mail::TestMailer.deliveries.first.should == mail
|
39
|
+
end
|
40
|
+
|
41
|
+
it "should clear the deliveries when told to" do
|
42
|
+
Mail.defaults do
|
43
|
+
delivery_method :test
|
44
|
+
end
|
45
|
+
mail = Mail.new do
|
46
|
+
to 'mikel@me.com'
|
47
|
+
from 'you@you.com'
|
48
|
+
subject 'testing'
|
49
|
+
body 'hello'
|
50
|
+
end
|
51
|
+
mail.deliver
|
52
|
+
Mail::TestMailer.deliveries.length.should == 1
|
53
|
+
Mail::TestMailer.deliveries.clear
|
54
|
+
Mail::TestMailer.deliveries.should be_empty
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
@@ -0,0 +1,180 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe "POP3 Retriever" do
|
5
|
+
|
6
|
+
before(:each) do
|
7
|
+
# Reset all defaults back to original state
|
8
|
+
Mail.defaults do
|
9
|
+
retriever_method :pop3, { :address => "localhost",
|
10
|
+
:port => 995,
|
11
|
+
:user_name => nil,
|
12
|
+
:password => nil,
|
13
|
+
:enable_ssl => true }
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
|
18
|
+
describe "find with and without block" do
|
19
|
+
|
20
|
+
it "should find all emails with a given block" do
|
21
|
+
MockPOP3.should_not be_started
|
22
|
+
|
23
|
+
messages = []
|
24
|
+
Mail.all do |message|
|
25
|
+
messages << message
|
26
|
+
end
|
27
|
+
|
28
|
+
messages.map { |m| m.raw_source }.sort.should == MockPOP3.popmails.map { |p| p.pop }.sort
|
29
|
+
MockPOP3.should_not be_started
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should get all emails without a given block" do
|
33
|
+
MockPOP3.should_not be_started
|
34
|
+
|
35
|
+
messages = []
|
36
|
+
Mail.all do |message|
|
37
|
+
messages << message
|
38
|
+
end
|
39
|
+
|
40
|
+
messages.map { |m| m.raw_source }.sort.should == MockPOP3.popmails.map { |p| p.pop }.sort
|
41
|
+
MockPOP3.should_not be_started
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
|
46
|
+
describe "find and options" do
|
47
|
+
|
48
|
+
it "should handle the :count option" do
|
49
|
+
messages = Mail.find(:count => :all, :what => :last, :order => :asc)
|
50
|
+
messages.map { |m| m.raw_source }.sort.should == MockPOP3.popmails.map { |p| p.pop }
|
51
|
+
|
52
|
+
message = Mail.find(:count => 1, :what => :last)
|
53
|
+
message.raw_source.should == MockPOP3.popmails.map { |p| p.pop }.last
|
54
|
+
|
55
|
+
messages = Mail.find(:count => 2, :what => :last, :order => :asc)
|
56
|
+
messages[0..1].collect {|m| m.raw_source}.should == MockPOP3.popmails.map { |p| p.pop }[-2..-1]
|
57
|
+
end
|
58
|
+
|
59
|
+
it "should handle the :what option" do
|
60
|
+
messages = Mail.find(:count => :all, :what => :last)
|
61
|
+
messages.map { |m| m.raw_source }.sort.should == MockPOP3.popmails.map { |p| p.pop }
|
62
|
+
|
63
|
+
messages = Mail.find(:count => 2, :what => :first, :order => :asc)
|
64
|
+
messages.map { |m| m.raw_source }.should == MockPOP3.popmails.map { |p| p.pop }[0..1]
|
65
|
+
end
|
66
|
+
|
67
|
+
it "should handle the :order option" do
|
68
|
+
messages = Mail.find(:order => :desc, :count => 5, :what => :last)
|
69
|
+
messages.map { |m| m.raw_source }.should == MockPOP3.popmails.map { |p| p.pop }[-5..-1].reverse
|
70
|
+
|
71
|
+
messages = Mail.find(:order => :asc, :count => 5, :what => :last)
|
72
|
+
messages.map { |m| m.raw_source }.should == MockPOP3.popmails.map { |p| p.pop }[-5..-1]
|
73
|
+
end
|
74
|
+
|
75
|
+
it "should find the last 10 messages by default" do
|
76
|
+
messages = Mail.find
|
77
|
+
|
78
|
+
messages.size.should == 10
|
79
|
+
end
|
80
|
+
|
81
|
+
end
|
82
|
+
|
83
|
+
describe "last" do
|
84
|
+
|
85
|
+
it "should find the last received messages" do
|
86
|
+
messages = Mail.last(:count => 5)
|
87
|
+
|
88
|
+
messages.should be_instance_of(Array)
|
89
|
+
messages.map { |m| m.raw_source }.should == MockPOP3.popmails.map { |p| p.pop }[-5..-1]
|
90
|
+
end
|
91
|
+
|
92
|
+
it "should find the last received message" do
|
93
|
+
message = Mail.last
|
94
|
+
|
95
|
+
message.should be_instance_of(Mail::Message)
|
96
|
+
message.raw_source.should == MockPOP3.popmails.last.pop
|
97
|
+
end
|
98
|
+
|
99
|
+
end
|
100
|
+
|
101
|
+
describe "first" do
|
102
|
+
|
103
|
+
it "should find the first received messages" do
|
104
|
+
messages = Mail.first(:count => 5)
|
105
|
+
|
106
|
+
messages.should be_instance_of(Array)
|
107
|
+
messages.map { |m| m.raw_source }.should == MockPOP3.popmails.map { |p| p.pop }[0..4]
|
108
|
+
end
|
109
|
+
|
110
|
+
it "should find the first received message" do
|
111
|
+
message = Mail.first
|
112
|
+
|
113
|
+
message.should be_instance_of(Mail::Message)
|
114
|
+
message.raw_source.should == MockPOP3.popmails.first.pop
|
115
|
+
end
|
116
|
+
|
117
|
+
end
|
118
|
+
|
119
|
+
describe "all" do
|
120
|
+
|
121
|
+
it "should find all messages" do
|
122
|
+
messages = Mail.all
|
123
|
+
|
124
|
+
messages.size.should == MockPOP3.popmails.size
|
125
|
+
messages.map { |m| m.raw_source }.should == MockPOP3.popmails.map { |p| p.pop }
|
126
|
+
end
|
127
|
+
|
128
|
+
end
|
129
|
+
|
130
|
+
describe "handling of options" do
|
131
|
+
|
132
|
+
it "should set default options" do
|
133
|
+
retrievable = Mail::POP3.new({})
|
134
|
+
options = retrievable.send(:validate_options, {})
|
135
|
+
|
136
|
+
options[:count].should be_present
|
137
|
+
options[:count].should == 10
|
138
|
+
|
139
|
+
options[:order].should be_present
|
140
|
+
options[:order].should == :asc
|
141
|
+
|
142
|
+
options[:what].should be_present
|
143
|
+
options[:what].should == :first
|
144
|
+
end
|
145
|
+
|
146
|
+
it "should not replace given configuration" do
|
147
|
+
retrievable = Mail::POP3.new({})
|
148
|
+
options = retrievable.send(:validate_options, {
|
149
|
+
:count => 2,
|
150
|
+
:order => :asc,
|
151
|
+
:what => :first
|
152
|
+
})
|
153
|
+
|
154
|
+
options[:count].should be_present
|
155
|
+
options[:count].should == 2
|
156
|
+
|
157
|
+
options[:order].should be_present
|
158
|
+
options[:order].should == :asc
|
159
|
+
|
160
|
+
options[:what].should be_present
|
161
|
+
options[:what].should == :first
|
162
|
+
end
|
163
|
+
|
164
|
+
end
|
165
|
+
|
166
|
+
describe "error handling" do
|
167
|
+
|
168
|
+
it "should finish the POP3 connection is an exception is raised" do
|
169
|
+
MockPOP3.should_not be_started
|
170
|
+
|
171
|
+
doing do
|
172
|
+
Mail.all { |m| raise ArgumentError.new }
|
173
|
+
end.should raise_error
|
174
|
+
|
175
|
+
MockPOP3.should_not be_started
|
176
|
+
end
|
177
|
+
|
178
|
+
end
|
179
|
+
|
180
|
+
end
|