Created
March 15, 2012 17:34
-
-
Save ezkl/2045510 to your computer and use it in GitHub Desktop.
mail v2.3.3 v2.4.0 diff
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.gitignore | 2 +- | |
.travis.yml | 7 + | |
CHANGELOG.rdoc | 6 + | |
CONTRIBUTING.md | 45 ++ | |
Gemfile | 10 +- | |
README.md | 649 ++++++++++++++++++ | |
README.rdoc | 563 ---------------- | |
Rakefile | 16 +- | |
lib/VERSION | 4 +- | |
lib/mail.rb | 4 +- | |
lib/mail/attachments_list.rb | 5 +- | |
lib/mail/body.rb | 3 +- | |
lib/mail/configuration.rb | 6 +- | |
lib/mail/core_extensions/nil.rb | 4 + | |
lib/mail/core_extensions/shell_escape.rb | 56 -- | |
lib/mail/core_extensions/shellwords.rb | 57 ++ | |
lib/mail/core_extensions/string.rb | 10 +- | |
lib/mail/core_extensions/string/access.rb | 41 ++ | |
lib/mail/encodings.rb | 16 +- | |
lib/mail/field.rb | 2 + | |
lib/mail/fields/common/parameter_hash.rb | 2 +- | |
lib/mail/fields/unstructured_field.rb | 2 +- | |
lib/mail/matchers/has_sent_mail.rb | 124 ++++ | |
lib/mail/message.rb | 91 ++- | |
lib/mail/multibyte/chars.rb | 4 +- | |
lib/mail/multibyte/utils.rb | 2 +- | |
lib/mail/network/delivery_methods/exim.rb | 43 +- | |
lib/mail/network/delivery_methods/file_delivery.rb | 4 +- | |
lib/mail/network/delivery_methods/sendmail.rb | 6 +- | |
lib/mail/network/delivery_methods/smtp.rb | 24 +- | |
lib/mail/network/retriever_methods/imap.rb | 6 +- | |
lib/mail/parsers/rfc2822.treetop | 2 +- | |
lib/mail/parsers/rfc2822_obsolete.rb | 17 +- | |
lib/mail/parsers/rfc2822_obsolete.treetop | 4 +- | |
lib/mail/parts_list.rb | 4 + | |
lib/mail/utilities.rb | 8 +- | |
lib/mail/version_specific/ruby_1_8.rb | 2 +- | |
lib/mail/version_specific/ruby_1_9.rb | 12 +- | |
mail.gemspec | 8 +- | |
.../raw_email_with_at_display_name.eml | 31 + | |
spec/mail/attachments_list_spec.rb | 90 +-- | |
spec/mail/body_spec.rb | 126 ++-- | |
spec/mail/configuration_spec.rb | 37 +- | |
spec/mail/core_extensions/string_spec.rb | 32 +- | |
spec/mail/core_extensions_spec.rb | 22 +- | |
spec/mail/elements/address_list_spec.rb | 36 +- | |
spec/mail/elements/address_spec.rb | 80 +-- | |
spec/mail/elements/envelope_from_element_spec.rb | 4 +- | |
spec/mail/elements/message_ids_element_spec.rb | 6 +- | |
spec/mail/elements/received_element_spec.rb | 4 +- | |
spec/mail/encoding_spec.rb | 40 +- | |
spec/mail/encodings/base64_spec.rb | 8 +- | |
spec/mail/encodings/quoted_printable_spec.rb | 8 +- | |
spec/mail/encodings_spec.rb | 241 ++++--- | |
spec/mail/example_emails_spec.rb | 166 ++--- | |
spec/mail/field_list_spec.rb | 12 +- | |
spec/mail/field_spec.rb | 93 +-- | |
spec/mail/fields/bcc_field_spec.rb | 26 +- | |
spec/mail/fields/cc_field_spec.rb | 28 +- | |
spec/mail/fields/comments_field_spec.rb | 8 +- | |
spec/mail/fields/common/address_container_spec.rb | 8 +- | |
spec/mail/fields/common/common_address_spec.rb | 50 +- | |
spec/mail/fields/common/common_date_spec.rb | 6 +- | |
spec/mail/fields/common/common_field_spec.rb | 22 +- | |
spec/mail/fields/common/common_message_id_spec.rb | 8 +- | |
spec/mail/fields/common/parameter_hash_spec.rb | 28 +- | |
spec/mail/fields/content_description_field_spec.rb | 8 +- | |
spec/mail/fields/content_disposition_field_spec.rb | 26 +- | |
spec/mail/fields/content_id_field_spec.rb | 34 +- | |
spec/mail/fields/content_location_field_spec.rb | 14 +- | |
.../fields/content_transfer_encoding_field_spec.rb | 26 +- | |
spec/mail/fields/content_type_field_spec.rb | 452 ++++++------- | |
spec/mail/fields/date_field_spec.rb | 22 +- | |
spec/mail/fields/envelope_spec.rb | 6 +- | |
spec/mail/fields/from_field_spec.rb | 36 +- | |
spec/mail/fields/in_reply_to_field_spec.rb | 28 +- | |
spec/mail/fields/keywords_field_spec.rb | 22 +- | |
spec/mail/fields/message_id_field_spec.rb | 36 +- | |
spec/mail/fields/mime_version_field_spec.rb | 30 +- | |
spec/mail/fields/received_field_spec.rb | 28 +- | |
spec/mail/fields/references_field_spec.rb | 26 +- | |
spec/mail/fields/reply_to_field_spec.rb | 24 +- | |
spec/mail/fields/resent_bcc_field_spec.rb | 24 +- | |
spec/mail/fields/resent_cc_field_spec.rb | 24 +- | |
spec/mail/fields/resent_date_field_spec.rb | 18 +- | |
spec/mail/fields/resent_from_field_spec.rb | 24 +- | |
spec/mail/fields/resent_message_id_field_spec.rb | 12 +- | |
spec/mail/fields/resent_sender_field_spec.rb | 16 +- | |
spec/mail/fields/resent_to_field_spec.rb | 24 +- | |
spec/mail/fields/return_path_field_spec.rb | 10 +- | |
spec/mail/fields/sender_field_spec.rb | 16 +- | |
spec/mail/fields/structured_field_spec.rb | 16 +- | |
spec/mail/fields/to_field_spec.rb | 32 +- | |
spec/mail/fields/unstructured_field_spec.rb | 56 +- | |
spec/mail/header_spec.rb | 200 +++--- | |
spec/mail/mail_spec.rb | 14 +- | |
spec/mail/message_spec.rb | 702 +++++++++++--------- | |
spec/mail/mime_messages_spec.rb | 158 ++--- | |
spec/mail/multipart_report_spec.rb | 20 +- | |
spec/mail/network/delivery_methods/exim_spec.rb | 161 ----- | |
.../network/delivery_methods/file_delivery_spec.rb | 21 +- | |
.../mail/network/delivery_methods/sendmail_spec.rb | 40 +- | |
.../delivery_methods/smtp_connection_spec.rb | 8 +- | |
spec/mail/network/delivery_methods/smtp_spec.rb | 66 +- | |
.../network/delivery_methods/test_mailer_spec.rb | 6 +- | |
spec/mail/network/retriever_methods/imap_spec.rb | 68 +- | |
spec/mail/network/retriever_methods/pop3_spec.rb | 46 +- | |
.../retriever_methods/test_retriever_spec.rb | 30 +- | |
spec/mail/network_spec.rb | 81 +-- | |
.../content_transfer_encoding_parser_spec.rb | 16 +- | |
spec/mail/part_spec.rb | 24 +- | |
spec/mail/parts_list_spec.rb | 2 +- | |
spec/mail/round_tripping_spec.rb | 18 +- | |
spec/mail/utilities_spec.rb | 100 +-- | |
spec/matchers_spec.rb | 130 ++++ | |
spec/spec_helper.rb | 14 +- | |
116 files changed, 3367 insertions(+), 2739 deletions(-) | |
diff --git a/.gitignore b/.gitignore | |
index e81d9ab..fa4e4d0 100644 | |
--- a/.gitignore | |
+++ b/.gitignore | |
@@ -1,5 +1,4 @@ | |
.bundle | |
-.rbx | |
Gemfile.lock | |
coverage | |
gems | |
@@ -13,3 +12,4 @@ spec/fixtures/emails/failed_emails/ | |
.idea | |
tmp | |
tags | |
+.rbx | |
diff --git a/.travis.yml b/.travis.yml | |
new file mode 100644 | |
index 0000000..eede0bb | |
--- /dev/null | |
+++ b/.travis.yml | |
@@ -0,0 +1,7 @@ | |
+rvm: | |
+ - 1.8.7 | |
+ - 1.9.2 | |
+ - 1.9.3 | |
+ - ree | |
+ - jruby | |
+ - rbx-18mode | |
diff --git a/CHANGELOG.rdoc b/CHANGELOG.rdoc | |
index 2f21764..574a6c6 100644 | |
--- a/CHANGELOG.rdoc | |
+++ b/CHANGELOG.rdoc | |
@@ -1,3 +1,9 @@ | |
+== Sun Jan 15 18:15:56 UTC 2011 Mikel Lindsaar <[email protected]> | |
+ | |
+* Bunch of bug fixes from contributed pull requests | |
+* Added explicit exim support | |
+* Version bump to 2.4.0 and gem release | |
+ | |
== Tue Apr 26 09:59:56 UTC 2011 Mikel Lindsaar <[email protected]> | |
* Remove ActiveSupport from the dependencies, load Active Support if present, or use internals if not | |
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md | |
new file mode 100644 | |
index 0000000..21d0a06 | |
--- /dev/null | |
+++ b/CONTRIBUTING.md | |
@@ -0,0 +1,45 @@ | |
+Contributing to Mail | |
+==================== | |
+ | |
+Hi there, I welcome pull requests! Here are some thoughts on how to get your | |
+pull request merged quickly: | |
+ | |
+1. Check the Reference RFCs, they are in the References directory, so no excuses. | |
+2. Check for a ticket on GitHub, maybe someone else has the problem too | |
+3. Make a fork of my GitHub repository | |
+4. Run the specs. We only take pull requests with passing tests, and it's great | |
+ to know that you have a clean slate: `bundle && bundle exec rake` | |
+5. Add a spec for your change. Only refactoring and documentation changes | |
+ require no new specs. If you are adding functionality or fixing a bug, we need | |
+ a spec! | |
+6. Test the spec _at_ _least_ against MRI-1.9.2 and MRI-1.8.7 | |
+7. Update the README if needed to reflect your change / addition | |
+8. With all specs passing push your changes back to your fork | |
+9. Send me a pull request | |
+ | |
+Note, specs that break MRI 1.8.7 will not be accepted. | |
+ | |
+At this point you're waiting on us. We like to at least comment on, if not | |
+accept, pull requests within three business days (and, typically, one business | |
+day). We may suggest some changes or improvements or alternatives. | |
+ | |
+Some things that will increase the chance that your pull request is accepted, | |
+taken straight from the Ruby on Rails guide: | |
+ | |
+* Tell me you have tested it against more than one version of Ruby, RVM is great for | |
+ this. I test against 7 rubies before I push into master. | |
+* Use good, idiomatic, strcutred and modular code | |
+* Include tests that fail without your code, and pass with it | |
+* Update the documentation, the surrounding one, examples elsewhere, guides, | |
+ whatever is affected by your contribution | |
+ | |
+Syntax: | |
+ | |
+* Two spaces, no tabs. | |
+* No trailing whitespace. Blank lines should not have any space. | |
+* Prefer &&/|| over and/or. | |
+* MyClass.my_method(my_arg) not my_method( my_arg ) or my_method my_arg. | |
+* a = b and not a=b. | |
+* Follow the conventions you see used in the source already. | |
+ | |
+And in case we didn't emphasize it enough: we love specs! | |
\ No newline at end of file | |
diff --git a/Gemfile b/Gemfile | |
index 5b59e81..013ce63 100644 | |
--- a/Gemfile | |
+++ b/Gemfile | |
@@ -11,14 +11,8 @@ if defined?(RUBY_ENGINE) && RUBY_ENGINE == 'jruby' | |
end | |
group :test do | |
- gem "ZenTest", "~> 4.4.0" | |
- gem "rake", "~> 0.8.7" | |
- gem "bundler" | |
- gem "rspec", "~> 1.3.0" | |
- gem "rspec-core", "~> 2.4.0" | |
- gem "rspec-mocks", "~> 2.4.0" | |
- gem "rspec-expectations", "~> 2.4.0" | |
- gem "diff-lcs" | |
+ gem "rake", "> 0.8.7" | |
+ gem "rspec", "~> 2.8.0" | |
case | |
when defined?(RUBY_ENGINE) && RUBY_ENGINE == 'rbx' | |
# Skip it | |
diff --git a/README.md b/README.md | |
new file mode 100644 | |
index 0000000..2a542d3 | |
--- /dev/null | |
+++ b/README.md | |
@@ -0,0 +1,649 @@ | |
+==== | |
+ | |
+Introduction | |
+------------ | |
+ | |
+Mail is an internet library for Ruby that is designed to handle emails | |
+generation, parsing and sending in a simple, rubyesque manner. | |
+ | |
+The purpose of this library is to provide a single point of access to handle | |
+all email functions, including sending and receiving emails. All network | |
+type actions are done through proxy methods to Net::SMTP, Net::POP3 etc. | |
+ | |
+Built from my experience with TMail, it is designed to be a pure ruby | |
+implementation that makes generating, sending and parsing emails a no | |
+brainer. | |
+ | |
+It is also designed form the ground up to work with Ruby 1.9. This is because | |
+Ruby 1.9 handles text encodings much more magically than Ruby 1.8.x and so | |
+these features have been taken full advantage of in this library allowing | |
+Mail to handle a lot more messages more cleanly than TMail. Mail does run on | |
+Ruby 1.8.x... it's just not as fun to code. | |
+ | |
+Finally, Mail has been designed with a very simple object oriented system | |
+that really opens up the email messages you are parsing, if you know what | |
+you are doing, you can fiddle with every last bit of your email directly. | |
+ | |
+Compatibility | |
+------------- | |
+ | |
+Mail is tested by Travis () and works on the following platforms: | |
+ | |
+* jruby-1.6.5.1 [ x86_64 ] | |
+* rbx-head-d18 [ x86_64 ] | |
+* ree-1.8.7-2011.03 [ i686 ] | |
+* ruby-1.8.7-p357 [ i686 ] | |
+* ruby-1.9.2-p290 [ x86_64 ] | |
+* ruby-1.9.3-p0 [ x86_64 ] | |
+ | |
+Discussion | |
+---------- | |
+ | |
+If you want to discuss mail with like minded individuals, please subscribe to | |
+the [Google Group](http://groups.google.com/group/mail-ruby). | |
+ | |
+Current Capabilities of Mail | |
+---------------------------- | |
+ | |
+* RFC2822 Support, Reading and Writing | |
+* RFC2045-2049 Support for multipart emails | |
+* Support for creating multipart alternate emails | |
+* Support for reading multipart/report emails & getting details from such | |
+* Support for multibyte emails - needs quite a lot of work and testing | |
+* Wrappers for File, Net/POP3, Net/SMTP | |
+* Auto encoding of non US-ASCII header fields | |
+* Auto encoding of non US-ASCII bodies | |
+ | |
+Mail is RFC2822 compliant now, that is, it can parse and generate valid US-ASCII | |
+emails. There are a few obsoleted syntax emails that it will have problems with, but | |
+it also is quite robust, meaning, if it finds something it doesn't understand it will | |
+not crash, instead, it will skip the problem and keep parsing. In the case of a header | |
+it doesn't understand, it will initialise the header as an optional unstructured | |
+field and continue parsing. | |
+ | |
+This means Mail won't (ever) crunch your data (I think). | |
+ | |
+You can also create MIME emails. There are helper methods for making a | |
+multipart/alternate email for text/plain and text/html (the most common pair) | |
+and you can manually create any other type of MIME email. | |
+ | |
+Roadmap | |
+------- | |
+ | |
+Next TODO: | |
+ | |
+* Improve MIME support for character sets in headers, currently works, mostly, needs | |
+ refinement. | |
+ | |
+Testing Policy | |
+-------------- | |
+ | |
+Basically... we do BDD on Mail. No method gets written in Mail without a | |
+corresponding or covering spec. We expect as a minimum 100% coverage | |
+measured by RCov. While this is not perfect by any measure, it is pretty | |
+good. Additionally, all functional tests from TMail are to be passing before | |
+the gem gets released. | |
+ | |
+It also means you can be sure Mail will behave correctly. | |
+ | |
+API Policy | |
+---------- | |
+ | |
+No API removals within a single point release. All removals to be depreciated with | |
+warnings for at least one MINOR point release before removal. | |
+ | |
+Also, all private or protected methods to be declared as such - though this is still I/P. | |
+ | |
+Installation | |
+------------ | |
+ | |
+Installation is fairly simple, I host mail on rubygems, so you can just do: | |
+ | |
+ # gem install mail | |
+ | |
+Encodings | |
+--------- | |
+ | |
+If you didn't know, handling encodings in Emails is not as straight forward as you | |
+would hope. | |
+ | |
+I have tried to simplify it some: | |
+ | |
+1. All objects that can render into an email, have an `#encoded` method. Encoded will | |
+ return the object as a complete string ready to send in the mail system, that is, | |
+ it will include the header field and value and CRLF at the end and wrapped as | |
+ needed. | |
+ | |
+2. All objects that can render into an email, have a :decoded method. Decoded will | |
+ return the object's "value" only as a string. This means it will not include | |
+ the header fields (like 'To:' or 'Subject:'). | |
+ | |
+3. By default, calling <code>#to_s</code> on a container object will call its encoded | |
+ method, while <code>#to_s</code> on a field object will call it's decoded method. | |
+ So calling <code>#to_s</code> on a Mail object will return the mail, all encoded | |
+ ready to send, while calling <code>#to_s</code> on the From field or the body will | |
+ return the decoded value of the object. The header object of Mail is considered a | |
+ container. If you are in doubt, call <code>#encoded</code>, or <code>#decoded</code> | |
+ explicitly, this is safer if you are not sure. | |
+ | |
+4. Structured fields that have parameter values that can be encoded (e.g. Content-Type) will | |
+ provide decoded parameter values when you call the parameter names as methods against | |
+ the object. | |
+ | |
+5. Structured fields that have parameter values that can be encoded (e.g. Content-Type) will | |
+ provide encoded parameter values when you call the parameter names through the | |
+ <code>object.parameters['<parameter_name>']</code> method call. | |
+ | |
+Contributing | |
+------------ | |
+ | |
+Please do! Contributing is easy in Mail. Please read the CONTRIBUTING.md document for more info | |
+ | |
+Usage | |
+----- | |
+ | |
+All major mail functions should be able to happen from the Mail module. | |
+So, you should be able to just <code>require 'mail'</code> to get started. | |
+ | |
+### Making an email | |
+ | |
+```ruby | |
+mail = Mail.new do | |
+ from '[email protected]' | |
+ to '[email protected]' | |
+ subject 'This is a test email' | |
+ body File.read('body.txt') | |
+end | |
+ | |
+mail.to_s #=> "From: [email protected]\r\nTo: you@... | |
+``` | |
+ | |
+### Making an email, have it your way: | |
+ | |
+```ruby | |
+mail = Mail.new do | |
+ body File.read('body.txt') | |
+end | |
+ | |
+mail['from'] = '[email protected]' | |
+mail[:to] = '[email protected]' | |
+mail.subject = 'This is a test email' | |
+ | |
+mail.to_s #=> "From: [email protected]\r\nTo: you@... | |
+``` | |
+ | |
+### Don't Worry About Message IDs: | |
+ | |
+```ruby | |
+mail = Mail.new do | |
+ to '[email protected]' | |
+ body 'Some simple body' | |
+end | |
+ | |
+mail.to_s =~ /Message\-ID: <[\d\w_]+@.+.mail/ #=> 27 | |
+``` | |
+ | |
+Mail will automatically add a Message-ID field if it is missing and | |
+give it a unique, random Message-ID along the lines of: | |
+ | |
+ <[email protected]> | |
+ | |
+### Or do worry about Message-IDs: | |
+ | |
+```ruby | |
+mail = Mail.new do | |
+ to '[email protected]' | |
+ message_id '<[email protected]>' | |
+ body 'Some simple body' | |
+end | |
+ | |
+mail.to_s =~ /Message\-ID: <[email protected]>/ #=> 27 | |
+``` | |
+ | |
+Mail will take the message_id you assign to it trusting that you know | |
+what you are doing. | |
+ | |
+### Sending an email: | |
+ | |
+Mail defaults to sending via SMTP to local host port 25. If you have a | |
+sendmail or postfix daemon running on on this port, sending email is as | |
+easy as: | |
+ | |
+```ruby | |
+Mail.deliver do | |
+ from '[email protected]' | |
+ to '[email protected]' | |
+ subject 'Here is the image you wanted' | |
+ body File.read('body.txt') | |
+ add_file '/full/path/to/somefile.png' | |
+end | |
+``` | |
+ | |
+or | |
+ | |
+```ruby | |
+mail = Mail.new do | |
+ from '[email protected]' | |
+ to '[email protected]' | |
+ subject 'Here is the image you wanted' | |
+ body File.read('body.txt') | |
+ add_file :filename => 'somefile.png', :content => File.read('/somefile.png') | |
+end | |
+ | |
+mail.deliver! | |
+``` | |
+ | |
+Sending via sendmail can be done like so: | |
+ | |
+```ruby | |
+mail = Mail.new do | |
+ from '[email protected]' | |
+ to '[email protected]' | |
+ subject 'Here is the image you wanted' | |
+ body File.read('body.txt') | |
+ add_file :filename => 'somefile.png', :content => File.read('/somefile.png') | |
+end | |
+ | |
+mail.delivery_method :sendmail | |
+ | |
+mail.deliver | |
+``` | |
+ | |
+Exim requires it's own delivery manager, and can be used like so: | |
+ | |
+```ruby | |
+mail.delivery_method :exim, :location => "/usr/bin/exim" | |
+ | |
+mail.deliver | |
+``` | |
+ | |
+### Getting emails from a pop server: | |
+ | |
+You can configure Mail to receive email using <code>retriever_method</code> | |
+within <code>Mail.defaults</code>: | |
+ | |
+```ruby | |
+Mail.defaults do | |
+ retriever_method :pop3, :address => "pop.gmail.com", | |
+ :port => 995, | |
+ :user_name => '<username>', | |
+ :password => '<password>', | |
+ :enable_ssl => true | |
+end | |
+``` | |
+ | |
+You can access incoming email in a number of ways. | |
+ | |
+The most recent email: | |
+ | |
+```ruby | |
+Mail.all #=> Returns an array of all emails | |
+Mail.first #=> Returns the first unread email | |
+Mail.last #=> Returns the first unread email | |
+``` | |
+ | |
+The first 10 emails sorted by date in ascending order: | |
+ | |
+```ruby | |
+emails = Mail.find(:what => :first, :count => 10, :order => :asc) | |
+emails.length #=> 10 | |
+``` | |
+ | |
+Or even all emails: | |
+ | |
+```ruby | |
+emails = Mail.all | |
+emails.length #=> LOTS! | |
+``` | |
+ | |
+ | |
+### Reading an Email | |
+ | |
+```ruby | |
+mail = Mail.read('/path/to/message.eml') | |
+ | |
+mail.envelope.from #=> '[email protected]' | |
+mail.from.addresses #=> ['[email protected]', '[email protected]'] | |
+mail.sender.address #=> '[email protected]' | |
+mail.to #=> '[email protected]' | |
+mail.cc #=> '[email protected]' | |
+mail.subject #=> "This is the subject" | |
+mail.date.to_s #=> '21 Nov 1997 09:55:06 -0600' | |
+mail.message_id #=> '<[email protected]>' | |
+mail.body.decoded #=> 'This is the body of the email... | |
+``` | |
+ | |
+Many more methods available. | |
+ | |
+### Reading a Multipart Email | |
+ | |
+```ruby | |
+mail = Mail.read('multipart_email') | |
+ | |
+mail.multipart? #=> true | |
+mail.parts.length #=> 2 | |
+mail.preamble #=> "Text before the first part" | |
+mail.epilogue #=> "Text after the last part" | |
+mail.parts.map { |p| p.content_type } #=> ['text/plain', 'application/pdf'] | |
+mail.parts.map { |p| p.class } #=> [Mail::Message, Mail::Message] | |
+mail.parts[0].content_type_parameters #=> {'charset' => 'ISO-8859-1'} | |
+mail.parts[1].content_type_parameters #=> {'name' => 'my.pdf'} | |
+``` | |
+ | |
+Mail generates a tree of parts. Each message has many or no parts. Each part | |
+is another message which can have many or no parts. | |
+ | |
+A message will only have parts if it is a multipart/mixed or related/mixed | |
+content type and has a boundary defined. | |
+ | |
+### Testing and extracting attachments | |
+```ruby | |
+mail.attachments.each do | attachment | | |
+ # Attachments is an AttachmentsList object containing a | |
+ # number of Part objects | |
+ if (attachment.content_type.start_with?('image/')) | |
+ # extracting images for example... | |
+ filename = attachment.filename | |
+ begin | |
+ File.open(images_dir + filename, "w+b", 0644) {|f| f.write attachment.body.decoded} | |
+ rescue Exception => e | |
+ puts "Unable to save data for #{filename} because #{e.message}" | |
+ end | |
+ end | |
+end | |
+``` | |
+### Writing and sending a multipart/alternative (html and text) email | |
+ | |
+Mail makes some basic assumptions and makes doing the common thing as | |
+simple as possible.... (asking a lot from a mail library) | |
+ | |
+```ruby | |
+mail = Mail.deliver do | |
+ to '[email protected]' | |
+ from 'Mikel Lindsaar <[email protected]>' | |
+ subject 'First multipart email sent with Mail' | |
+ | |
+ text_part do | |
+ body 'This is plain text' | |
+ end | |
+ | |
+ html_part do | |
+ content_type 'text/html; charset=UTF-8' | |
+ body '<h1>This is HTML</h1>' | |
+ end | |
+end | |
+``` | |
+ | |
+Mail then delivers the email at the end of the block and returns the | |
+resulting Mail::Message object, which you can then inspect if you | |
+so desire... | |
+ | |
+``` | |
+puts mail.to_s #=> | |
+ | |
+To: [email protected] | |
+From: Mikel Lindsaar <[email protected]> | |
+Subject: First multipart email sent with Mail | |
+Content-Type: multipart/alternative; | |
+ boundary=--==_mimepart_4a914f0c911be_6f0f1ab8026659 | |
+Message-ID: <[email protected]> | |
+Date: Mon, 24 Aug 2009 00:15:46 +1000 | |
+Mime-Version: 1.0 | |
+Content-Transfer-Encoding: 7bit | |
+ | |
+ | |
+----==_mimepart_4a914f0c911be_6f0f1ab8026659 | |
+Content-ID: <[email protected]> | |
+Date: Mon, 24 Aug 2009 00:15:46 +1000 | |
+Mime-Version: 1.0 | |
+Content-Type: text/plain | |
+Content-Transfer-Encoding: 7bit | |
+ | |
+This is plain text | |
+----==_mimepart_4a914f0c911be_6f0f1ab8026659 | |
+Content-Type: text/html; charset=UTF-8 | |
+Content-ID: <[email protected]> | |
+Date: Mon, 24 Aug 2009 00:15:46 +1000 | |
+Mime-Version: 1.0 | |
+Content-Transfer-Encoding: 7bit | |
+ | |
+<h1>This is HTML</h1> | |
+----==_mimepart_4a914f0c911be_6f0f1ab8026659-- | |
+``` | |
+ | |
+Mail inserts the content transfer encoding, the mime version, | |
+the content-id's and handles the content-type and boundary. | |
+ | |
+Mail assumes that if your text in the body is only us-ascii, that your | |
+transfer encoding is 7bit and it is text/plain. You can override this | |
+by explicitly declaring it. | |
+ | |
+### Making Multipart/Alternate, without a block | |
+ | |
+You don't have to use a block with the text and html part included, you | |
+can just do it declaratively. However, you need to add Mail::Parts to | |
+an email, not Mail::Messages. | |
+ | |
+```ruby | |
+mail = Mail.new do | |
+ to '[email protected]' | |
+ from 'Mikel Lindsaar <[email protected]>' | |
+ subject 'First multipart email sent with Mail' | |
+end | |
+ | |
+text_part = Mail::Part.new do | |
+ body 'This is plain text' | |
+end | |
+ | |
+html_part = Mail::Part.new do | |
+ content_type 'text/html; charset=UTF-8' | |
+ body '<h1>This is HTML</h1>' | |
+end | |
+ | |
+mail.text_part = text_part | |
+mail.html_part = html_part | |
+``` | |
+ | |
+Results in the same email as done using the block form | |
+ | |
+### Getting error reports from an email: | |
+ | |
+```ruby | |
+@mail = Mail.read('/path/to/bounce_message.eml') | |
+ | |
[email protected]? #=> true | |
[email protected]_recipient #=> rfc822;[email protected] | |
[email protected] #=> failed | |
[email protected]_status #=> 5.5.0 | |
[email protected]_code #=> smtp;550 Requested action not taken: mailbox unavailable | |
[email protected]? #=> false | |
+``` | |
+ | |
+### Attaching and Detaching Files | |
+ | |
+You can just read the file off an absolute path, Mail will try | |
+to guess the mime_type and will encode the file in Base64 for you. | |
+ | |
+```ruby | |
+@mail = Mail.new | |
[email protected]_file("/path/to/file.jpg") | |
[email protected]? #=> true | |
[email protected]_transfer_encoding.to_s #=> 'base64' | |
[email protected]_type #=> 'image/jpg' | |
[email protected] #=> 'file.jpg' | |
[email protected] == File.read('/path/to/file.jpg') #=> true | |
+``` | |
+ | |
+Or You can pass in file_data and give it a filename, again, mail | |
+will try and guess the mime_type for you. | |
+ | |
+```ruby | |
+@mail = Mail.new | |
[email protected]['myfile.pdf'] = File.read('path/to/myfile.pdf') | |
[email protected]? #=> true | |
[email protected]_type #=> 'application/pdf' | |
[email protected] == File.read('path/to/myfile.pdf') #=> true | |
+``` | |
+ | |
+You can also override the guessed MIME media type if you really know better | |
+than mail (this should be rarely needed) | |
+ | |
+```ruby | |
+@mail = Mail.new | |
+file_data = File.read('path/to/myfile.pdf') | |
[email protected]['myfile.pdf'] = { :mime_type => 'application/x-pdf', | |
+ :content => File.read('path/to/myfile.pdf') } | |
[email protected]_type #=> 'application/x-pdf' | |
+``` | |
+ | |
+Of course... Mail will round trip an attachment as well | |
+ | |
+```ruby | |
+@mail = Mail.new do | |
+ to '[email protected]' | |
+ from 'Mikel Lindsaar <[email protected]>' | |
+ subject 'First multipart email sent with Mail' | |
+ | |
+ text_part do | |
+ body 'Here is the attachment you wanted' | |
+ end | |
+ | |
+ html_part do | |
+ content_type 'text/html; charset=UTF-8' | |
+ body '<h1>Funky Title</h1><p>Here is the attachment you wanted</p>' | |
+ end | |
+ | |
+ add_file '/path/to/myfile.pdf' | |
+end | |
+ | |
+@round_tripped_mail = Mail.new(@mail.encoded) | |
+ | |
+@round_tripped_mail.attachments.length #=> 1 | |
+@round_tripped_mail.attachments.first.filename #=> 'myfile.pdf' | |
+``` | |
+See "Testing and extracting attachments" above for more details. | |
+ | |
+Using Mail with Testing or Spec'ing Libraries | |
+--------------------------------------------- | |
+ | |
+If mail is part of your system, you'll need a way to test it without actually | |
+sending emails, the TestMailer can do this for you. | |
+ | |
+``` | |
+require 'mail' | |
+=> true | |
+Mail.defaults do | |
+ delivery_method :test | |
+end | |
+=> #<Mail::Configuration:0x19345a8 @delivery_method=Mail::TestMailer> | |
+Mail::TestMailer.deliveries | |
+=> [] | |
+Mail.deliver do | |
+ to '[email protected]' | |
+ from '[email protected]' | |
+ subject 'testing' | |
+ body 'hello' | |
+end | |
+=> #<Mail::Message:0x19284ec ... | |
+Mail::TestMailer.deliveries.length | |
+=> 1 | |
+Mail::TestMailer.deliveries.first | |
+=> #<Mail::Message:0x19284ec ... | |
+Mail::TestMailer.deliveries.clear | |
+=> [] | |
+``` | |
+ | |
+There is also a set of RSpec matchers stolen fr^H^H^H^H^H^H^H^H inspired by Shoulda's ActionMailer matchers (you'll want to set <code>delivery_method</code> as above too): | |
+ | |
+``` | |
+Mail.defaults do | |
+ delivery_method :test # in practice you'd do this in spec_helper.rb | |
+end | |
+ | |
+describe "sending an email" do | |
+ include Mail::Matchers | |
+ | |
+ before(:each) do | |
+ Mail::TestMailer.deliveries.clear | |
+ | |
+ Mail.deliver do | |
+ to ['[email protected]', '[email protected]'] | |
+ from '[email protected]' | |
+ subject 'testing' | |
+ body 'hello' | |
+ end | |
+ end | |
+ | |
+ it { should have_sent_email } # passes if any email at all was sent | |
+ | |
+ it { should have_sent_email.from('[email protected]') } | |
+ it { should have_sent_email.to('[email protected]') } | |
+ | |
+ # can specify a list of recipients... | |
+ it { should have_sent_email.to(['[email protected]', '[email protected]']) } | |
+ | |
+ # ...or chain recipients together | |
+ it { should have_sent_email.to('[email protected]').to('[email protected]') } | |
+ | |
+ it { should have_sent_email.with_subject('testing') } | |
+ | |
+ it { should have_sent_email.with_body('hello') } | |
+ | |
+ # Can match subject or body with a regex | |
+ # (or anything that responds_to? :match) | |
+ | |
+ it { should have_sent_email.matching_subject(/test(ing)?/) } | |
+ it { should have_sent_email.matching_body(/h(a|e)llo/) } | |
+ | |
+ # Can chain together modifiers | |
+ # Note that apart from recipients, repeating a modifier overwrites old value. | |
+ | |
+ it { should have_sent_email.from('[email protected]').to('[email protected]').matching_body(/hell/) | |
+end | |
+``` | |
+ | |
+Excerpts from TREC Spam Corpus 2005 | |
+----------------------------------- | |
+ | |
+The spec fixture files in spec/fixtures/emails/from_trec_2005 are from the | |
+2005 TREC Public Spam Corpus. They remain copyrighted under the terms of | |
+that project and license agreement. They are used in this project to verify | |
+and describe the development of this email parser implementation. | |
+ | |
+http://plg.uwaterloo.ca/~gvcormac/treccorpus/ | |
+ | |
+They are used as allowed by 'Permitted Uses, Clause 3': | |
+ | |
+ "Small excerpts of the information may be displayed to others | |
+ or published in a scientific or technical context, solely for | |
+ the purpose of describing the research and development and | |
+ related issues." | |
+ | |
+ -- http://plg.uwaterloo.ca/~gvcormac/treccorpus/ | |
+ | |
+License | |
+------- | |
+ | |
+(The MIT License) | |
+ | |
+Copyright (c) 2009, 2010, 2011, 2012 | |
+ | |
+Permission is hereby granted, free of charge, to any person obtaining | |
+a copy of this software and associated documentation files (the | |
+'Software'), to deal in the Software without restriction, including | |
+without limitation the rights to use, copy, modify, merge, publish, | |
+distribute, sublicense, and/or sell copies of the Software, and to | |
+permit persons to whom the Software is furnished to do so, subject to | |
+the following conditions: | |
+ | |
+The above copyright notice and this permission notice shall be | |
+included in all copies or substantial portions of the Software. | |
+ | |
+THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, | |
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | |
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. | |
+IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY | |
+CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, | |
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE | |
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | |
diff --git a/README.rdoc b/README.rdoc | |
deleted file mode 100644 | |
index 05f2c04..0000000 | |
--- a/README.rdoc | |
+++ /dev/null | |
@@ -1,563 +0,0 @@ | |
- | |
-== Introduction | |
- | |
-Mail is an internet library for Ruby that is designed to handle emails | |
-generation, parsing and sending in a simple, rubyesque manner. | |
- | |
-The purpose of this library is to provide a single point of access to handle | |
-all email functions, including sending and receiving emails. All network | |
-type actions are done through proxy methods to Net::SMTP, Net::POP3 etc. | |
- | |
-Built from my experience with TMail, it is designed to be a pure ruby | |
-implementation that makes generating, sending and parsing emails a no | |
-brainer. | |
- | |
-It is also designed form the ground up to work with Ruby 1.9. This is because | |
-Ruby 1.9 handles text encodings much more magically than Ruby 1.8.x and so | |
-these features have been taken full advantage of in this library allowing | |
-Mail to handle a lot more messages more cleanly than TMail. Mail does run on | |
-Ruby 1.8.x... it's just not as fun to code. | |
- | |
-Finally, Mail has been designed with a very simple object oriented system | |
-that really opens up the email messages you are parsing, if you know what | |
-you are doing, you can fiddle with every last bit of your email directly. | |
- | |
-== Compatibility | |
- | |
-Mail is tested and works on the following platforms: | |
- | |
-* jruby-1.5.2 [ [x86_64-java] ] | |
-* ree-1.8.7-2010.02 [ x86_64 ] | |
-* ruby-1.8.6-p399 [ x86_64 ] | |
-* ruby-1.8.7-p302 [ x86_64 ] | |
-* ruby-1.9.2-p0 [ x86_64 ] | |
- | |
-== Discussion | |
- | |
-If you want to discuss mail with like minded individuals, please subscribe to | |
-the Google Group http://groups.google.com/group/mail-ruby | |
- | |
-== Current Capabilities of Mail | |
- | |
-* RFC2822 Support, Reading and Writing | |
-* RFC2045-2049 Support for multipart emails | |
-* Support for creating multipart alternate emails | |
-* Support for reading multipart/report emails & getting details from such | |
-* Support for multibyte emails - needs quite a lot of work and testing | |
-* Wrappers for File, Net/POP3, Net/SMTP | |
-* Auto encoding of non US-ASCII header fields | |
-* Auto encoding of non US-ASCII bodies | |
- | |
-Mail is RFC2822 compliant now, that is, it can parse and generate valid US-ASCII | |
-emails. There are a few obsoleted syntax emails that it will have problems with, but | |
-it also is quite robust, meaning, if it finds something it doesn't understand it will | |
-not crash, instead, it will skip the problem and keep parsing. In the case of a header | |
-it doesn't understand, it will initialise the header as an optional unstructured | |
-field and continue parsing. | |
- | |
-This means Mail won't (ever) crunch your data (I think). | |
- | |
-You can also create MIME emails. There are helper methods for making a | |
-multipart/alternate email for text/plain and text/html (the most common pair) | |
-and you can manually create any other type of MIME email. | |
- | |
-== Roadmap | |
- | |
-Next TODO: | |
- | |
-* Improve MIME support for character sets in headers, currently works, mostly, needs | |
- refinement. | |
- | |
-== Testing Policy | |
- | |
-Basically... we do BDD on Mail. No method gets written in Mail without a | |
-corresponding or covering spec. We expect as a minimum 100% coverage | |
-measured by RCov. While this is not perfect by any measure, it is pretty | |
-good. Additionally, all functional tests from TMail are to be passing before | |
-the gem gets released. | |
- | |
-It also means you can be sure Mail will behave correctly. | |
- | |
-== API Policy | |
- | |
-No API removals within a single point release. All removals to be depreciated with | |
-warnings for at least one MINOR point release before removal. | |
- | |
-Also, all private or protected methods to be declared as such - though this is still I/P. | |
- | |
-== Installation | |
- | |
-Installation is fairly simple, I host mail on rubygems, so you can just do: | |
- | |
- # gem install mail | |
- | |
-== Encodings | |
- | |
-If you didn't know, handling encodings in Emails is not as straight forward as you | |
-would hope. | |
- | |
-I have tried to simplify it some: | |
- | |
-1. All objects that can render into an email, have an :encoded method. Encoded will | |
- return the object as a complete string ready to send in the mail system, that is, | |
- it will include the header field and value and CRLF at the end and wrapped as | |
- needed. | |
- | |
-2. All objects that can render into an email, have a :decoded method. Decoded will | |
- return the object's "value" only as a string. This means it will not include | |
- the header fields (like 'To:' or 'Subject:'). | |
- | |
-3. By default, calling :to_s on a container object will call it's encoded method, while | |
- :to_s on a field object will call it's decoded method. So calling :to_s on a Mail | |
- object will return the mail, all encoded ready to send, while calling :to_s on the | |
- From field or the body will return the decoded value of the object. The header object | |
- of Mail is considered a container. If you are in doubt, call :encoded, or :decoded | |
- explicitly, this is safer if you are not sure. | |
- | |
-4. Structured fields that have parameter values that can be encoded (e.g. Content-Type) will | |
- provide decoded parameter values when you call the parameter names as methods against | |
- the object. | |
- | |
-5. Structured fields that have parameter values that can be encoded (e.g. Content-Type) will | |
- provide encoded parameter values when you call the parameter names through the | |
- object.parameters['<parameter_name>'] method call. | |
- | |
-== Contributing | |
- | |
-Please do! Contributing is easy in Mail: | |
- | |
-1. Check the Reference RFCs, they are in the References directory, so no excuses. | |
-2. Open a ticket on github, maybe someone else has the problem too | |
-3. Make a fork of my github repository | |
-4. Make a spec driven change to the code base | |
-5. Make sure it works and all specs pass, on Ruby versions 1.8.6, 1.8.7 and 1.9 | |
-6. Update the README if needed to reflect your change / addition | |
-7. With all specs passing push your changes back to your fork | |
-8. Send me a pull request | |
- | |
-== Usage | |
- | |
-All major mail functions should be able to happen from the Mail::module. | |
-So, you should be able to just "require 'mail'" to get started. | |
- | |
-=== Making an email | |
- | |
- require 'mail' | |
- | |
- mail = Mail.new do | |
- from '[email protected]' | |
- to '[email protected]' | |
- subject 'This is a test email' | |
- body File.read('body.txt') | |
- end | |
- | |
- mail.to_s #=> "From: [email protected]\r\nTo: you@... | |
- | |
-=== Making an email, have it your way: | |
- | |
- require 'mail' | |
- | |
- mail = Mail.new do | |
- body File.read('body.txt') | |
- end | |
- | |
- mail['from'] = '[email protected]' | |
- mail[:to] = '[email protected]' | |
- mail.subject = 'This is a test email' | |
- | |
- mail.to_s #=> "From: [email protected]\r\nTo: you@... | |
- | |
-=== Don't Worry About Message IDs: | |
- | |
- require 'mail' | |
- | |
- mail = Mail.new do | |
- to '[email protected]' | |
- body 'Some simple body' | |
- end | |
- | |
- mail.to_s =~ /Message\-ID: <[\d\w_]+@.+.mail/ #=> 27 | |
- | |
-Mail will automatically add a Message-ID field if it is missing and | |
-give it a unique, random Message-ID along the lines of: | |
- | |
- <[email protected]> | |
- | |
-=== Or do worry about Message-IDs: | |
- | |
- require 'mail' | |
- | |
- mail = Mail.new do | |
- to '[email protected]' | |
- message_id '<[email protected]>' | |
- body 'Some simple body' | |
- end | |
- | |
- mail.to_s =~ /Message\-ID: <[email protected]>/ #=> 27 | |
- | |
-Mail will take the message_id you assign to it trusting that you know | |
-what you are doing. | |
- | |
-=== Sending an email: | |
- | |
-Mail defaults to sending via SMTP to local host port 25. If you have a | |
-sendmail or postfix daemon running on on this port, sending email is as | |
-easy as: | |
- | |
- Mail.deliver do | |
- from '[email protected]' | |
- to '[email protected]' | |
- subject 'Here is the image you wanted' | |
- body File.read('body.txt') | |
- add_file '/full/path/to/somefile.png' | |
- end | |
- | |
-or | |
- | |
- mail = Mail.new do | |
- from '[email protected]' | |
- to '[email protected]' | |
- subject 'Here is the image you wanted' | |
- body File.read('body.txt') | |
- add_file {:filename => 'somefile.png', :content => File.read('/somefile.png')} | |
- end | |
- | |
- mail.deliver! | |
- | |
-Sending via sendmail can be done like so: | |
- | |
- mail = Mail.new do | |
- from '[email protected]' | |
- to '[email protected]' | |
- subject 'Here is the image you wanted' | |
- body File.read('body.txt') | |
- add_file {:filename => 'somefile.png', :content => File.read('/somefile.png')} | |
- end | |
- | |
- mail.delivery_method :sendmail | |
- | |
- mail.deliver | |
- | |
-{Learn more about SMTP Delivery}[link:classes/Mail/SMTP.html] | |
- | |
-{Learn more about File Delivery}[link:classes/Mail/FileDelivery.html] | |
- | |
-{Learn more about Sendmail Delivery}[link:classes/Mail/Sendmail.html] | |
- | |
-{Learn more about Test Email Delivery}[link:classes/Mail/TestMailer.html] | |
- | |
-=== Getting emails from a pop server: | |
- | |
-The most recent email: | |
- | |
- Mail.defaults do | |
- retriever_method :pop3, { :address => "pop.gmail.com", | |
- :port => 995, | |
- :user_name => '<username>', | |
- :password => '<password>', | |
- :enable_ssl => true } | |
- end | |
- | |
- Mail.all #=> Returns an array of all emails | |
- Mail.first #=> Returns the first unread email | |
- Mail.last #=> Returns the first unread email | |
- | |
-The first 10 emails sorted by date in ascending order: | |
- | |
- require 'mail' | |
- | |
- Mail.defaults do | |
- retriever_method :pop3, { :address => "pop.gmail.com", | |
- :port => 995, | |
- :user_name => '<username>', | |
- :password => '<password>', | |
- :enable_ssl => true } | |
- end | |
- | |
- emails = Mail.find(:what => :first, :count => 10, :order => :asc) | |
- emails.length #=> 10 | |
- | |
-Or even all emails: | |
- | |
- Mail.defaults do | |
- retriever_method :pop3, { :address => "pop.gmail.com", | |
- :port => 995, | |
- :user_name => '<username>', | |
- :password => '<password>', | |
- :enable_ssl => true } | |
- end | |
- | |
- emails = Mail.all | |
- | |
- emails.length #=> LOTS! | |
- | |
-{Learn more about POP3}[link:classes/Mail/POP3.html] | |
- | |
-{Learn more about IMAP}[link:classes/Mail/IMAP.html] | |
- | |
-=== Reading an Email | |
- | |
- require 'mail' | |
- | |
- mail = Mail.read('/path/to/message.eml') | |
- | |
- mail.envelope.from #=> '[email protected]' | |
- mail.from.addresses #=> ['[email protected]', '[email protected]'] | |
- mail.sender.address #=> '[email protected]' | |
- mail.to #=> '[email protected]' | |
- mail.cc #=> '[email protected]' | |
- mail.subject #=> "This is the subject" | |
- mail.date.to_s #=> '21 Nov 1997 09:55:06 -0600' | |
- mail.message_id #=> '<[email protected]>' | |
- mail.body.decoded #=> 'This is the body of the email... | |
- | |
-Many more methods available. | |
- | |
-=== Reading a Multipart Email | |
- | |
- require 'mail' | |
- | |
- mail = Mail.read('multipart_email') | |
- | |
- mail.multipart? #=> true | |
- mail.parts.length #=> 2 | |
- mail.preamble #=> "Text before the first part" | |
- mail.epilogue #=> "Text after the last part" | |
- mail.parts.map { |p| p.content_type } #=> ['text/plain', 'application/pdf'] | |
- mail.parts.map { |p| p.class } #=> [Mail::Message, Mail::Message] | |
- mail.parts[0].content_type_parameters #=> {'charset' => 'ISO-8859-1'} | |
- mail.parts[1].content_type_parameters #=> {'name' => 'my.pdf'} | |
- | |
-Mail generates a tree of parts. Each message has many or no parts. Each part | |
-is another message which can have many or no parts. | |
- | |
-A message will only have parts if it is a multipart/mixed or related/mixed | |
-content type and has a boundary defined. | |
- | |
-=== Writing and sending a multipart/alternative (html and text) email | |
- | |
-Mail makes some basic assumptions and makes doing the common thing as | |
-simple as possible.... (asking a lot from a mail library) | |
- | |
- require 'mail' | |
- | |
- mail = Mail.deliver do | |
- to '[email protected]' | |
- from 'Mikel Lindsaar <[email protected]>' | |
- subject 'First multipart email sent with Mail' | |
- text_part do | |
- body 'This is plain text' | |
- end | |
- html_part do | |
- content_type 'text/html; charset=UTF-8' | |
- body '<h1>This is HTML</h1>' | |
- end | |
- end | |
- | |
-Mail then delivers the email at the end of the block and returns the | |
-resulting Mail::Message object, which you can then inspect if you | |
-so desire... | |
- | |
- puts mail.to_s #=> | |
- | |
- To: [email protected] | |
- From: Mikel Lindsaar <[email protected]> | |
- Subject: First multipart email sent with Mail | |
- Content-Type: multipart/alternative; | |
- boundary=--==_mimepart_4a914f0c911be_6f0f1ab8026659 | |
- Message-ID: <[email protected]> | |
- Date: Mon, 24 Aug 2009 00:15:46 +1000 | |
- Mime-Version: 1.0 | |
- Content-Transfer-Encoding: 7bit | |
- | |
- | |
- ----==_mimepart_4a914f0c911be_6f0f1ab8026659 | |
- Content-ID: <[email protected]> | |
- Date: Mon, 24 Aug 2009 00:15:46 +1000 | |
- Mime-Version: 1.0 | |
- Content-Type: text/plain | |
- Content-Transfer-Encoding: 7bit | |
- | |
- This is plain text | |
- ----==_mimepart_4a914f0c911be_6f0f1ab8026659 | |
- Content-Type: text/html; charset=UTF-8 | |
- Content-ID: <[email protected]> | |
- Date: Mon, 24 Aug 2009 00:15:46 +1000 | |
- Mime-Version: 1.0 | |
- Content-Transfer-Encoding: 7bit | |
- | |
- <h1>This is HTML</h1> | |
- ----==_mimepart_4a914f0c911be_6f0f1ab8026659-- | |
- | |
-Mail inserts the content transfer encoding, the mime version, | |
-the content-id's and handles the content-type and boundary. | |
- | |
-Mail assumes that if your text in the body is only us-ascii, that your | |
-transfer encoding is 7bit and it is text/plain. You can override this | |
-by explicitly declaring it. | |
- | |
-=== Making Multipart/Alternate, without a block | |
- | |
-You don't have to use a block with the text and html part included, you | |
-can just do it declaratively. However, you need to add Mail::Parts to | |
-an email, not Mail::Messages. | |
- | |
- require 'mail' | |
- | |
- mail = Mail.new do | |
- to '[email protected]' | |
- from 'Mikel Lindsaar <[email protected]>' | |
- subject 'First multipart email sent with Mail' | |
- end | |
- | |
- text_part = Mail::Part.new do | |
- body 'This is plain text' | |
- end | |
- | |
- html_part = Mail::Part.new do | |
- content_type 'text/html; charset=UTF-8' | |
- body '<h1>This is HTML</h1>' | |
- end | |
- | |
- mail.text_part = text_part | |
- mail.html_part = html_part | |
- | |
-Results in the same email as done using the block form | |
- | |
-=== Getting error reports from an email: | |
- | |
- require 'mail' | |
- | |
- @mail = Mail.read('/path/to/bounce_message.eml') | |
- | |
- @mail.bounced? #=> true | |
- @mail.final_recipient #=> rfc822;[email protected] | |
- @mail.action #=> failed | |
- @mail.error_status #=> 5.5.0 | |
- @mail.diagnostic_code #=> smtp;550 Requested action not taken: mailbox unavailable | |
- @mail.retryable? #=> false | |
- | |
-=== Attaching and Detaching Files | |
- | |
- require 'mail' | |
- | |
-You can just read the file off an absolute path, Mail will try | |
-to guess the mime_type and will encode the file in Base64 for you. | |
- | |
- @mail = Mail.new | |
- @mail.add_file("/path/to/file.jpg") | |
- @mail.parts.first.attachment? #=> true | |
- @mail.parts.first.content_transfer_encoding.to_s #=> 'base64' | |
- @mail.attachments.first.mime_type #=> 'image/jpg' | |
- @mail.attachments.first.filename #=> 'file.jpg' | |
- @mail.attachments.first.decoded == File.read('/path/to/file.jpg') #=> true | |
- | |
-Or You can pass in file_data and give it a filename, again, mail | |
-will try and guess the mime_type for you. | |
- | |
- @mail = Mail.new | |
- @mail.attachments['myfile.pdf'] = File.read('path/to/myfile.pdf') | |
- @mail.parts.first.attachment? #=> true | |
- @mail.attachments.first.mime_type #=> 'application/pdf' | |
- @mail.attachments.first.decoded == File.read('path/to/myfile.pdf') #=> true | |
- | |
-You can also override the guessed MIME media type if you really know better | |
-than mail (this should be rarely needed) | |
- | |
- @mail = Mail.new | |
- file_data = File.read('path/to/myfile.pdf') | |
- @mail.attachments['myfile.pdf'] = { :mime_type => 'application/x-pdf', | |
- :content => File.read('path/to/myfile.pdf') } | |
- @mail.parts.first.mime_type #=> 'application/x-pdf' | |
- | |
-Of course... Mail will round trip an attachment as well | |
- | |
- @mail = Mail.new do | |
- to '[email protected]' | |
- from 'Mikel Lindsaar <[email protected]>' | |
- subject 'First multipart email sent with Mail' | |
- text_part do | |
- body 'Here is the attachment you wanted' | |
- end | |
- html_part do | |
- content_type 'text/html; charset=UTF-8' | |
- body '<h1>Funky Title</h1><p>Here is the attachment you wanted</p>' | |
- end | |
- add_file '/path/to/myfile.pdf' | |
- end | |
- | |
- @round_tripped_mail = Mail.new(@mail.encoded) | |
- | |
- @round_tripped_mail.attachments.length #=> 1 | |
- @round_tripped_mail.attachments.first.filename #=> 'myfile.pdf' | |
- | |
-== Using Mail with Testing or Spec'ing Libraries | |
- | |
-If mail is part of your system, you'll need a way to test it without actually | |
-sending emails, the TestMailer can do this for you. | |
- | |
- require 'mail' | |
- => true | |
- Mail.defaults do | |
- delivery_method :test | |
- end | |
- => #<Mail::Configuration:0x19345a8 @delivery_method=Mail::TestMailer> | |
- Mail::TestMailer.deliveries | |
- => [] | |
- Mail.deliver do | |
- to '[email protected]' | |
- from '[email protected]' | |
- subject 'testing' | |
- body 'hello' | |
- end | |
- => #<Mail::Message:0x19284ec ... | |
- Mail::TestMailer.deliveries.length | |
- => 1 | |
- Mail::TestMailer.deliveries.first | |
- => #<Mail::Message:0x19284ec ... | |
- Mail::TestMailer.deliveries.clear | |
- => [] | |
- | |
-== Excerpts from TREC Spam Corpus 2005 | |
- | |
-The spec fixture files in spec/fixtures/emails/from_trec_2005 are from the | |
-2005 TREC Public Spam Corpus. They remain copyrighted under the terms of | |
-that project and license agreement. They are used in this project to verify | |
-and describe the development of this email parser implementation. | |
- | |
-http://plg.uwaterloo.ca/~gvcormac/treccorpus/ | |
- | |
-They are used as allowed by 'Permitted Uses, Clause 3': | |
- | |
- "Small excerpts of the information may be displayed to others | |
- or published in a scientific or technical context, solely for | |
- the purpose of describing the research and development and | |
- related issues." | |
- | |
- -- http://plg.uwaterloo.ca/~gvcormac/treccorpus/ | |
- | |
-== License: | |
- | |
-(The MIT License) | |
- | |
-Copyright (c) 2009, 2010, 2011 | |
- | |
-Permission is hereby granted, free of charge, to any person obtaining | |
-a copy of this software and associated documentation files (the | |
-'Software'), to deal in the Software without restriction, including | |
-without limitation the rights to use, copy, modify, merge, publish, | |
-distribute, sublicense, and/or sell copies of the Software, and to | |
-permit persons to whom the Software is furnished to do so, subject to | |
-the following conditions: | |
- | |
-The above copyright notice and this permission notice shall be | |
-included in all copies or substantial portions of the Software. | |
- | |
-THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, | |
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | |
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. | |
-IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY | |
-CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, | |
-TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE | |
-SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | |
diff --git a/Rakefile b/Rakefile | |
index 46d0c40..ee9f344 100644 | |
--- a/Rakefile | |
+++ b/Rakefile | |
@@ -23,7 +23,7 @@ require File.expand_path('../spec/environment', __FILE__) | |
require 'rake/rdoctask' | |
require 'rake/testtask' | |
-require 'spec/rake/spectask' | |
+require 'rspec/core/rake_task' | |
desc "Build a gem file" | |
task :build do | |
@@ -32,18 +32,15 @@ end | |
task :default => :spec | |
-Spec::Rake::SpecTask.new(:rcov) do |t| | |
- t.spec_files = FileList['test/**/tc_*.rb', 'spec/**/*_spec.rb'] | |
+RSpec::Core::RakeTask.new(:rcov) do |t| | |
t.rcov = true | |
+ t.rcov_opts ||= [] | |
t.rcov_opts = t.rcov_opts << ['--exclude', '/Library,/opt,/System,/usr'] | |
end | |
-Spec::Rake::SpecTask.new(:spec) do |t| | |
- t.warning = true | |
- t.spec_files = FileList["#{File.dirname(__FILE__)}/spec/**/*_spec.rb"] | |
- t.spec_opts = %w(--backtrace --diff --color) | |
- t.libs << "#{File.dirname(__FILE__)}/spec" | |
- t.libs << "#{File.dirname(__FILE__)}/spec/mail" | |
+RSpec::Core::RakeTask.new(:spec) do |t| | |
+ t.ruby_opts = '-w' | |
+ t.rspec_opts = %w(--backtrace --color) | |
end | |
Rake::RDocTask.new(:rdoc) do |rdoc| | |
@@ -59,7 +56,6 @@ Rake::RDocTask.new(:rdoc) do |rdoc| | |
rdoc.rdoc_files.include('lib/**/*.rb') | |
rdoc.rdoc_files.include('lib/network/**/*.rb') | |
rdoc.rdoc_files.exclude('lib/parsers/*') | |
- | |
end | |
# load custom rake tasks | |
diff --git a/lib/VERSION b/lib/VERSION | |
index 144bbb0..5288c76 100644 | |
--- a/lib/VERSION | |
+++ b/lib/VERSION | |
@@ -1,4 +1,4 @@ | |
major:2 | |
-minor:3 | |
-patch:3 | |
+minor:4 | |
+patch:0 | |
build: | |
diff --git a/lib/mail.rb b/lib/mail.rb | |
index 758de74..362fb10 100644 | |
--- a/lib/mail.rb | |
+++ b/lib/mail.rb | |
@@ -29,7 +29,7 @@ module Mail # :doc: | |
require 'mail/core_extensions/nil' | |
require 'mail/core_extensions/object' | |
require 'mail/core_extensions/string' | |
- require 'mail/core_extensions/shell_escape' | |
+ require 'mail/core_extensions/shellwords' unless String.new.respond_to?(:shellescape) | |
require 'mail/core_extensions/smtp' if RUBY_VERSION < '1.9.3' | |
require 'mail/indifferent_hash' | |
@@ -84,6 +84,8 @@ module Mail # :doc: | |
require 'mail/encodings/base64' | |
require 'mail/encodings/quoted_printable' | |
+ require 'mail/matchers/has_sent_mail' | |
+ | |
# Finally... require all the Mail.methods | |
require 'mail/mail' | |
end | |
diff --git a/lib/mail/attachments_list.rb b/lib/mail/attachments_list.rb | |
index 5c41b74..740dd51 100644 | |
--- a/lib/mail/attachments_list.rb | |
+++ b/lib/mail/attachments_list.rb | |
@@ -94,10 +94,9 @@ module Mail | |
def set_mime_type(filename) | |
# Have to do this because MIME::Types is not Ruby 1.9 safe yet | |
if RUBY_VERSION >= '1.9' | |
- new_file = String.new(filename).force_encoding(Encoding::BINARY) | |
- ext = new_file.split('.'.force_encoding(Encoding::BINARY)).last | |
- filename = "file.#{ext}".force_encoding('US-ASCII') | |
+ filename = filename.encode(Encoding::UTF_8) if filename.respond_to?(:encode) | |
end | |
+ | |
@mime_type = MIME::Types.type_for(filename).first | |
end | |
diff --git a/lib/mail/body.rb b/lib/mail/body.rb | |
index d9f2fae..641c821 100644 | |
--- a/lib/mail/body.rb | |
+++ b/lib/mail/body.rb | |
@@ -267,8 +267,7 @@ module Mail | |
end | |
def only_us_ascii? | |
- raw_source.each_byte {|b| return false if (b == 0 || b > 127)} | |
- true | |
+ !(raw_source =~ /[^\x01-\x7f]/) | |
end | |
def empty? | |
diff --git a/lib/mail/configuration.rb b/lib/mail/configuration.rb | |
index 75840f7..fbbf961 100644 | |
--- a/lib/mail/configuration.rb | |
+++ b/lib/mail/configuration.rb | |
@@ -5,10 +5,10 @@ | |
require 'singleton' | |
module Mail | |
- | |
+ | |
# The Configuration class is a Singleton used to hold the default | |
# configuration for all Mail objects. | |
- # | |
+ # | |
# Each new mail object gets a copy of these values at initialization | |
# which can be overwritten on a per mail object basis. | |
class Configuration | |
@@ -50,7 +50,7 @@ module Mail | |
return @retriever_method if @retriever_method && method.nil? | |
@retriever_method = lookup_retriever_method(method).new(settings) | |
end | |
- | |
+ | |
def lookup_retriever_method(method) | |
case method | |
when nil | |
diff --git a/lib/mail/core_extensions/nil.rb b/lib/mail/core_extensions/nil.rb | |
index 1adb5e4..8f39c6d 100644 | |
--- a/lib/mail/core_extensions/nil.rb | |
+++ b/lib/mail/core_extensions/nil.rb | |
@@ -3,6 +3,10 @@ | |
# This is not loaded if ActiveSupport is already loaded | |
class NilClass #:nodoc: | |
+ def blank? | |
+ true | |
+ end | |
+ | |
def to_crlf | |
'' | |
end | |
diff --git a/lib/mail/core_extensions/shell_escape.rb b/lib/mail/core_extensions/shell_escape.rb | |
deleted file mode 100644 | |
index 8972698..0000000 | |
--- a/lib/mail/core_extensions/shell_escape.rb | |
+++ /dev/null | |
@@ -1,56 +0,0 @@ | |
-# encoding: utf-8 | |
- | |
-# The following is an adaptation of ruby 1.9.2's shellwords.rb file, | |
-# it is modified to include '+' in the allowed list to allow for | |
-# sendmail to accept email addresses as the sender with a + in them | |
-# | |
-module Mail | |
- module ShellEscape | |
- # Escapes a string so that it can be safely used in a Bourne shell | |
- # command line. | |
- # | |
- # Note that a resulted string should be used unquoted and is not | |
- # intended for use in double quotes nor in single quotes. | |
- # | |
- # open("| grep #{Shellwords.escape(pattern)} file") { |pipe| | |
- # # ... | |
- # } | |
- # | |
- # +String#shellescape+ is a shorthand for this function. | |
- # | |
- # open("| grep #{pattern.shellescape} file") { |pipe| | |
- # # ... | |
- # } | |
- # | |
- def escape_for_shell(str) | |
- # An empty argument will be skipped, so return empty quotes. | |
- return "''" if str.empty? | |
- | |
- str = str.dup | |
- | |
- # Process as a single byte sequence because not all shell | |
- # implementations are multibyte aware. | |
- str.gsub!(/([^A-Za-z0-9_\s\+\-.,:\/@\n])/n, "\\\\\\1") | |
- | |
- # A LF cannot be escaped with a backslash because a backslash + LF | |
- # combo is regarded as line continuation and simply ignored. | |
- str.gsub!(/\n/, "'\n'") | |
- | |
- return str | |
- end | |
- | |
- module_function :escape_for_shell | |
- end | |
-end | |
- | |
-class String | |
- # call-seq: | |
- # str.shellescape => string | |
- # | |
- # Escapes +str+ so that it can be safely used in a Bourne shell | |
- # command line. See +Shellwords::shellescape+ for details. | |
- # | |
- def escape_for_shell | |
- Mail::ShellEscape.escape_for_shell(self) | |
- end | |
-end | |
\ No newline at end of file | |
diff --git a/lib/mail/core_extensions/shellwords.rb b/lib/mail/core_extensions/shellwords.rb | |
new file mode 100644 | |
index 0000000..bd433e4 | |
--- /dev/null | |
+++ b/lib/mail/core_extensions/shellwords.rb | |
@@ -0,0 +1,57 @@ | |
+# encoding: utf-8 | |
+ | |
+# The following is imported from ruby 1.9.2 shellwords.rb | |
+# | |
+module Shellwords | |
+ # Escapes a string so that it can be safely used in a Bourne shell | |
+ # command line. | |
+ # | |
+ # Note that a resulted string should be used unquoted and is not | |
+ # intended for use in double quotes nor in single quotes. | |
+ # | |
+ # open("| grep #{Shellwords.escape(pattern)} file") { |pipe| | |
+ # # ... | |
+ # } | |
+ # | |
+ # +String#shellescape+ is a shorthand for this function. | |
+ # | |
+ # open("| grep #{pattern.shellescape} file") { |pipe| | |
+ # # ... | |
+ # } | |
+ # | |
+ def shellescape(str) | |
+ # An empty argument will be skipped, so return empty quotes. | |
+ return "''" if str.empty? | |
+ | |
+ str = str.dup | |
+ | |
+ # Process as a single byte sequence because not all shell | |
+ # implementations are multibyte aware. | |
+ str.gsub!(/([^A-Za-z0-9_\-.,:\/@\n])/n, "\\\\\\1") | |
+ | |
+ # A LF cannot be escaped with a backslash because a backslash + LF | |
+ # combo is regarded as line continuation and simply ignored. | |
+ str.gsub!(/\n/, "'\n'") | |
+ | |
+ return str | |
+ end | |
+ | |
+ module_function :shellescape | |
+ | |
+ class << self | |
+ alias escape shellescape | |
+ end | |
+ | |
+end | |
+ | |
+class String | |
+ # call-seq: | |
+ # str.shellescape => string | |
+ # | |
+ # Escapes +str+ so that it can be safely used in a Bourne shell | |
+ # command line. See +Shellwords::shellescape+ for details. | |
+ # | |
+ def shellescape | |
+ Shellwords.escape(self) | |
+ end | |
+end | |
\ No newline at end of file | |
diff --git a/lib/mail/core_extensions/string.rb b/lib/mail/core_extensions/string.rb | |
index c24ffe1..ce70f84 100644 | |
--- a/lib/mail/core_extensions/string.rb | |
+++ b/lib/mail/core_extensions/string.rb | |
@@ -1,15 +1,17 @@ | |
# encoding: utf-8 | |
class String #:nodoc: | |
def to_crlf | |
- gsub(/\n|\r\n|\r/) { "\r\n" } | |
+ to_str.gsub(/\n|\r\n|\r/) { "\r\n" } | |
end | |
def to_lf | |
- gsub(/\n|\r\n|\r/) { "\n" } | |
+ to_str.gsub(/\n|\r\n|\r/) { "\n" } | |
end | |
- def blank? | |
- self !~ /\S/ | |
+ unless String.instance_methods(false).map {|m| m.to_sym}.include?(:blank?) | |
+ def blank? | |
+ self !~ /\S/ | |
+ end | |
end | |
unless method_defined?(:ascii_only?) | |
diff --git a/lib/mail/core_extensions/string/access.rb b/lib/mail/core_extensions/string/access.rb | |
index 7412b36..ca6fb63 100644 | |
--- a/lib/mail/core_extensions/string/access.rb | |
+++ b/lib/mail/core_extensions/string/access.rb | |
@@ -101,4 +101,45 @@ class String | |
end | |
end | |
end | |
+ | |
+ if Module.method(:const_get).arity == 1 | |
+ # Tries to find a constant with the name specified in the argument string: | |
+ # | |
+ # "Module".constantize # => Module | |
+ # "Test::Unit".constantize # => Test::Unit | |
+ # | |
+ # The name is assumed to be the one of a top-level constant, no matter whether | |
+ # it starts with "::" or not. No lexical context is taken into account: | |
+ # | |
+ # C = 'outside' | |
+ # module M | |
+ # C = 'inside' | |
+ # C # => 'inside' | |
+ # "C".constantize # => 'outside', same as ::C | |
+ # end | |
+ # | |
+ # NameError is raised when the name is not in CamelCase or the constant is | |
+ # unknown. | |
+ def constantize | |
+ names = self.split('::') | |
+ names.shift if names.empty? || names.first.empty? | |
+ | |
+ constant = Object | |
+ names.each do |name| | |
+ constant = constant.const_defined?(name) ? constant.const_get(name) : constant.const_missing(name) | |
+ end | |
+ constant | |
+ end | |
+ else | |
+ def constantize #:nodoc: | |
+ names = self.split('::') | |
+ names.shift if names.empty? || names.first.empty? | |
+ | |
+ constant = Object | |
+ names.each do |name| | |
+ constant = constant.const_defined?(name, false) ? constant.const_get(name) : constant.const_missing(name) | |
+ end | |
+ constant | |
+ end | |
+ end | |
end | |
diff --git a/lib/mail/encodings.rb b/lib/mail/encodings.rb | |
index 11b5f58..65a94c7 100644 | |
--- a/lib/mail/encodings.rb | |
+++ b/lib/mail/encodings.rb | |
@@ -181,7 +181,7 @@ module Mail | |
return address if address.ascii_only? or charset.nil? | |
us_ascii = %Q{\x00-\x7f} | |
# Encode any non usascii strings embedded inside of quotes | |
- address.gsub!(/(".*?[^#{us_ascii}].+?")/) { |s| Encodings.b_value_encode(unquote(s), charset) } | |
+ address.gsub!(/(".*?[^#{us_ascii}].*?")/) { |s| Encodings.b_value_encode(unquote(s), charset) } | |
# Then loop through all remaining items and encode as needed | |
tokens = address.split(/\s/) | |
map_with_index(tokens) do |word, i| | |
@@ -204,9 +204,9 @@ module Mail | |
# | |
# Encodings.b_value_encode('This is あ string', 'UTF-8') | |
# #=> "=?UTF-8?B?VGhpcyBpcyDjgYIgc3RyaW5n?=" | |
- def Encodings.b_value_encode(str, encoding = nil) | |
- return str if str.to_s.ascii_only? | |
- string, encoding = RubyVer.b_value_encode(str, encoding) | |
+ def Encodings.b_value_encode(encoded_str, encoding = nil) | |
+ return encoded_str if encoded_str.to_s.ascii_only? | |
+ string, encoding = RubyVer.b_value_encode(encoded_str, encoding) | |
map_lines(string) do |str| | |
"=?#{encoding}?B?#{str.chomp}?=" | |
end.join(" ") | |
@@ -219,9 +219,9 @@ module Mail | |
# | |
# Encodings.q_value_encode('This is あ string', 'UTF-8') | |
# #=> "=?UTF-8?Q?This_is_=E3=81=82_string?=" | |
- def Encodings.q_value_encode(str, encoding = nil) | |
- return str if str.to_s.ascii_only? | |
- string, encoding = RubyVer.q_value_encode(str, encoding) | |
+ def Encodings.q_value_encode(encoded_str, encoding = nil) | |
+ return encoded_str if encoded_str.to_s.ascii_only? | |
+ string, encoding = RubyVer.q_value_encode(encoded_str, encoding) | |
string.gsub!("=\r\n", '') # We already have limited the string to the length we want | |
map_lines(string) do |str| | |
"=?#{encoding}?Q?#{str.chomp.gsub(/ /, '_')}?=" | |
@@ -247,7 +247,7 @@ module Mail | |
# Encodings.q_value_decode("=?UTF-8?Q?This_is_=E3=81=82_string?=") | |
# #=> 'This is あ string' | |
def Encodings.q_value_decode(str) | |
- RubyVer.q_value_decode(str).gsub(/_/, ' ') | |
+ RubyVer.q_value_decode(str) | |
end | |
def Encodings.split_encoding_from_string( str ) | |
diff --git a/lib/mail/field.rb b/lib/mail/field.rb | |
index c5cd0a4..9e198aa 100644 | |
--- a/lib/mail/field.rb | |
+++ b/lib/mail/field.rb | |
@@ -113,6 +113,8 @@ module Mail | |
match_to_s(other.name, field.name) | |
end | |
+ alias_method :==, :same | |
+ | |
def <=>( other ) | |
self_order = FIELD_ORDER.rindex(self.name.to_s.downcase) || 100 | |
other_order = FIELD_ORDER.rindex(other.name.to_s.downcase) || 100 | |
diff --git a/lib/mail/fields/common/parameter_hash.rb b/lib/mail/fields/common/parameter_hash.rb | |
index 17402de..3969990 100644 | |
--- a/lib/mail/fields/common/parameter_hash.rb | |
+++ b/lib/mail/fields/common/parameter_hash.rb | |
@@ -29,7 +29,7 @@ module Mail | |
super(exact || key_name) | |
else # Dealing with a multiple value pair or a single encoded value pair | |
string = pairs.sort { |a,b| a.first.to_s <=> b.first.to_s }.map { |v| v.last }.join('') | |
- if mt = string.match(/([\w\d\-]+)'(\w\w)'(.*)/) | |
+ if mt = string.match(/([\w\-]+)'(\w\w)'(.*)/) | |
string = mt[3] | |
encoding = mt[1] | |
else | |
diff --git a/lib/mail/fields/unstructured_field.rb b/lib/mail/fields/unstructured_field.rb | |
index 2578cb2..19183fe 100644 | |
--- a/lib/mail/fields/unstructured_field.rb | |
+++ b/lib/mail/fields/unstructured_field.rb | |
@@ -166,7 +166,7 @@ module Mail | |
end | |
def encode(value) | |
- value.encode!(charset) if defined?(Encoding) && charset | |
+ value.encode!(charset) if charset && value.respond_to?(:encode!) | |
(value.not_ascii_only? ? [value].pack("M").gsub("=\n", '') : value).gsub("\r", "=0D").gsub("\n", "=0A") | |
end | |
diff --git a/lib/mail/matchers/has_sent_mail.rb b/lib/mail/matchers/has_sent_mail.rb | |
new file mode 100644 | |
index 0000000..73386b0 | |
--- /dev/null | |
+++ b/lib/mail/matchers/has_sent_mail.rb | |
@@ -0,0 +1,124 @@ | |
+module Mail | |
+ module Matchers | |
+ def have_sent_email | |
+ HasSentEmailMatcher.new(self) | |
+ end | |
+ | |
+ class HasSentEmailMatcher | |
+ def initialize(_context) | |
+ end | |
+ | |
+ def matches?(subject) | |
+ matching_deliveries = filter_matched_deliveries(Mail::TestMailer.deliveries) | |
+ !(matching_deliveries.empty?) | |
+ end | |
+ | |
+ def from(sender) | |
+ @sender = sender | |
+ self | |
+ end | |
+ | |
+ def to(recipient_or_list) | |
+ @recipients ||= [] | |
+ | |
+ if recipient_or_list.kind_of?(Array) | |
+ @recipients += recipient_or_list | |
+ else | |
+ @recipients << recipient_or_list | |
+ end | |
+ self | |
+ end | |
+ | |
+ def with_subject(subject) | |
+ @subject = subject | |
+ self | |
+ end | |
+ | |
+ def matching_subject(subject_matcher) | |
+ @subject_matcher = subject_matcher | |
+ self | |
+ end | |
+ | |
+ def with_body(body) | |
+ @body = body | |
+ self | |
+ end | |
+ | |
+ def matching_body(body_matcher) | |
+ @body_matcher = body_matcher | |
+ self | |
+ end | |
+ | |
+ def description | |
+ result = "send a matching email" | |
+ result | |
+ end | |
+ | |
+ def failure_message | |
+ result = "Expected email to be sent " | |
+ result += explain_expectations | |
+ result += dump_deliveries | |
+ result | |
+ end | |
+ | |
+ def negative_failure_message | |
+ result = "Expected no email to be sent " | |
+ result += explain_expectations | |
+ result += dump_deliveries | |
+ result | |
+ end | |
+ | |
+ protected | |
+ | |
+ def filter_matched_deliveries(deliveries) | |
+ candidate_deliveries = deliveries | |
+ | |
+ %w(sender recipients subject subject_matcher body body_matcher).each do |modifier_name| | |
+ next unless instance_variable_defined?("@#{modifier_name}") | |
+ candidate_deliveries = candidate_deliveries.select{|matching_delivery| self.send("matches_on_#{modifier_name}?", matching_delivery)} | |
+ end | |
+ | |
+ candidate_deliveries | |
+ end | |
+ | |
+ def matches_on_sender?(delivery) | |
+ delivery.from.include?(@sender) | |
+ end | |
+ | |
+ def matches_on_recipients?(delivery) | |
+ @recipients.all? {|recipient| delivery.to.include?(recipient) } | |
+ end | |
+ | |
+ def matches_on_subject?(delivery) | |
+ delivery.subject == @subject | |
+ end | |
+ | |
+ def matches_on_subject_matcher?(delivery) | |
+ @subject_matcher.match delivery.subject | |
+ end | |
+ | |
+ def matches_on_body?(delivery) | |
+ delivery.body == @body | |
+ end | |
+ | |
+ def matches_on_body_matcher?(delivery) | |
+ @body_matcher.match delivery.body.raw_source | |
+ end | |
+ | |
+ def explain_expectations | |
+ result = '' | |
+ result += "from #{@sender} " if instance_variable_defined?('@sender') | |
+ result += "to #{@recipients.inspect} " if instance_variable_defined?('@recipients') | |
+ result += "with subject \"#{@subject}\" " if instance_variable_defined?('@subject') | |
+ result += "with subject matching \"#{@subject_matcher}\" " if instance_variable_defined?('@subject_matcher') | |
+ result += "with body \"#{@body}\" " if instance_variable_defined?('@body') | |
+ result += "with body matching \"#{@body_matcher}\" " if instance_variable_defined?('@body_matcher') | |
+ result | |
+ end | |
+ | |
+ def dump_deliveries | |
+ "(actual deliveries: " + Mail::TestMailer.deliveries.inspect + ")" | |
+ end | |
+ end | |
+ end | |
+end | |
diff --git a/lib/mail/message.rb b/lib/mail/message.rb | |
index 72ece8a..68a15fd 100644 | |
--- a/lib/mail/message.rb | |
+++ b/lib/mail/message.rb | |
@@ -10,7 +10,7 @@ module Mail | |
# | |
# A Message object by default has the following objects inside it: | |
# | |
- # * A Header object which contians all information and settings of the header of the email | |
+ # * A Header object which contains all information and settings of the header of the email | |
# * Body object which contains all parts of the email that are not part of the header, this | |
# includes any attachments, body text, MIME parts etc. | |
# | |
@@ -100,7 +100,6 @@ module Mail | |
def initialize(*args, &block) | |
@body = nil | |
@body_raw = nil | |
- @body_raw_index = nil | |
@separate_parts = false | |
@text_part = nil | |
@html_part = nil | |
@@ -1134,7 +1133,7 @@ module Mail | |
# mail.parts.length #=> 2 | |
# mail.parts.last.content_type.content_type #=> 'This is a body' | |
def body=(value) | |
- body_lazy(value, 0) | |
+ body_lazy(value) | |
end | |
# Returns the body of the message object. Or, if passed | |
@@ -1711,19 +1710,54 @@ module Mail | |
buffer | |
end | |
- def to_yaml | |
- ready_to_send! | |
+ def without_attachments! | |
+ return self unless has_attachments? | |
+ | |
+ parts.delete_if { |p| p.attachment? } | |
+ body_raw = if parts.empty? | |
+ '' | |
+ else | |
+ body.encoded | |
+ end | |
+ | |
+ @body = Mail::Body.new(body_raw) | |
+ | |
+ self | |
+ end | |
+ | |
+ def to_yaml(opts = {}) | |
hash = {} | |
+ hash['headers'] = {} | |
header.fields.each do |field| | |
- hash[field.name] = field.value | |
+ hash['headers'][field.name] = field.value | |
+ end | |
+ hash['delivery_handler'] = delivery_handler.to_s if delivery_handler | |
+ hash['transport_encoding'] = transport_encoding.to_s | |
+ special_variables = [:@header, :@delivery_handler, :@transport_encoding] | |
+ (instance_variables.map(&:to_sym) - special_variables).each do |var| | |
+ hash[var.to_s] = instance_variable_get(var) | |
end | |
- hash['subject'] = subject | |
- hash['body'] = body.encoded(content_transfer_encoding) | |
- hash.to_yaml | |
+ hash.to_yaml(opts) | |
end | |
def self.from_yaml(str) | |
- from_hash(YAML::load(str)) | |
+ hash = YAML.load(str) | |
+ m = Mail::Message.new(:headers => hash['headers']) | |
+ hash.delete('headers') | |
+ hash.each do |k,v| | |
+ case | |
+ when k == 'delivery_handler' | |
+ begin | |
+ m.delivery_handler = Object.const_get(v) unless v.blank? | |
+ rescue NameError | |
+ end | |
+ when k == 'transport_encoding' | |
+ m.transport_encoding(v) | |
+ when k =~ /^@/ | |
+ m.instance_variable_set(k.to_sym, v) | |
+ end | |
+ end | |
+ m | |
end | |
def self.from_hash(hash) | |
@@ -1740,6 +1774,8 @@ module Mail | |
def decoded | |
case | |
+ when self.text? | |
+ decode_body_as_text | |
when self.attachment? | |
decode_body | |
when !self.multipart? | |
@@ -1814,6 +1850,10 @@ module Mail | |
return @mark_for_delete | |
end | |
+ def text? | |
+ has_content_type? ? !!(main_type =~ /^text$/i) : false | |
+ end | |
+ | |
private | |
# 2.1. General Description | |
@@ -1839,31 +1879,28 @@ module Mail | |
@raw_source = value.to_crlf | |
end | |
- # see comments to body=. We take data starting from index and process it lazily | |
- def body_lazy(value, index) | |
+ # see comments to body=. We take data and process it lazily | |
+ def body_lazy(value) | |
process_body_raw if @body_raw && value | |
case | |
- when value == nil || value.length<=index | |
+ when value == nil || value.length<=0 | |
@body = Mail::Body.new('') | |
@body_raw = nil | |
- @body_raw_index = nil | |
add_encoding_to_body | |
when @body && @body.multipart? | |
- @body << Mail::Part.new(value[index, value.length-index]) | |
+ @body << Mail::Part.new(value) | |
add_encoding_to_body | |
else | |
@body_raw = value | |
- @body_raw_index = index | |
# process_body_raw | |
end | |
end | |
def process_body_raw | |
- @body = Mail::Body.new(@body_raw[@body_raw_index, @body_raw.length-@body_raw_index]) | |
+ @body = Mail::Body.new(@body_raw) | |
@body_raw = nil | |
- @body_raw_index = nil | |
- separate_parts if @separate_parts | |
+ separate_parts if @separate_parts | |
add_encoding_to_body | |
end | |
@@ -1993,5 +2030,21 @@ module Mail | |
end | |
end | |
+ def decode_body_as_text | |
+ body_text = decode_body | |
+ if charset | |
+ if RUBY_VERSION < '1.9' | |
+ require 'iconv' | |
+ return Iconv.conv("UTF-8//TRANSLIT//IGNORE", charset, body_text) | |
+ else | |
+ if encoding = Encoding.find(charset) rescue nil | |
+ body_text.force_encoding(encoding) | |
+ return body_text.encode(Encoding::UTF_8) | |
+ end | |
+ end | |
+ end | |
+ body_text | |
+ end | |
+ | |
end | |
end | |
diff --git a/lib/mail/multibyte/chars.rb b/lib/mail/multibyte/chars.rb | |
index c6d37fa..899d843 100644 | |
--- a/lib/mail/multibyte/chars.rb | |
+++ b/lib/mail/multibyte/chars.rb | |
@@ -339,7 +339,7 @@ module Mail #:nodoc: | |
# Example: | |
# 'Laurent, où sont les tests ?'.mb_chars.upcase.to_s # => "LAURENT, OÙ SONT LES TESTS ?" | |
def upcase | |
- chars(Unicode.apply_mapping @wrapped_string, :uppercase_mapping) | |
+ chars(Unicode.apply_mapping(@wrapped_string), :uppercase_mapping) | |
end | |
# Convert characters in the string to lowercase. | |
@@ -347,7 +347,7 @@ module Mail #:nodoc: | |
# Example: | |
# 'VĚDA A VÝZKUM'.mb_chars.downcase.to_s # => "věda a výzkum" | |
def downcase | |
- chars(Unicode.apply_mapping @wrapped_string, :lowercase_mapping) | |
+ chars(Unicode.apply_mapping(@wrapped_string), :lowercase_mapping) | |
end | |
# Converts the first character to uppercase and the remainder to lowercase. | |
diff --git a/lib/mail/multibyte/utils.rb b/lib/mail/multibyte/utils.rb | |
index 5371fa5..016101b 100644 | |
--- a/lib/mail/multibyte/utils.rb | |
+++ b/lib/mail/multibyte/utils.rb | |
@@ -2,7 +2,7 @@ | |
module Mail #:nodoc: | |
module Multibyte #:nodoc: | |
- if Kernel.const_defined?(:Encoding) | |
+ if RUBY_VERSION >= "1.9" | |
# Returns a regular expression that matches valid characters in the current encoding | |
def self.valid_character | |
VALID_CHARACTER[Encoding.default_external.to_s] | |
diff --git a/lib/mail/network/delivery_methods/exim.rb b/lib/mail/network/delivery_methods/exim.rb | |
index c5762ab..03b59ba 100644 | |
--- a/lib/mail/network/delivery_methods/exim.rb | |
+++ b/lib/mail/network/delivery_methods/exim.rb | |
@@ -1,45 +1,12 @@ | |
module Mail | |
- # A delivery method implementation which sends via exim. | |
- # | |
- # To use this, first find out where the exim binary is on your computer, | |
- # if you are on a mac or unix box, it is usually in /usr/sbin/exim, this will | |
- # be your exim location. | |
- # | |
- # Mail.defaults do | |
- # delivery_method :exim | |
- # end | |
- # | |
- # Or if your exim binary is not at '/usr/sbin/exim' | |
- # | |
- # Mail.defaults do | |
- # delivery_method :exim, :location => '/absolute/path/to/your/exim' | |
- # end | |
- # | |
- # Then just deliver the email as normal: | |
- # | |
- # Mail.deliver do | |
- # to '[email protected]' | |
- # from '[email protected]' | |
- # subject 'testing exim' | |
- # body 'testing exim' | |
- # end | |
- # | |
- # Or by calling deliver on a Mail message | |
- # | |
- # mail = Mail.new do | |
- # to '[email protected]' | |
- # from '[email protected]' | |
- # subject 'testing exim' | |
- # body 'testing exim' | |
- # end | |
- # | |
- # mail.deliver! | |
class Exim < Sendmail | |
- def initialize(values) | |
- self.settings = { :location => '/usr/sbin/exim', | |
- :arguments => '-i -t' }.merge(values) | |
+ def deliver!(mail) | |
+ envelope_from = mail.return_path || mail.sender || mail.from_addrs.first | |
+ return_path = "-f \"#{envelope_from.to_s.shellescape}\"" if envelope_from | |
+ arguments = [settings[:arguments], return_path].compact.join(" ") | |
+ self.class.call(settings[:location], arguments, mail) | |
end | |
def self.call(path, arguments, mail) | |
diff --git a/lib/mail/network/delivery_methods/file_delivery.rb b/lib/mail/network/delivery_methods/file_delivery.rb | |
index fec750a..fc3e3b2 100644 | |
--- a/lib/mail/network/delivery_methods/file_delivery.rb | |
+++ b/lib/mail/network/delivery_methods/file_delivery.rb | |
@@ -6,7 +6,7 @@ module Mail | |
# So if you have an email going to fred@test, bob@test, joe@anothertest, and you | |
# set your location path to /path/to/mails then FileDelivery will create the directory | |
# if it does not exist, and put one copy of the email in three files, called | |
- # by their message id | |
+ # "fred@test", "bob@test" and "joe@anothertest" | |
# | |
# Make sure the path you specify with :location is writable by the Ruby process | |
# running Mail. | |
@@ -32,7 +32,7 @@ module Mail | |
end | |
mail.destinations.uniq.each do |to| | |
- ::File.open(::File.join(settings[:location], File.basename(to.to_s)), 'a') { |f| "#{f.write(mail.encoded)}\r\n\r\n" } | |
+ ::File.open(::File.join(settings[:location], to), 'a') { |f| "#{f.write(mail.encoded)}\r\n\r\n" } | |
end | |
end | |
diff --git a/lib/mail/network/delivery_methods/sendmail.rb b/lib/mail/network/delivery_methods/sendmail.rb | |
index 73ef921..85dac4f 100644 | |
--- a/lib/mail/network/delivery_methods/sendmail.rb | |
+++ b/lib/mail/network/delivery_methods/sendmail.rb | |
@@ -45,14 +45,14 @@ module Mail | |
def deliver!(mail) | |
envelope_from = mail.return_path || mail.sender || mail.from_addrs.first | |
- return_path = "-f " + '"' + envelope_from.escape_for_shell + '"' if envelope_from | |
+ return_path = "-f \"#{envelope_from.to_s.gsub('"', '\"')}\"" if envelope_from | |
arguments = [settings[:arguments], return_path].compact.join(" ") | |
- self.class.call(settings[:location], arguments, mail.destinations.collect(&:escape_for_shell).join(" "), mail) | |
+ Sendmail.call(settings[:location], arguments, mail.destinations.collect(&:shellescape).join(" "), mail) | |
end | |
- def self.call(path, arguments, destinations, mail) | |
+ def Sendmail.call(path, arguments, destinations, mail) | |
IO.popen("#{path} #{arguments} #{destinations}", "w+") do |io| | |
io.puts mail.encoded.to_lf | |
io.flush | |
diff --git a/lib/mail/network/delivery_methods/smtp.rb b/lib/mail/network/delivery_methods/smtp.rb | |
index 8d4d995..1b3462e 100644 | |
--- a/lib/mail/network/delivery_methods/smtp.rb | |
+++ b/lib/mail/network/delivery_methods/smtp.rb | |
@@ -81,7 +81,9 @@ module Mail | |
:password => nil, | |
:authentication => nil, | |
:enable_starttls_auto => true, | |
- :openssl_verify_mode => nil | |
+ :openssl_verify_mode => nil, | |
+ :ssl => nil, | |
+ :tls => nil | |
}.merge!(values) | |
end | |
@@ -108,7 +110,21 @@ module Mail | |
end | |
smtp = Net::SMTP.new(settings[:address], settings[:port]) | |
- if settings[:enable_starttls_auto] | |
+ if settings[:tls] || settings[:ssl] | |
+ if smtp.respond_to?(:enable_tls) | |
+ unless settings[:openssl_verify_mode] | |
+ smtp.enable_tls | |
+ else | |
+ openssl_verify_mode = settings[:openssl_verify_mode] | |
+ if openssl_verify_mode.kind_of?(String) | |
+ openssl_verify_mode = "OpenSSL::SSL::VERIFY_#{openssl_verify_mode.upcase}".constantize | |
+ end | |
+ context = Net::SMTP.default_ssl_context | |
+ context.verify_mode = openssl_verify_mode | |
+ smtp.enable_tls(context) | |
+ end | |
+ end | |
+ elsif settings[:enable_starttls_auto] | |
if smtp.respond_to?(:enable_starttls_auto) | |
unless settings[:openssl_verify_mode] | |
smtp.enable_starttls_auto | |
@@ -125,8 +141,8 @@ module Mail | |
end | |
response = nil | |
- smtp.start(settings[:domain], settings[:user_name], settings[:password], settings[:authentication]) do |smtp| | |
- response = smtp.sendmail(message, envelope_from, destinations) | |
+ smtp.start(settings[:domain], settings[:user_name], settings[:password], settings[:authentication]) do |smtp_obj| | |
+ response = smtp_obj.sendmail(message, envelope_from, destinations) | |
end | |
return settings[:return_response] ? response : self | |
diff --git a/lib/mail/network/retriever_methods/imap.rb b/lib/mail/network/retriever_methods/imap.rb | |
index 7825d9b..c679e3f 100644 | |
--- a/lib/mail/network/retriever_methods/imap.rb | |
+++ b/lib/mail/network/retriever_methods/imap.rb | |
@@ -54,6 +54,8 @@ module Mail | |
# order: order of emails returned. Possible values are :asc or :desc. Default value is :asc. | |
# count: number of emails to retrieve. The default value is 10. A value of 1 returns an | |
# instance of Message, not an array of Message instances. | |
+ # ready_only: will ensure that no writes are made to the inbox during the session. | |
+ # This is helpful when you don't want your messages to be set to read automatically. Default is false. | |
# delete_after_find: flag for whether to delete each retreived email after find. Default | |
# is false. Use #find_and_delete if you would like this to default to true. | |
# | |
@@ -61,7 +63,7 @@ module Mail | |
options = validate_options(options) | |
start do |imap| | |
- imap.select(options[:mailbox]) | |
+ options[:read_only] ? imap.select(options[:mailbox]) : imap.examine(options[:mailbox]) | |
message_ids = imap.uid_search(options[:keys]) | |
message_ids.reverse! if options[:what].to_sym == :last | |
@@ -101,7 +103,6 @@ module Mail | |
mailbox = Net::IMAP.encode_utf7(mailbox) | |
start do |imap| | |
- imap.select(mailbox) | |
imap.uid_search(['ALL']).each do |message_id| | |
imap.uid_store(message_id, "+FLAGS", [Net::IMAP::DELETED]) | |
end | |
@@ -130,6 +131,7 @@ module Mail | |
options[:keys] ||= 'ALL' | |
options[:delete_after_find] ||= false | |
options[:mailbox] = Net::IMAP.encode_utf7(options[:mailbox]) | |
+ options[:read_only] ||= false | |
options | |
end | |
diff --git a/lib/mail/parsers/rfc2822.treetop b/lib/mail/parsers/rfc2822.treetop | |
index c2b94f0..107d1ea 100644 | |
--- a/lib/mail/parsers/rfc2822.treetop | |
+++ b/lib/mail/parsers/rfc2822.treetop | |
@@ -110,7 +110,7 @@ module Mail | |
end | |
rule local_dot_atom_text | |
- ("."* domain_text)+ | |
+ ("."? domain_text)+ | |
end | |
rule domain_text | |
diff --git a/lib/mail/parsers/rfc2822_obsolete.rb b/lib/mail/parsers/rfc2822_obsolete.rb | |
index f73e9ea..c8bccab 100644 | |
--- a/lib/mail/parsers/rfc2822_obsolete.rb | |
+++ b/lib/mail/parsers/rfc2822_obsolete.rb | |
@@ -257,8 +257,19 @@ module Mail | |
if r3 | |
r1 = r3 | |
else | |
- @index = i1 | |
- r1 = nil | |
+ if has_terminal?("@", false, index) | |
+ r4 = instantiate_node(SyntaxNode,input, index...(index + 1)) | |
+ @index += 1 | |
+ else | |
+ terminal_parse_failure("@") | |
+ r4 = nil | |
+ end | |
+ if r4 | |
+ r1 = r4 | |
+ else | |
+ @index = i1 | |
+ r1 = nil | |
+ end | |
end | |
end | |
if r1 | |
@@ -3754,4 +3765,4 @@ module Mail | |
include RFC2822Obsolete | |
end | |
-end | |
\ No newline at end of file | |
+end | |
diff --git a/lib/mail/parsers/rfc2822_obsolete.treetop b/lib/mail/parsers/rfc2822_obsolete.treetop | |
index 1763389..83a4831 100644 | |
--- a/lib/mail/parsers/rfc2822_obsolete.treetop | |
+++ b/lib/mail/parsers/rfc2822_obsolete.treetop | |
@@ -20,7 +20,7 @@ module Mail | |
end | |
rule obs_phrase | |
- (word / ".")+ | |
+ (word / "." / "@")+ | |
end | |
rule obs_phrase_list | |
@@ -238,4 +238,4 @@ module Mail | |
field_name WSP* ":" unstructured CRLF | |
end | |
end | |
-end | |
\ No newline at end of file | |
+end | |
diff --git a/lib/mail/parts_list.rb b/lib/mail/parts_list.rb | |
index 74fa653..38c465f 100644 | |
--- a/lib/mail/parts_list.rb | |
+++ b/lib/mail/parts_list.rb | |
@@ -26,6 +26,10 @@ module Mail | |
raise NoMethodError, "#collect! is not defined, please call #collect and create a new PartsList" | |
end | |
+ def sort | |
+ self.class.new(super) | |
+ end | |
+ | |
def sort!(order) | |
sorted = self.sort do |a, b| | |
# OK, 10000 is arbitrary... if anyone actually wants to explicitly sort 10000 parts of a | |
diff --git a/lib/mail/utilities.rb b/lib/mail/utilities.rb | |
index 85329c1..0e0de28 100644 | |
--- a/lib/mail/utilities.rb | |
+++ b/lib/mail/utilities.rb | |
@@ -116,11 +116,15 @@ module Mail | |
end | |
def uri_escape( str ) | |
- URI.escape(str) | |
+ uri_parser.escape(str) | |
end | |
def uri_unescape( str ) | |
- URI.unescape(str) | |
+ uri_parser.unescape(str) | |
+ end | |
+ | |
+ def uri_parser | |
+ @uri_parser ||= URI.const_defined?(:Parser) ? URI::Parser.new : URI | |
end | |
# Matches two objects with their to_s values case insensitively | |
diff --git a/lib/mail/version_specific/ruby_1_8.rb b/lib/mail/version_specific/ruby_1_8.rb | |
index 5558f5e..1cb73c7 100644 | |
--- a/lib/mail/version_specific/ruby_1_8.rb | |
+++ b/lib/mail/version_specific/ruby_1_8.rb | |
@@ -80,7 +80,7 @@ module Mail | |
match = str.match(/\=\?(.+)?\?[Qq]\?(.+)?\?\=/m) | |
if match | |
encoding = match[1] | |
- str = Encodings::QuotedPrintable.decode(match[2]) | |
+ str = Encodings::QuotedPrintable.decode(match[2].gsub(/_/, '=20')) | |
end | |
str | |
end | |
diff --git a/lib/mail/version_specific/ruby_1_9.rb b/lib/mail/version_specific/ruby_1_9.rb | |
index f708b07..0eb3806 100644 | |
--- a/lib/mail/version_specific/ruby_1_9.rb | |
+++ b/lib/mail/version_specific/ruby_1_9.rb | |
@@ -68,7 +68,7 @@ module Mail | |
match = str.match(/\=\?(.+)?\?[Qq]\?(.+)?\?\=/m) | |
if match | |
encoding = match[1] | |
- str = Encodings::QuotedPrintable.decode(match[2]) | |
+ str = Encodings::QuotedPrintable.decode(match[2].gsub(/_/, '=20')) | |
str.force_encoding(fix_encoding(encoding)) | |
end | |
decoded = str.encode("utf-8", :invalid => :replace, :replace => "") | |
@@ -76,7 +76,7 @@ module Mail | |
end | |
def Ruby19.param_decode(str, encoding) | |
- string = URI.unescape(str) | |
+ string = uri_parser.unescape(str) | |
string.force_encoding(encoding) if encoding | |
string | |
end | |
@@ -84,7 +84,11 @@ module Mail | |
def Ruby19.param_encode(str) | |
encoding = str.encoding.to_s.downcase | |
language = Configuration.instance.param_encode_language | |
- "#{encoding}'#{language}'#{URI.escape(str)}" | |
+ "#{encoding}'#{language}'#{uri_parser.escape(str)}" | |
+ end | |
+ | |
+ def Ruby19.uri_parser | |
+ @uri_parser ||= URI::Parser.new | |
end | |
# mails somtimes includes invalid encodings like iso885915 or utf8 so we transform them to iso885915 or utf8 | |
@@ -98,7 +102,7 @@ module Mail | |
# "ISO-2022-JP-KDDI" and alike | |
when /iso-?(\d{4})-?(\w{1,2})-?(\w*)/i then return "ISO-#{$1}-#{$2}-#{$3}" | |
# UTF-8, UTF-32BE and alike | |
- when /utf-?(\d{1,2})?(\w{1,2})/i then return "UTF-#{$1}#{$2}" | |
+ when /utf-?(\d{1,2})?(\w{1,2})/i then return "UTF-#{$1}#{$2}".gsub(/\A(UTF-(?:16|32))\z/, '\\1BE') | |
# Windows-1252 and alike | |
when /Windows-?(.*)/i then return "Windows-#{$1}" | |
#more aliases to be added if needed | |
diff --git a/mail.gemspec b/mail.gemspec | |
index 701b662..ffaf025 100644 | |
--- a/mail.gemspec | |
+++ b/mail.gemspec | |
@@ -1,4 +1,6 @@ | |
-require File.dirname(__FILE__) + "/lib/mail/version" | |
+lib_dir = File.expand_path('../lib', __FILE__) | |
+$:.unshift lib_dir unless $:.include? lib_dir | |
+require 'mail/version' | |
Gem::Specification.new do |s| | |
s.name = "mail" | |
@@ -11,7 +13,7 @@ Gem::Specification.new do |s| | |
s.platform = Gem::Platform::RUBY | |
s.has_rdoc = true | |
- s.extra_rdoc_files = ["README.rdoc", "CHANGELOG.rdoc", "TODO.rdoc"] | |
+ s.extra_rdoc_files = ["README.md", "CONTRIBUTING.md", "CHANGELOG.rdoc", "TODO.rdoc"] | |
s.add_dependency('mime-types', "~> 1.16") | |
s.add_dependency('treetop', '~> 1.4.8') | |
@@ -20,5 +22,5 @@ Gem::Specification.new do |s| | |
s.add_dependency('tlsmail', '~> 0.0.1') if RUBY_VERSION == '1.8.6' | |
s.require_path = 'lib' | |
- s.files = %w(README.rdoc CHANGELOG.rdoc Dependencies.txt Gemfile Rakefile TODO.rdoc) + Dir.glob("lib/**/*") | |
+ s.files = %w(README.md CONTRIBUTING.md CHANGELOG.rdoc Dependencies.txt Gemfile Gemfile.lock Rakefile TODO.rdoc) + Dir.glob("lib/**/*") | |
end | |
diff --git a/spec/fixtures/emails/plain_emails/raw_email_with_at_display_name.eml b/spec/fixtures/emails/plain_emails/raw_email_with_at_display_name.eml | |
new file mode 100644 | |
index 0000000..55a2e7c | |
--- /dev/null | |
+++ b/spec/fixtures/emails/plain_emails/raw_email_with_at_display_name.eml | |
@@ -0,0 +1,31 @@ | |
+Delivered-To: [email protected] | |
+Received: by 10.140.178.13 with SMTP id a13cs354079rvf; | |
+ Fri, 21 Nov 2008 20:05:05 -0800 (PST) | |
+Received: by 10.151.44.15 with SMTP id w15mr2254748ybj.98.1227326704711; | |
+ Fri, 21 Nov 2008 20:05:04 -0800 (PST) | |
+Return-Path: <[email protected]> | |
+Received: from mail11.tpgi.com.au (mail11.tpgi.com.au [203.12.160.161]) | |
+ by mx.google.com with ESMTP id 10si5117885gxk.81.2008.11.21.20.05.03; | |
+ Fri, 21 Nov 2008 20:05:04 -0800 (PST) | |
+Received-SPF: neutral (google.com: 203.12.160.161 is neither permitted nor denied by domain of [email protected]) client-ip=203.12.160.161; | |
+Authentication-Results: mx.google.com; spf=neutral (google.com: 203.12.160.161 is neither permitted nor denied by domain of [email protected]) [email protected] | |
+X-TPG-Junk-Status: Message not scanned | |
+X-TPG-Antivirus: Passed | |
+Received: from [192.0.0.253] (60-241-138-146.static.tpgi.com.au [60.0.0.146]) | |
+ by mail11.tpgi.com.au (envelope-from [email protected]) (8.14.3/8.14.3) with ESMTP id mAM44xew022221 | |
+ for <[email protected]>; Sat, 22 Nov 2008 15:05:01 +1100 | |
+Message-Id: <[email protected]> | |
+From: Mikel Lindsaar <[email protected]>, [email protected] | |
+To: [email protected], Mikel@Lindsaar <[email protected]>, [email protected] | |
+Content-Type: text/plain; charset=US-ASCII; format=flowed | |
+Content-Transfer-Encoding: 7bit | |
+Mime-Version: 1.0 (Apple Message framework v929.2) | |
+Subject: Testing 123 | |
+Date: Sat, 22 Nov 2008 15:04:59 +1100 | |
+X-Mailer: Apple Mail (2.929.2) | |
+ | |
+Plain email. | |
+ | |
+Hope it works well! | |
+ | |
+Mikel | |
diff --git a/spec/mail/attachments_list_spec.rb b/spec/mail/attachments_list_spec.rb | |
index 8b0f631..029266c 100644 | |
--- a/spec/mail/attachments_list_spec.rb | |
+++ b/spec/mail/attachments_list_spec.rb | |
@@ -8,9 +8,9 @@ end | |
def check_decoded(actual, expected) | |
if RUBY_VERSION >= '1.9' | |
- actual.should == expected.force_encoding(Encoding::BINARY) | |
+ actual.should eq expected.force_encoding(Encoding::BINARY) | |
else | |
- actual.should == expected | |
+ actual.should eq expected | |
end | |
end | |
@@ -24,27 +24,27 @@ describe "Attachments" do | |
it "should work" do | |
file_data = File.read(filename = fixture('attachments', 'test.png')) | |
@mail.attachments['test.png'] = File.read(fixture('attachments', 'test.png')) | |
- @mail.attachments['test.png'].filename.should == 'test.png' | |
+ @mail.attachments['test.png'].filename.should eq 'test.png' | |
check_decoded(@mail.attachments[0].decoded, file_data) | |
end | |
it "should work out magically the mime_type" do | |
file_data = File.read(filename = fixture('attachments', 'test.png')) | |
@mail.attachments['test.png'] = File.read(fixture('attachments', 'test.png')) | |
- @mail.attachments[0].mime_type.should == 'image/png' | |
+ @mail.attachments[0].mime_type.should eq 'image/png' | |
end | |
it "should assign the filename" do | |
file_data = File.read(filename = fixture('attachments', 'test.png')) | |
@mail.attachments['test.png'] = file_data | |
- @mail.attachments[0].filename.should == 'test.png' | |
+ @mail.attachments[0].filename.should eq 'test.png' | |
end | |
it "should assign mime-encoded multibyte filename" do | |
file_data = File.read(filename = fixture('attachments', 'てすと.txt')) | |
@mail.attachments['てすと.txt'] = file_data | |
@mail.attachments.should_not be_blank | |
- Mail::Encodings.decode_encode(@mail.attachments[0].filename, :decode).should == 'てすと.txt' | |
+ Mail::Encodings.decode_encode(@mail.attachments[0].filename, :decode).should eq 'てすと.txt' | |
end | |
end | |
@@ -52,7 +52,7 @@ describe "Attachments" do | |
it "should work" do | |
file_data = File.read(filename = fixture('attachments', 'test.png')) | |
@mail.attachments['test.png'] = { :content => file_data } | |
- @mail.attachments[0].filename.should == 'test.png' | |
+ @mail.attachments[0].filename.should eq 'test.png' | |
check_decoded(@mail.attachments[0].decoded, file_data) | |
end | |
@@ -60,14 +60,14 @@ describe "Attachments" do | |
file_data = File.read(filename = fixture('attachments', 'test.png')) | |
@mail.attachments['test.png'] = { :content => file_data, | |
:content_type => "application/x-gzip" } | |
- @mail.attachments[0].content_type.should == 'application/x-gzip' | |
+ @mail.attachments[0].content_type.should eq 'application/x-gzip' | |
end | |
it "should allow you to override the mime_type" do | |
file_data = File.read(filename = fixture('attachments', 'test.png')) | |
@mail.attachments['test.png'] = { :content => file_data, | |
:mime_type => "application/x-gzip" } | |
- @mail.attachments[0].mime_type.should == 'application/x-gzip' | |
+ @mail.attachments[0].mime_type.should eq 'application/x-gzip' | |
end | |
it "should allow you to override the mime_type" do | |
@@ -75,7 +75,7 @@ describe "Attachments" do | |
@mail.attachments['invoice.jpg'] = { :data => "you smiling", | |
:mime_type => "image/x-jpg", | |
:transfer_encoding => "base64" } | |
- @mail.attachments[0].mime_type.should == 'image/x-jpg' | |
+ @mail.attachments[0].mime_type.should eq 'image/x-jpg' | |
end | |
end | |
@@ -86,7 +86,7 @@ describe "Attachments" do | |
file_data = File.read(filename = fixture('attachments', 'test.png')) | |
@mail.attachments['test.png'] = { :content => file_data } | |
@mail.ready_to_send! | |
- @mail.attachments[0].content_transfer_encoding.should == 'base64' | |
+ @mail.attachments[0].content_transfer_encoding.should eq 'base64' | |
end | |
it "should encode it's body to base64" do | |
@@ -119,7 +119,7 @@ describe "Attachments" do | |
else | |
expected = @mail.attachments[0].read | |
end | |
- expected.should == file_data | |
+ expected.should eq file_data | |
end | |
end | |
@@ -132,10 +132,10 @@ describe "Attachments" do | |
mail.attachments['test.gif'] = File.read(fixture('attachments', 'test.gif')) | |
mail.attachments['test.jpg'] = File.read(fixture('attachments', 'test.jpg')) | |
mail.attachments['test.zip'] = File.read(fixture('attachments', 'test.zip')) | |
- mail.attachments[0].filename.should == 'test.pdf' | |
- mail.attachments[1].filename.should == 'test.gif' | |
- mail.attachments[2].filename.should == 'test.jpg' | |
- mail.attachments[3].filename.should == 'test.zip' | |
+ mail.attachments[0].filename.should eq 'test.pdf' | |
+ mail.attachments[1].filename.should eq 'test.gif' | |
+ mail.attachments[2].filename.should eq 'test.jpg' | |
+ mail.attachments[3].filename.should eq 'test.zip' | |
end | |
end | |
@@ -145,15 +145,15 @@ describe "Attachments" do | |
it "should set the content_disposition to inline or attachment as appropriate" do | |
mail = Mail.new | |
mail.attachments['test.pdf'] = File.read(fixture('attachments', 'test.pdf')) | |
- mail.attachments['test.pdf'].content_disposition.should == 'attachment; filename=test.pdf' | |
+ mail.attachments['test.pdf'].content_disposition.should eq 'attachment; filename=test.pdf' | |
mail.attachments.inline['test.png'] = File.read(fixture('attachments', 'test.png')) | |
- mail.attachments.inline['test.png'].content_disposition.should == 'inline; filename=test.png' | |
+ mail.attachments.inline['test.png'].content_disposition.should eq 'inline; filename=test.png' | |
end | |
it "should return a cid" do | |
mail = Mail.new | |
mail.attachments.inline['test.png'] = File.read(fixture('attachments', 'test.png')) | |
- mail.attachments['test.png'].url.should == "cid:#{mail.attachments['test.png'].cid}" | |
+ mail.attachments['test.png'].url.should eq "cid:#{mail.attachments['test.png'].cid}" | |
end | |
it "should respond true to inline?" do | |
@@ -180,7 +180,8 @@ describe "Attachments" do | |
it "should provide a URL escaped content_id (without brackets) for use inside an email" do | |
@inline = @mail.attachments['test.gif'].cid | |
- @inline.should == URI.escape(@cid.gsub(/^</, '').gsub(/>$/, '')) | |
+ uri_parser = URI.const_defined?(:Parser) ? URI::Parser.new : URI | |
+ @inline.should eq uri_parser.escape(@cid.gsub(/^</, '').gsub(/>$/, '')) | |
end | |
end | |
@@ -189,7 +190,20 @@ describe "Attachments" do | |
mail = Mail.new | |
mail.attachments['test.pdf'] = File.read(fixture('attachments', 'test.pdf')) | |
mail.encoded | |
- mail.mime_type.should == 'multipart/mixed' | |
+ mail.mime_type.should eq 'multipart/mixed' | |
+ end | |
+ end | |
+ | |
+ describe "should handle filenames with non-7bit characters correctly" do | |
+ it "should not raise an exception with a filename that contains a non-7bit-character" do | |
+ filename = "f\u00f6\u00f6.b\u00e4r" | |
+ if RUBY_VERSION >= '1.9' | |
+ filename.encoding.should eq Encoding::UTF_8 | |
+ end | |
+ mail = Mail.new | |
+ doing { | |
+ mail.attachments[filename] = File.read(fixture('attachments', 'test.pdf')) | |
+ }.should_not raise_error | |
end | |
end | |
@@ -200,42 +214,42 @@ describe "reading emails with attachments" do | |
it "should find the attachment using content location" do | |
mail = Mail.read(fixture(File.join('emails', 'attachment_emails', 'attachment_content_location.eml'))) | |
- mail.attachments.length.should == 1 | |
+ mail.attachments.length.should eq 1 | |
end | |
it "should find an attachment defined with 'name' and Content-Disposition: attachment" do | |
mail = Mail.read(fixture(File.join('emails', 'attachment_emails', 'attachment_content_disposition.eml'))) | |
- mail.attachments.length.should == 1 | |
+ mail.attachments.length.should eq 1 | |
end | |
it "should use the content-type filename or name over the content-disposition filename" do | |
mail = Mail.read(fixture(File.join('emails', 'attachment_emails', 'attachment_content_disposition.eml'))) | |
- mail.attachments[0].filename.should == 'hello.rb' | |
+ mail.attachments[0].filename.should eq 'hello.rb' | |
end | |
it "should decode an attachment" do | |
mail = Mail.read(fixture(File.join('emails', 'attachment_emails', 'attachment_pdf.eml'))) | |
- mail.attachments[0].decoded.length.should == 1026 | |
+ mail.attachments[0].decoded.length.should eq 1026 | |
end | |
it "should find an attachment that has an encoded name value" do | |
mail = Mail.read(fixture(File.join('emails', 'attachment_emails', 'attachment_with_encoded_name.eml'))) | |
- mail.attachments.length.should == 1 | |
+ mail.attachments.length.should eq 1 | |
result = mail.attachments[0].filename | |
if RUBY_VERSION >= '1.9' | |
expected = "01 Quien Te Dij\212at. Pitbull.mp3".force_encoding(result.encoding) | |
else | |
expected = "01 Quien Te Dij\212at. Pitbull.mp3" | |
end | |
- result.should == expected | |
+ result.should eq expected | |
end | |
it "should find attachments inside parts with content-type message/rfc822" do | |
mail = Mail.read(fixture(File.join("emails", | |
"attachment_emails", | |
"attachment_message_rfc822.eml"))) | |
- mail.attachments.length.should == 1 | |
- mail.attachments[0].decoded.length.should == 1026 | |
+ mail.attachments.length.should eq 1 | |
+ mail.attachments[0].decoded.length.should eq 1026 | |
end | |
it "attach filename decoding (issue 83)" do | |
@@ -270,7 +284,7 @@ YWFhCg== | |
limitMAIL | |
mail = Mail.new(data) | |
#~ puts Mail::Encodings.decode_encode(mail.attachments[0].filename, :decode) | |
- mail.attachments[0].filename.should == "Foto0009.jpg" | |
+ mail.attachments[0].filename.should eq "Foto0009.jpg" | |
end | |
end | |
@@ -293,16 +307,16 @@ describe "attachment order" do | |
mail.attachments['test.pdf'] = File.read(fixture('attachments', 'test.pdf')) | |
mail.attachments['test.gif'] = File.read(fixture('attachments', 'test.gif')) | |
mail.attachments['test.jpg'] = File.read(fixture('attachments', 'test.jpg')) | |
- mail.attachments[0].filename.should == 'test.zip' | |
- mail.attachments[1].filename.should == 'test.pdf' | |
- mail.attachments[2].filename.should == 'test.gif' | |
- mail.attachments[3].filename.should == 'test.jpg' | |
+ mail.attachments[0].filename.should eq 'test.zip' | |
+ mail.attachments[1].filename.should eq 'test.pdf' | |
+ mail.attachments[2].filename.should eq 'test.gif' | |
+ mail.attachments[3].filename.should eq 'test.jpg' | |
mail2 = Mail.new(mail.encoded) | |
- mail2.attachments[0].filename.should == 'test.zip' | |
- mail2.attachments[1].filename.should == 'test.pdf' | |
- mail2.attachments[2].filename.should == 'test.gif' | |
- mail2.attachments[3].filename.should == 'test.jpg' | |
+ mail2.attachments[0].filename.should eq 'test.zip' | |
+ mail2.attachments[1].filename.should eq 'test.pdf' | |
+ mail2.attachments[2].filename.should eq 'test.gif' | |
+ mail2.attachments[3].filename.should eq 'test.jpg' | |
end | |
end | |
diff --git a/spec/mail/body_spec.rb b/spec/mail/body_spec.rb | |
index 4e7b1c7..29d7684 100644 | |
--- a/spec/mail/body_spec.rb | |
+++ b/spec/mail/body_spec.rb | |
@@ -35,12 +35,12 @@ describe Mail::Body do | |
it "should accept text as raw source data" do | |
body = Mail::Body.new('this is some text') | |
- body.to_s.should == 'this is some text' | |
+ body.to_s.should eq 'this is some text' | |
end | |
it "should accept nil as a value and return an empty body" do | |
body = Mail::Body.new | |
- body.to_s.should == '' | |
+ body.to_s.should eq '' | |
end | |
it "should accept an array as the body and join it" do | |
@@ -49,7 +49,7 @@ describe Mail::Body do | |
it "should accept an array as the body and join it" do | |
body = Mail::Body.new(["line one\n", "line two\n"]) | |
- body.encoded.should == "line one\r\nline two\r\n" | |
+ body.encoded.should eq "line one\r\nline two\r\n" | |
end | |
end | |
@@ -58,29 +58,29 @@ describe Mail::Body do | |
it "should accept text as raw source data" do | |
body = Mail::Body.new('this is some text') | |
- body.encoded.should == 'this is some text' | |
+ body.encoded.should eq 'this is some text' | |
end | |
it "should set it's own encoding to us_ascii if it is ascii only body" do | |
body = Mail::Body.new('This is some text') | |
- body.charset.should == 'US-ASCII' | |
+ body.charset.should eq 'US-ASCII' | |
end | |
it "should allow you to set it's encoding" do | |
body = Mail::Body.new('') | |
body.charset = 'UTF-8' | |
- body.charset.should == 'UTF-8' | |
+ body.charset.should eq 'UTF-8' | |
end | |
it "should allow you to specify an encoding" do | |
body = Mail::Body.new('') | |
body.encoding = 'base64' | |
- body.encoding.should == 'base64' | |
+ body.encoding.should eq 'base64' | |
end | |
it "should convert all new lines to crlf" do | |
body = Mail::Body.new("This has \n various \r new \r\n lines") | |
- body.encoded.should == "This has \r\n various \r\n new \r\n lines" | |
+ body.encoded.should eq "This has \r\n various \r\n new \r\n lines" | |
end | |
end | |
@@ -89,30 +89,30 @@ describe Mail::Body do | |
it "should convert all new lines to crlf" do | |
body = Mail::Body.new("This has \n various \r new \r\n lines") | |
- body.decoded.should == "This has \n various \n new \n lines" | |
+ body.decoded.should eq "This has \n various \n new \n lines" | |
end | |
it "should not change a body on decode if not given an encoding type to decode" do | |
body = Mail::Body.new("The=3Dbody") | |
- body.decoded.should == "The=3Dbody" | |
+ body.decoded.should eq "The=3Dbody" | |
end | |
it "should change return the raw text if it does not recognise the encoding" do | |
body = Mail::Body.new("The=3Dbody") | |
body.encoding = '7bit' | |
- body.decoded.should == "The=3Dbody" | |
+ body.decoded.should eq "The=3Dbody" | |
end | |
it "should change a body on decode if given an encoding type to decode" do | |
body = Mail::Body.new("The=3Dbody") | |
body.encoding = 'quoted-printable' | |
- body.decoded.should == "The=body" | |
+ body.decoded.should eq "The=body" | |
end | |
it "should change a body on decode if given an encoding type to decode" do | |
body = Mail::Body.new("VGhlIGJvZHk=\n") | |
body.encoding = 'base64' | |
- body.decoded.should == "The body" | |
+ body.decoded.should eq "The body" | |
end | |
end | |
@@ -123,42 +123,42 @@ describe Mail::Body do | |
multipart_body = "this is some text\r\n\r\n------=_Part_2192_32400445\r\nContent-Type: text/plain; charset=ISO-8859-1\r\n\r\nThis is a plain text\r\n\r\n------=_Part_2192_32400445\r\nContent-Type: text/html\r\n\r\n<p>This is HTML</p>\r\nn------=_Part_2192_32400445--\r\n" | |
body = Mail::Body.new(multipart_body) | |
body.split!('----=_Part_2192_32400445') | |
- body.boundary.should == '----=_Part_2192_32400445' | |
+ body.boundary.should eq '----=_Part_2192_32400445' | |
end | |
it "should split at the boundry string given returning two message bodies" do | |
multipart_body = "this is some text\r\n\r\n------=_Part_2192_32400445\r\nContent-Type: text/plain; charset=ISO-8859-1\r\n\r\nThis is a plain text\r\n\r\n------=_Part_2192_32400445\r\nContent-Type: text/html\r\n\r\n<p>This is HTML</p>\r\nn------=_Part_2192_32400445--\r\n" | |
body = Mail::Body.new(multipart_body) | |
- body.split!('----=_Part_2192_32400445').parts.length.should == 2 | |
+ body.split!('----=_Part_2192_32400445').parts.length.should eq 2 | |
end | |
it "should keep the preamble text as it's own preamble" do | |
multipart_body = "this is some text\r\n\r\n------=_Part_2192_32400445\r\nContent-Type: text/plain; charset=ISO-8859-1\r\n\r\nThis is a plain text\r\n\r\n------=_Part_2192_32400445\r\nContent-Type: text/html\r\n\r\n<p>This is HTML</p>\r\nn------=_Part_2192_32400445--\r\n" | |
body = Mail::Body.new(multipart_body) | |
body.split!('----=_Part_2192_32400445') | |
- body.preamble.should == "this is some text" | |
+ body.preamble.should eq "this is some text" | |
end | |
it "should return the parts as their own messages" do | |
multipart_body = "this is some text\r\n\r\n------=_Part_2192_32400445\r\nContent-Type: text/plain; charset=ISO-8859-1\r\n\r\nThis is a plain text\r\n\r\n------=_Part_2192_32400445\r\nContent-Type: text/html\r\n\r\n<p>This is HTML</p>\r\nn------=_Part_2192_32400445--\r\n" | |
body = Mail::Body.new(multipart_body) | |
body.split!('----=_Part_2192_32400445') | |
- body.parts[0].class.should == Mail::Part | |
- body.parts[1].class.should == Mail::Part | |
+ body.parts[0].class.should eq Mail::Part | |
+ body.parts[1].class.should eq Mail::Part | |
end | |
it "should return the first part as it's own message" do | |
multipart_body = "this is some text\r\n\r\n------=_Part_2192_32400445\r\nContent-Type: text/plain; charset=ISO-8859-1\r\n\r\nThis is a plain text\r\n\r\n------=_Part_2192_32400445\r\nContent-Type: text/html\r\n\r\n<p>This is HTML</p>\r\nn------=_Part_2192_32400445--\r\n" | |
body = Mail::Body.new(multipart_body) | |
body.split!('----=_Part_2192_32400445') | |
- body.parts[0].content_type.should == "text/plain; charset=ISO-8859-1" | |
+ body.parts[0].content_type.should eq "text/plain; charset=ISO-8859-1" | |
end | |
it "should return the first part as it's own message" do | |
multipart_body = "this is some text\r\n\r\n------=_Part_2192_32400445\r\nContent-Type: text/plain; charset=ISO-8859-1\r\n\r\nThis is a plain text\r\n\r\n------=_Part_2192_32400445\r\nContent-Type: text/html\r\n\r\n<p>This is HTML</p>\r\nn------=_Part_2192_32400445--\r\n" | |
body = Mail::Body.new(multipart_body) | |
body.split!('----=_Part_2192_32400445') | |
- body.parts[1].content_type.should == "text/html" | |
+ body.parts[1].content_type.should eq "text/html" | |
end | |
it "should separate out it's parts" do | |
@@ -172,7 +172,7 @@ describe Mail::Body do | |
multipart_body = "this is some text\r\n\r\n------=_Part_2192_32400445\r\nContent-Type: text/plain; charset=ISO-8859-1\r\n\r\nThis is a plain text\r\n\r\n------=_Part_2192_32400445\r\nContent-Type: text/html\r\n\r\n<p>This is HTML</p>\r\nn------=_Part_2192_32400445--\r\n" | |
body = Mail::Body.new(multipart_body) | |
body.split!('----=_Part_2192_32400445') | |
- body.parts.length.should == 2 | |
+ body.parts.length.should eq 2 | |
end | |
it "should round trip it's parts" do | |
@@ -183,9 +183,9 @@ describe Mail::Body do | |
body.epilogue = "And this is the end" | |
new_body = Mail::Body.new(body.encoded) | |
new_body.split!('----=_Part_2192_32400445') | |
- new_body.parts.length.should == 2 | |
- new_body.preamble.should == "Really! this is some text" | |
- new_body.epilogue.should == "And this is the end" | |
+ new_body.parts.length.should eq 2 | |
+ new_body.preamble.should eq "Really! this is some text" | |
+ new_body.epilogue.should eq "And this is the end" | |
end | |
it "should allow you to change the boundary" do | |
@@ -195,8 +195,8 @@ describe Mail::Body do | |
body.boundary = '------=_MIMEPART' | |
new_body = Mail::Body.new(body.encoded) | |
new_body.split!('------=_MIMEPART') | |
- new_body.parts.length.should == 2 | |
- new_body.preamble.should == "this is some text" | |
+ new_body.parts.length.should eq 2 | |
+ new_body.preamble.should eq "this is some text" | |
end | |
end | |
@@ -222,7 +222,7 @@ describe Mail::Body do | |
it "should allow you to add a part" do | |
body = Mail::Body.new('') | |
body << Mail::Part.new('') | |
- body.parts.length.should == 1 | |
+ body.parts.length.should eq 1 | |
body.should be_multipart | |
end | |
@@ -231,12 +231,12 @@ describe Mail::Body do | |
body << Mail::Part.new("content-type: text/html\r\nsubject: HTML") | |
body << Mail::Part.new("content-type: text/plain\r\nsubject: Plain Text") | |
body << Mail::Part.new("content-type: text/enriched\r\nsubject: Enriched") | |
- body.parts.length.should == 3 | |
+ body.parts.length.should eq 3 | |
body.should be_multipart | |
body.sort_parts! | |
- body.parts[0].content_type.should == "text/plain" | |
- body.parts[1].content_type.should == "text/enriched" | |
- body.parts[2].content_type.should == "text/html" | |
+ body.parts[0].content_type.should eq "text/plain" | |
+ body.parts[1].content_type.should eq "text/enriched" | |
+ body.parts[2].content_type.should eq "text/html" | |
end | |
it "should allow you to sort the parts with an arbitrary sort order" do | |
@@ -245,12 +245,12 @@ describe Mail::Body do | |
body << Mail::Part.new("content-type: text/html\r\nsubject: HTML") | |
body << Mail::Part.new("content-type: text/plain\r\nsubject: Plain Text") | |
body << Mail::Part.new("content-type: text/enriched\r\nsubject: Enriched") | |
- body.parts.length.should == 3 | |
+ body.parts.length.should eq 3 | |
body.should be_multipart | |
body.sort_parts! | |
- body.parts[0].content_type.should == "text/plain" | |
- body.parts[1].content_type.should == "text/html" | |
- body.parts[2].content_type.should == "text/enriched" | |
+ body.parts[0].content_type.should eq "text/plain" | |
+ body.parts[1].content_type.should eq "text/html" | |
+ body.parts[2].content_type.should eq "text/enriched" | |
end | |
it "should allow you to sort the parts with an arbitrary sort order" do | |
@@ -259,12 +259,12 @@ describe Mail::Body do | |
body << Mail::Part.new("content-type: text/plain\r\nsubject: HTML") | |
body << Mail::Part.new("content-type: text/html\r\nsubject: Plain Text") | |
body << Mail::Part.new("content-type: application/x-yaml\r\nsubject: Enriched") | |
- body.parts.length.should == 3 | |
+ body.parts.length.should eq 3 | |
body.should be_multipart | |
body.sort_parts! | |
- body.parts[0].content_type.should == "application/x-yaml" | |
- body.parts[1].content_type.should == "text/plain" | |
- body.parts[2].content_type.should == "text/html" | |
+ body.parts[0].content_type.should eq "application/x-yaml" | |
+ body.parts[1].content_type.should eq "text/plain" | |
+ body.parts[2].content_type.should eq "text/html" | |
end | |
it "should sort the parts on encode" do | |
@@ -272,12 +272,12 @@ describe Mail::Body do | |
body << Mail::Part.new("content-type: text/html\r\nsubject: HTML") | |
body << Mail::Part.new("content-type: text/plain\r\nsubject: Plain Text") | |
body << Mail::Part.new("content-type: text/enriched\r\nsubject: Enriched") | |
- body.parts.length.should == 3 | |
+ body.parts.length.should eq 3 | |
body.should be_multipart | |
body.encoded | |
- body.parts[0].content_type.should == "text/plain" | |
- body.parts[1].content_type.should == "text/enriched" | |
- body.parts[2].content_type.should == "text/html" | |
+ body.parts[0].content_type.should eq "text/plain" | |
+ body.parts[1].content_type.should eq "text/enriched" | |
+ body.parts[2].content_type.should eq "text/html" | |
end | |
it "should put the part types it doesn't know about at the end" do | |
@@ -285,12 +285,12 @@ describe Mail::Body do | |
body << Mail::Part.new("content-type: text/html\r\nsubject: HTML") | |
body << Mail::Part.new("content-type: text/plain\r\nsubject: Plain Text") | |
body << Mail::Part.new("content-type: image/jpeg\r\n") | |
- body.parts.length.should == 3 | |
+ body.parts.length.should eq 3 | |
body.should be_multipart | |
body.encoded | |
- body.parts[0].content_type.should == "text/plain" | |
- body.parts[1].content_type.should == "text/html" | |
- body.parts[2].content_type.should == "image/jpeg" | |
+ body.parts[0].content_type.should eq "text/plain" | |
+ body.parts[1].content_type.should eq "text/html" | |
+ body.parts[2].content_type.should eq "image/jpeg" | |
end | |
it "should allow you to sort the parts recursively" do | |
@@ -301,14 +301,14 @@ describe Mail::Body do | |
body = Mail::Body.new('') | |
body << part | |
body << Mail::Part.new("content-type: image/jpeg\r\nsubject: JPGEG\r\n\r\nsdkjskjdksjdkjsd") | |
- body.parts.length.should == 2 | |
+ body.parts.length.should eq 2 | |
body.should be_multipart | |
body.sort_parts! | |
body.parts[0].content_type.should match %r{\Amultipart/alternate(;|\Z)} | |
- body.parts[1].content_type.should == "image/jpeg" | |
- body.parts[0].parts[0].content_type.should == "text/plain" | |
- body.parts[0].parts[1].content_type.should == "text/enriched" | |
- body.parts[0].parts[2].content_type.should == "text/html" | |
+ body.parts[1].content_type.should eq "image/jpeg" | |
+ body.parts[0].parts[0].content_type.should eq "text/plain" | |
+ body.parts[0].parts[1].content_type.should eq "text/enriched" | |
+ body.parts[0].parts[2].content_type.should eq "text/html" | |
end | |
it "should allow you to sort the parts recursively" do | |
@@ -319,14 +319,14 @@ describe Mail::Body do | |
body = Mail::Body.new('') | |
body << part | |
body << Mail::Part.new("content-type: image/jpeg\r\nsubject: JPGEG\r\n\r\nsdkjskjdksjdkjsd") | |
- body.parts.length.should == 2 | |
+ body.parts.length.should eq 2 | |
body.should be_multipart | |
body.sort_parts! | |
body.parts[0].content_type.should match %r{\Amultipart/alternate(;|\Z)} | |
- body.parts[1].content_type.should == "image/jpeg" | |
- body.parts[0].parts[0].content_type.should == "text/plain" | |
- body.parts[0].parts[1].content_type.should == "text/enriched" | |
- body.parts[0].parts[2].content_type.should == "text/html" | |
+ body.parts[1].content_type.should eq "image/jpeg" | |
+ body.parts[0].parts[0].content_type.should eq "text/plain" | |
+ body.parts[0].parts[1].content_type.should eq "text/enriched" | |
+ body.parts[0].parts[2].content_type.should eq "text/html" | |
end | |
end | |
@@ -335,7 +335,7 @@ describe Mail::Body do | |
it "should still equal itself" do | |
body = Mail::Body.new('The body') | |
- body.should == body | |
+ body.should eq body | |
end | |
it "should match on the body part decoded if given a string to ==" do | |
@@ -351,24 +351,24 @@ describe Mail::Body do | |
it "should match on the body part decoded if given a string to =~" do | |
body = Mail::Body.new('The body') | |
- (body =~ /The/).should == 0 | |
+ (body =~ /The/).should eq 0 | |
end | |
it "should match on the body part decoded if given a string to ==" do | |
body = Mail::Body.new("VGhlIGJvZHk=\n") | |
body.encoding = 'base64' | |
- (body =~ /The/).should == 0 | |
+ (body =~ /The/).should eq 0 | |
end | |
it "should match on the body part decoded if given a string to match" do | |
body = Mail::Body.new('The body') | |
- (body.match(/The/))[0].should == 'The' | |
+ (body.match(/The/))[0].should eq 'The' | |
end | |
it "should match on the body part decoded if given a string to match" do | |
body = Mail::Body.new("VGhlIGJvZHk=\n") | |
body.encoding = 'base64' | |
- (body.match(/The/))[0].should == 'The' | |
+ (body.match(/The/))[0].should eq 'The' | |
end | |
it "should match on the body part decoded if given a string to include?" do | |
@@ -388,7 +388,7 @@ describe Mail::Body do | |
body = Mail::Body.new("あいうえお\n") | |
body.charset = 'iso-2022-jp' | |
expect = (RUBY_VERSION < '1.9') ? "あいうえお\r\n" : "\e$B$\"$$$&$($*\e(B\r\n" | |
- body.encoded.should == expect | |
+ body.encoded.should eq expect | |
end | |
end | |
end | |
diff --git a/spec/mail/configuration_spec.rb b/spec/mail/configuration_spec.rb | |
index 48570aa..686b991 100644 | |
--- a/spec/mail/configuration_spec.rb | |
+++ b/spec/mail/configuration_spec.rb | |
@@ -1,26 +1,47 @@ | |
require 'spec_helper' | |
+class MyTestDeliveryMethod | |
+ attr_accessor :settings | |
+ | |
+ def initialize(values) | |
+ self.settings = {}.merge!(values) | |
+ end | |
+end | |
+ | |
describe Mail::Configuration do | |
describe "network configurations" do | |
- | |
+ | |
it "should be available from the Mail.defaults method" do | |
Mail.defaults { delivery_method :smtp, { :address => 'some.host' } } | |
- Mail.delivery_method.settings[:address].should == 'some.host' | |
+ Mail.delivery_method.settings[:address].should eq 'some.host' | |
end | |
it "should configure sendmail" do | |
Mail.defaults { delivery_method :sendmail, :location => "/usr/bin/sendmail" } | |
- Mail.delivery_method.class.should == Mail::Sendmail | |
- Mail.delivery_method.settings[:location].should == "/usr/bin/sendmail" | |
+ Mail.delivery_method.class.should eq Mail::Sendmail | |
+ Mail.delivery_method.settings[:location].should eq "/usr/bin/sendmail" | |
end | |
- | |
+ | |
+ it "should configure exim" do | |
+ Mail.defaults { delivery_method :exim, :location => "/usr/bin/exim" } | |
+ Mail.delivery_method.class.should eq Mail::Exim | |
+ Mail.delivery_method.settings[:location].should eq "/usr/bin/exim" | |
+ end | |
+ | |
it "should configure an open SMTP connection" do | |
smtp = Net::SMTP.start('127.0.0.1', 25) | |
Mail.defaults { delivery_method :smtp_connection, {:connection => smtp} } | |
- Mail.delivery_method.class.should == Mail::SMTPConnection | |
- Mail.delivery_method.smtp.should == smtp | |
+ Mail.delivery_method.class.should eq Mail::SMTPConnection | |
+ Mail.delivery_method.smtp.should eq smtp | |
end | |
- | |
+ | |
+ it "should accept a plug-in delivery method" do | |
+ Mail.defaults { delivery_method MyTestDeliveryMethod, { :option1 => "one", :option2 => "two" }} | |
+ Mail.delivery_method.class.should eq MyTestDeliveryMethod | |
+ Mail.delivery_method.settings[:option1].should eq "one" | |
+ Mail.delivery_method.settings[:option2].should eq "two" | |
+ end | |
+ | |
end | |
end | |
diff --git a/spec/mail/core_extensions/string_spec.rb b/spec/mail/core_extensions/string_spec.rb | |
index 498898a..4e68908 100644 | |
--- a/spec/mail/core_extensions/string_spec.rb | |
+++ b/spec/mail/core_extensions/string_spec.rb | |
@@ -5,57 +5,63 @@ describe 'core_extensions/string' do | |
describe "to_crlf" do | |
it "should change a single LF to CRLF" do | |
- "\n".to_crlf.should == "\r\n" | |
+ "\n".to_crlf.should eq "\r\n" | |
end | |
it "should change multiple LF to CRLF" do | |
- "\n\n".to_crlf.should == "\r\n\r\n" | |
+ "\n\n".to_crlf.should eq "\r\n\r\n" | |
end | |
it "should change a single CR to CRLF" do | |
- "\r".to_crlf.should == "\r\n" | |
+ "\r".to_crlf.should eq "\r\n" | |
end | |
it "should not change CRLF" do | |
- "\r\n".to_crlf.should == "\r\n" | |
+ "\r\n".to_crlf.should eq "\r\n" | |
end | |
it "should not change multiple CRLF" do | |
- "\r\n\r\n".to_crlf.should == "\r\n\r\n" | |
+ "\r\n\r\n".to_crlf.should eq "\r\n\r\n" | |
end | |
it "should handle a mix" do | |
- "\r \n\r\n".to_crlf.should == "\r\n \r\n\r\n" | |
+ "\r \n\r\n".to_crlf.should eq "\r\n \r\n\r\n" | |
end | |
end | |
describe "to_lf" do | |
it "should change a single CR to LF" do | |
- "\r".to_lf.should == "\n" | |
+ "\r".to_lf.should eq "\n" | |
end | |
it "should change multiple LF to CRLF" do | |
- "\r\r".to_lf.should == "\n\n" | |
+ "\r\r".to_lf.should eq "\n\n" | |
end | |
it "should change a single CRLF to LF" do | |
- "\r\n".to_lf.should == "\n" | |
+ "\r\n".to_lf.should eq "\n" | |
end | |
it "should change multiple CR to LF" do | |
- "\r\n\r\n".to_lf.should == "\n\n" | |
+ "\r\n\r\n".to_lf.should eq "\n\n" | |
end | |
it "should not change LF" do | |
- "\n".to_lf.should == "\n" | |
+ "\n".to_lf.should eq "\n" | |
end | |
it "should not change multiple CRLF" do | |
- "\n\n".to_lf.should == "\n\n" | |
+ "\n\n".to_lf.should eq "\n\n" | |
end | |
it "should handle a mix" do | |
- "\r \n\r\n".to_lf.should == "\n \n\n" | |
+ "\r \n\r\n".to_lf.should eq "\n \n\n" | |
+ end | |
+ end | |
+ | |
+ describe 'constantize' do | |
+ it 'should converts string to constant' do | |
+ "Kernel".constantize.should eq Kernel | |
end | |
end | |
diff --git a/spec/mail/core_extensions_spec.rb b/spec/mail/core_extensions_spec.rb | |
index af3c84e..6ce9e87 100644 | |
--- a/spec/mail/core_extensions_spec.rb | |
+++ b/spec/mail/core_extensions_spec.rb | |
@@ -49,51 +49,51 @@ describe Object do | |
describe "to_lf method on String" do | |
it "should leave lf as lf" do | |
- "\n".to_lf.should == "\n" | |
+ "\n".to_lf.should eq "\n" | |
end | |
it "should clean just cr to lf" do | |
- "\r".to_lf.should == "\n" | |
+ "\r".to_lf.should eq "\n" | |
end | |
it "should leave crlf as lf" do | |
- "\r\n".to_lf.should == "\n" | |
+ "\r\n".to_lf.should eq "\n" | |
end | |
it "should handle japanese characters" do | |
string = "\343\201\202\343\201\210\343\201\206\343\201\210\343\201\212\r\n\r\n\343\201\213\343\201\215\343\201\217\343\201\221\343\201\223\r\n\r\n\343\201\225\343\201\227\343\201\244\343\201\233\343\201\235\r\n\r\n" | |
- string.to_lf.should == "\343\201\202\343\201\210\343\201\206\343\201\210\343\201\212\n\n\343\201\213\343\201\215\343\201\217\343\201\221\343\201\223\n\n\343\201\225\343\201\227\343\201\244\343\201\233\343\201\235\n\n" | |
+ string.to_lf.should eq "\343\201\202\343\201\210\343\201\206\343\201\210\343\201\212\n\n\343\201\213\343\201\215\343\201\217\343\201\221\343\201\223\n\n\343\201\225\343\201\227\343\201\244\343\201\233\343\201\235\n\n" | |
end | |
end | |
describe "to_crlf method on String" do | |
it "should clean just lf to crlf" do | |
- "\n".to_crlf.should == "\r\n" | |
+ "\n".to_crlf.should eq "\r\n" | |
end | |
it "should clean just cr to crlf" do | |
- "\r".to_crlf.should == "\r\n" | |
+ "\r".to_crlf.should eq "\r\n" | |
end | |
it "should leave crlf as crlf" do | |
- "\r\n".to_crlf.should == "\r\n" | |
+ "\r\n".to_crlf.should eq "\r\n" | |
end | |
it "should handle japanese characters" do | |
string = "\343\201\202\343\201\210\343\201\206\343\201\210\343\201\212\r\n\r\n\343\201\213\343\201\215\343\201\217\343\201\221\343\201\223\r\n\r\n\343\201\225\343\201\227\343\201\244\343\201\233\343\201\235\r\n\r\n" | |
- string.to_crlf.should == "\343\201\202\343\201\210\343\201\206\343\201\210\343\201\212\r\n\r\n\343\201\213\343\201\215\343\201\217\343\201\221\343\201\223\r\n\r\n\343\201\225\343\201\227\343\201\244\343\201\233\343\201\235\r\n\r\n" | |
+ string.to_crlf.should eq "\343\201\202\343\201\210\343\201\206\343\201\210\343\201\212\r\n\r\n\343\201\213\343\201\215\343\201\217\343\201\221\343\201\223\r\n\r\n\343\201\225\343\201\227\343\201\244\343\201\233\343\201\235\r\n\r\n" | |
end | |
end | |
describe "methods on NilClass" do | |
it "should return empty string on to_crlf" do | |
- nil.to_crlf.should == '' | |
+ nil.to_crlf.should eq '' | |
end | |
it "should return empty string on to_lf" do | |
- nil.to_lf.should == '' | |
+ nil.to_lf.should eq '' | |
end | |
end | |
-end | |
\ No newline at end of file | |
+end | |
diff --git a/spec/mail/elements/address_list_spec.rb b/spec/mail/elements/address_list_spec.rb | |
index cd18023..f8d9df4 100644 | |
--- a/spec/mail/elements/address_list_spec.rb | |
+++ b/spec/mail/elements/address_list_spec.rb | |
@@ -28,43 +28,43 @@ describe Mail::AddressList do | |
parse_text = '[email protected]' | |
result = '[email protected]' | |
a = Mail::AddressList.new(parse_text) | |
- a.addresses.first.to_s.should == result | |
+ a.addresses.first.to_s.should eq result | |
end | |
it "should give the addresses passed in" do | |
parse_text = '[email protected], [email protected]' | |
result = ['[email protected]', '[email protected]'] | |
a = Mail::AddressList.new(parse_text) | |
- a.addresses.map {|addr| addr.to_s }.should == result | |
+ a.addresses.map {|addr| addr.to_s }.should eq result | |
end | |
it "should preserve the display name" do | |
parse_text = '"Mikel Lindsaar" <[email protected]>' | |
result = 'Mikel Lindsaar <[email protected]>' | |
a = Mail::AddressList.new(parse_text) | |
- a.addresses.first.format.should == result | |
- a.addresses.first.display_name.should == 'Mikel Lindsaar' | |
+ a.addresses.first.format.should eq result | |
+ a.addresses.first.display_name.should eq 'Mikel Lindsaar' | |
end | |
it "should handle and ignore nil addresses" do | |
parse_text = ' , [email protected], [email protected]' | |
result = ['[email protected]', '[email protected]'] | |
a = Mail::AddressList.new(parse_text) | |
- a.addresses.map {|addr| addr.to_s }.should == result | |
+ a.addresses.map {|addr| addr.to_s }.should eq result | |
end | |
it "should handle truly horrific combinations of commas, spaces, and addresses" do | |
parse_text = ' ,, [email protected], , ,,, [email protected] ,,' | |
result = ['[email protected]', '[email protected]'] | |
a = Mail::AddressList.new(parse_text) | |
- a.addresses.map {|addr| addr.to_s }.should == result | |
+ a.addresses.map {|addr| addr.to_s }.should eq result | |
end | |
it "should handle folding whitespace" do | |
parse_text = "[email protected],\r\n\[email protected]" | |
result = ['[email protected]', '[email protected]'] | |
a = Mail::AddressList.new(parse_text) | |
- a.addresses.map {|addr| addr.to_s }.should == result | |
+ a.addresses.map {|addr| addr.to_s }.should eq result | |
end | |
it "should handle malformed folding whitespace" do | |
@@ -72,7 +72,7 @@ describe Mail::AddressList do | |
parse_text = "[email protected],\n\t [email protected],\n\t [email protected],\n\t [email protected],\n\t [email protected],\n\t\n\t [email protected]" | |
result = %w([email protected] [email protected] [email protected] [email protected] [email protected] [email protected]) | |
a = Mail::AddressList.new(parse_text) | |
- a.addresses.map {|addr| addr.to_s }.should == result | |
+ a.addresses.map {|addr| addr.to_s }.should eq result | |
end | |
end | |
@@ -80,57 +80,57 @@ describe Mail::AddressList do | |
describe "functionality" do | |
it "should give back a list of address nodes" do | |
list = Mail::AddressList.new('[email protected], [email protected]') | |
- list.address_nodes.length.should == 2 | |
+ list.address_nodes.length.should eq 2 | |
end | |
it "should have each nood a class of SyntaxNode" do | |
list = Mail::AddressList.new('[email protected], [email protected]') | |
- list.address_nodes.each { |n| n.class.should == Treetop::Runtime::SyntaxNode } | |
+ list.address_nodes.each { |n| n.class.should eq Treetop::Runtime::SyntaxNode } | |
end | |
it "should give a block of address nodes with groups" do | |
list = Mail::AddressList.new('[email protected], my_group: [email protected], [email protected];') | |
- list.address_nodes.length.should == 2 | |
+ list.address_nodes.length.should eq 2 | |
end | |
it "should give all the recipients when asked" do | |
list = Mail::AddressList.new('[email protected], my_group: [email protected], [email protected];') | |
- list.individual_recipients.length.should == 1 | |
+ list.individual_recipients.length.should eq 1 | |
end | |
it "should give all the groups when asked" do | |
list = Mail::AddressList.new('[email protected], my_group: [email protected], [email protected];') | |
- list.group_recipients.length.should == 1 | |
+ list.group_recipients.length.should eq 1 | |
end | |
it "should ask the group for all it's addresses" do | |
list = Mail::AddressList.new('[email protected], my_group: [email protected], [email protected];') | |
- list.group_recipients.first.group_list.addresses.length.should == 2 | |
+ list.group_recipients.first.group_list.addresses.length.should eq 2 | |
end | |
it "should give all the addresses when asked" do | |
list = Mail::AddressList.new('[email protected], my_group: [email protected], [email protected];') | |
- list.addresses.length.should == 3 | |
+ list.addresses.length.should eq 3 | |
end | |
it "should handle a really nasty obsolete address list" do | |
pending | |
psycho_obsolete = "Mary Smith <@machine.tld:[email protected]>, , jdoe@test . example" | |
list = Mail::AddressList.new(psycho_obsolete) | |
- list.addresses.length.should == 2 | |
+ list.addresses.length.should eq 2 | |
end | |
it "should create an address instance for each address returned" do | |
list = Mail::AddressList.new('[email protected], my_group: [email protected], [email protected];') | |
list.addresses.each do |address| | |
- address.class.should == Mail::Address | |
+ address.class.should eq Mail::Address | |
end | |
end | |
it "should provide a list of group names" do | |
list = Mail::AddressList.new('[email protected], my_group: [email protected], [email protected];') | |
- list.group_names.should == ["my_group"] | |
+ list.group_names.should eq ["my_group"] | |
end | |
end | |
diff --git a/spec/mail/elements/address_spec.rb b/spec/mail/elements/address_spec.rb | |
index 38d732e..d4c4504 100644 | |
--- a/spec/mail/elements/address_spec.rb | |
+++ b/spec/mail/elements/address_spec.rb | |
@@ -12,34 +12,34 @@ describe Mail::Address do | |
end | |
it "should allow us to instantiate an empty address object and call to_s" do | |
- Mail::Address.new.to_s.should == '' | |
+ Mail::Address.new.to_s.should eq '' | |
end | |
it "should allow us to instantiate an empty address object and call format" do | |
- Mail::Address.new.format.should == '' | |
+ Mail::Address.new.format.should eq '' | |
end | |
it "should allow us to instantiate an empty address object and call address" do | |
[nil, '', ' '].each do |input| | |
- Mail::Address.new(input).address.should == nil | |
+ Mail::Address.new(input).address.should eq nil | |
end | |
end | |
it "should allow us to instantiate an empty address object and call local" do | |
[nil, '', ' '].each do |input| | |
- Mail::Address.new(input).local.should == nil | |
+ Mail::Address.new(input).local.should eq nil | |
end | |
end | |
it "should allow us to instantiate an empty address object and call domain" do | |
[nil, '', ' '].each do |input| | |
- Mail::Address.new(input).domain.should == nil | |
+ Mail::Address.new(input).domain.should eq nil | |
end | |
end | |
['"-Earnings...Notification-" <vodacom.co.rs>', '<56253817>'].each do |spammy_address| | |
it "should allow for funky spammy address #{spammy_address}" do | |
- Mail::Address.new(spammy_address).address.should == nil | |
+ Mail::Address.new(spammy_address).address.should eq nil | |
end | |
end | |
@@ -47,83 +47,83 @@ describe Mail::Address do | |
it "should give it's address back on :to_s if there is no display name" do | |
parse_text = '[email protected]' | |
result = '[email protected]' | |
- Mail::Address.new(parse_text).to_s.should == '[email protected]' | |
+ Mail::Address.new(parse_text).to_s.should eq '[email protected]' | |
end | |
it "should give it's format back on :to_s if there is a display name" do | |
parse_text = 'Mikel Lindsaar <[email protected]>' | |
result = 'Mikel Lindsaar <[email protected]>' | |
- Mail::Address.new(parse_text).to_s.should == 'Mikel Lindsaar <[email protected]>' | |
+ Mail::Address.new(parse_text).to_s.should eq 'Mikel Lindsaar <[email protected]>' | |
end | |
it "should give back the display name" do | |
parse_text = 'Mikel Lindsaar <[email protected]>' | |
result = 'Mikel Lindsaar' | |
a = Mail::Address.new(parse_text) | |
- a.display_name.should == result | |
+ a.display_name.should eq result | |
end | |
it "should preserve the display name passed in" do | |
parse_text = '"Mikel Lindsaar" <[email protected]>' | |
result = 'Mikel Lindsaar' | |
a = Mail::Address.new(parse_text) | |
- a.display_name.should == result | |
+ a.display_name.should eq result | |
end | |
it "should preserve the display name passed in with token unsafe chars" do | |
parse_text = '"Mikel@@@Lindsaar" <[email protected]>' | |
result = 'Mikel@@@Lindsaar' | |
a = Mail::Address.new(parse_text) | |
- a.display_name.should == result | |
+ a.display_name.should eq result | |
end | |
it "should give back the local part" do | |
parse_text = 'Mikel Lindsaar <[email protected]>' | |
result = 'test' | |
a = Mail::Address.new(parse_text) | |
- a.local.should == result | |
+ a.local.should eq result | |
end | |
it "should give back the domain" do | |
parse_text = 'Mikel Lindsaar <[email protected]>' | |
result = 'lindsaar.net' | |
a = Mail::Address.new(parse_text) | |
- a.domain.should == result | |
+ a.domain.should eq result | |
end | |
it "should give back the formated address" do | |
parse_text = 'Mikel Lindsaar <[email protected]>' | |
result = 'Mikel Lindsaar <[email protected]>' | |
a = Mail::Address.new(parse_text) | |
- a.format.should == result | |
+ a.format.should eq result | |
end | |
it "should handle an address without a domain" do | |
parse_text = 'test' | |
result = 'test' | |
a = Mail::Address.new(parse_text) | |
- a.address.should == result | |
+ a.address.should eq result | |
end | |
it "should handle comments" do | |
parse_text = "Mikel Lindsaar (author) <[email protected]>" | |
result = ['author'] | |
a = Mail::Address.new(parse_text) | |
- a.comments.should == result | |
+ a.comments.should eq result | |
end | |
it "should handle multiple comments" do | |
parse_text = "Mikel (first name) Lindsaar (author) <[email protected]>" | |
result = ['first name', 'author'] | |
a = Mail::Address.new(parse_text) | |
- a.comments.should == result | |
+ a.comments.should eq result | |
end | |
it "should give back the raw value" do | |
parse_text = "Mikel (first name) Lindsaar (author) <[email protected]>" | |
result = "Mikel (first name) Lindsaar (author) <[email protected]>" | |
a = Mail::Address.new(parse_text) | |
- a.raw.should == result | |
+ a.raw.should eq result | |
end | |
end | |
@@ -132,27 +132,27 @@ describe Mail::Address do | |
it "should allow you to assign an address" do | |
a = Mail::Address.new | |
a.address = '[email protected]' | |
- a.address.should == '[email protected]' | |
- a.format.should == '[email protected]' | |
+ a.address.should eq '[email protected]' | |
+ a.format.should eq '[email protected]' | |
end | |
it "should allow you to assign a display name" do | |
a = Mail::Address.new | |
a.display_name = 'Mikel Lindsaar' | |
- a.display_name.should == 'Mikel Lindsaar' | |
+ a.display_name.should eq 'Mikel Lindsaar' | |
end | |
it "should return an empty format a display name and no address defined" do | |
a = Mail::Address.new | |
a.display_name = 'Mikel Lindsaar' | |
- a.format.should == '' | |
+ a.format.should eq '' | |
end | |
it "should allow you to assign an address and a display name" do | |
a = Mail::Address.new | |
a.address = '[email protected]' | |
a.display_name = 'Mikel Lindsaar' | |
- a.format.should == 'Mikel Lindsaar <[email protected]>' | |
+ a.format.should eq 'Mikel Lindsaar <[email protected]>' | |
end | |
end | |
@@ -167,7 +167,7 @@ describe Mail::Address do | |
].each do |(words, ok)| | |
a = Mail::Address.new(words) | |
- a.local.should == ok | |
+ a.local.should eq ok | |
end | |
end | |
@@ -180,7 +180,7 @@ describe Mail::Address do | |
].each do |(words, ok)| | |
a = Mail::Address.new(%Q|me@#{words}|) | |
- a.domain.should == ok | |
+ a.domain.should eq ok | |
end | |
end | |
end | |
@@ -246,18 +246,10 @@ describe Mail::Address do | |
:raw => 'Minero Aoki<[email protected]>'}) | |
end | |
- it "should handle lots of dots" do | |
- 1.upto(10) do |times| | |
+ it "should reject multiple dots" do | |
+ 2.upto(10) do |times| | |
dots = "." * times | |
- address = Mail::Address.new("hoge#{dots}[email protected]") | |
- address.should break_down_to({ | |
- :display_name => nil, | |
- :address => "hoge#{dots}[email protected]", | |
- :local => "hoge#{dots}test", | |
- :domain => 'docomo.ne.jp', | |
- :format => "hoge#{dots}[email protected]", | |
- :comments => nil, | |
- :raw => "hoge#{dots}[email protected]"}) | |
+ doing { Mail::Address.new("hoge#{dots}[email protected]") }.should raise_error | |
end | |
end | |
@@ -577,7 +569,7 @@ describe Mail::Address do | |
it "should add a display name" do | |
address = Mail::Address.new | |
address.display_name = "Mikel Lindsaar" | |
- address.display_name.should == 'Mikel Lindsaar' | |
+ address.display_name.should eq 'Mikel Lindsaar' | |
end | |
end | |
@@ -593,21 +585,21 @@ describe Mail::Address do | |
it "should add a display name" do | |
address = Mail::Address.new | |
address.display_name = "Mikel Lindsaar" | |
- address.display_name.should == 'Mikel Lindsaar' | |
+ address.display_name.should eq 'Mikel Lindsaar' | |
end | |
it "should take an address and a display name and join them" do | |
address = Mail::Address.new | |
address.address = "[email protected]" | |
address.display_name = "Mikel Lindsaar" | |
- address.format.should == 'Mikel Lindsaar <[email protected]>' | |
+ address.format.should eq 'Mikel Lindsaar <[email protected]>' | |
end | |
it "should take a display name and an address and join them" do | |
address = Mail::Address.new | |
address.display_name = "Mikel Lindsaar" | |
address.address = "[email protected]" | |
- address.format.should == 'Mikel Lindsaar <[email protected]>' | |
+ address.format.should eq 'Mikel Lindsaar <[email protected]>' | |
end | |
end | |
@@ -617,7 +609,7 @@ describe Mail::Address do | |
address = Mail::Address.new | |
address.display_name = "Mikel Lindsaar" | |
address.address = "[email protected]" | |
- address.encoded.should == 'Mikel Lindsaar <[email protected]>' | |
+ address.encoded.should eq 'Mikel Lindsaar <[email protected]>' | |
end | |
it "should provide an encoded output for non us-ascii" do | |
@@ -625,9 +617,9 @@ describe Mail::Address do | |
address.display_name = "まける" | |
address.address = "[email protected]" | |
if RUBY_VERSION >= '1.9' | |
- address.encoded.should == '=?UTF-8?B?44G+44GR44KL?= <[email protected]>' | |
+ address.encoded.should eq '=?UTF-8?B?44G+44GR44KL?= <[email protected]>' | |
else | |
- address.encoded.should == '=?UTF8?B?44G+44GR44KL?= <[email protected]>' | |
+ address.encoded.should eq '=?UTF8?B?44G+44GR44KL?= <[email protected]>' | |
end | |
end | |
@@ -635,7 +627,7 @@ describe Mail::Address do | |
address = Mail::Address.new | |
address.display_name = "まける" | |
address.address = "[email protected]" | |
- address.decoded.should == '"まける" <[email protected]>' | |
+ address.decoded.should eq '"まける" <[email protected]>' | |
end | |
end | |
diff --git a/spec/mail/elements/envelope_from_element_spec.rb b/spec/mail/elements/envelope_from_element_spec.rb | |
index 1f29271..fc91925 100644 | |
--- a/spec/mail/elements/envelope_from_element_spec.rb | |
+++ b/spec/mail/elements/envelope_from_element_spec.rb | |
@@ -19,12 +19,12 @@ describe Mail::EnvelopeFromElement do | |
describe "accessor methods" do | |
it "should return the address" do | |
envelope = Mail::EnvelopeFromElement.new("[email protected] Mon Aug 17 00:39:21 2009") | |
- envelope.address.should == "[email protected]" | |
+ envelope.address.should eq "[email protected]" | |
end | |
it "should return the date_time" do | |
envelope = Mail::EnvelopeFromElement.new("[email protected] Mon Aug 17 00:39:21 2009") | |
- envelope.date_time.should == ::DateTime.parse("Mon Aug 17 00:39:21 2009") | |
+ envelope.date_time.should eq ::DateTime.parse("Mon Aug 17 00:39:21 2009") | |
end | |
end | |
diff --git a/spec/mail/elements/message_ids_element_spec.rb b/spec/mail/elements/message_ids_element_spec.rb | |
index 1a0d3cd..78f3ba5 100644 | |
--- a/spec/mail/elements/message_ids_element_spec.rb | |
+++ b/spec/mail/elements/message_ids_element_spec.rb | |
@@ -25,19 +25,19 @@ describe Mail::MessageIdsElement do | |
it "should respond to message_ids" do | |
msg_id_text = '<[email protected]> <[email protected]>' | |
msg_ids = Mail::MessageIdsElement.new(msg_id_text) | |
- msg_ids.message_ids.should == ['[email protected]', '[email protected]'] | |
+ msg_ids.message_ids.should eq ['[email protected]', '[email protected]'] | |
end | |
it "should respond to message_id" do | |
msg_id_text = '<[email protected]>' | |
msg_ids = Mail::MessageIdsElement.new(msg_id_text) | |
- msg_ids.message_id.should == '[email protected]' | |
+ msg_ids.message_id.should eq '[email protected]' | |
end | |
it "should not fail to parse a message id with dots in it" do | |
text = "<[email protected]>" | |
m = Mail::MessageIdsElement.new(text) | |
- m.message_id.should == "[email protected]" | |
+ m.message_id.should eq "[email protected]" | |
end | |
end | |
diff --git a/spec/mail/elements/received_element_spec.rb b/spec/mail/elements/received_element_spec.rb | |
index 84cb7ec..6461ebd 100644 | |
--- a/spec/mail/elements/received_element_spec.rb | |
+++ b/spec/mail/elements/received_element_spec.rb | |
@@ -21,14 +21,14 @@ describe Mail::ReceivedElement do | |
received_text = 'from localhost (localhost [127.0.0.1]) by xxx.xxxxx.com (Postfix) with ESMTP id 50FD3A96F for <[email protected]>; Tue, 10 May 2005 17:26:50 +0000 (GMT)' | |
date_text = '10 May 2005 17:26:50 +0000 (GMT)' | |
rec = Mail::ReceivedElement.new(received_text) | |
- rec.date_time.should == ::DateTime.parse(date_text) | |
+ rec.date_time.should eq ::DateTime.parse(date_text) | |
end | |
it "should give back the info" do | |
received_text = 'from localhost (localhost [127.0.0.1]) by xxx.xxxxx.com (Postfix) with ESMTP id 50FD3A96F for <[email protected]>; Tue, 10 May 2005 17:26:50 +0000 (GMT)' | |
info_text = 'from localhost (localhost [127.0.0.1]) by xxx.xxxxx.com (Postfix) with ESMTP id 50FD3A96F for <[email protected]>' | |
rec = Mail::ReceivedElement.new(received_text) | |
- rec.info.should == info_text | |
+ rec.info.should eq info_text | |
end | |
end | |
diff --git a/spec/mail/encoding_spec.rb b/spec/mail/encoding_spec.rb | |
index ce0aeb6..11e8538 100644 | |
--- a/spec/mail/encoding_spec.rb | |
+++ b/spec/mail/encoding_spec.rb | |
@@ -6,7 +6,7 @@ describe "mail encoding" do | |
it "should allow you to assign a mail wide charset" do | |
mail = Mail.new | |
mail.charset = 'utf-8' | |
- mail.charset.should == 'utf-8' | |
+ mail.charset.should eq 'utf-8' | |
end | |
describe "using default encoding" do | |
@@ -15,7 +15,7 @@ describe "mail encoding" do | |
mail.charset = 'utf-8' | |
mail.subject = "This is あ string" | |
result = "Subject: =?UTF8?Q?This_is_=E3=81=82_string?=\r\n" | |
- mail[:subject].encoded.gsub("UTF-8", "UTF8").should == result | |
+ mail[:subject].encoded.gsub("UTF-8", "UTF8").should eq result | |
end | |
it "should allow you to send in unencoded strings to address fields and encode them" do | |
@@ -23,7 +23,7 @@ describe "mail encoding" do | |
mail.charset = 'utf-8' | |
mail.to = "Mikel Lindsああr <[email protected]>" | |
result = "To: Mikel =?UTF-8?B?TGluZHPjgYLjgYJy?= <[email protected]>\r\n" | |
- mail[:to].encoded.should == result | |
+ mail[:to].encoded.should eq result | |
end | |
it "should allow you to send in unencoded strings to address fields and encode them" do | |
@@ -31,7 +31,7 @@ describe "mail encoding" do | |
mail.charset = 'utf-8' | |
mail.to = "あdあ <[email protected]>" | |
result = "To: =?UTF-8?B?44GCZOOBgg==?= <[email protected]>\r\n" | |
- mail[:to].encoded.should == result | |
+ mail[:to].encoded.should eq result | |
end | |
it "should allow you to send in multiple unencoded strings to address fields and encode them" do | |
@@ -39,7 +39,7 @@ describe "mail encoding" do | |
mail.charset = 'utf-8' | |
mail.to = ["Mikel Lindsああr <[email protected]>", "あdあ <[email protected]>"] | |
result = "To: Mikel =?UTF-8?B?TGluZHPjgYLjgYJy?= <[email protected]>, \r\n\s=?UTF-8?B?44GCZOOBgg==?= <[email protected]>\r\n" | |
- mail[:to].encoded.should == result | |
+ mail[:to].encoded.should eq result | |
end | |
it "should allow you to send unquoted non us-ascii strings, with spaces in them" do | |
@@ -47,7 +47,7 @@ describe "mail encoding" do | |
mail.charset = 'utf-8' | |
mail.to = ["Foo áëô îü <[email protected]>"] | |
result = "To: Foo =?UTF-8?B?w6HDq8O0?= =?UTF-8?B?IMOuw7w=?= <[email protected]>\r\n" | |
- mail[:to].encoded.should == result | |
+ mail[:to].encoded.should eq result | |
end | |
it "should allow you to send in multiple unencoded strings to any address field" do | |
@@ -56,7 +56,7 @@ describe "mail encoding" do | |
['To', 'From', 'Cc', 'Reply-To'].each do |field| | |
mail.send("#{field.downcase.gsub("-", '_')}=", ["Mikel Lindsああr <[email protected]>", "あdあ <[email protected]>"]) | |
result = "#{field}: Mikel =?UTF-8?B?TGluZHPjgYLjgYJy?= <[email protected]>, \r\n\s=?UTF-8?B?44GCZOOBgg==?= <[email protected]>\r\n" | |
- mail[field].encoded.should == result | |
+ mail[field].encoded.should eq result | |
end | |
end | |
@@ -65,7 +65,7 @@ describe "mail encoding" do | |
mail.charset = 'utf-8' | |
mail.to = "[email protected], group: [email protected], [email protected];" | |
result = "To: [email protected], \r\n\sgroup: [email protected], \r\n\[email protected];\r\n" | |
- mail[:to].encoded.should == result | |
+ mail[:to].encoded.should eq result | |
end | |
it "should handle groups with funky characters" do | |
@@ -73,7 +73,7 @@ describe "mail encoding" do | |
mail.charset = 'utf-8' | |
mail.to = '"Mikel Lindsああr" <[email protected]>, group: "あdあ" <[email protected]>, [email protected];' | |
result = "To: =?UTF-8?B?TWlrZWwgTGluZHPjgYLjgYJy?= <[email protected]>, \r\n\sgroup: =?UTF-8?B?44GCZOOBgg==?= <[email protected]>, \r\n\[email protected];\r\n" | |
- mail[:to].encoded.should == result | |
+ mail[:to].encoded.should eq result | |
end | |
describe "quoting token safe chars" do | |
@@ -82,14 +82,14 @@ describe "mail encoding" do | |
mail = Mail.new | |
mail.charset = 'utf-8' | |
mail.to = 'Mikel Lindsaar <[email protected]>' | |
- mail[:to].encoded.should == %{To: Mikel Lindsaar <[email protected]>\r\n} | |
+ mail[:to].encoded.should eq %{To: Mikel Lindsaar <[email protected]>\r\n} | |
end | |
it "should not quote the display name if already quoted" do | |
mail = Mail.new | |
mail.charset = 'utf-8' | |
mail.to = '"Mikel Lindsaar" <[email protected]>' | |
- mail[:to].encoded.should == %{To: Mikel Lindsaar <[email protected]>\r\n} | |
+ mail[:to].encoded.should eq %{To: Mikel Lindsaar <[email protected]>\r\n} | |
end | |
end | |
@@ -100,14 +100,14 @@ describe "mail encoding" do | |
mail = Mail.new | |
mail.charset = 'utf-8' | |
mail.to = "Mikel @ me Lindsaar <[email protected]>" | |
- mail[:to].encoded.should == %{To: "Mikel @ me Lindsaar" <[email protected]>\r\n} | |
+ mail[:to].encoded.should eq %{To: "Mikel @ me Lindsaar" <[email protected]>\r\n} | |
end | |
it "should preserve quotes needed from the user and not double quote" do | |
mail = Mail.new | |
mail.charset = 'utf-8' | |
mail.to = %{"Mikel @ me Lindsaar" <[email protected]>} | |
- mail[:to].encoded.should == %{To: "Mikel @ me Lindsaar" <[email protected]>\r\n} | |
+ mail[:to].encoded.should eq %{To: "Mikel @ me Lindsaar" <[email protected]>\r\n} | |
end | |
end | |
end | |
@@ -125,7 +125,7 @@ describe "mail encoding" do | |
string.force_encoding('ISO8859-1') | |
result.force_encoding('ISO8859-1') | |
end | |
- result.should == string | |
+ result.should eq string | |
end | |
it "should allow you to send in unencoded strings to address fields and encode them" do | |
@@ -140,7 +140,7 @@ describe "mail encoding" do | |
string.force_encoding('ISO8859-1') | |
result.force_encoding('ISO8859-1') | |
end | |
- result.should == string | |
+ result.should eq string | |
end | |
it "should allow you to send in multiple unencoded strings to address fields and encode them" do | |
@@ -155,7 +155,7 @@ describe "mail encoding" do | |
string.force_encoding('ISO8859-1') | |
result.force_encoding('ISO8859-1') | |
end | |
- result.should == string | |
+ result.should eq string | |
end | |
it "should allow you to send in multiple unencoded strings to any address field" do | |
@@ -171,7 +171,7 @@ describe "mail encoding" do | |
string.force_encoding('ISO8859-1') | |
result.force_encoding('ISO8859-1') | |
end | |
- result.should == string | |
+ result.should eq string | |
end | |
end | |
end | |
@@ -183,7 +183,7 @@ describe "mail encoding" do | |
part.charset = "ISO-8859-1" | |
part.body = "blah" | |
mail.add_part(part) | |
- mail.parts[0].content_type.should == "text/html; charset=ISO-8859-1" | |
+ mail.parts[0].content_type.should eq "text/html; charset=ISO-8859-1" | |
end | |
it "should skip invalid characters" do | |
@@ -192,7 +192,7 @@ describe "mail encoding" do | |
if RUBY_VERSION > '1.9' | |
lambda { m.subject.should be_valid_encoding }.should_not raise_error | |
else | |
- m.subject.should == "Hello \226 World" | |
+ m.subject.should eq "Hello \226 World" | |
end | |
end | |
-end | |
\ No newline at end of file | |
+end | |
diff --git a/spec/mail/encodings/base64_spec.rb b/spec/mail/encodings/base64_spec.rb | |
index d74d2ae..4f33f09 100644 | |
--- a/spec/mail/encodings/base64_spec.rb | |
+++ b/spec/mail/encodings/base64_spec.rb | |
@@ -4,22 +4,22 @@ describe Mail::Encodings::Base64 do | |
it "should encode base 64 from text" do | |
result = "VGhpcyBpcyBhIHRlc3Q=\r\n" | |
- Mail::Encodings::Base64.encode('This is a test').should == result | |
+ Mail::Encodings::Base64.encode('This is a test').should eq result | |
end | |
it "should decode base 64 text" do | |
result = 'This is a test' | |
- Mail::Encodings::Base64.decode("VGhpcyBpcyBhIHRlc3Q=\n").should == result | |
+ Mail::Encodings::Base64.decode("VGhpcyBpcyBhIHRlc3Q=\n").should eq result | |
end | |
it "should encode base 64 from binary" do | |
result = "AAAAAA==\r\n" | |
- Mail::Encodings::Base64.encode("\000\000\000\000").should == result | |
+ Mail::Encodings::Base64.encode("\000\000\000\000").should eq result | |
end | |
it "should decode base 64 text" do | |
result = "\000\000\000\000" | |
- Mail::Encodings::Base64.decode("AAAAAA==\n").should == result | |
+ Mail::Encodings::Base64.decode("AAAAAA==\n").should eq result | |
end | |
end | |
diff --git a/spec/mail/encodings/quoted_printable_spec.rb b/spec/mail/encodings/quoted_printable_spec.rb | |
index 744197b..68faaec 100644 | |
--- a/spec/mail/encodings/quoted_printable_spec.rb | |
+++ b/spec/mail/encodings/quoted_printable_spec.rb | |
@@ -4,22 +4,22 @@ describe Mail::Encodings::QuotedPrintable do | |
it "should encode quoted printable from text" do | |
result = "This is a test=\r\n" | |
- Mail::Encodings::QuotedPrintable.encode('This is a test').should == result | |
+ Mail::Encodings::QuotedPrintable.encode('This is a test').should eq result | |
end | |
it "should decode quoted printable" do | |
result = "This is a test" | |
- Mail::Encodings::QuotedPrintable.decode("This is a test").should == result | |
+ Mail::Encodings::QuotedPrintable.decode("This is a test").should eq result | |
end | |
it "should encode quoted printable from binary" do | |
result = "=00=00=00=00=\r\n" | |
- Mail::Encodings::QuotedPrintable.encode("\000\000\000\000").should == result | |
+ Mail::Encodings::QuotedPrintable.encode("\000\000\000\000").should eq result | |
end | |
it "should decode quoted printable text" do | |
result = "\000\000\000\000" | |
- Mail::Encodings::QuotedPrintable.decode("=00=00=00=00").should == result | |
+ Mail::Encodings::QuotedPrintable.decode("=00=00=00=00").should eq result | |
end | |
end | |
diff --git a/spec/mail/encodings_spec.rb b/spec/mail/encodings_spec.rb | |
index 01d7766..926c48c 100644 | |
--- a/spec/mail/encodings_spec.rb | |
+++ b/spec/mail/encodings_spec.rb | |
@@ -18,15 +18,15 @@ describe Mail::Encodings do | |
end | |
it "should return the Base64 Encoding class" do | |
- Mail::Encodings.get_encoding('Base64').should == Mail::Encodings::Base64 | |
+ Mail::Encodings.get_encoding('Base64').should eq Mail::Encodings::Base64 | |
end | |
it "should return the base64 Encoding class" do | |
- Mail::Encodings.get_encoding('base64').should == Mail::Encodings::Base64 | |
+ Mail::Encodings.get_encoding('base64').should eq Mail::Encodings::Base64 | |
end | |
it "should return the base64 Encoding class" do | |
- Mail::Encodings.get_encoding(:base64).should == Mail::Encodings::Base64 | |
+ Mail::Encodings.get_encoding(:base64).should eq Mail::Encodings::Base64 | |
end | |
end | |
@@ -46,15 +46,15 @@ describe Mail::Encodings do | |
end | |
it "should return the QuotedPrintable Encoding class" do | |
- Mail::Encodings.get_encoding('quoted-printable').should == Mail::Encodings::QuotedPrintable | |
+ Mail::Encodings.get_encoding('quoted-printable').should eq Mail::Encodings::QuotedPrintable | |
end | |
it "should return the QuotedPrintable Encoding class" do | |
- Mail::Encodings.get_encoding('Quoted-Printable').should == Mail::Encodings::QuotedPrintable | |
+ Mail::Encodings.get_encoding('Quoted-Printable').should eq Mail::Encodings::QuotedPrintable | |
end | |
it "should return the QuotedPrintable Encoding class" do | |
- Mail::Encodings.get_encoding(:quoted_printable).should == Mail::Encodings::QuotedPrintable | |
+ Mail::Encodings.get_encoding(:quoted_printable).should eq Mail::Encodings::QuotedPrintable | |
end | |
end | |
@@ -80,11 +80,11 @@ describe Mail::Encodings do | |
if RUBY_VERSION >= "1.9.1" | |
string = "This is a string" | |
string = string.force_encoding('US-ASCII') | |
- Mail::Encodings.b_value_encode(string).should == "This is a string" | |
+ Mail::Encodings.b_value_encode(string).should eq "This is a string" | |
else | |
string = "This is a string" | |
encoding = 'US-ASCII' | |
- Mail::Encodings.b_value_encode(string, encoding).should == "This is a string" | |
+ Mail::Encodings.b_value_encode(string, encoding).should eq "This is a string" | |
end | |
end | |
@@ -92,11 +92,11 @@ describe Mail::Encodings do | |
if RUBY_VERSION >= "1.9.1" | |
string = "This is あ string" | |
string = string.force_encoding('UTF-8') | |
- Mail::Encodings.b_value_encode(string).should == '=?UTF-8?B?VGhpcyBpcyDjgYIgc3RyaW5n?=' | |
+ Mail::Encodings.b_value_encode(string).should eq '=?UTF-8?B?VGhpcyBpcyDjgYIgc3RyaW5n?=' | |
else | |
string = "This is あ string" | |
encoding = 'UTF-8' | |
- Mail::Encodings.b_value_encode(string, encoding).should == '=?UTF-8?B?VGhpcyBpcyDjgYIgc3RyaW5n?=' | |
+ Mail::Encodings.b_value_encode(string, encoding).should eq '=?UTF-8?B?VGhpcyBpcyDjgYIgc3RyaW5n?=' | |
end | |
end | |
@@ -116,11 +116,11 @@ describe Mail::Encodings do | |
if RUBY_VERSION >= "1.9.1" | |
string = "This is あ really long string This is あ really long string This is あ really long string This is あ really long string This is あ really long string" | |
string = string.force_encoding('UTF-8') | |
- Mail::Encodings.b_value_encode(string).should == '=?UTF-8?B?VGhpcyBpcyDjgYIgcmVhbGx5IGxvbmcgc3RyaW5nIFRoaXMgaXMg44GCIHJl?= =?UTF-8?B?YWxseSBsb25nIHN0cmluZyBUaGlzIGlzIOOBgiByZWFsbHkgbG9uZyBzdHJp?= =?UTF-8?B?bmcgVGhpcyBpcyDjgYIgcmVhbGx5IGxvbmcgc3RyaW5nIFRoaXMgaXMg44GC?= =?UTF-8?B?IHJlYWxseSBsb25nIHN0cmluZw==?=' | |
+ Mail::Encodings.b_value_encode(string).should eq '=?UTF-8?B?VGhpcyBpcyDjgYIgcmVhbGx5IGxvbmcgc3RyaW5nIFRoaXMgaXMg44GCIHJl?= =?UTF-8?B?YWxseSBsb25nIHN0cmluZyBUaGlzIGlzIOOBgiByZWFsbHkgbG9uZyBzdHJp?= =?UTF-8?B?bmcgVGhpcyBpcyDjgYIgcmVhbGx5IGxvbmcgc3RyaW5nIFRoaXMgaXMg44GC?= =?UTF-8?B?IHJlYWxseSBsb25nIHN0cmluZw==?=' | |
else | |
string = "This is あ really long string This is あ really long string This is あ really long string This is あ really long string This is あ really long string" | |
encoding = 'UTF-8' | |
- Mail::Encodings.b_value_encode(string, encoding).should == '=?UTF-8?B?VGhpcyBpcyDjgYIgcmVhbGx5IGxvbmcgc3RyaW5nIFRoaXMgaXMg44GCIHJl?= =?UTF-8?B?YWxseSBsb25nIHN0cmluZyBUaGlzIGlzIOOBgiByZWFsbHkgbG9uZyBzdHJp?= =?UTF-8?B?bmcgVGhpcyBpcyDjgYIgcmVhbGx5IGxvbmcgc3RyaW5nIFRoaXMgaXMg44GC?= =?UTF-8?B?IHJlYWxseSBsb25nIHN0cmluZw==?=' | |
+ Mail::Encodings.b_value_encode(string, encoding).should eq '=?UTF-8?B?VGhpcyBpcyDjgYIgcmVhbGx5IGxvbmcgc3RyaW5nIFRoaXMgaXMg44GCIHJl?= =?UTF-8?B?YWxseSBsb25nIHN0cmluZyBUaGlzIGlzIOOBgiByZWFsbHkgbG9uZyBzdHJp?= =?UTF-8?B?bmcgVGhpcyBpcyDjgYIgcmVhbGx5IGxvbmcgc3RyaW5nIFRoaXMgaXMg44GC?= =?UTF-8?B?IHJlYWxseSBsb25nIHN0cmluZw==?=' | |
end | |
end | |
@@ -128,16 +128,41 @@ describe Mail::Encodings do | |
string = '=?UTF-8?B?VGhpcyBpcyDjgYIgc3RyaW5n?=' | |
result = "This is あ string" | |
result.force_encoding('UTF-8') if RUBY_VERSION >= '1.9' | |
- Mail::Encodings.value_decode(string).should == result | |
+ Mail::Encodings.value_decode(string).should eq result | |
end | |
it "should decode a long encoded string" do | |
string = '=?UTF-8?B?VGhpcyBpcyDjgYIgcmVhbGx5IGxvbmcgc3RyaW5nIFRoaXMgaXMg44GCIHJl?= =?UTF-8?B?YWxseSBsb25nIHN0cmluZyBUaGlzIGlzIOOBgiByZWFsbHkgbG9uZyBzdHJp?= =?UTF-8?B?bmcgVGhpcyBpcyDjgYIgcmVhbGx5IGxvbmcgc3RyaW5nIFRoaXMgaXMg44GC?= =?UTF-8?B?IHJlYWxseSBsb25nIHN0cmluZw==?=' | |
result = "This is あ really long string This is あ really long string This is あ really long string This is あ really long string This is あ really long string" | |
result.force_encoding('UTF-8') if RUBY_VERSION >= '1.9' | |
- Mail::Encodings.value_decode(string).should == result | |
+ Mail::Encodings.value_decode(string).should eq result | |
end | |
+ it "should decode UTF-16 encoded string" do | |
+ if RUBY_VERSION >= '1.9' | |
+ string = "=?UTF-16?B?MEIwRDBGMEgwSg==?=" | |
+ result = "あいうえお" | |
+ result.force_encoding('UTF-8') | |
+ Mail::Encodings.value_decode(string).should == result | |
+ else | |
+ string = "=?UTF-16?B?MEIwRDBGMEgwSg==?=" | |
+ result = "0B0D0F0H0J" | |
+ Mail::Encodings.value_decode(string).should == result | |
+ end | |
+ end | |
+ | |
+ it "should decode UTF-32 encoded string" do | |
+ if RUBY_VERSION >= '1.9' | |
+ string = "=?UTF-32?B?AAAwQgAAMEQAADBGAAAwSAAAMEo=?=" | |
+ result = "あいうえお" | |
+ result.force_encoding('UTF-8') | |
+ Mail::Encodings.value_decode(string).should == result | |
+ else | |
+ string = "=?UTF-32?B?AAAwQgAAMEQAADBGAAAwSAAAMEo=?=" | |
+ result = "\000\0000B\000\0000D\000\0000F\000\0000H\000\0000J" | |
+ Mail::Encodings.value_decode(string).should == result | |
+ end | |
+ end | |
end | |
describe "Q encodings" do | |
@@ -161,11 +186,11 @@ describe Mail::Encodings do | |
if RUBY_VERSION >= "1.9.1" | |
string = "This is a string" | |
string = string.force_encoding('US-ASCII') | |
- Mail::Encodings.q_value_encode(string).should == "This is a string" | |
+ Mail::Encodings.q_value_encode(string).should eq "This is a string" | |
else | |
string = "This is a string" | |
encoding = 'US-ASCII' | |
- Mail::Encodings.q_value_encode(string, encoding).should == "This is a string" | |
+ Mail::Encodings.q_value_encode(string, encoding).should eq "This is a string" | |
end | |
end | |
@@ -185,11 +210,11 @@ describe Mail::Encodings do | |
if RUBY_VERSION >= "1.9.1" | |
string = "This is あ string" | |
string = string.force_encoding('UTF-8') | |
- Mail::Encodings.q_value_encode(string).should == '=?UTF-8?Q?This_is_=E3=81=82_string?=' | |
+ Mail::Encodings.q_value_encode(string).should eq '=?UTF-8?Q?This_is_=E3=81=82_string?=' | |
else | |
string = "This is あ string" | |
encoding = 'UTF-8' | |
- Mail::Encodings.q_value_encode(string, encoding).should == '=?UTF-8?Q?This_is_=E3=81=82_string?=' | |
+ Mail::Encodings.q_value_encode(string, encoding).should eq '=?UTF-8?Q?This_is_=E3=81=82_string?=' | |
end | |
end | |
@@ -197,14 +222,21 @@ describe Mail::Encodings do | |
string = '=?UTF-8?Q?This_is_=E3=81=82_string?=' | |
result = "This is あ string" | |
result.force_encoding('UTF-8') if RUBY_VERSION >= '1.9' | |
- Mail::Encodings.value_decode(string).should == result | |
+ Mail::Encodings.value_decode(string).should eq result | |
end | |
it "should detect a q encoded string and decode it" do | |
string = '=?UTF-8?Q?This_is_=E3=81=82_string?=' | |
result = "This is あ string" | |
result.force_encoding('UTF-8') if RUBY_VERSION >= '1.9' | |
- Mail::Encodings.value_decode(string).should == result | |
+ Mail::Encodings.value_decode(string).should eq result | |
+ end | |
+ | |
+ it "should decode q encoded =5F as underscore" do | |
+ string = "=?UTF-8?Q?This_=C2=AD_and=5Fthat?=" | |
+ result = "This and_that" | |
+ result.force_encoding('UTF-8') if RUBY_VERSION >= '1.9' | |
+ Mail::Encodings.value_decode(string).should eq result | |
end | |
it "should not fold a long string that has no spaces" do | |
@@ -217,8 +249,8 @@ describe Mail::Encodings do | |
end | |
mail = Mail.new | |
mail.subject = original | |
- mail[:subject].decoded.should == original | |
- mail[:subject].encoded.gsub("UTF-8", "UTF8").should == result | |
+ mail[:subject].decoded.should eq original | |
+ mail[:subject].encoded.gsub("UTF-8", "UTF8").should eq result | |
end | |
it "should round trip a complex string properly" do | |
@@ -229,14 +261,14 @@ describe Mail::Encodings do | |
result = "Subject: =?UTF8?Q?=D0=92=D0=BE=D1=81=D1=81=D1=82=D0=B0=D0=BD=D0=BE=D0=B2=D0=BB=D0=B5=D0=BD=D0=B8=D0=B5=D0=92=D0=BE=D1=81=D1=81=D1=82=D0=B0=D0=BD=D0=BE=D0=B2=D0=BB=D0=B5=D0=BD=D0=B8=D0=B5=D0=92=D0=B0=D1=88=D0=B5=D0=B3=D0=BE=D0=BF=D0=B0=D1=80=D0=BE=D0=BB=D1=8F?=\r\n\sThis is a NUT?????Z__string that== could (break) anything\r\n" | |
mail = Mail.new | |
mail.subject = original | |
- mail[:subject].decoded.should == original | |
- mail[:subject].encoded.gsub("UTF-8", "UTF8").should == result | |
+ mail[:subject].decoded.should eq original | |
+ mail[:subject].encoded.gsub("UTF-8", "UTF8").should eq result | |
mail = Mail.new(mail.encoded) | |
- mail[:subject].decoded.should == original | |
- mail[:subject].encoded.gsub("UTF-8", "UTF8").should == result | |
+ mail[:subject].decoded.should eq original | |
+ mail[:subject].encoded.gsub("UTF-8", "UTF8").should eq result | |
mail = Mail.new(mail.encoded) | |
- mail[:subject].decoded.should == original | |
- mail[:subject].encoded.gsub("UTF-8", "UTF8").should == result | |
+ mail[:subject].decoded.should eq original | |
+ mail[:subject].encoded.gsub("UTF-8", "UTF8").should eq result | |
end | |
it "should round trip another complex string (koi-8)" do | |
@@ -247,7 +279,7 @@ describe Mail::Encodings do | |
mail[:subject].charset = 'koi8-r' | |
wrapped = mail[:subject].wrapped_value | |
unwrapped = Mail::Encodings.value_decode(wrapped) | |
- unwrapped.gsub("Subject: ", "").should == original | |
+ unwrapped.gsub("Subject: ", "").should eq original | |
end | |
end | |
@@ -289,54 +321,54 @@ describe Mail::Encodings do | |
it "should leave an unencoded string alone" do | |
string = "this isn't encoded" | |
result = "this isn't encoded" | |
- Mail::Encodings.param_decode(string, 'us-ascii').should == result | |
+ Mail::Encodings.param_decode(string, 'us-ascii').should eq result | |
end | |
it "should unencode an encoded string" do | |
string = "This%20is%20even%20more%20" | |
result = "This is even more " | |
result.force_encoding('us-ascii') if RUBY_VERSION >= '1.9' | |
- Mail::Encodings.param_decode(string, 'us-ascii').should == result | |
+ Mail::Encodings.param_decode(string, 'us-ascii').should eq result | |
end | |
it "should unencoded an encoded string and return the right charset on 1.9" do | |
string = "This%20is%20even%20more%20" | |
result = "This is even more " | |
result.force_encoding('us-ascii') if RUBY_VERSION >= '1.9' | |
- Mail::Encodings.param_decode(string, 'us-ascii').should == result | |
+ Mail::Encodings.param_decode(string, 'us-ascii').should eq result | |
end | |
it "should unencode a complete string that included unencoded parts" do | |
string = "This%20is%20even%20more%20%2A%2A%2Afun%2A%2A%2A%20isn't it" | |
result = "This is even more ***fun*** isn't it" | |
result.force_encoding('iso-8859-1') if RUBY_VERSION >= '1.9' | |
- Mail::Encodings.param_decode(string, 'iso-8859-1').should == result | |
+ Mail::Encodings.param_decode(string, 'iso-8859-1').should eq result | |
end | |
it "should encode a string" do | |
string = "This is あ string" | |
if RUBY_VERSION >= '1.9' | |
- Mail::Encodings.param_encode(string).should == "utf-8'en'This%20is%20%20%E3%81%82%20string" | |
+ Mail::Encodings.param_encode(string).should eq "utf-8'en'This%20is%20%20%E3%81%82%20string" | |
else | |
- Mail::Encodings.param_encode(string).should == "utf8'en'This%20is%20%20%E3%81%82%20string" | |
+ Mail::Encodings.param_encode(string).should eq "utf8'en'This%20is%20%20%E3%81%82%20string" | |
end | |
end | |
it "should just quote US-ASCII with spaces" do | |
string = "This is even more" | |
if RUBY_VERSION >= '1.9' | |
- Mail::Encodings.param_encode(string).should == '"This is even more"' | |
+ Mail::Encodings.param_encode(string).should eq '"This is even more"' | |
else | |
- Mail::Encodings.param_encode(string).should == '"This is even more"' | |
+ Mail::Encodings.param_encode(string).should eq '"This is even more"' | |
end | |
end | |
it "should leave US-ASCII without spaces alone" do | |
string = "fun" | |
if RUBY_VERSION >= '1.9' | |
- Mail::Encodings.param_encode(string).should == 'fun' | |
+ Mail::Encodings.param_encode(string).should eq 'fun' | |
else | |
- Mail::Encodings.param_encode(string).should == 'fun' | |
+ Mail::Encodings.param_encode(string).should eq 'fun' | |
end | |
end | |
@@ -348,96 +380,122 @@ describe Mail::Encodings do | |
string = '=?UTF-8?B?VGhpcyBpcyDjgYIgc3RyaW5n?=' | |
result = "This is あ string" | |
result.force_encoding('UTF-8') if RUBY_VERSION >= '1.9' | |
- Mail::Encodings.value_decode(string).should == result | |
+ Mail::Encodings.value_decode(string).should eq result | |
end | |
it "should detect a multiple encoded Base64 string to the decoded string" do | |
string = '=?UTF-8?B?VGhpcyBpcyDjgYIgc3RyaW5n?==?UTF-8?B?VGhpcyBpcyDjgYIgc3RyaW5n?=' | |
result = "This is あ stringThis is あ string" | |
result.force_encoding('UTF-8') if RUBY_VERSION >= '1.9' | |
- Mail::Encodings.value_decode(string).should == result | |
+ Mail::Encodings.value_decode(string).should eq result | |
end | |
it "should detect a multiple encoded Base64 string with a space to the decoded string" do | |
string = '=?UTF-8?B?VGhpcyBpcyDjgYIgc3RyaW5n?= =?UTF-8?B?VGhpcyBpcyDjgYIgc3RyaW5n?=' | |
result = "This is あ stringThis is あ string" | |
result.force_encoding('UTF-8') if RUBY_VERSION >= '1.9' | |
- Mail::Encodings.value_decode(string).should == result | |
+ Mail::Encodings.value_decode(string).should eq result | |
end | |
it "should detect a multiple encoded Base64 string with a whitespace to the decoded string" do | |
string = "=?UTF-8?B?VGhpcyBpcyDjgYIgc3RyaW5n?= \r\n\s=?UTF-8?B?VGhpcyBpcyDjgYIgc3RyaW5n?=" | |
result = "This is あ stringThis is あ string" | |
result.force_encoding('UTF-8') if RUBY_VERSION >= '1.9' | |
- Mail::Encodings.value_decode(string).should == result | |
+ Mail::Encodings.value_decode(string).should eq result | |
end | |
it "should decode B and Q encodings together if needed" do | |
string = "=?UTF-8?Q?This_is_=E3=81=82_string?==?UTF-8?Q?This_is_=E3=81=82_string?= Some non encoded stuff =?UTF-8?B?VGhpcyBpcyDjgYIgc3RyaW5n?= \r\n\sMore non encoded stuff" | |
result = "This is あ stringThis is あ string Some non encoded stuff This is あ string \r\n\sMore non encoded stuff" | |
result.force_encoding('UTF-8') if RUBY_VERSION >= '1.9' | |
- Mail::Encodings.value_decode(string).should == result | |
+ Mail::Encodings.value_decode(string).should eq result | |
end | |
it "should detect a encoded and unencoded Base64 string to the decoded string" do | |
string = "Some non encoded stuff =?UTF-8?B?VGhpcyBpcyDjgYIgc3RyaW5n?= \r\n\sMore non encoded stuff" | |
result = "Some non encoded stuff This is あ string \r\n\sMore non encoded stuff" | |
result.force_encoding('UTF-8') if RUBY_VERSION >= '1.9' | |
- Mail::Encodings.value_decode(string).should == result | |
+ Mail::Encodings.value_decode(string).should eq result | |
end | |
it "should detect an encoded QP string to the decoded string" do | |
string = '=?UTF-8?Q?This_is_=E3=81=82_string?=' | |
result = "This is あ string" | |
result.force_encoding('UTF-8') if RUBY_VERSION >= '1.9' | |
- Mail::Encodings.value_decode(string).should == result | |
+ Mail::Encodings.value_decode(string).should eq result | |
+ end | |
+ | |
+ it "should decode UTF-16 encoded string" do | |
+ if RUBY_VERSION >= '1.9' | |
+ string = "=?UTF-16?Q?0B0D0F0H0J=?=" | |
+ result = "あいうえお" | |
+ result.force_encoding('UTF-8') | |
+ Mail::Encodings.value_decode(string).should == result | |
+ else | |
+ string = "=?UTF-16?Q?0B0D0F0H0J=?=" | |
+ result = "0B0D0F0H0J" | |
+ Mail::Encodings.value_decode(string).should == result | |
+ end | |
+ end | |
+ | |
+ it "should decode UTF-32 encoded string" do | |
+ if RUBY_VERSION >= '1.9' | |
+ string = "=?UTF-32?Q?=00=000B=00=000D=00=000F=00=000H=00=000J=?=" | |
+ result = "あいうえお" | |
+ result.force_encoding('UTF-8') | |
+ Mail::Encodings.value_decode(string).should == result | |
+ else | |
+ string = "=?UTF-32?Q?=00=000B=00=000D=00=000F=00=000H=00=000J=?=" | |
+ result = "\x00\x000B\x00\x000D\x00\x000F\x00\x000H\x00\x000J" | |
+ Mail::Encodings.value_decode(string).should == result | |
+ end | |
end | |
it "should detect multiple encoded QP string to the decoded string" do | |
string = '=?UTF-8?Q?This_is_=E3=81=82_string?==?UTF-8?Q?This_is_=E3=81=82_string?=' | |
result = "This is あ stringThis is あ string" | |
result.force_encoding('UTF-8') if RUBY_VERSION >= '1.9' | |
- Mail::Encodings.value_decode(string).should == result | |
+ Mail::Encodings.value_decode(string).should eq result | |
end | |
it "should detect multiple encoded QP string with a space to the decoded string" do | |
string = '=?UTF-8?Q?This_is_=E3=81=82_string?= =?UTF-8?Q?This_is_=E3=81=82_string?=' | |
result = "This is あ stringThis is あ string" | |
result.force_encoding('UTF-8') if RUBY_VERSION >= '1.9' | |
- Mail::Encodings.value_decode(string).should == result | |
+ Mail::Encodings.value_decode(string).should eq result | |
end | |
it "should detect multiple encoded QP string with a space to the decoded string" do | |
string = "=?UTF-8?Q?This_is_=E3=81=82_string?= \r\n\s=?UTF-8?Q?This_is_=E3=81=82_string?=" | |
result = "This is あ stringThis is あ string" | |
result.force_encoding('UTF-8') if RUBY_VERSION >= '1.9' | |
- Mail::Encodings.value_decode(string).should == result | |
+ Mail::Encodings.value_decode(string).should eq result | |
end | |
it "should detect a encoded and unencoded QP string to the decoded string" do | |
string = "Some non encoded stuff =?UTF-8?Q?This_is_=E3=81=82_string?= \r\n\sMore non encoded stuff" | |
result = "Some non encoded stuff This is あ string \r\n\sMore non encoded stuff" | |
result.force_encoding('UTF-8') if RUBY_VERSION >= '1.9' | |
- Mail::Encodings.value_decode(string).should == result | |
+ Mail::Encodings.value_decode(string).should eq result | |
end | |
it "should detect a plain string and return it" do | |
string = 'This is あ string' | |
result = "This is あ string" | |
result.force_encoding('UTF-8') if RUBY_VERSION >= '1.9' | |
- Mail::Encodings.value_decode(string).should == result | |
+ Mail::Encodings.value_decode(string).should eq result | |
end | |
it "should handle a very long string efficiently" do | |
string = "This is a string " * 10000 | |
- Mail::Encodings.value_decode(string).should == string | |
+ Mail::Encodings.value_decode(string).should eq string | |
end | |
it "should handle Base64 encoded ISO-2022-JP string" do | |
pending | |
string = "ISO-2022-JP =?iso-2022-jp?B?GyRCJCQkPSRLITwkXiRrJEskSyE8JDgkJyQkJFQhPBsoQg==?=" | |
result = "ISO-2022-JP いそにーまるににーじぇいぴー" | |
- Mail::Encodings.value_decode(string).should == result | |
+ Mail::Encodings.value_decode(string).should eq result | |
end | |
end | |
@@ -461,7 +519,7 @@ describe Mail::Encodings do | |
else | |
$KCODE = 'UTF-8' | |
end | |
- Mail::Encodings.decode_encode(string, :decode).should == result | |
+ Mail::Encodings.decode_encode(string, :decode).should eq result | |
end | |
it "should detect an encoded QP string and return the decoded string" do | |
@@ -472,7 +530,7 @@ describe Mail::Encodings do | |
else | |
$KCODE = 'UTF-8' | |
end | |
- Mail::Encodings.decode_encode(string, :decode).should == result | |
+ Mail::Encodings.decode_encode(string, :decode).should eq result | |
end | |
it "should detect an a string is already decoded and leave it alone" do | |
@@ -483,7 +541,7 @@ describe Mail::Encodings do | |
else | |
$KCODE = 'UTF-8' | |
end | |
- Mail::Encodings.decode_encode(string, :decode).should == result | |
+ Mail::Encodings.decode_encode(string, :decode).should eq result | |
end | |
end | |
@@ -499,7 +557,7 @@ describe Mail::Encodings do | |
result = '=?UTF8?B?VGhpcyBpcyDjgYIgc3RyaW5n?=' | |
$KCODE = 'UTF-8' | |
end | |
- Mail::Encodings.decode_encode(string, :encode).should == result | |
+ Mail::Encodings.decode_encode(string, :encode).should eq result | |
end | |
it "should leave a string that doesn't need encoding alone" do | |
@@ -510,7 +568,7 @@ describe Mail::Encodings do | |
else | |
$KCODE = 'UTF-8' | |
end | |
- Mail::Encodings.decode_encode(string, :encode).should == result | |
+ Mail::Encodings.decode_encode(string, :encode).should eq result | |
end | |
end | |
@@ -519,31 +577,31 @@ describe Mail::Encodings do | |
it "should unquote quoted printable and convert to utf-8" do | |
a ="=?ISO-8859-1?Q?[166417]_Bekr=E6ftelse_fra_Rejsefeber?=" | |
b = Mail::Encodings.unquote_and_convert_to(a, 'utf-8') | |
- b.should == "[166417] Bekr\303\246ftelse fra Rejsefeber" | |
+ b.should eq "[166417] Bekr\303\246ftelse fra Rejsefeber" | |
end | |
it "should unquote base64 and convert to utf-8" do | |
a ="=?ISO-8859-1?B?WzE2NjQxN10gQmVrcuZmdGVsc2UgZnJhIFJlanNlZmViZXI=?=" | |
b = Mail::Encodings.unquote_and_convert_to(a, 'utf-8') | |
- b.should == "[166417] Bekr\303\246ftelse fra Rejsefeber" | |
+ b.should eq "[166417] Bekr\303\246ftelse fra Rejsefeber" | |
end | |
it "should handle no charset" do | |
a ="[166417]_Bekr=E6ftelse_fra_Rejsefeber" | |
b = Mail::Encodings.unquote_and_convert_to(a, 'utf-8') | |
- b.should == "[166417]_Bekr=E6ftelse_fra_Rejsefeber" | |
+ b.should eq "[166417]_Bekr=E6ftelse_fra_Rejsefeber" | |
end | |
it "should unquote multiple lines" do | |
a ="=?utf-8?q?Re=3A_=5B12=5D_=23137=3A_Inkonsistente_verwendung_von_=22Hin?==?utf-8?b?enVmw7xnZW4i?=" | |
b = Mail::Encodings.unquote_and_convert_to(a, 'utf-8') | |
- b.should == "Re: [12] #137: Inkonsistente verwendung von \"Hinzuf\303\274gen\"" | |
+ b.should eq "Re: [12] #137: Inkonsistente verwendung von \"Hinzuf\303\274gen\"" | |
end | |
it "should unquote a string in the middle of the text" do | |
a ="Re: Photos =?ISO-8859-1?Q?Brosch=FCre_Rand?=" | |
b = Mail::Encodings.unquote_and_convert_to(a, 'utf-8') | |
- b.should == "Re: Photos Brosch\303\274re Rand" | |
+ b.should eq "Re: Photos Brosch\303\274re Rand" | |
end | |
it "should unquote and change to an ISO encoding if we really want" do | |
@@ -551,13 +609,13 @@ describe Mail::Encodings do | |
b = Mail::Encodings.unquote_and_convert_to(a, 'iso-8859-1') | |
expected = "Brosch\374re Rand" | |
expected.force_encoding('iso-8859-1').encode!('utf-8') if expected.respond_to?(:force_encoding) | |
- b.should == expected | |
+ b.should eq expected | |
end | |
it "should unquote multiple strings in the middle of the text" do | |
a = "=?Shift_JIS?Q?=93=FA=96{=8C=EA=?= <[email protected]>, =?Shift_JIS?Q?=93=FA=96{=8C=EA=?= <[email protected]>" | |
b = Mail::Encodings.unquote_and_convert_to(a, 'utf-8') | |
- b.should == "日本語 <[email protected]>, 日本語 <[email protected]>" | |
+ b.should eq "日本語 <[email protected]>, 日本語 <[email protected]>" | |
end | |
end | |
end | |
@@ -565,20 +623,20 @@ describe Mail::Encodings do | |
describe "quoted printable encoding and decoding" do | |
it "should handle underscores in the text" do | |
expected = 'something_with_underscores' | |
- encoded = [expected].pack('*M') | |
- Mail::Encodings.get_encoding(:quoted_printable).encode(expected).unpack("*M").first.should == expected | |
+ encoded = [expected].pack('M') | |
+ Mail::Encodings.get_encoding(:quoted_printable).encode(expected).unpack("M").first.should eq expected | |
end | |
it "should handle underscores in the text" do | |
expected = 'something with_underscores' | |
- encoded = [expected].pack('*M') | |
- Mail::Encodings.get_encoding(:quoted_printable).encode(expected).unpack("*M").first.should == expected | |
+ encoded = [expected].pack('M') | |
+ Mail::Encodings.get_encoding(:quoted_printable).encode(expected).unpack("M").first.should eq expected | |
end | |
it "should keep the underscores in the text" do | |
expected = 'something_with_underscores' | |
encoded = Mail::Encodings.get_encoding(:quoted_printable).encode(expected) | |
- Mail::Encodings.get_encoding(:quoted_printable).decode(encoded).should == expected | |
+ Mail::Encodings.get_encoding(:quoted_printable).decode(encoded).should eq expected | |
end | |
it "should handle a new line in the text" do | |
@@ -588,7 +646,7 @@ describe Mail::Encodings do | |
expected = "\nRe: ol\341" | |
end | |
encoded = "=?ISO-8859-1?Q?\nRe=3A_ol=E1?=" | |
- Mail::Encodings.value_decode(encoded).should == expected | |
+ Mail::Encodings.value_decode(encoded).should eq expected | |
end | |
end | |
@@ -596,88 +654,99 @@ describe Mail::Encodings do | |
describe "pre encoding non usascii text" do | |
it "should not change an ascii string" do | |
raw = '[email protected]' | |
- Mail::Encodings.encode_non_usascii(raw, 'utf-8').should == raw | |
+ Mail::Encodings.encode_non_usascii(raw, 'utf-8').should eq raw | |
end | |
it "should encode a display that contains non usascii" do | |
raw = 'Lindsああr <[email protected]>' | |
encoded = '=?UTF-8?B?TGluZHPjgYLjgYJy?= <[email protected]>' | |
- Mail::Encodings.encode_non_usascii(raw, 'utf-8').should == encoded | |
+ Mail::Encodings.encode_non_usascii(raw, 'utf-8').should eq encoded | |
end | |
it "should encode a display that contains non usascii with quotes as no quotes" do | |
raw = '"Lindsああr" <[email protected]>' | |
encoded = '=?UTF-8?B?TGluZHPjgYLjgYJy?= <[email protected]>' | |
- Mail::Encodings.encode_non_usascii(raw, 'utf-8').should == encoded | |
+ Mail::Encodings.encode_non_usascii(raw, 'utf-8').should eq encoded | |
end | |
it "should encode a display name with us-ascii and non-usascii parts" do | |
raw = 'Mikel Lindsああr <[email protected]>' | |
encoded = 'Mikel =?UTF-8?B?TGluZHPjgYLjgYJy?= <[email protected]>' | |
- Mail::Encodings.encode_non_usascii(raw, 'utf-8').should == encoded | |
+ Mail::Encodings.encode_non_usascii(raw, 'utf-8').should eq encoded | |
end | |
it "should encode a display name with us-ascii and non-usascii parts ignoring quotes" do | |
raw = '"Mikel Lindsああr" <[email protected]>' | |
encoded = '=?UTF-8?B?TWlrZWwgTGluZHPjgYLjgYJy?= <[email protected]>' | |
- Mail::Encodings.encode_non_usascii(raw, 'utf-8').should == encoded | |
+ Mail::Encodings.encode_non_usascii(raw, 'utf-8').should eq encoded | |
+ end | |
+ | |
+ it "should encode a quoted display name with us-ascii and non-usascii that ends with a non-usascii part" do | |
+ raw = '"Marc André" <[email protected]>' | |
+ encoded = '=?UTF-8?B?TWFyYyBBbmRyw6k=?= <[email protected]>' | |
+ Mail::Encodings.encode_non_usascii(raw, 'utf-8').should eq encoded | |
end | |
it "should encode multiple addresses correctly" do | |
raw = '"Mikel Lindsああr" <[email protected]>, "あdあ" <[email protected]>' | |
encoded = '=?UTF-8?B?TWlrZWwgTGluZHPjgYLjgYJy?= <[email protected]>, =?UTF-8?B?44GCZOOBgg==?= <[email protected]>' | |
- Mail::Encodings.encode_non_usascii(raw, 'utf-8').should == encoded | |
+ Mail::Encodings.encode_non_usascii(raw, 'utf-8').should eq encoded | |
end | |
it "should encode multiple unquoted addresses correctly" do | |
raw = 'Mikel Lindsああr <[email protected]>, あdあ <[email protected]>' | |
encoded = 'Mikel =?UTF-8?B?TGluZHPjgYLjgYJy?= <[email protected]>, =?UTF-8?B?44GCZOOBgg==?= <[email protected]>' | |
- Mail::Encodings.encode_non_usascii(raw, 'utf-8').should == encoded | |
+ Mail::Encodings.encode_non_usascii(raw, 'utf-8').should eq encoded | |
end | |
it "should encode multiple un bracketed addresses and groups correctly" do | |
raw = '"Mikel Lindsああr" [email protected], group: "あdあ" [email protected], [email protected];' | |
encoded = '=?UTF-8?B?TWlrZWwgTGluZHPjgYLjgYJy?= [email protected], group: =?UTF-8?B?44GCZOOBgg==?= [email protected], [email protected];' | |
- Mail::Encodings.encode_non_usascii(raw, 'utf-8').should == encoded | |
+ Mail::Encodings.encode_non_usascii(raw, 'utf-8').should eq encoded | |
+ end | |
+ | |
+ it "should correctly match and encode non-usascii letters at the end of a quoted string" do | |
+ raw = '"Felix Baarß" <[email protected]>' | |
+ encoded = '=?UTF-8?B?RmVsaXggQmFhcsOf?= <[email protected]>' | |
+ Mail::Encodings.encode_non_usascii(raw, 'utf-8').should eq encoded | |
end | |
- | |
end | |
describe "address encoding" do | |
it "should not do anything to a plain address" do | |
raw = '[email protected]' | |
encoded = '[email protected]' | |
- Mail::Encodings.address_encode(raw, 'utf-8').should == encoded | |
+ Mail::Encodings.address_encode(raw, 'utf-8').should eq encoded | |
end | |
it "should encode an address correctly" do | |
raw = '"Mikel Lindsああr" <[email protected]>' | |
encoded = '=?UTF-8?B?TWlrZWwgTGluZHPjgYLjgYJy?= <[email protected]>' | |
- Mail::Encodings.address_encode(raw, 'utf-8').should == encoded | |
+ Mail::Encodings.address_encode(raw, 'utf-8').should eq encoded | |
end | |
it "should encode multiple addresses correctly" do | |
raw = ['"Mikel Lindsああr" <[email protected]>', '"あdあ" <[email protected]>'] | |
encoded = '=?UTF-8?B?TWlrZWwgTGluZHPjgYLjgYJy?= <[email protected]>, =?UTF-8?B?44GCZOOBgg==?= <[email protected]>' | |
- Mail::Encodings.address_encode(raw, 'utf-8').should == encoded | |
+ Mail::Encodings.address_encode(raw, 'utf-8').should eq encoded | |
end | |
it "should handle a single ascii address correctly from a string" do | |
raw = ['"Mikel Lindsaar" <[email protected]>'] | |
encoded = '"Mikel Lindsaar" <[email protected]>' | |
- Mail::Encodings.address_encode(raw, 'utf-8').should == encoded | |
+ Mail::Encodings.address_encode(raw, 'utf-8').should eq encoded | |
end | |
it "should handle multiple ascii addresses correctly from a string" do | |
raw = 'Mikel Lindsaar <[email protected]>, Ada <[email protected]>' | |
encoded = 'Mikel Lindsaar <[email protected]>, Ada <[email protected]>' | |
- Mail::Encodings.address_encode(raw, 'utf-8').should == encoded | |
+ Mail::Encodings.address_encode(raw, 'utf-8').should eq encoded | |
end | |
it "should handle ascii addresses correctly as an array" do | |
raw = ['Mikel Lindsaar <[email protected]>', 'Ada <[email protected]>'] | |
encoded = 'Mikel Lindsaar <[email protected]>, Ada <[email protected]>' | |
- Mail::Encodings.address_encode(raw, 'utf-8').should == encoded | |
+ Mail::Encodings.address_encode(raw, 'utf-8').should eq encoded | |
end | |
end | |
diff --git a/spec/mail/example_emails_spec.rb b/spec/mail/example_emails_spec.rb | |
index e395138..04efce2 100644 | |
--- a/spec/mail/example_emails_spec.rb | |
+++ b/spec/mail/example_emails_spec.rb | |
@@ -11,11 +11,11 @@ describe "Test emails" do | |
# message identifier, and a textual message in the body. | |
it "should handle the basic test email" do | |
mail = Mail.read(fixture('emails', 'rfc2822', 'example01.eml')) | |
- mail.from.should == ["[email protected]"] | |
- mail.to.should == ['[email protected]'] | |
- mail.message_id.should == '[email protected]' | |
- mail.date.should == ::DateTime.parse('21 Nov 1997 09:55:06 -0600') | |
- mail.subject.should == 'Saying Hello' | |
+ mail.from.should eq ["[email protected]"] | |
+ mail.to.should eq ['[email protected]'] | |
+ mail.message_id.should eq '[email protected]' | |
+ mail.date.should eq ::DateTime.parse('21 Nov 1997 09:55:06 -0600') | |
+ mail.subject.should eq 'Saying Hello' | |
end | |
# From RFC 2822: | |
@@ -24,12 +24,12 @@ describe "Test emails" do | |
# sender field would be used: | |
it "should handle the sender test email" do | |
mail = Mail.read(fixture('emails', 'rfc2822', 'example02.eml')) | |
- mail.from.should == ['[email protected]'] | |
- mail.sender.should == '[email protected]' | |
- mail.to.should == ['[email protected]'] | |
- mail.message_id.should == '[email protected]' | |
- mail.date.should == ::DateTime.parse('21 Nov 1997 09:55:06 -0600') | |
- mail.subject.should == 'Saying Hello' | |
+ mail.from.should eq ['[email protected]'] | |
+ mail.sender.should eq '[email protected]' | |
+ mail.to.should eq ['[email protected]'] | |
+ mail.message_id.should eq '[email protected]' | |
+ mail.date.should eq ::DateTime.parse('21 Nov 1997 09:55:06 -0600') | |
+ mail.subject.should eq 'Saying Hello' | |
end | |
# From RFC 2822: | |
@@ -49,11 +49,11 @@ describe "Test emails" do | |
# "Giant; \"Big\" Box" <[email protected]> | |
it "should handle multiple recipients test email" do | |
mail = Mail.read(fixture('emails', 'rfc2822', 'example03.eml')) | |
- mail.from.should == ['[email protected]'] | |
- mail.to.should == ['[email protected]', '[email protected]', '[email protected]'] | |
- mail.cc.should == ['[email protected]', "[email protected]"] | |
- mail.message_id.should == '[email protected]' | |
- mail.date.should == ::DateTime.parse('1 Jul 2003 10:52:37 +0200') | |
+ mail.from.should eq ['[email protected]'] | |
+ mail.to.should eq ['[email protected]', '[email protected]', '[email protected]'] | |
+ mail.cc.should eq ['[email protected]', "[email protected]"] | |
+ mail.message_id.should eq '[email protected]' | |
+ mail.date.should eq ::DateTime.parse('1 Jul 2003 10:52:37 +0200') | |
end | |
# From RFC 2822: | |
@@ -63,11 +63,11 @@ describe "Test emails" do | |
# group recipient named Undisclosed recipients. | |
it "should handle group address email test" do | |
mail = Mail.read(fixture('emails', 'rfc2822', 'example04.eml')) | |
- mail.from.should == ['[email protected]'] | |
- mail.to.should == ['[email protected]', '[email protected]', '[email protected]'] | |
- mail[:cc].group_names.should == ['Undisclosed recipients'] | |
- mail.message_id.should == '[email protected]' | |
- mail.date.should == ::DateTime.parse('Thu, 13 Feb 1969 23:32:54 -0330') | |
+ mail.from.should eq ['[email protected]'] | |
+ mail.to.should eq ['[email protected]', '[email protected]', '[email protected]'] | |
+ mail[:cc].group_names.should eq ['Undisclosed recipients'] | |
+ mail.message_id.should eq '[email protected]' | |
+ mail.date.should eq ::DateTime.parse('Thu, 13 Feb 1969 23:32:54 -0330') | |
end | |
@@ -82,11 +82,11 @@ describe "Test emails" do | |
# fields in each message. | |
it "should handle reply messages" do | |
mail = Mail.read(fixture('emails', 'rfc2822', 'example05.eml')) | |
- mail.from.should == ["[email protected]"] | |
- mail.to.should == ['[email protected]'] | |
- mail.subject.should == 'Saying Hello' | |
- mail.message_id.should == '[email protected]' | |
- mail.date.should == ::DateTime.parse('Fri, 21 Nov 1997 09:55:06 -0600') | |
+ mail.from.should eq ["[email protected]"] | |
+ mail.to.should eq ['[email protected]'] | |
+ mail.subject.should eq 'Saying Hello' | |
+ mail.message_id.should eq '[email protected]' | |
+ mail.date.should eq ::DateTime.parse('Fri, 21 Nov 1997 09:55:06 -0600') | |
end | |
# From RFC 2822: | |
@@ -97,27 +97,27 @@ describe "Test emails" do | |
# "Reply-To:" field instead of the address in the "From:" field. | |
it "should handle reply message 2" do | |
mail = Mail.read(fixture('emails', 'rfc2822', 'example06.eml')) | |
- mail.from.should == ['[email protected]'] | |
- mail.to.should == ['[email protected]'] | |
- mail.reply_to.should == ['[email protected]'] | |
- mail.subject.should == 'Re: Saying Hello' | |
- mail.message_id.should == '[email protected]' | |
- mail[:in_reply_to].message_ids.should == ['[email protected]'] | |
- mail[:references].message_ids.should == ['[email protected]'] | |
- mail.date.should == ::DateTime.parse('Fri, 21 Nov 1997 10:01:10 -0600') | |
+ mail.from.should eq ['[email protected]'] | |
+ mail.to.should eq ['[email protected]'] | |
+ mail.reply_to.should eq ['[email protected]'] | |
+ mail.subject.should eq 'Re: Saying Hello' | |
+ mail.message_id.should eq '[email protected]' | |
+ mail[:in_reply_to].message_ids.should eq ['[email protected]'] | |
+ mail[:references].message_ids.should eq ['[email protected]'] | |
+ mail.date.should eq ::DateTime.parse('Fri, 21 Nov 1997 10:01:10 -0600') | |
end | |
# From RFC 2822: | |
# Final reply message | |
it "should handle the final reply message" do | |
mail = Mail.read(fixture('emails', 'rfc2822', 'example07.eml')) | |
- mail.to.should == ['[email protected]'] | |
- mail.from.should == ['[email protected]'] | |
- mail.subject.should == 'Re: Saying Hello' | |
- mail.date.should == ::DateTime.parse('Fri, 21 Nov 1997 11:00:00 -0600') | |
- mail.message_id.should == '[email protected]' | |
- mail.in_reply_to.should == '[email protected]' | |
- mail[:references].message_ids.should == ['[email protected]', '[email protected]'] | |
+ mail.to.should eq ['[email protected]'] | |
+ mail.from.should eq ['[email protected]'] | |
+ mail.subject.should eq 'Re: Saying Hello' | |
+ mail.date.should eq ::DateTime.parse('Fri, 21 Nov 1997 11:00:00 -0600') | |
+ mail.message_id.should eq '[email protected]' | |
+ mail.in_reply_to.should eq '[email protected]' | |
+ mail[:references].message_ids.should eq ['[email protected]', '[email protected]'] | |
end | |
# From RFC2822 | |
@@ -135,15 +135,15 @@ describe "Test emails" do | |
# and send that. | |
it "should handle the rfc resent example email" do | |
mail = Mail.read(fixture('emails', 'rfc2822', 'example08.eml')) | |
- mail.resent_from.should == ['[email protected]'] | |
- mail.resent_to.should == ['[email protected]'] | |
- mail.resent_date.should == ::DateTime.parse('Mon, 24 Nov 1997 14:22:01 -0800') | |
- mail.resent_message_id.should == '[email protected]' | |
- mail.from.should == ['[email protected]'] | |
- mail.to.should == ['[email protected]'] | |
- mail.subject.should == 'Saying Hello' | |
- mail.date.should == ::DateTime.parse('Fri, 21 Nov 1997 09:55:06 -0600') | |
- mail.message_id.should == '[email protected]' | |
+ mail.resent_from.should eq ['[email protected]'] | |
+ mail.resent_to.should eq ['[email protected]'] | |
+ mail.resent_date.should eq ::DateTime.parse('Mon, 24 Nov 1997 14:22:01 -0800') | |
+ mail.resent_message_id.should eq '[email protected]' | |
+ mail.from.should eq ['[email protected]'] | |
+ mail.to.should eq ['[email protected]'] | |
+ mail.subject.should eq 'Saying Hello' | |
+ mail.date.should eq ::DateTime.parse('Fri, 21 Nov 1997 09:55:06 -0600') | |
+ mail.message_id.should eq '[email protected]' | |
end | |
# A.4. Messages with trace fields | |
@@ -154,15 +154,15 @@ describe "Test emails" do | |
# can be long. | |
it "should handle the RFC trace example email" do | |
mail = Mail.read(fixture('emails', 'rfc2822', 'example09.eml')) | |
- mail.received[0].info.should == 'from x.y.test by example.net via TCP with ESMTP id ABC12345 for <[email protected]>' | |
- mail.received[0].date_time.should == ::DateTime.parse('21 Nov 1997 10:05:43 -0600') | |
- mail.received[1].info.should == 'from machine.example by x.y.test' | |
- mail.received[1].date_time.should == ::DateTime.parse('21 Nov 1997 10:01:22 -0600') | |
- mail.from.should == ['[email protected]'] | |
- mail.to.should == ['[email protected]'] | |
- mail.subject.should == 'Saying Hello' | |
- mail.date.should == ::DateTime.parse('Fri, 21 Nov 1997 09:55:06 -0600') | |
- mail.message_id.should == '[email protected]' | |
+ mail.received[0].info.should eq 'from x.y.test by example.net via TCP with ESMTP id ABC12345 for <[email protected]>' | |
+ mail.received[0].date_time.should eq ::DateTime.parse('21 Nov 1997 10:05:43 -0600') | |
+ mail.received[1].info.should eq 'from machine.example by x.y.test' | |
+ mail.received[1].date_time.should eq ::DateTime.parse('21 Nov 1997 10:01:22 -0600') | |
+ mail.from.should eq ['[email protected]'] | |
+ mail.to.should eq ['[email protected]'] | |
+ mail.subject.should eq 'Saying Hello' | |
+ mail.date.should eq ::DateTime.parse('Fri, 21 Nov 1997 09:55:06 -0600') | |
+ mail.message_id.should eq '[email protected]' | |
end | |
# A.5. White space, comments, and other oddities | |
@@ -186,11 +186,11 @@ describe "Test emails" do | |
it "should handle the rfc whitespace test email" do | |
mail = Mail.read(fixture('emails', 'rfc2822', 'example10.eml')) | |
- mail.from.should == ["pete(his account)@silly.test"] | |
- mail.to.should == ["c@(Chris's host.)public.example", "[email protected]", "[email protected]"] | |
- mail[:cc].group_names.should == ['(Empty list)(start)Undisclosed recipients '] | |
- mail.date.should == ::DateTime.parse('Thu, 13 Feb 1969 23:32 -0330') | |
- mail.message_id.should == '[email protected]' | |
+ mail.from.should eq ["pete(his account)@silly.test"] | |
+ mail.to.should eq ["c@(Chris's host.)public.example", "[email protected]", "[email protected]"] | |
+ mail[:cc].group_names.should eq ['(Empty list)(start)Undisclosed recipients '] | |
+ mail.date.should eq ::DateTime.parse('Thu, 13 Feb 1969 23:32 -0330') | |
+ mail.message_id.should eq '[email protected]' | |
end | |
# A.6. Obsoleted forms | |
@@ -205,11 +205,11 @@ describe "Test emails" do | |
it "should handle the rfc obsolete addressing" do | |
pending | |
mail = Mail.read(fixture('emails', 'rfc2822', 'example11.eml')) | |
- mail[:from].addresses.should == ['[email protected]'] | |
- mail.from.should == '"Joe Q. Public" <[email protected]>' | |
- mail.to.should == ["@machine.tld:[email protected]", '[email protected]'] | |
- mail.date.should == ::DateTime.parse('Tue, 1 Jul 2003 10:52:37 +0200') | |
- mail.message_id.should == '[email protected]' | |
+ mail[:from].addresses.should eq ['[email protected]'] | |
+ mail.from.should eq '"Joe Q. Public" <[email protected]>' | |
+ mail.to.should eq ["@machine.tld:[email protected]", '[email protected]'] | |
+ mail.date.should eq ::DateTime.parse('Tue, 1 Jul 2003 10:52:37 +0200') | |
+ mail.message_id.should eq '[email protected]' | |
end | |
# A.6.2. Obsolete dates | |
@@ -221,10 +221,10 @@ describe "Test emails" do | |
it "should handle the rfc obsolete dates" do | |
pending | |
mail = Mail.read(fixture('emails', 'rfc2822', 'example12.eml')) | |
- mail.from.should == '[email protected]' | |
- mail.to.should == '[email protected]' | |
- mail.date.should == ::DateTime.parse('21 Nov 97 09:55:06 GMT') | |
- mail.message_id.should == '[email protected]' | |
+ mail.from.should eq '[email protected]' | |
+ mail.to.should eq '[email protected]' | |
+ mail.date.should eq ::DateTime.parse('21 Nov 97 09:55:06 GMT') | |
+ mail.message_id.should eq '[email protected]' | |
end | |
# A.6.3. Obsolete white space and comments | |
@@ -242,10 +242,10 @@ describe "Test emails" do | |
it "should handle the rfc obsolete whitespace email" do | |
pending | |
mail = Mail.read(fixture('emails', 'rfc2822', 'example13.eml')) | |
- mail.from.should == 'John Doe <jdoe@machine(comment).example>' | |
- mail.to.should == 'Mary Smith <[email protected]>' | |
- mail.date.should == ::DateTime.parse('Fri, 21 Nov 1997 09:55:06 -0600') | |
- mail.message_id.should == '1234@local(blah).machine.example' | |
+ mail.from.should eq 'John Doe <jdoe@machine(comment).example>' | |
+ mail.to.should eq 'Mary Smith <[email protected]>' | |
+ mail.date.should eq ::DateTime.parse('Fri, 21 Nov 1997 09:55:06 -0600') | |
+ mail.message_id.should eq '1234@local(blah).machine.example' | |
doing { Mail::Message.new(email) }.should_not raise_error | |
end | |
@@ -263,7 +263,7 @@ describe "Test emails" do | |
end | |
it "should have two parts" do | |
- @message.parts.length.should == 2 | |
+ @message.parts.length.should eq 2 | |
end | |
end | |
@@ -278,8 +278,8 @@ describe "Test emails" do | |
end | |
it "should have one attachment called signature.asc" do | |
- @message.attachments.length.should == 1 | |
- @message.attachments.first.filename.should == 'signature.asc' | |
+ @message.attachments.length.should eq 1 | |
+ @message.attachments.first.filename.should eq 'signature.asc' | |
end | |
end | |
@@ -294,7 +294,7 @@ describe "Test emails" do | |
end | |
it "should return an empty groups list" do | |
- @message[:to].group_addresses.should == [] | |
+ @message[:to].group_addresses.should eq [] | |
end | |
end | |
@@ -311,9 +311,9 @@ describe "Test emails" do | |
end | |
it "should return an empty groups list" do | |
- @message.to.should == ['[email protected]', '[email protected]'] | |
+ @message.to.should eq ['[email protected]', '[email protected]'] | |
end | |
end | |
-end | |
\ No newline at end of file | |
+end | |
diff --git a/spec/mail/field_list_spec.rb b/spec/mail/field_list_spec.rb | |
index ad725ed..db2ad43 100644 | |
--- a/spec/mail/field_list_spec.rb | |
+++ b/spec/mail/field_list_spec.rb | |
@@ -5,7 +5,7 @@ describe Mail::FieldList do | |
fl = Mail::FieldList.new | |
fl << Mail::Field.new("To: [email protected]") | |
fl << Mail::Field.new("From: [email protected]") | |
- fl.length.should == 2 | |
+ fl.length.should eq 2 | |
end | |
it "should be able to add new fields in the right order" do | |
@@ -14,10 +14,10 @@ describe Mail::FieldList do | |
fl << Mail::Field.new("From: [email protected]") | |
fl << Mail::Field.new("Received: from xxx.xxxx.xxx by xxx.xxxx.xxx with ESMTP id 6AAEE3B4D23 for <[email protected]>; Sun, 8 May 2005 12:30:23 -0500") | |
fl << Mail::Field.new("Return-Path: [email protected]") | |
- fl[0].field.class.should == Mail::ReturnPathField | |
- fl[1].field.class.should == Mail::ReceivedField | |
- fl[2].field.class.should == Mail::FromField | |
- fl[3].field.class.should == Mail::ToField | |
+ fl[0].field.class.should eq Mail::ReturnPathField | |
+ fl[1].field.class.should eq Mail::ReceivedField | |
+ fl[2].field.class.should eq Mail::FromField | |
+ fl[3].field.class.should eq Mail::ToField | |
end | |
it "should add new Received items after the existing ones" do | |
@@ -27,7 +27,7 @@ describe Mail::FieldList do | |
fl << Mail::Field.new("Received: from xxx.xxxx.xxx by xxx.xxxx.xxx with ESMTP id 6AAEE3B4D23 for <[email protected]>; Sun, 8 May 2005 12:30:23 -0500") | |
fl << Mail::Field.new("Return-Path: [email protected]") | |
fl << Mail::Field.new("Received: from 123.xxxx.xxx by xxx.xxxx.xxx with ESMTP id 6AAEE3B4D23 for <[email protected]>; Sun, 8 May 2005 12:30:23 -0500") | |
- fl[2].field.value.should == 'from 123.xxxx.xxx by xxx.xxxx.xxx with ESMTP id 6AAEE3B4D23 for <[email protected]>; Sun, 8 May 2005 12:30:23 -0500' | |
+ fl[2].field.value.should eq 'from 123.xxxx.xxx by xxx.xxxx.xxx with ESMTP id 6AAEE3B4D23 for <[email protected]>; Sun, 8 May 2005 12:30:23 -0500' | |
end | |
end | |
diff --git a/spec/mail/field_spec.rb b/spec/mail/field_spec.rb | |
index 25107c8..5c4206c 100644 | |
--- a/spec/mail/field_spec.rb | |
+++ b/spec/mail/field_spec.rb | |
@@ -7,22 +7,22 @@ describe Mail::Field do | |
it "should be instantiated" do | |
doing {Mail::Field.new('To: Mikel')}.should_not raise_error | |
- Mail::Field.new('To: Mikel').field.class.should == Mail::ToField | |
+ Mail::Field.new('To: Mikel').field.class.should eq Mail::ToField | |
end | |
it "should allow you to init on an array" do | |
field = Mail::Field.new("To", ['[email protected]', 'Mikel <[email protected]>']) | |
- field.addresses.should == ["[email protected]", "[email protected]"] | |
+ field.addresses.should eq ["[email protected]", "[email protected]"] | |
end | |
it "should allow us to pass an empty value" do | |
doing {Mail::Field.new('To')}.should_not raise_error | |
- Mail::Field.new('To').field.class.should == Mail::ToField | |
+ Mail::Field.new('To').field.class.should eq Mail::ToField | |
end | |
it "should allow us to pass a value" do | |
doing {Mail::Field.new('To', 'Mikel')}.should_not raise_error | |
- Mail::Field.new('To', 'Mikel').field.class.should == Mail::ToField | |
+ Mail::Field.new('To', 'Mikel').field.class.should eq Mail::ToField | |
end | |
it "should match up fields to class names" do | |
@@ -35,7 +35,7 @@ describe Mail::Field do | |
structured_fields.each do |sf| | |
words = sf.split("-").map { |a| a.capitalize } | |
klass = "#{words.join}Field" | |
- Mail::Field.new("#{sf}: ").field.class.should == Mail.const_get(klass) | |
+ Mail::Field.new("#{sf}: ").field.class.should eq Mail.const_get(klass) | |
end | |
end | |
@@ -49,41 +49,41 @@ describe Mail::Field do | |
structured_fields.each do |sf| | |
words = sf.split("-").map { |a| a.capitalize } | |
klass = "#{words.join}Field" | |
- Mail::Field.new("#{sf}: ").field.class.should == Mail.const_get(klass) | |
+ Mail::Field.new("#{sf}: ").field.class.should eq Mail.const_get(klass) | |
end | |
end | |
it "should say anything that is not a known field is an optional field" do | |
unstructured_fields = %w[ Too Becc bccc Random X-Mail MySpecialField ] | |
unstructured_fields.each do |sf| | |
- Mail::Field.new("#{sf}: Value").field.class.should == Mail::OptionalField | |
+ Mail::Field.new("#{sf}: Value").field.class.should eq Mail::OptionalField | |
end | |
end | |
it "should split the name and values out of the raw field passed in" do | |
field = Mail::Field.new('To: Bob') | |
- field.name.should == 'To' | |
- field.value.should == 'Bob' | |
+ field.name.should eq 'To' | |
+ field.value.should eq 'Bob' | |
end | |
it "should split the name and values out of the raw field passed in if missing whitespace" do | |
field = Mail::Field.new('To:Bob') | |
- field.name.should == 'To' | |
- field.value.should == 'Bob' | |
+ field.name.should eq 'To' | |
+ field.value.should eq 'Bob' | |
end | |
it "should split the name and values out of the raw field passed in if having added inapplicable whitespace" do | |
field = Mail::Field.new('To : Bob ') | |
- field.name.should == 'To' | |
- field.value.should == 'Bob' | |
+ field.name.should eq 'To' | |
+ field.value.should eq 'Bob' | |
end | |
it "should return an unstuctured field if the structured field parsing raises an error" do | |
Mail::ToField.should_receive(:new).and_raise(Mail::Field::ParseError) | |
field = Mail::Field.new('To: Bob, ,,, Frank, Smith') | |
- field.field.class.should == Mail::UnstructuredField | |
- field.name.should == 'To' | |
- field.value.should == 'Bob, ,,, Frank, Smith' | |
+ field.field.class.should eq Mail::UnstructuredField | |
+ field.name.should eq 'To' | |
+ field.value.should eq 'Bob, ,,, Frank, Smith' | |
end | |
it "should call to_s on it's field when sent to_s" do | |
@@ -101,28 +101,28 @@ describe Mail::Field do | |
it "should change it's type if you change the name" do | |
field = Mail::Field.new("To: [email protected]") | |
- field.field.class.should == Mail::ToField | |
+ field.field.class.should eq Mail::ToField | |
field.value = "[email protected]" | |
- field.field.class.should == Mail::ToField | |
+ field.field.class.should eq Mail::ToField | |
end | |
it "should create a field without trying to parse if given a symbol" do | |
field = Mail::Field.new('Message-ID') | |
- field.field.class.should == Mail::MessageIdField | |
+ field.field.class.should eq Mail::MessageIdField | |
end | |
it "should inherit charset" do | |
charset = 'iso-2022-jp' | |
field = Mail::Field.new('Subject: こんにちは', charset) | |
- field.charset.should == charset | |
+ field.charset.should eq charset | |
end | |
end | |
describe "error handling" do | |
it "should populate the errors array if it finds a field it can't deal with" do | |
field = Mail::Field.new('Content-Transfer-Encoding: bit') | |
- field.field.errors[0][0].should == 'Content-Transfer-Encoding' | |
- field.field.errors[0][1].should == 'bit' | |
+ field.field.errors[0][0].should eq 'Content-Transfer-Encoding' | |
+ field.field.errors[0][1].should eq 'bit' | |
field.field.errors[0][2].to_s.should =~ /ContentTransferEncodingElement can not parse |17-bit|/ | |
end | |
end | |
@@ -153,36 +153,45 @@ describe Mail::Field do | |
it "should sort according to the field order" do | |
list = [Mail::Field.new("To: mikel"), Mail::Field.new("Return-Path: bob")] | |
- list.sort[0].name.should == "Return-Path" | |
+ list.sort[0].name.should eq "Return-Path" | |
+ end | |
+ end | |
+ | |
+ describe 'user defined fields' do | |
+ it "should say it is == to another if their field names match" do | |
+ Mail::Field.new("X-Foo: mikel").same(Mail::Field.new("X-Foo: bob")).should be_true | |
end | |
+ it "should say it is not == to another if their field names do not match" do | |
+ Mail::Field.new("X-Foo: mikel").should_not == Mail::Field.new("X-Bar: bob") | |
+ end | |
end | |
describe "passing an encoding" do | |
it "should allow you to send in unencoded strings to fields and encode them" do | |
subject = Mail::SubjectField.new("This is あ string", 'utf-8') | |
- subject.encoded.should == "Subject: =?UTF-8?Q?This_is_=E3=81=82_string?=\r\n" | |
- subject.decoded.should == "This is あ string" | |
+ subject.encoded.should eq "Subject: =?UTF-8?Q?This_is_=E3=81=82_string?=\r\n" | |
+ subject.decoded.should eq "This is あ string" | |
end | |
it "should allow you to send in unencoded strings to address fields and encode them" do | |
to = Mail::ToField.new('"Mikel Lindsああr" <[email protected]>', 'utf-8') | |
- to.encoded.should == "To: =?UTF-8?B?TWlrZWwgTGluZHPjgYLjgYJy?= <[email protected]>\r\n" | |
+ to.encoded.should eq "To: =?UTF-8?B?TWlrZWwgTGluZHPjgYLjgYJy?= <[email protected]>\r\n" | |
end | |
it "should allow you to send in unencoded strings without quotes to address fields and encode them" do | |
to = Mail::ToField.new('Mikel Lindsああr <[email protected]>', 'utf-8') | |
- to.encoded.should == "To: Mikel =?UTF-8?B?TGluZHPjgYLjgYJy?= <[email protected]>\r\n" | |
+ to.encoded.should eq "To: Mikel =?UTF-8?B?TGluZHPjgYLjgYJy?= <[email protected]>\r\n" | |
end | |
it "should allow you to send in unencoded strings to address fields and encode them" do | |
to = Mail::ToField.new("あdあ <[email protected]>", 'utf-8') | |
- to.encoded.should == "To: =?UTF-8?B?44GCZOOBgg==?= <[email protected]>\r\n" | |
+ to.encoded.should eq "To: =?UTF-8?B?44GCZOOBgg==?= <[email protected]>\r\n" | |
end | |
it "should allow you to send in multiple unencoded strings to address fields and encode them" do | |
to = Mail::ToField.new(["Mikel Lindsああr <[email protected]>", "あdあ <[email protected]>"], 'utf-8') | |
- to.encoded.should == "To: Mikel =?UTF-8?B?TGluZHPjgYLjgYJy?= <[email protected]>, \r\n\s=?UTF-8?B?44GCZOOBgg==?= <[email protected]>\r\n" | |
+ to.encoded.should eq "To: Mikel =?UTF-8?B?TGluZHPjgYLjgYJy?= <[email protected]>, \r\n\s=?UTF-8?B?44GCZOOBgg==?= <[email protected]>\r\n" | |
end | |
it "should allow you to send in multiple unencoded strings to any address field" do | |
@@ -190,56 +199,56 @@ describe Mail::Field do | |
mail.charset = 'utf-8' | |
array = ["Mikel Lindsああr <[email protected]>", "あdあ <[email protected]>"] | |
field = Mail::ToField.new(array, 'utf-8') | |
- field.encoded.should == "#{Mail::ToField::CAPITALIZED_FIELD}: Mikel =?UTF-8?B?TGluZHPjgYLjgYJy?= <[email protected]>, \r\n\s=?UTF-8?B?44GCZOOBgg==?= <[email protected]>\r\n" | |
+ field.encoded.should eq "#{Mail::ToField::CAPITALIZED_FIELD}: Mikel =?UTF-8?B?TGluZHPjgYLjgYJy?= <[email protected]>, \r\n\s=?UTF-8?B?44GCZOOBgg==?= <[email protected]>\r\n" | |
field = Mail::FromField.new(array, 'utf-8') | |
- field.encoded.should == "#{Mail::FromField::CAPITALIZED_FIELD}: Mikel =?UTF-8?B?TGluZHPjgYLjgYJy?= <[email protected]>, \r\n\s=?UTF-8?B?44GCZOOBgg==?= <[email protected]>\r\n" | |
+ field.encoded.should eq "#{Mail::FromField::CAPITALIZED_FIELD}: Mikel =?UTF-8?B?TGluZHPjgYLjgYJy?= <[email protected]>, \r\n\s=?UTF-8?B?44GCZOOBgg==?= <[email protected]>\r\n" | |
field = Mail::CcField.new(array, 'utf-8') | |
- field.encoded.should == "#{Mail::CcField::CAPITALIZED_FIELD}: Mikel =?UTF-8?B?TGluZHPjgYLjgYJy?= <[email protected]>, \r\n\s=?UTF-8?B?44GCZOOBgg==?= <[email protected]>\r\n" | |
+ field.encoded.should eq "#{Mail::CcField::CAPITALIZED_FIELD}: Mikel =?UTF-8?B?TGluZHPjgYLjgYJy?= <[email protected]>, \r\n\s=?UTF-8?B?44GCZOOBgg==?= <[email protected]>\r\n" | |
field = Mail::ReplyToField.new(array, 'utf-8') | |
- field.encoded.should == "#{Mail::ReplyToField::CAPITALIZED_FIELD}: Mikel =?UTF-8?B?TGluZHPjgYLjgYJy?= <[email protected]>, \r\n\s=?UTF-8?B?44GCZOOBgg==?= <[email protected]>\r\n" | |
+ field.encoded.should eq "#{Mail::ReplyToField::CAPITALIZED_FIELD}: Mikel =?UTF-8?B?TGluZHPjgYLjgYJy?= <[email protected]>, \r\n\s=?UTF-8?B?44GCZOOBgg==?= <[email protected]>\r\n" | |
end | |
it "should allow an encoded value in the Subject field and decode it automatically (issue 44)" do | |
pending if RUBY_VERSION < '1.9' | |
subject = Mail::SubjectField.new("=?ISO-8859-1?Q?2_=FAlt?=", 'utf-8') | |
- subject.decoded.should == "2 últ" | |
+ subject.decoded.should eq "2 últ" | |
end | |
it "should allow you to encoded text in the middle (issue 44)" do | |
pending if RUBY_VERSION < '1.9' | |
subject = Mail::SubjectField.new("ma=?ISO-8859-1?Q?=F1ana?=", 'utf-8') | |
- subject.decoded.should == "mañana" | |
+ subject.decoded.should eq "mañana" | |
end | |
it "more tolerable to encoding definitions, ISO (issue 120)" do | |
pending if RUBY_VERSION < '1.9' | |
subject = Mail::SubjectField.new("ma=?ISO88591?Q?=F1ana?=", 'utf-8') | |
- subject.decoded.should == "mañana" | |
+ subject.decoded.should eq "mañana" | |
end | |
it "more tolerable to encoding definitions, ISO-long (issue 120)" do | |
pending if RUBY_VERSION < '1.9' | |
subject = Mail::SubjectField.new("=?iso2022jp?B?SEVBUlQbJEIkSiQ0TyJNbRsoQg?=", 'utf-8') | |
- subject.decoded.should == "HEARTなご連絡" | |
+ subject.decoded.should eq "HEARTなご連絡" | |
end | |
it "more tolerable to encoding definitions, UTF (issue 120)" do | |
to = Mail::ToField.new("=?utf8?B?44GCZOOBgg==?= <[email protected]>", 'utf-8') | |
- to.encoded.should == "To: =?utf8?B?44GCZOOBgg==?= <[email protected]>\r\n" | |
- to.decoded.should == "\"あdあ\" <[email protected]>" | |
+ to.encoded.should eq "To: =?utf8?B?44GCZOOBgg==?= <[email protected]>\r\n" | |
+ to.decoded.should eq "\"あdあ\" <[email protected]>" | |
end | |
it "more tolerable to encoding definitions, ISO (issue 120)" do | |
subject = Mail::SubjectField.new("=?UTF8?B?UmU6IHRlc3QgZW52w61vIG1lbnNhamUgY29u?=", 'utf-8') | |
- subject.decoded.should == "Re: test envío mensaje con" | |
+ subject.decoded.should eq "Re: test envío mensaje con" | |
end | |
it "more tolerable to encoding definitions, Windows (issue 120)" do | |
pending if RUBY_VERSION < '1.9' | |
subject = Mail::SubjectField.new("=?Windows1252?Q?It=92s_a_test=3F?=", 'utf-8') | |
- subject.decoded.should == "It’s a test?" | |
+ subject.decoded.should eq "It’s a test?" | |
end | |
end | |
-end | |
\ No newline at end of file | |
+end | |
diff --git a/spec/mail/fields/bcc_field_spec.rb b/spec/mail/fields/bcc_field_spec.rb | |
index c067816..14d7287 100644 | |
--- a/spec/mail/fields/bcc_field_spec.rb | |
+++ b/spec/mail/fields/bcc_field_spec.rb | |
@@ -35,14 +35,14 @@ describe Mail::BccField do | |
it "should accept a string with the field name" do | |
t = Mail::BccField.new('Bcc: Mikel Lindsaar <[email protected]>, "Bob Smith" <[email protected]>') | |
- t.name.should == 'Bcc' | |
- t.value.should == 'Mikel Lindsaar <[email protected]>, "Bob Smith" <[email protected]>' | |
+ t.name.should eq 'Bcc' | |
+ t.value.should eq 'Mikel Lindsaar <[email protected]>, "Bob Smith" <[email protected]>' | |
end | |
it "should accept a string without the field name" do | |
t = Mail::BccField.new('Mikel Lindsaar <[email protected]>, "Bob Smith" <[email protected]>') | |
- t.name.should == 'Bcc' | |
- t.value.should == 'Mikel Lindsaar <[email protected]>, "Bob Smith" <[email protected]>' | |
+ t.name.should eq 'Bcc' | |
+ t.value.should eq 'Mikel Lindsaar <[email protected]>, "Bob Smith" <[email protected]>' | |
end | |
end | |
@@ -52,35 +52,35 @@ describe Mail::BccField do | |
describe "instance methods" do | |
it "should return an address" do | |
t = Mail::BccField.new('Mikel Lindsaar <[email protected]>') | |
- t.formatted.should == ['Mikel Lindsaar <[email protected]>'] | |
+ t.formatted.should eq ['Mikel Lindsaar <[email protected]>'] | |
end | |
it "should return two addresses" do | |
t = Mail::BccField.new('Mikel Lindsaar <[email protected]>, Ada Lindsaar <[email protected]>') | |
- t.formatted.first.should == 'Mikel Lindsaar <[email protected]>' | |
- t.addresses.last.should == '[email protected]' | |
+ t.formatted.first.should eq 'Mikel Lindsaar <[email protected]>' | |
+ t.addresses.last.should eq '[email protected]' | |
end | |
it "should return one address and a group" do | |
t = Mail::BccField.new('[email protected], my_group: [email protected], [email protected];') | |
- t.addresses[0].should == '[email protected]' | |
- t.addresses[1].should == '[email protected]' | |
- t.addresses[2].should == '[email protected]' | |
+ t.addresses[0].should eq '[email protected]' | |
+ t.addresses[1].should eq '[email protected]' | |
+ t.addresses[2].should eq '[email protected]' | |
end | |
it "should return the formatted line on to_s" do | |
t = Mail::BccField.new('[email protected], my_group: [email protected], [email protected];') | |
- t.value.should == '[email protected], my_group: [email protected], [email protected];' | |
+ t.value.should eq '[email protected], my_group: [email protected], [email protected];' | |
end | |
it "should return nothing on encoded as Bcc should not be in the mail" do | |
t = Mail::BccField.new('[email protected], my_group: [email protected], [email protected];') | |
- t.encoded.should == "" | |
+ t.encoded.should eq "" | |
end | |
it "should return the decoded line" do | |
t = Mail::BccField.new('[email protected], my_group: [email protected], [email protected];') | |
- t.decoded.should == "[email protected], my_group: [email protected], [email protected];" | |
+ t.decoded.should eq "[email protected], my_group: [email protected], [email protected];" | |
end | |
end | |
diff --git a/spec/mail/fields/cc_field_spec.rb b/spec/mail/fields/cc_field_spec.rb | |
index ec94026..f3ce02e 100644 | |
--- a/spec/mail/fields/cc_field_spec.rb | |
+++ b/spec/mail/fields/cc_field_spec.rb | |
@@ -20,14 +20,14 @@ describe Mail::CcField do | |
it "should accept a string with the field name" do | |
t = Mail::CcField.new('Cc: Mikel Lindsaar <[email protected]>, "Bob Smith" <[email protected]>') | |
- t.name.should == 'Cc' | |
- t.value.should == 'Mikel Lindsaar <[email protected]>, "Bob Smith" <[email protected]>' | |
+ t.name.should eq 'Cc' | |
+ t.value.should eq 'Mikel Lindsaar <[email protected]>, "Bob Smith" <[email protected]>' | |
end | |
it "should accept a string without the field name" do | |
t = Mail::CcField.new('Mikel Lindsaar <[email protected]>, "Bob Smith" <[email protected]>') | |
- t.name.should == 'Cc' | |
- t.value.should == 'Mikel Lindsaar <[email protected]>, "Bob Smith" <[email protected]>' | |
+ t.name.should eq 'Cc' | |
+ t.value.should eq 'Mikel Lindsaar <[email protected]>, "Bob Smith" <[email protected]>' | |
end | |
end | |
@@ -37,40 +37,40 @@ describe Mail::CcField do | |
describe "instance methods" do | |
it "should return an address" do | |
t = Mail::CcField.new('Mikel Lindsaar <[email protected]>') | |
- t.formatted.should == ['Mikel Lindsaar <[email protected]>'] | |
+ t.formatted.should eq ['Mikel Lindsaar <[email protected]>'] | |
end | |
it "should return two addresses" do | |
t = Mail::CcField.new('Mikel Lindsaar <[email protected]>, Ada Lindsaar <[email protected]>') | |
- t.formatted.first.should == 'Mikel Lindsaar <[email protected]>' | |
- t.addresses.last.should == '[email protected]' | |
+ t.formatted.first.should eq 'Mikel Lindsaar <[email protected]>' | |
+ t.addresses.last.should eq '[email protected]' | |
end | |
it "should return one address and a group" do | |
t = Mail::CcField.new('[email protected], my_group: [email protected], [email protected];') | |
- t.addresses[0].should == '[email protected]' | |
- t.addresses[1].should == '[email protected]' | |
- t.addresses[2].should == '[email protected]' | |
+ t.addresses[0].should eq '[email protected]' | |
+ t.addresses[1].should eq '[email protected]' | |
+ t.addresses[2].should eq '[email protected]' | |
end | |
it "should return the formatted line on to_s" do | |
t = Mail::CcField.new('[email protected], my_group: [email protected], [email protected];') | |
- t.value.should == '[email protected], my_group: [email protected], [email protected];' | |
+ t.value.should eq '[email protected], my_group: [email protected], [email protected];' | |
end | |
it "should return the encoded line for one address" do | |
t = Mail::CcField.new('[email protected]') | |
- t.encoded.should == "Cc: [email protected]\r\n" | |
+ t.encoded.should eq "Cc: [email protected]\r\n" | |
end | |
it "should return the encoded line" do | |
t = Mail::CcField.new('[email protected], my_group: [email protected], [email protected];') | |
- t.encoded.should == "Cc: [email protected], \r\n\smy_group: [email protected], \r\n\[email protected];\r\n" | |
+ t.encoded.should eq "Cc: [email protected], \r\n\smy_group: [email protected], \r\n\[email protected];\r\n" | |
end | |
it "should return the decoded line" do | |
t = Mail::CcField.new('[email protected], my_group: [email protected], [email protected];') | |
- t.decoded.should == "[email protected], my_group: [email protected], [email protected];" | |
+ t.decoded.should eq "[email protected], my_group: [email protected], [email protected];" | |
end | |
end | |
diff --git a/spec/mail/fields/comments_field_spec.rb b/spec/mail/fields/comments_field_spec.rb | |
index aa7bb68..4a47eaf 100644 | |
--- a/spec/mail/fields/comments_field_spec.rb | |
+++ b/spec/mail/fields/comments_field_spec.rb | |
@@ -11,14 +11,14 @@ describe Mail::CommentsField do | |
it "should accept a string with the field name" do | |
t = Mail::CommentsField.new('Comments: this is a comment') | |
- t.name.should == 'Comments' | |
- t.value.should == 'this is a comment' | |
+ t.name.should eq 'Comments' | |
+ t.value.should eq 'this is a comment' | |
end | |
it "should accept a string with the field name" do | |
t = Mail::CommentsField.new('this is a comment') | |
- t.name.should == 'Comments' | |
- t.value.should == 'this is a comment' | |
+ t.name.should eq 'Comments' | |
+ t.value.should eq 'this is a comment' | |
end | |
diff --git a/spec/mail/fields/common/address_container_spec.rb b/spec/mail/fields/common/address_container_spec.rb | |
index 80ac2b1..c680d4f 100644 | |
--- a/spec/mail/fields/common/address_container_spec.rb | |
+++ b/spec/mail/fields/common/address_container_spec.rb | |
@@ -4,15 +4,15 @@ require 'spec_helper' | |
describe 'AddressContainer' do | |
it "should allow you to append an address to an address field result" do | |
m = Mail.new("To: [email protected]") | |
- m.to.should == ['[email protected]'] | |
+ m.to.should eq ['[email protected]'] | |
m.to << '[email protected]' | |
- m.to.should == ['[email protected]', '[email protected]'] | |
+ m.to.should eq ['[email protected]', '[email protected]'] | |
end | |
it "should handle complex addresses correctly" do | |
m = Mail.new("From: [email protected]") | |
- m.from.should == ['[email protected]'] | |
+ m.from.should eq ['[email protected]'] | |
m.from << '"Ada Lindsaar" <[email protected]>, [email protected]' | |
- m.from.should == ['[email protected]', '[email protected]', '[email protected]'] | |
+ m.from.should eq ['[email protected]', '[email protected]', '[email protected]'] | |
end | |
end | |
diff --git a/spec/mail/fields/common/common_address_spec.rb b/spec/mail/fields/common/common_address_spec.rb | |
index 02cc669..a8355d8 100644 | |
--- a/spec/mail/fields/common/common_address_spec.rb | |
+++ b/spec/mail/fields/common/common_address_spec.rb | |
@@ -7,81 +7,81 @@ describe "Mail::CommonAddress" do | |
it "should give the addresses it is going to" do | |
field = Mail::ToField.new("To: [email protected]") | |
- field.addresses.first.should == "[email protected]" | |
+ field.addresses.first.should eq "[email protected]" | |
end | |
it "should split up the address list into individual addresses" do | |
field = Mail::ToField.new("To: [email protected], [email protected]") | |
- field.addresses.should == ["[email protected]", "[email protected]"] | |
+ field.addresses.should eq ["[email protected]", "[email protected]"] | |
end | |
it "should give the formatted addresses" do | |
field = Mail::ToField.new("To: Mikel <[email protected]>, Bob <[email protected]>") | |
- field.formatted.should == ["Mikel <[email protected]>", "Bob <[email protected]>"] | |
+ field.formatted.should eq ["Mikel <[email protected]>", "Bob <[email protected]>"] | |
end | |
it "should give the display names" do | |
field = Mail::ToField.new("To: Mikel <[email protected]>, Bob <[email protected]>") | |
- field.display_names.should == ["Mikel", "Bob"] | |
+ field.display_names.should eq ["Mikel", "Bob"] | |
end | |
it "should give the actual address objects" do | |
field = Mail::ToField.new("To: Mikel <[email protected]>, Bob <[email protected]>") | |
field.addrs.each do |addr| | |
- addr.class.should == Mail::Address | |
+ addr.class.should eq Mail::Address | |
end | |
end | |
it "should handle groups as well" do | |
field = Mail::ToField.new("To: [email protected], group: [email protected], [email protected];") | |
- field.addresses.should == ["[email protected]", "[email protected]", "[email protected]"] | |
+ field.addresses.should eq ["[email protected]", "[email protected]", "[email protected]"] | |
end | |
it "should provide a list of groups" do | |
field = Mail::ToField.new("To: [email protected], My Group: [email protected], [email protected];") | |
- field.group_names.should == ["My Group"] | |
+ field.group_names.should eq ["My Group"] | |
end | |
it "should provide a list of addresses per group" do | |
field = Mail::ToField.new("To: [email protected], My Group: [email protected], [email protected];") | |
- field.groups["My Group"].length.should == 2 | |
- field.groups["My Group"].first.to_s.should == '[email protected]' | |
- field.groups["My Group"].last.to_s.should == '[email protected]' | |
+ field.groups["My Group"].length.should eq 2 | |
+ field.groups["My Group"].first.to_s.should eq '[email protected]' | |
+ field.groups["My Group"].last.to_s.should eq '[email protected]' | |
end | |
it "should provide a list of addresses that are just in the groups" do | |
field = Mail::ToField.new("To: [email protected], My Group: [email protected], [email protected];") | |
- field.group_addresses.should == ['[email protected]', '[email protected]'] | |
+ field.group_addresses.should eq ['[email protected]', '[email protected]'] | |
end | |
it "should handle initializing as an empty string" do | |
field = Mail::ToField.new("") | |
- field.addresses.should == [] | |
+ field.addresses.should eq [] | |
field.value = '[email protected]' | |
- field.addresses.should == ['[email protected]'] | |
+ field.addresses.should eq ['[email protected]'] | |
end | |
it "should encode to an empty string if it has no addresses or groups" do | |
field = Mail::ToField.new("") | |
- field.encoded.should == '' | |
+ field.encoded.should eq '' | |
field.value = '[email protected]' | |
- field.encoded.should == "To: [email protected]\r\n" | |
+ field.encoded.should eq "To: [email protected]\r\n" | |
end | |
it "should allow you to append an address" do | |
field = Mail::ToField.new("") | |
field << '[email protected]' | |
- field.addresses.should == ["[email protected]"] | |
+ field.addresses.should eq ["[email protected]"] | |
end | |
it "should preserve the display name" do | |
field = Mail::ToField.new('"Mikel Lindsaar" <[email protected]>') | |
- field.display_names.should == ["Mikel Lindsaar"] | |
+ field.display_names.should eq ["Mikel Lindsaar"] | |
end | |
it "should handle multiple addresses" do | |
field = Mail::ToField.new(['[email protected]', 'Mikel <[email protected]>']) | |
- field.addresses.should == ['[email protected]', '[email protected]'] | |
+ field.addresses.should eq ['[email protected]', '[email protected]'] | |
end | |
end | |
@@ -90,32 +90,32 @@ describe "Mail::CommonAddress" do | |
it "should allow us to encode an address field" do | |
field = Mail::ToField.new("[email protected], My Group: [email protected], [email protected];") | |
- field.encoded.should == "To: [email protected], \r\n\sMy Group: [email protected], \r\n\[email protected];\r\n" | |
+ field.encoded.should eq "To: [email protected], \r\n\sMy Group: [email protected], \r\n\[email protected];\r\n" | |
end | |
it "should allow us to encode a simple address field" do | |
field = Mail::ToField.new("[email protected]") | |
- field.encoded.should == "To: [email protected]\r\n" | |
+ field.encoded.should eq "To: [email protected]\r\n" | |
end | |
it "should allow us to encode an address field" do | |
field = Mail::CcField.new("[email protected], My Group: [email protected], [email protected];") | |
- field.encoded.should == "Cc: [email protected], \r\n\sMy Group: [email protected], \r\n\[email protected];\r\n" | |
+ field.encoded.should eq "Cc: [email protected], \r\n\sMy Group: [email protected], \r\n\[email protected];\r\n" | |
end | |
it "should allow us to decode an address field" do | |
field = Mail::ToField.new("[email protected], My Group: [email protected], [email protected];") | |
- field.decoded.should == "[email protected], My Group: [email protected], [email protected];" | |
+ field.decoded.should eq "[email protected], My Group: [email protected], [email protected];" | |
end | |
it "should allow us to decode a non ascii address field" do | |
field = Mail::ToField.new("=?UTF-8?B?44G/44GR44KL?= <[email protected]>") | |
- field.decoded.should == '"みける" <[email protected]>' | |
+ field.decoded.should eq '"みける" <[email protected]>' | |
end | |
it "should allow us to decode a non ascii address field" do | |
field = Mail::ToField.new("=?UTF-8?B?44G/44GR44KL?= <[email protected]>, =?UTF-8?B?44G/44GR44KL?= <[email protected]>") | |
- field.decoded.should == '"みける" <[email protected]>, "みける" <[email protected]>' | |
+ field.decoded.should eq '"みける" <[email protected]>, "みける" <[email protected]>' | |
end | |
end | |
@@ -126,7 +126,7 @@ describe "Mail::CommonAddress" do | |
field.each do |address| | |
addresses << address.address | |
end | |
- addresses.should == ["[email protected]", "[email protected]", "[email protected]"] | |
+ addresses.should eq ["[email protected]", "[email protected]", "[email protected]"] | |
end | |
end | |
diff --git a/spec/mail/fields/common/common_date_spec.rb b/spec/mail/fields/common/common_date_spec.rb | |
index 8d53f02..d0bc7c3 100644 | |
--- a/spec/mail/fields/common/common_date_spec.rb | |
+++ b/spec/mail/fields/common/common_date_spec.rb | |
@@ -6,17 +6,17 @@ describe Mail::CommonAddress do | |
it "should allow us to encode an date field" do | |
field = Mail::DateField.new('12 Aug 2009 00:00:02 GMT') | |
- field.encoded.should == "Date: Wed, 12 Aug 2009 00:00:02 +0000\r\n" | |
+ field.encoded.should eq "Date: Wed, 12 Aug 2009 00:00:02 +0000\r\n" | |
end | |
it "should allow us to encode an resent date field" do | |
field = Mail::ResentDateField.new('12 Aug 2009 00:00:02 GMT') | |
- field.encoded.should == "Resent-Date: Wed, 12 Aug 2009 00:00:02 +0000\r\n" | |
+ field.encoded.should eq "Resent-Date: Wed, 12 Aug 2009 00:00:02 +0000\r\n" | |
end | |
it "should allow us to decode an address field" do | |
field = Mail::DateField.new('12 Aug 2009 00:00:02 GMT') | |
- field.decoded.should == "Wed, 12 Aug 2009 00:00:02 +0000" | |
+ field.decoded.should eq "Wed, 12 Aug 2009 00:00:02 +0000" | |
end | |
end | |
diff --git a/spec/mail/fields/common/common_field_spec.rb b/spec/mail/fields/common/common_field_spec.rb | |
index ba6972d..65962dd 100644 | |
--- a/spec/mail/fields/common/common_field_spec.rb | |
+++ b/spec/mail/fields/common/common_field_spec.rb | |
@@ -15,8 +15,8 @@ describe Mail::CommonField do | |
it "should leave ascii alone" do | |
field = Mail::SubjectField.new("This is a test") | |
- field.encoded.should == "Subject: This is a test\r\n" | |
- field.decoded.should == "This is a test" | |
+ field.encoded.should eq "Subject: This is a test\r\n" | |
+ field.decoded.should eq "This is a test" | |
end | |
it "should encode a utf-8 string as utf-8 quoted printable" do | |
@@ -29,9 +29,9 @@ describe Mail::CommonField do | |
result = "Subject: =?UTF-8?Q?=E3=81=8B=E3=81=8D=E3=81=8F=E3=81=91=E3=81=93?=\r\n" | |
end | |
field = Mail::SubjectField.new(value) | |
- field.encoded.should == result | |
- field.decoded.should == value | |
- field.value.should == value | |
+ field.encoded.should eq result | |
+ field.decoded.should eq value | |
+ field.value.should eq value | |
end | |
it "should wrap an encoded at 60 characters" do | |
@@ -44,9 +44,9 @@ describe Mail::CommonField do | |
result = "Subject: =?UTF-8?Q?=E3=81=8B=E3=81=8D=E3=81=8F=E3=81=91=E3=81=93?=\r\n\s=?UTF-8?Q?_=E3=81=8B=E3=81=8D=E3=81=8F=E3=81=91=E3=81=93?=\r\n\s=?UTF-8?Q?_=E3=81=8B=E3=81=8D=E3=81=8F=E3=81=91=E3=81=93?=\r\n\s=?UTF-8?Q?_=E3=81=8B=E3=81=8D=E3=81=8F=E3=81=91=E3=81=93?=\r\n\s=?UTF-8?Q?_=E3=81=8B=E3=81=8D=E3=81=8F=E3=81=91=E3=81=93?=\r\n\s=?UTF-8?Q?_=E3=81=8B=E3=81=8D=E3=81=8F=E3=81=91=E3=81=93?=\r\n\s=?UTF-8?Q?_=E3=81=8B=E3=81=8D=E3=81=8F=E3=81=91=E3=81=93?=\r\n\s=?UTF-8?Q?_=E3=81=8B=E3=81=8D=E3=81=8F=E3=81=91=E3=81=93?=\r\n\s=?UTF-8?Q?_=E3=81=8B=E3=81=8D=E3=81=8F=E3=81=91=E3=81=93?=\r\n" | |
end | |
field = Mail::SubjectField.new(value) | |
- field.encoded.should == result | |
- field.decoded.should == value | |
- field.value.should == value | |
+ field.encoded.should eq result | |
+ field.decoded.should eq value | |
+ field.value.should eq value | |
end | |
it "should handle charsets in assigned addresses" do | |
@@ -59,9 +59,9 @@ describe Mail::CommonField do | |
result = "From: =?UTF-8?B?44GL44GN44GP44GR44GT?= <[email protected]>\r\n" | |
end | |
field = Mail::FromField.new(value) | |
- field.encoded.should == result | |
- field.decoded.should == value | |
- field.value.should == "=?UTF-8?B?44GL44GN44GP44GR44GT?= <[email protected]>" | |
+ field.encoded.should eq result | |
+ field.decoded.should eq value | |
+ field.value.should eq "=?UTF-8?B?44GL44GN44GP44GR44GT?= <[email protected]>" | |
end | |
end | |
diff --git a/spec/mail/fields/common/common_message_id_spec.rb b/spec/mail/fields/common/common_message_id_spec.rb | |
index 7624fe6..668feca 100644 | |
--- a/spec/mail/fields/common/common_message_id_spec.rb | |
+++ b/spec/mail/fields/common/common_message_id_spec.rb | |
@@ -7,22 +7,22 @@ describe Mail::CommonMessageId do | |
it "should allow us to encode a message id field" do | |
field = Mail::MessageIdField.new('<[email protected]>') | |
- field.encoded.should == "Message-ID: <[email protected]>\r\n" | |
+ field.encoded.should eq "Message-ID: <[email protected]>\r\n" | |
end | |
it "should allow us to encode a message id field" do | |
field = Mail::MessageIdField.new('<[email protected]>') | |
- field.encoded.should == "Message-ID: <[email protected]>\r\n" | |
+ field.encoded.should eq "Message-ID: <[email protected]>\r\n" | |
end | |
it "should allow us to encode an in reply to field" do | |
field = Mail::InReplyToField.new('<[email protected]>') | |
- field.encoded.should == "In-Reply-To: <[email protected]>\r\n" | |
+ field.encoded.should eq "In-Reply-To: <[email protected]>\r\n" | |
end | |
it "should allow us to decode a message id field" do | |
field = Mail::MessageIdField.new('<[email protected]>') | |
- field.decoded.should == "<[email protected]>" | |
+ field.decoded.should eq "<[email protected]>" | |
end | |
end | |
diff --git a/spec/mail/fields/common/parameter_hash_spec.rb b/spec/mail/fields/common/parameter_hash_spec.rb | |
index ad8645c..137a6d2 100644 | |
--- a/spec/mail/fields/common/parameter_hash_spec.rb | |
+++ b/spec/mail/fields/common/parameter_hash_spec.rb | |
@@ -14,32 +14,32 @@ describe Mail::ParameterHash do | |
it "should return the values in the hash regardless of symbol or string" do | |
hash = Mail::ParameterHash.new | |
hash.merge!({'value1' => 'one', 'value2' => 'two'}) | |
- hash['value1'].should == 'one' | |
- hash['value2'].should == 'two' | |
- hash[:value1].should == 'one' | |
- hash[:value2].should == 'two' | |
+ hash['value1'].should eq 'one' | |
+ hash['value2'].should eq 'two' | |
+ hash[:value1].should eq 'one' | |
+ hash[:value2].should eq 'two' | |
end | |
it "should return the values in the hash using case-insensitive key matching" do | |
hash = Mail::ParameterHash.new | |
hash.merge!({'value1' => 'one', 'VALUE2' => 'two'}) | |
- hash['VALUE1'].should == 'one' | |
- hash['vAlUe2'].should == 'two' | |
- hash[:VaLuE1].should == 'one' | |
- hash[:value2].should == 'two' | |
+ hash['VALUE1'].should eq 'one' | |
+ hash['vAlUe2'].should eq 'two' | |
+ hash[:VaLuE1].should eq 'one' | |
+ hash[:value2].should eq 'two' | |
end | |
it "should return the correct value if they are not encoded" do | |
hash = Mail::ParameterHash.new | |
hash.merge!({'value1' => 'one', 'value2' => 'two'}) | |
- hash['value1'].should == 'one' | |
- hash['value2'].should == 'two' | |
+ hash['value1'].should eq 'one' | |
+ hash['value2'].should eq 'two' | |
end | |
it "should return a name list concatenated" do | |
hash = Mail::ParameterHash.new | |
hash.merge!({'value*1' => 'one', 'value*2' => 'two'}) | |
- hash['value'].should == 'onetwo' | |
+ hash['value'].should eq 'onetwo' | |
end | |
it "should return a name list concatenated and unencoded" do | |
@@ -47,13 +47,13 @@ describe Mail::ParameterHash do | |
hash.merge!({'value*0*' => "us-ascii'en'This%20is%20even%20more%20", | |
'value*1*' => "%2A%2A%2Afun%2A%2A%2A%20", | |
'value*2' => "isn't it"}) | |
- hash['value'].should == "This is even more ***fun*** isn't it" | |
+ hash['value'].should eq "This is even more ***fun*** isn't it" | |
end | |
it "should allow us to add a value" do | |
hash = Mail::ParameterHash.new | |
hash['value'] = 'bob' | |
- hash['value'].should == 'bob' | |
+ hash['value'].should eq 'bob' | |
end | |
it "should return an encoded value" do | |
@@ -61,7 +61,7 @@ describe Mail::ParameterHash do | |
hash.merge!({'value*0*' => "us-ascii'en'This%20is%20even%20more%20", | |
'value*1*' => "%2A%2A%2Afun%2A%2A%2A%20", | |
'value*2' => "isn't it"}) | |
- hash.encoded.should == %Q{value*0*=us-ascii'en'This%20is%20even%20more%20;\r\n\svalue*1*=%2A%2A%2Afun%2A%2A%2A%20;\r\n\svalue*2="isn't it"} | |
+ hash.encoded.should eq %Q{value*0*=us-ascii'en'This%20is%20even%20more%20;\r\n\svalue*1*=%2A%2A%2Afun%2A%2A%2A%20;\r\n\svalue*2="isn't it"} | |
end | |
end | |
diff --git a/spec/mail/fields/content_description_field_spec.rb b/spec/mail/fields/content_description_field_spec.rb | |
index 21f7d6b..3ccbb08 100644 | |
--- a/spec/mail/fields/content_description_field_spec.rb | |
+++ b/spec/mail/fields/content_description_field_spec.rb | |
@@ -24,14 +24,14 @@ describe Mail::ContentDescriptionField do | |
it "should accept a string with the field name" do | |
t = Mail::ContentDescriptionField.new('Content-Description: This is a description') | |
- t.name.should == 'Content-Description' | |
- t.value.should == 'This is a description' | |
+ t.name.should eq 'Content-Description' | |
+ t.value.should eq 'This is a description' | |
end | |
it "should accept a string without the field name" do | |
t = Mail::ContentDescriptionField.new('This is a description') | |
- t.name.should == 'Content-Description' | |
- t.value.should == 'This is a description' | |
+ t.name.should eq 'Content-Description' | |
+ t.value.should eq 'This is a description' | |
end | |
end | |
diff --git a/spec/mail/fields/content_disposition_field_spec.rb b/spec/mail/fields/content_disposition_field_spec.rb | |
index 1ba9d19..2b3f4ec 100644 | |
--- a/spec/mail/fields/content_disposition_field_spec.rb | |
+++ b/spec/mail/fields/content_disposition_field_spec.rb | |
@@ -10,55 +10,55 @@ describe Mail::ContentDispositionField do | |
it "should accept a string with the field name" do | |
c = Mail::ContentDispositionField.new('Content-Disposition: attachment; filename=File') | |
- c.name.should == 'Content-Disposition' | |
- c.value.should == 'attachment; filename=File' | |
+ c.name.should eq 'Content-Disposition' | |
+ c.value.should eq 'attachment; filename=File' | |
end | |
it "should accept a string without the field name" do | |
c = Mail::ContentDispositionField.new('attachment; filename=File') | |
- c.name.should == 'Content-Disposition' | |
- c.value.should == 'attachment; filename=File' | |
+ c.name.should eq 'Content-Disposition' | |
+ c.value.should eq 'attachment; filename=File' | |
end | |
it "should accept a nil value and generate a disposition type" do | |
c = Mail::ContentDispositionField.new(nil) | |
- c.name.should == 'Content-Disposition' | |
+ c.name.should eq 'Content-Disposition' | |
c.value.should_not be_nil | |
end | |
it "should render encoded" do | |
c = Mail::ContentDispositionField.new('Content-Disposition: attachment; filename=File') | |
- c.encoded.should == "Content-Disposition: attachment;\r\n\sfilename=File\r\n" | |
+ c.encoded.should eq "Content-Disposition: attachment;\r\n\sfilename=File\r\n" | |
end | |
it "should render encoded for inline" do | |
c = Mail::ContentDispositionField.new('Content-Disposition: inline') | |
- c.encoded.should == "Content-Disposition: inline\r\n" | |
+ c.encoded.should eq "Content-Disposition: inline\r\n" | |
end | |
it "should render decoded" do | |
c = Mail::ContentDispositionField.new('Content-Disposition: attachment; filename=File') | |
- c.decoded.should == 'attachment; filename=File' | |
+ c.decoded.should eq 'attachment; filename=File' | |
end | |
it "should render decoded inline" do | |
c = Mail::ContentDispositionField.new('Content-Disposition: inline') | |
- c.decoded.should == 'inline' | |
+ c.decoded.should eq 'inline' | |
end | |
it "should handle upper and mixed case INLINE and AttachMent" do | |
c = Mail::ContentDispositionField.new('Content-Disposition: INLINE') | |
- c.decoded.should == 'inline' | |
+ c.decoded.should eq 'inline' | |
c = Mail::ContentDispositionField.new('Content-Disposition: AttachMent') | |
- c.decoded.should == 'attachment' | |
+ c.decoded.should eq 'attachment' | |
end | |
end | |
describe "instance methods" do | |
it "should give it's disposition type" do | |
c = Mail::ContentDispositionField.new('Content-Disposition: attachment; filename=File') | |
- c.disposition_type.should == 'attachment' | |
- c.parameters.should == {"filename" => 'File'} | |
+ c.disposition_type.should eq 'attachment' | |
+ c.parameters.should eql({"filename" => 'File'}) | |
end | |
# see spec/fixtures/trec_2005_corpus/missing_content_disposition.eml | |
diff --git a/spec/mail/fields/content_id_field_spec.rb b/spec/mail/fields/content_id_field_spec.rb | |
index d2fb4ee..df4e1a5 100644 | |
--- a/spec/mail/fields/content_id_field_spec.rb | |
+++ b/spec/mail/fields/content_id_field_spec.rb | |
@@ -35,32 +35,32 @@ describe Mail::ContentIdField do | |
it "should accept a string with the field name" do | |
c = Mail::ContentIdField.new('Content-ID: <[email protected]>') | |
- c.name.should == 'Content-ID' | |
- c.value.should == '<[email protected]>' | |
- c.content_id.should == '[email protected]' | |
+ c.name.should eq 'Content-ID' | |
+ c.value.should eq '<[email protected]>' | |
+ c.content_id.should eq '[email protected]' | |
end | |
it "should accept a string without the field name" do | |
m = Mail::ContentIdField.new('<[email protected]>') | |
- m.name.should == 'Content-ID' | |
- m.value.should == '<[email protected]>' | |
- m.content_id.should == '[email protected]' | |
+ m.name.should eq 'Content-ID' | |
+ m.value.should eq '<[email protected]>' | |
+ m.content_id.should eq '[email protected]' | |
end | |
it "should accept a nil value and generate a content_id" do | |
m = Mail::ContentIdField.new(nil) | |
- m.name.should == 'Content-ID' | |
+ m.name.should eq 'Content-ID' | |
m.value.should_not be_nil | |
end | |
it "should allow it to be encoded" do | |
m = Mail::ContentIdField.new('<[email protected]>') | |
- m.encoded.should == "Content-ID: <[email protected]>\r\n" | |
+ m.encoded.should eq "Content-ID: <[email protected]>\r\n" | |
end | |
it "should allow it to be decoded" do | |
m = Mail::ContentIdField.new('<[email protected]>') | |
- m.decoded.should == "<[email protected]>" | |
+ m.decoded.should eq "<[email protected]>" | |
end | |
end | |
@@ -69,16 +69,16 @@ describe Mail::ContentIdField do | |
it "should not accept a string with multiple message IDs but only return the first" do | |
m = Mail::ContentIdField.new('<[email protected]> <[email protected]>') | |
- m.name.should == 'Content-ID' | |
- m.to_s.should == '<[email protected]>' | |
- m.content_id.should == '[email protected]' | |
+ m.name.should eq 'Content-ID' | |
+ m.to_s.should eq '<[email protected]>' | |
+ m.content_id.should eq '[email protected]' | |
end | |
it "should change the message id if given a new message id" do | |
m = Mail::ContentIdField.new('<[email protected]>') | |
- m.to_s.should == '<[email protected]>' | |
+ m.to_s.should eq '<[email protected]>' | |
m.value = '<[email protected]>' | |
- m.to_s.should == '<[email protected]>' | |
+ m.to_s.should eq '<[email protected]>' | |
end | |
end | |
@@ -86,13 +86,13 @@ describe Mail::ContentIdField do | |
describe "instance methods" do | |
it "should provide to_s" do | |
m = Mail::ContentIdField.new('<[email protected]>') | |
- m.to_s.should == '<[email protected]>' | |
- m.content_id.to_s.should == '[email protected]' | |
+ m.to_s.should eq '<[email protected]>' | |
+ m.content_id.to_s.should eq '[email protected]' | |
end | |
it "should provide encoded" do | |
m = Mail::ContentIdField.new('<[email protected]>') | |
- m.encoded.should == "Content-ID: <[email protected]>\r\n" | |
+ m.encoded.should eq "Content-ID: <[email protected]>\r\n" | |
end | |
it "should respond to :responsible_for?" do | |
diff --git a/spec/mail/fields/content_location_field_spec.rb b/spec/mail/fields/content_location_field_spec.rb | |
index 9469ae5..795e037 100644 | |
--- a/spec/mail/fields/content_location_field_spec.rb | |
+++ b/spec/mail/fields/content_location_field_spec.rb | |
@@ -12,24 +12,24 @@ describe Mail::ContentLocationField do | |
it "should accept a string with the field name" do | |
t = Mail::ContentLocationField.new('Content-Location: photo.jpg') | |
- t.name.should == 'Content-Location' | |
- t.value.should == 'photo.jpg' | |
+ t.name.should eq 'Content-Location' | |
+ t.value.should eq 'photo.jpg' | |
end | |
it "should accept a string without the field name" do | |
t = Mail::ContentLocationField.new('photo.jpg') | |
- t.name.should == 'Content-Location' | |
- t.value.should == 'photo.jpg' | |
+ t.name.should eq 'Content-Location' | |
+ t.value.should eq 'photo.jpg' | |
end | |
it "should render an encoded field" do | |
t = Mail::ContentLocationField.new('photo.jpg') | |
- t.encoded.should == "Content-Location: photo.jpg\r\n" | |
+ t.encoded.should eq "Content-Location: photo.jpg\r\n" | |
end | |
it "should render a decoded field" do | |
t = Mail::ContentLocationField.new('photo.jpg') | |
- t.decoded.should == 'photo.jpg' | |
+ t.decoded.should eq 'photo.jpg' | |
end | |
end | |
@@ -38,7 +38,7 @@ describe Mail::ContentLocationField do | |
it "should return an encoding string unquoted" do | |
t = Mail::ContentLocationField.new('"A quoted filename.jpg"') | |
- t.location.should == 'A quoted filename.jpg' | |
+ t.location.should eq 'A quoted filename.jpg' | |
end | |
end | |
diff --git a/spec/mail/fields/content_transfer_encoding_field_spec.rb b/spec/mail/fields/content_transfer_encoding_field_spec.rb | |
index 6f3cdab..654ef79 100644 | |
--- a/spec/mail/fields/content_transfer_encoding_field_spec.rb | |
+++ b/spec/mail/fields/content_transfer_encoding_field_spec.rb | |
@@ -45,24 +45,24 @@ describe Mail::ContentTransferEncodingField do | |
it "should accept a string with the field name" do | |
t = Mail::ContentTransferEncodingField.new('Content-Transfer-Encoding: 7bit') | |
- t.name.should == 'Content-Transfer-Encoding' | |
- t.value.should == '7bit' | |
+ t.name.should eq 'Content-Transfer-Encoding' | |
+ t.value.should eq '7bit' | |
end | |
it "should accept a string without the field name" do | |
t = Mail::ContentTransferEncodingField.new('7bit') | |
- t.name.should == 'Content-Transfer-Encoding' | |
- t.value.should == '7bit' | |
+ t.name.should eq 'Content-Transfer-Encoding' | |
+ t.value.should eq '7bit' | |
end | |
it "should render an encoded field" do | |
t = Mail::ContentTransferEncodingField.new('7bit') | |
- t.encoded.should == "Content-Transfer-Encoding: 7bit\r\n" | |
+ t.encoded.should eq "Content-Transfer-Encoding: 7bit\r\n" | |
end | |
it "should render a decoded field" do | |
t = Mail::ContentTransferEncodingField.new('7bit') | |
- t.decoded.should == '7bit' | |
+ t.decoded.should eq '7bit' | |
end | |
end | |
@@ -72,24 +72,24 @@ describe Mail::ContentTransferEncodingField do | |
it "should return an encoding string" do | |
["7bit", "8bit", "binary", 'quoted-printable', "base64"].each do |encoding| | |
t = Mail::ContentTransferEncodingField.new(encoding) | |
- t.encoding.should == encoding | |
+ t.encoding.should eq encoding | |
end | |
end | |
it "should handle any valid 'x-token' value" do | |
t = Mail::ContentTransferEncodingField.new('X-This-is_MY-encoding') | |
- t.encoding.should == 'x-this-is_my-encoding' | |
+ t.encoding.should eq 'x-this-is_my-encoding' | |
end | |
it "should handle an x-encoding" do | |
t = Mail::ContentTransferEncodingField.new("x-uuencode") | |
- t.encoding.should == "x-uuencode" | |
+ t.encoding.should eq "x-uuencode" | |
end | |
it "should replace the existing value" do | |
t = Mail::ContentTransferEncodingField.new("7bit") | |
t.parse("quoted-printable") | |
- t.encoding.should == 'quoted-printable' | |
+ t.encoding.should eq 'quoted-printable' | |
end | |
it "should raise an error on bogus values" do | |
@@ -98,14 +98,14 @@ describe Mail::ContentTransferEncodingField do | |
it "should handle an empty content transfer encoding" do | |
t = Mail::ContentTransferEncodingField.new("") | |
- t.encoding.should == "" | |
+ t.encoding.should eq "" | |
end | |
it "should handle a hyphen" do | |
t = Mail::ContentTransferEncodingField.new('7-bit') | |
- t.decoded.should == '7bit' | |
+ t.decoded.should eq '7bit' | |
t = Mail::ContentTransferEncodingField.new('8-bit') | |
- t.decoded.should == '8bit' | |
+ t.decoded.should eq '8bit' | |
end | |
end | |
diff --git a/spec/mail/fields/content_type_field_spec.rb b/spec/mail/fields/content_type_field_spec.rb | |
index 8a2d704..1a4d099 100644 | |
--- a/spec/mail/fields/content_type_field_spec.rb | |
+++ b/spec/mail/fields/content_type_field_spec.rb | |
@@ -76,94 +76,94 @@ describe Mail::ContentTypeField do | |
it "should accept a string with the field name" do | |
c = Mail::ContentTypeField.new('Content-Type: text/plain') | |
- c.name.should == 'Content-Type' | |
- c.value.should == 'text/plain' | |
+ c.name.should eq 'Content-Type' | |
+ c.value.should eq 'text/plain' | |
end | |
it "should accept a string without the field name" do | |
c = Mail::ContentTypeField.new('text/plain') | |
- c.name.should == 'Content-Type' | |
- c.value.should == 'text/plain' | |
+ c.name.should eq 'Content-Type' | |
+ c.value.should eq 'text/plain' | |
end | |
it "should accept a nil value and generate a content_type" do | |
c = Mail::ContentTypeField.new('Content-Type', nil) | |
- c.name.should == 'Content-Type' | |
+ c.name.should eq 'Content-Type' | |
c.value.should_not be_nil | |
end | |
it "should render encoded" do | |
c = Mail::ContentTypeField.new('Content-Type: text/plain') | |
- c.encoded.should == "Content-Type: text/plain\r\n" | |
+ c.encoded.should eq "Content-Type: text/plain\r\n" | |
end | |
it "should render encoded with parameters" do | |
c = Mail::ContentTypeField.new('text/plain; charset=US-ASCII; format=flowed') | |
- c.encoded.should == %Q{Content-Type: text/plain;\r\n\scharset=US-ASCII;\r\n\sformat=flowed\r\n} | |
+ c.encoded.should eq %Q{Content-Type: text/plain;\r\n\scharset=US-ASCII;\r\n\sformat=flowed\r\n} | |
end | |
it "should render quoted values encoded" do | |
c = Mail::ContentTypeField.new('text/plain; example="foo bar"') | |
- c.encoded.should == %Q{Content-Type: text/plain;\r\n\sexample="foo bar"\r\n} | |
+ c.encoded.should eq %Q{Content-Type: text/plain;\r\n\sexample="foo bar"\r\n} | |
end | |
it "should render decoded" do | |
c = Mail::ContentTypeField.new('text/plain; charset=US-ASCII; format=flowed') | |
- c.decoded.should == 'text/plain; charset=US-ASCII; format=flowed' | |
+ c.decoded.should eq 'text/plain; charset=US-ASCII; format=flowed' | |
end | |
it "should render quoted values decoded" do | |
c = Mail::ContentTypeField.new('text/plain; example="foo bar"') | |
- c.decoded.should == 'text/plain; example="foo bar"' | |
+ c.decoded.should eq 'text/plain; example="foo bar"' | |
end | |
it "should render " do | |
c = Mail::ContentTypeField.new('message/delivery-status') | |
- c.main_type.should == 'message' | |
- c.sub_type.should == 'delivery-status' | |
+ c.main_type.should eq 'message' | |
+ c.sub_type.should eq 'delivery-status' | |
end | |
end | |
describe "instance methods" do | |
it "should return a content_type" do | |
c = Mail::ContentTypeField.new('text/plain') | |
- c.content_type.should == 'text/plain' | |
+ c.content_type.should eq 'text/plain' | |
end | |
it "should return a content_type for the :string method" do | |
c = Mail::ContentTypeField.new('text/plain') | |
- c.string.should == 'text/plain' | |
+ c.string.should eq 'text/plain' | |
end | |
it "should return a main_type" do | |
c = Mail::ContentTypeField.new('text/plain') | |
- c.main_type.should == 'text' | |
+ c.main_type.should eq 'text' | |
end | |
it "should return a sub_type" do | |
c = Mail::ContentTypeField.new('text/plain') | |
- c.main_type.should == 'text' | |
+ c.main_type.should eq 'text' | |
end | |
it "should return a parameter as a hash" do | |
c = Mail::ContentTypeField.new('text/plain; charset=US-ASCII') | |
- c.parameters.should == {"charset" => 'US-ASCII'} | |
+ c.parameters.should eql({"charset" => 'US-ASCII'}) | |
end | |
it "should return multiple parameters as a hash" do | |
c = Mail::ContentTypeField.new('text/plain; charset=US-ASCII; format=flowed') | |
- c.parameters.should == {"charset" => 'US-ASCII', "format" => 'flowed'} | |
+ c.parameters.should eql({"charset" => 'US-ASCII', "format" => 'flowed'}) | |
end | |
it "should return boundry parameters" do | |
c = Mail::ContentTypeField.new('multipart/mixed; boundary=Apple-Mail-13-196941151') | |
- c.parameters.should == {"boundary" => 'Apple-Mail-13-196941151'} | |
+ c.parameters.should eql({"boundary" => 'Apple-Mail-13-196941151'}) | |
end | |
it "should be indifferent with the access" do | |
c = Mail::ContentTypeField.new('multipart/mixed; boundary=Apple') | |
- c.parameters[:boundary].should == "Apple" | |
- c.parameters['boundary'].should == "Apple" | |
+ c.parameters[:boundary].should eq "Apple" | |
+ c.parameters['boundary'].should eq "Apple" | |
end | |
end | |
@@ -194,388 +194,388 @@ describe Mail::ContentTypeField do | |
it "should handle 'application/octet-stream; name*=iso-2022-jp'ja'01%20Quien%20Te%20Dij%8aat.%20Pitbull.mp3'" do | |
string = %q{application/octet-stream; name*=iso-2022-jp'ja'01%20Quien%20Te%20Dij%8aat.%20Pitbull.mp3} | |
c = Mail::ContentTypeField.new(string) | |
- c.content_type.should == 'application/octet-stream' | |
- c.main_type.should == 'application' | |
- c.sub_type.should == 'octet-stream' | |
- c.parameters.should == {'name*' => "iso-2022-jp'ja'01%20Quien%20Te%20Dij%8aat.%20Pitbull.mp3"} | |
+ c.content_type.should eq 'application/octet-stream' | |
+ c.main_type.should eq 'application' | |
+ c.sub_type.should eq 'octet-stream' | |
+ c.parameters.should eql({'name*' => "iso-2022-jp'ja'01%20Quien%20Te%20Dij%8aat.%20Pitbull.mp3"}) | |
end | |
it "should handle 'application/pdf;'" do | |
string = %q{application/pdf;} | |
c = Mail::ContentTypeField.new(string) | |
- c.content_type.should == 'application/pdf' | |
- c.main_type.should == 'application' | |
- c.sub_type.should == 'pdf' | |
- c.parameters.should == {} | |
+ c.content_type.should eq 'application/pdf' | |
+ c.main_type.should eq 'application' | |
+ c.sub_type.should eq 'pdf' | |
+ c.parameters.should eql({}) | |
end | |
it "should handle 'application/pdf; name=\"broken.pdf\"'" do | |
string = %q{application/pdf; name="broken.pdf"} | |
c = Mail::ContentTypeField.new(string) | |
- c.content_type.should == 'application/pdf' | |
- c.main_type.should == 'application' | |
- c.sub_type.should == 'pdf' | |
- c.parameters.should == {"name" => "broken.pdf"} | |
+ c.content_type.should eq 'application/pdf' | |
+ c.main_type.should eq 'application' | |
+ c.sub_type.should eq 'pdf' | |
+ c.parameters.should eql({"name" => "broken.pdf"}) | |
end | |
it "should handle 'application/pkcs7-signature;'" do | |
string = %q{application/pkcs7-signature;} | |
c = Mail::ContentTypeField.new(string) | |
- c.content_type.should == 'application/pkcs7-signature' | |
- c.main_type.should == 'application' | |
- c.sub_type.should == 'pkcs7-signature' | |
- c.parameters.should == {} | |
+ c.content_type.should eq 'application/pkcs7-signature' | |
+ c.main_type.should eq 'application' | |
+ c.sub_type.should eq 'pkcs7-signature' | |
+ c.parameters.should eql({}) | |
end | |
it "should handle 'application/pkcs7-signature; name=smime.p7s'" do | |
string = %q{application/pkcs7-signature; name=smime.p7s} | |
c = Mail::ContentTypeField.new(string) | |
- c.content_type.should == 'application/pkcs7-signature' | |
- c.main_type.should == 'application' | |
- c.sub_type.should == 'pkcs7-signature' | |
- c.parameters.should == {"name" => "smime.p7s"} | |
+ c.content_type.should eq 'application/pkcs7-signature' | |
+ c.main_type.should eq 'application' | |
+ c.sub_type.should eq 'pkcs7-signature' | |
+ c.parameters.should eql({"name" => "smime.p7s"}) | |
end | |
it "should handle 'application/x-gzip; NAME=blah.gz'" do | |
string = %q{application/x-gzip; NAME=blah.gz} | |
c = Mail::ContentTypeField.new(string) | |
- c.content_type.should == 'application/x-gzip' | |
- c.main_type.should == 'application' | |
- c.sub_type.should == 'x-gzip' | |
- c.parameters.should == {"NAME" => "blah.gz"} | |
+ c.content_type.should eq 'application/x-gzip' | |
+ c.main_type.should eq 'application' | |
+ c.sub_type.should eq 'x-gzip' | |
+ c.parameters.should eql({"NAME" => "blah.gz"}) | |
end | |
it "should handle 'image/jpeg'" do | |
string = %q{image/jpeg} | |
c = Mail::ContentTypeField.new(string) | |
- c.content_type.should == 'image/jpeg' | |
- c.main_type.should == 'image' | |
- c.sub_type.should == 'jpeg' | |
- c.parameters.should == {} | |
+ c.content_type.should eq 'image/jpeg' | |
+ c.main_type.should eq 'image' | |
+ c.sub_type.should eq 'jpeg' | |
+ c.parameters.should eql({}) | |
end | |
it "should handle 'image/jpeg'" do | |
string = %q{image/jpeg} | |
c = Mail::ContentTypeField.new(string) | |
- c.content_type.should == 'image/jpeg' | |
- c.main_type.should == 'image' | |
- c.sub_type.should == 'jpeg' | |
- c.parameters.should == {} | |
+ c.content_type.should eq 'image/jpeg' | |
+ c.main_type.should eq 'image' | |
+ c.sub_type.should eq 'jpeg' | |
+ c.parameters.should eql({}) | |
end | |
it "should handle 'image/jpeg;'" do | |
string = %q{image/jpeg} | |
c = Mail::ContentTypeField.new(string) | |
- c.content_type.should == 'image/jpeg' | |
- c.main_type.should == 'image' | |
- c.sub_type.should == 'jpeg' | |
- c.parameters.should == {} | |
+ c.content_type.should eq 'image/jpeg' | |
+ c.main_type.should eq 'image' | |
+ c.sub_type.should eq 'jpeg' | |
+ c.parameters.should eql({}) | |
end | |
it "should handle 'image/png;'" do | |
string = %q{image/png} | |
c = Mail::ContentTypeField.new(string) | |
- c.content_type.should == 'image/png' | |
- c.main_type.should == 'image' | |
- c.sub_type.should == 'png' | |
- c.parameters.should == {} | |
+ c.content_type.should eq 'image/png' | |
+ c.main_type.should eq 'image' | |
+ c.sub_type.should eq 'png' | |
+ c.parameters.should eql({}) | |
end | |
it "should handle 'message/delivery-status'" do | |
string = %q{message/delivery-status} | |
c = Mail::ContentTypeField.new(string) | |
- c.content_type.should == 'message/delivery-status' | |
- c.main_type.should == 'message' | |
- c.sub_type.should == 'delivery-status' | |
- c.parameters.should == {} | |
+ c.content_type.should eq 'message/delivery-status' | |
+ c.main_type.should eq 'message' | |
+ c.sub_type.should eq 'delivery-status' | |
+ c.parameters.should eql({}) | |
end | |
it "should handle 'message/rfc822'" do | |
string = %q{message/rfc822} | |
c = Mail::ContentTypeField.new(string) | |
- c.content_type.should == 'message/rfc822' | |
- c.main_type.should == 'message' | |
- c.sub_type.should == 'rfc822' | |
- c.parameters.should == {} | |
+ c.content_type.should eq 'message/rfc822' | |
+ c.main_type.should eq 'message' | |
+ c.sub_type.should eq 'rfc822' | |
+ c.parameters.should eql({}) | |
end | |
it "should handle 'multipart/alternative;'" do | |
string = %q{multipart/alternative;} | |
c = Mail::ContentTypeField.new(string) | |
- c.content_type.should == 'multipart/alternative' | |
- c.main_type.should == 'multipart' | |
- c.sub_type.should == 'alternative' | |
- c.parameters.should == {} | |
+ c.content_type.should eq 'multipart/alternative' | |
+ c.main_type.should eq 'multipart' | |
+ c.sub_type.should eq 'alternative' | |
+ c.parameters.should eql({}) | |
end | |
it "should handle 'multipart/alternative; boundary=\"----=_NextPart_000_0093_01C81419.EB75E850\"'" do | |
string = %q{multipart/alternative; boundary="----=_NextPart_000_0093_01C81419.EB75E850"} | |
c = Mail::ContentTypeField.new(string) | |
- c.content_type.should == 'multipart/alternative' | |
- c.main_type.should == 'multipart' | |
- c.sub_type.should == 'alternative' | |
- c.parameters.should == {"boundary" =>"----=_NextPart_000_0093_01C81419.EB75E850"} | |
+ c.content_type.should eq 'multipart/alternative' | |
+ c.main_type.should eq 'multipart' | |
+ c.sub_type.should eq 'alternative' | |
+ c.parameters.should eql({"boundary" =>"----=_NextPart_000_0093_01C81419.EB75E850"}) | |
end | |
it "should handle 'multipart/alternative; boundary=----=_NextPart_000_0093_01C81419.EB75E850'" do | |
string = %q{multipart/alternative; boundary="----=_NextPart_000_0093_01C81419.EB75E850"} | |
c = Mail::ContentTypeField.new(string) | |
- c.content_type.should == 'multipart/alternative' | |
- c.main_type.should == 'multipart' | |
- c.sub_type.should == 'alternative' | |
- c.parameters.should == {"boundary" =>"----=_NextPart_000_0093_01C81419.EB75E850"} | |
+ c.content_type.should eq 'multipart/alternative' | |
+ c.main_type.should eq 'multipart' | |
+ c.sub_type.should eq 'alternative' | |
+ c.parameters.should eql({"boundary" =>"----=_NextPart_000_0093_01C81419.EB75E850"}) | |
end | |
it "should handle 'Multipart/Alternative;boundary=MuLtIpArT_BoUnDaRy'" do | |
string = %q{Multipart/Alternative; boundary=MuLtIpArT_BoUnDaRy} | |
c = Mail::ContentTypeField.new(string) | |
- c.content_type.should == 'multipart/alternative' | |
- c.main_type.should == 'multipart' | |
- c.sub_type.should == 'alternative' | |
- c.parameters.should == {"boundary" =>"MuLtIpArT_BoUnDaRy"} | |
+ c.content_type.should eq 'multipart/alternative' | |
+ c.main_type.should eq 'multipart' | |
+ c.sub_type.should eq 'alternative' | |
+ c.parameters.should eql({"boundary" =>"MuLtIpArT_BoUnDaRy"}) | |
end | |
it "should handle 'Multipart/Alternative;boundary=MuLtIpArT_BoUnDaRy'" do | |
string = %q{Multipart/Alternative;boundary=MuLtIpArT_BoUnDaRy} | |
c = Mail::ContentTypeField.new(string) | |
- c.content_type.should == 'multipart/alternative' | |
- c.main_type.should == 'multipart' | |
- c.sub_type.should == 'alternative' | |
- c.parameters.should == {"boundary" =>"MuLtIpArT_BoUnDaRy"} | |
+ c.content_type.should eq 'multipart/alternative' | |
+ c.main_type.should eq 'multipart' | |
+ c.sub_type.should eq 'alternative' | |
+ c.parameters.should eql({"boundary" =>"MuLtIpArT_BoUnDaRy"}) | |
end | |
it "should handle 'multipart/mixed'" do | |
string = %q{multipart/mixed} | |
c = Mail::ContentTypeField.new(string) | |
- c.content_type.should == 'multipart/mixed' | |
- c.main_type.should == 'multipart' | |
- c.sub_type.should == 'mixed' | |
- c.parameters.should == {} | |
+ c.content_type.should eq 'multipart/mixed' | |
+ c.main_type.should eq 'multipart' | |
+ c.sub_type.should eq 'mixed' | |
+ c.parameters.should eql({}) | |
end | |
it "should handle 'multipart/mixed;'" do | |
string = %q{multipart/mixed;} | |
c = Mail::ContentTypeField.new(string) | |
- c.content_type.should == 'multipart/mixed' | |
- c.main_type.should == 'multipart' | |
- c.sub_type.should == 'mixed' | |
- c.parameters.should == {} | |
+ c.content_type.should eq 'multipart/mixed' | |
+ c.main_type.should eq 'multipart' | |
+ c.sub_type.should eq 'mixed' | |
+ c.parameters.should eql({}) | |
end | |
it "should handle 'multipart/mixed; boundary=Apple-Mail-13-196941151'" do | |
string = %q{multipart/mixed; boundary=Apple-Mail-13-196941151} | |
c = Mail::ContentTypeField.new(string) | |
- c.content_type.should == 'multipart/mixed' | |
- c.main_type.should == 'multipart' | |
- c.sub_type.should == 'mixed' | |
- c.parameters.should == {"boundary" => "Apple-Mail-13-196941151"} | |
+ c.content_type.should eq 'multipart/mixed' | |
+ c.main_type.should eq 'multipart' | |
+ c.sub_type.should eq 'mixed' | |
+ c.parameters.should eql({"boundary" => "Apple-Mail-13-196941151"}) | |
end | |
it "should handle 'multipart/mixed; boundary=mimepart_427e4cb4ca329_133ae40413c81ef'" do | |
string = %q{multipart/mixed; boundary=mimepart_427e4cb4ca329_133ae40413c81ef} | |
c = Mail::ContentTypeField.new(string) | |
- c.content_type.should == 'multipart/mixed' | |
- c.main_type.should == 'multipart' | |
- c.sub_type.should == 'mixed' | |
- c.parameters.should == {"boundary" => "mimepart_427e4cb4ca329_133ae40413c81ef"} | |
+ c.content_type.should eq 'multipart/mixed' | |
+ c.main_type.should eq 'multipart' | |
+ c.sub_type.should eq 'mixed' | |
+ c.parameters.should eql({"boundary" => "mimepart_427e4cb4ca329_133ae40413c81ef"}) | |
end | |
it "should handle 'multipart/report; report-type=delivery-status;'" do | |
string = %q{multipart/report; report-type=delivery-status;} | |
c = Mail::ContentTypeField.new(string) | |
- c.content_type.should == 'multipart/report' | |
- c.main_type.should == 'multipart' | |
- c.sub_type.should == 'report' | |
- c.parameters.should == {"report-type" => "delivery-status"} | |
+ c.content_type.should eq 'multipart/report' | |
+ c.main_type.should eq 'multipart' | |
+ c.sub_type.should eq 'report' | |
+ c.parameters.should eql({"report-type" => "delivery-status"}) | |
end | |
it "should handle 'multipart/signed;'" do | |
string = %q{multipart/signed;} | |
c = Mail::ContentTypeField.new(string) | |
- c.content_type.should == 'multipart/signed' | |
- c.main_type.should == 'multipart' | |
- c.sub_type.should == 'signed' | |
- c.parameters.should == {} | |
+ c.content_type.should eq 'multipart/signed' | |
+ c.main_type.should eq 'multipart' | |
+ c.sub_type.should eq 'signed' | |
+ c.parameters.should eql({}) | |
end | |
it "should handle 'text/enriched;'" do | |
string = %q{text/enriched;} | |
c = Mail::ContentTypeField.new(string) | |
- c.content_type.should == 'text/enriched' | |
- c.main_type.should == 'text' | |
- c.sub_type.should == 'enriched' | |
- c.parameters.should == {} | |
+ c.content_type.should eq 'text/enriched' | |
+ c.main_type.should eq 'text' | |
+ c.sub_type.should eq 'enriched' | |
+ c.parameters.should eql({}) | |
end | |
it "should handle 'text/html;'" do | |
string = %q{text/html;} | |
c = Mail::ContentTypeField.new(string) | |
- c.content_type.should == 'text/html' | |
- c.main_type.should == 'text' | |
- c.sub_type.should == 'html' | |
- c.parameters.should == {} | |
+ c.content_type.should eq 'text/html' | |
+ c.main_type.should eq 'text' | |
+ c.sub_type.should eq 'html' | |
+ c.parameters.should eql({}) | |
end | |
it "should handle 'text/html; charset=iso-8859-1;'" do | |
string = %q{text/html; charset=iso-8859-1;} | |
c = Mail::ContentTypeField.new(string) | |
- c.content_type.should == 'text/html' | |
- c.main_type.should == 'text' | |
- c.sub_type.should == 'html' | |
- c.parameters.should == {"charset" => 'iso-8859-1'} | |
+ c.content_type.should eq 'text/html' | |
+ c.main_type.should eq 'text' | |
+ c.sub_type.should eq 'html' | |
+ c.parameters.should eql({"charset" => 'iso-8859-1'}) | |
end | |
it "should handle 'TEXT/PLAIN; charset=ISO-8859-1;'" do | |
string = %q{TEXT/PLAIN; charset=ISO-8859-1;} | |
c = Mail::ContentTypeField.new(string) | |
- c.content_type.should == 'text/plain' | |
- c.main_type.should == 'text' | |
- c.sub_type.should == 'plain' | |
- c.parameters.should == {"charset" => 'ISO-8859-1'} | |
+ c.content_type.should eq 'text/plain' | |
+ c.main_type.should eq 'text' | |
+ c.sub_type.should eq 'plain' | |
+ c.parameters.should eql({"charset" => 'ISO-8859-1'}) | |
end | |
it "should handle 'text/plain'" do | |
string = %q{text/plain} | |
c = Mail::ContentTypeField.new(string) | |
- c.content_type.should == 'text/plain' | |
- c.main_type.should == 'text' | |
- c.sub_type.should == 'plain' | |
- c.parameters.should == {} | |
+ c.content_type.should eq 'text/plain' | |
+ c.main_type.should eq 'text' | |
+ c.sub_type.should eq 'plain' | |
+ c.parameters.should eql({}) | |
end | |
it "should handle 'text/plain;'" do | |
string = %q{text/plain;} | |
c = Mail::ContentTypeField.new(string) | |
- c.content_type.should == 'text/plain' | |
- c.main_type.should == 'text' | |
- c.sub_type.should == 'plain' | |
- c.parameters.should == {} | |
+ c.content_type.should eq 'text/plain' | |
+ c.main_type.should eq 'text' | |
+ c.sub_type.should eq 'plain' | |
+ c.parameters.should eql({}) | |
end | |
it "should handle 'text/plain; charset=ISO-8859-1'" do | |
string = %q{text/plain; charset=ISO-8859-1} | |
c = Mail::ContentTypeField.new(string) | |
- c.content_type.should == 'text/plain' | |
- c.main_type.should == 'text' | |
- c.sub_type.should == 'plain' | |
- c.parameters.should == {"charset" => 'ISO-8859-1'} | |
+ c.content_type.should eq 'text/plain' | |
+ c.main_type.should eq 'text' | |
+ c.sub_type.should eq 'plain' | |
+ c.parameters.should eql({"charset" => 'ISO-8859-1'}) | |
end | |
it "should handle 'text/plain; charset=ISO-8859-1;'" do | |
string = %q{text/plain; charset=ISO-8859-1; format=flowed} | |
c = Mail::ContentTypeField.new(string) | |
- c.content_type.should == 'text/plain' | |
- c.main_type.should == 'text' | |
- c.sub_type.should == 'plain' | |
- c.parameters.should == {"charset" => 'ISO-8859-1', "format" => 'flowed'} | |
+ c.content_type.should eq 'text/plain' | |
+ c.main_type.should eq 'text' | |
+ c.sub_type.should eq 'plain' | |
+ c.parameters.should eql({"charset" => 'ISO-8859-1', "format" => 'flowed'}) | |
end | |
it "should handle 'text/plain; charset=us-ascii;'" do | |
string = %q{text/plain; charset=us-ascii} | |
c = Mail::ContentTypeField.new(string) | |
- c.content_type.should == 'text/plain' | |
- c.main_type.should == 'text' | |
- c.sub_type.should == 'plain' | |
- c.parameters.should == {"charset" => 'us-ascii'} | |
+ c.content_type.should eq 'text/plain' | |
+ c.main_type.should eq 'text' | |
+ c.sub_type.should eq 'plain' | |
+ c.parameters.should eql({"charset" => 'us-ascii'}) | |
end | |
it "should handle 'text/plain; charset=US-ASCII; format=flowed'" do | |
string = %q{text/plain; charset=US-ASCII; format=flowed} | |
c = Mail::ContentTypeField.new(string) | |
- c.content_type.should == 'text/plain' | |
- c.main_type.should == 'text' | |
- c.sub_type.should == 'plain' | |
- c.parameters.should == {"charset" => 'US-ASCII', "format" => 'flowed'} | |
+ c.content_type.should eq 'text/plain' | |
+ c.main_type.should eq 'text' | |
+ c.sub_type.should eq 'plain' | |
+ c.parameters.should eql({"charset" => 'US-ASCII', "format" => 'flowed'}) | |
end | |
it "should handle 'text/plain; charset=US-ASCII; format=flowed'" do | |
string = %q{text/plain; charset=US-ASCII; format=flowed} | |
c = Mail::ContentTypeField.new(string) | |
- c.content_type.should == 'text/plain' | |
- c.main_type.should == 'text' | |
- c.sub_type.should == 'plain' | |
- c.parameters.should == {"charset" => 'US-ASCII', "format" => 'flowed'} | |
+ c.content_type.should eq 'text/plain' | |
+ c.main_type.should eq 'text' | |
+ c.sub_type.should eq 'plain' | |
+ c.parameters.should eql({"charset" => 'US-ASCII', "format" => 'flowed'}) | |
end | |
it "should handle 'text/plain; charset=utf-8'" do | |
string = %q{text/plain; charset=utf-8} | |
c = Mail::ContentTypeField.new(string) | |
- c.content_type.should == 'text/plain' | |
- c.main_type.should == 'text' | |
- c.sub_type.should == 'plain' | |
- c.parameters.should == {"charset" => 'utf-8'} | |
+ c.content_type.should eq 'text/plain' | |
+ c.main_type.should eq 'text' | |
+ c.sub_type.should eq 'plain' | |
+ c.parameters.should eql({"charset" => 'utf-8'}) | |
end | |
it "should handle 'text/plain; charset=utf-8'" do | |
string = %q{text/plain; charset=X-UNKNOWN} | |
c = Mail::ContentTypeField.new(string) | |
- c.content_type.should == 'text/plain' | |
- c.main_type.should == 'text' | |
- c.sub_type.should == 'plain' | |
- c.parameters.should == {"charset" => 'X-UNKNOWN'} | |
+ c.content_type.should eq 'text/plain' | |
+ c.main_type.should eq 'text' | |
+ c.sub_type.should eq 'plain' | |
+ c.parameters.should eql({"charset" => 'X-UNKNOWN'}) | |
end | |
it "should handle 'text/x-ruby-script;'" do | |
string = %q{text/x-ruby-script;} | |
c = Mail::ContentTypeField.new(string) | |
- c.content_type.should == 'text/x-ruby-script' | |
- c.main_type.should == 'text' | |
- c.sub_type.should == 'x-ruby-script' | |
- c.parameters.should == {} | |
+ c.content_type.should eq 'text/x-ruby-script' | |
+ c.main_type.should eq 'text' | |
+ c.sub_type.should eq 'x-ruby-script' | |
+ c.parameters.should eql({}) | |
end | |
it "should handle 'text/x-ruby-script; name=\"hello.rb\"'" do | |
string = %q{text/x-ruby-script; name="hello.rb"} | |
c = Mail::ContentTypeField.new(string) | |
- c.content_type.should == 'text/x-ruby-script' | |
- c.main_type.should == 'text' | |
- c.sub_type.should == 'x-ruby-script' | |
- c.parameters.should == {"name" => 'hello.rb'} | |
+ c.content_type.should eq 'text/x-ruby-script' | |
+ c.main_type.should eq 'text' | |
+ c.sub_type.should eq 'x-ruby-script' | |
+ c.parameters.should eql({"name" => 'hello.rb'}) | |
end | |
it "should handle 'multipart/mixed; boundary=\"=_NextPart_Lycos_15031600484464_ID\"" do | |
string = %q{multipart/mixed; boundary="=_NextPart_Lycos_15031600484464_ID"} | |
c = Mail::ContentTypeField.new(string) | |
- c.content_type.should == 'multipart/mixed' | |
- c.main_type.should == 'multipart' | |
- c.sub_type.should == 'mixed' | |
- c.parameters.should == {"boundary" => '=_NextPart_Lycos_15031600484464_ID'} | |
+ c.content_type.should eq 'multipart/mixed' | |
+ c.main_type.should eq 'multipart' | |
+ c.sub_type.should eq 'mixed' | |
+ c.parameters.should eql({"boundary" => '=_NextPart_Lycos_15031600484464_ID'}) | |
end | |
it "should handle 'multipart/alternative; boundary=----=_=NextPart_000_0093_01C81419.EB75E850" do | |
string = %q{multipart/alternative; boundary=----=_=NextPart_000_0093_01C81419.EB75E850} | |
c = Mail::ContentTypeField.new(string) | |
- c.content_type.should == 'multipart/alternative' | |
- c.main_type.should == 'multipart' | |
- c.sub_type.should == 'alternative' | |
- c.parameters.should == {"boundary" => '----=_=NextPart_000_0093_01C81419.EB75E850'} | |
+ c.content_type.should eq 'multipart/alternative' | |
+ c.main_type.should eq 'multipart' | |
+ c.sub_type.should eq 'alternative' | |
+ c.parameters.should eql({"boundary" => '----=_=NextPart_000_0093_01C81419.EB75E850'}) | |
end | |
it "should handle 'multipart/alternative; boundary=\"----=_=NextPart_000_0093_01C81419.EB75E850\"" do | |
string = %q{multipart/alternative; boundary="----=_=NextPart_000_0093_01C81419.EB75E850"} | |
c = Mail::ContentTypeField.new(string) | |
- c.content_type.should == 'multipart/alternative' | |
- c.main_type.should == 'multipart' | |
- c.sub_type.should == 'alternative' | |
- c.parameters.should == {"boundary" => '----=_=NextPart_000_0093_01C81419.EB75E850'} | |
+ c.content_type.should eq 'multipart/alternative' | |
+ c.main_type.should eq 'multipart' | |
+ c.sub_type.should eq 'alternative' | |
+ c.parameters.should eql({"boundary" => '----=_=NextPart_000_0093_01C81419.EB75E850'}) | |
end | |
it "should handle 'multipart/related;boundary=1_4626B816_9F1690;Type=\"application/smil\";Start=\"<mms.smil.txt>\"'" do | |
string = %q{multipart/related;boundary=1_4626B816_9F1690;Type="application/smil";Start="<mms.smil.txt>"} | |
c = Mail::ContentTypeField.new(string) | |
- c.content_type.should == 'multipart/related' | |
- c.main_type.should == 'multipart' | |
- c.sub_type.should == 'related' | |
- c.parameters.should == {"boundary" => '1_4626B816_9F1690', "Type" => 'application/smil', "Start" => '<mms.smil.txt>'} | |
+ c.content_type.should eq 'multipart/related' | |
+ c.main_type.should eq 'multipart' | |
+ c.sub_type.should eq 'related' | |
+ c.parameters.should eql({"boundary" => '1_4626B816_9F1690', "Type" => 'application/smil', "Start" => '<mms.smil.txt>'}) | |
end | |
it "should handle 'IMAGE/JPEG; name=\"IM 006.jpg\"'" do | |
string = %q{IMAGE/JPEG; name="IM 006.jpg"} | |
c = Mail::ContentTypeField.new(string) | |
- c.content_type.should == 'image/jpeg' | |
- c.main_type.should == 'image' | |
- c.sub_type.should == 'jpeg' | |
- c.parameters.should == {"name" => "IM 006.jpg"} | |
+ c.content_type.should eq 'image/jpeg' | |
+ c.main_type.should eq 'image' | |
+ c.sub_type.should eq 'jpeg' | |
+ c.parameters.should eql({"name" => "IM 006.jpg"}) | |
end | |
end | |
@@ -585,13 +585,13 @@ describe Mail::ContentTypeField do | |
it "should locate a filename if there is a filename" do | |
string = %q{application/octet-stream; filename=mikel.jpg} | |
c = Mail::ContentTypeField.new(string) | |
- c.filename.should == 'mikel.jpg' | |
+ c.filename.should eq 'mikel.jpg' | |
end | |
it "should locate a name if there is no filename" do | |
string = %q{application/octet-stream; name=mikel.jpg} | |
c = Mail::ContentTypeField.new(string) | |
- c.filename.should == 'mikel.jpg' | |
+ c.filename.should eq 'mikel.jpg' | |
end | |
it "should locate an encoded name as a filename" do | |
@@ -604,7 +604,7 @@ describe Mail::ContentTypeField do | |
expected = "01 Quien Te Dij\221at. Pitbull.mp3" | |
result = c.filename | |
end | |
- expected.should == result | |
+ expected.should eq result | |
end | |
it "should encode a non us-ascii filename" do | |
@@ -614,7 +614,11 @@ describe Mail::ContentTypeField do | |
end | |
c = Mail::ContentTypeField.new('application/octet-stream') | |
string = "01 Quien Te Dij\221at. Pitbull.mp3" | |
- if RUBY_VERSION >= '1.9' | |
+ case | |
+ when RUBY_VERSION >= '1.9.3' | |
+ string.force_encoding('SJIS') | |
+ result = %Q{Content-Type: application/octet-stream;\r\n\sfilename*=windows-31j'jp'01%20Quien%20Te%20Dij%91%61t.%20Pitbull.mp3\r\n} | |
+ when RUBY_VERSION >= '1.9' | |
string.force_encoding('SJIS') | |
result = %Q{Content-Type: application/octet-stream;\r\n\sfilename*=shift_jis'jp'01%20Quien%20Te%20Dij%91%61t.%20Pitbull.mp3\r\n} | |
else | |
@@ -623,8 +627,8 @@ describe Mail::ContentTypeField do | |
result = %Q{Content-Type: application/octet-stream;\r\n\sfilename*=sjis'jp'01%20Quien%20Te%20Dij%91at.%20Pitbull.mp3\r\n} | |
end | |
c.filename = string | |
- c.parameters.should == {"filename" => string} | |
- c.encoded.should == result | |
+ c.parameters.should eql({"filename" => string}) | |
+ c.encoded.should eq result | |
$KCODE = @original if RUBY_VERSION < '1.9' | |
end | |
@@ -634,13 +638,13 @@ describe Mail::ContentTypeField do | |
it "should handle missing sub-type on a text content type" do | |
c = Mail::ContentTypeField.new('Content-Type: text') | |
- c.content_type.should == 'text/plain' | |
+ c.content_type.should eq 'text/plain' | |
end | |
it "should handle missing ; after content-type" do | |
c = Mail::ContentTypeField.new('Content-Type: multipart/mixed boundary="----=_NextPart_000_000F_01C17754.8C3CAF30"') | |
- c.content_type.should == 'multipart/mixed' | |
- c.parameters['boundary'].should == '----=_NextPart_000_000F_01C17754.8C3CAF30' | |
+ c.content_type.should eq 'multipart/mixed' | |
+ c.parameters['boundary'].should eq '----=_NextPart_000_000F_01C17754.8C3CAF30' | |
end | |
end | |
@@ -648,70 +652,70 @@ describe Mail::ContentTypeField do | |
describe "initializing with an array" do | |
it "should initialize with an array" do | |
c = Mail::ContentTypeField.new(['text', 'html', {'charset' => 'UTF-8'}]) | |
- c.content_type.should == 'text/html' | |
- c.parameters['charset'].should == 'UTF-8' | |
+ c.content_type.should eq 'text/html' | |
+ c.parameters['charset'].should eq 'UTF-8' | |
end | |
it "should allow many parameters to be passed in" do | |
c = Mail::ContentTypeField.new(['text', 'html', {"format"=>"flowed", "charset"=>"utf-8"}]) | |
- c.content_type.should == 'text/html' | |
- c.parameters['charset'].should == 'utf-8' | |
- c.parameters['format'].should == 'flowed' | |
+ c.content_type.should eq 'text/html' | |
+ c.parameters['charset'].should eq 'utf-8' | |
+ c.parameters['format'].should eq 'flowed' | |
end | |
end | |
describe "special case values needing sanity" do | |
it "should handle 'text/plain;ISO-8559-1'" do | |
c = Mail::ContentTypeField.new('text/plain;ISO-8559-1') | |
- c.string.should == 'text/plain' | |
- c.parameters['charset'].should == 'iso-8559-1' | |
+ c.string.should eq 'text/plain' | |
+ c.parameters['charset'].should eq 'iso-8559-1' | |
end | |
it "should handle text; params" do | |
c = Mail::ContentTypeField.new('text; charset=utf-8') | |
- c.string.should == 'text/plain' | |
- c.parameters['charset'].should == 'utf-8' | |
+ c.string.should eq 'text/plain' | |
+ c.parameters['charset'].should eq 'utf-8' | |
end | |
it 'should handle text/html; charset="charset="GB2312""' do | |
c = Mail::ContentTypeField.new('text/html; charset="charset="GB2312""') | |
- c.string.should == 'text/html' | |
- c.parameters['charset'].should == 'gb2312' | |
+ c.string.should eq 'text/html' | |
+ c.parameters['charset'].should eq 'gb2312' | |
end | |
it "should handle application/octet-stream; name=archiveshelp1[1].htm" do | |
c = Mail::ContentTypeField.new('application/octet-stream; name=archiveshelp1[1].htm') | |
- c.string.should == 'application/octet-stream' | |
- c.parameters['name'].should == 'archiveshelp1[1].htm' | |
+ c.string.should eq 'application/octet-stream' | |
+ c.parameters['name'].should eq 'archiveshelp1[1].htm' | |
end | |
it 'should handle text/plain;; format="flowed"' do | |
c = Mail::ContentTypeField.new('text/plain;; format="flowed"') | |
- c.string.should == 'text/plain' | |
- c.parameters['format'].should == 'flowed' | |
+ c.string.should eq 'text/plain' | |
+ c.parameters['format'].should eq 'flowed' | |
end | |
it 'set an empty content type to text/plain' do | |
c = Mail::ContentTypeField.new('') | |
- c.string.should == 'text/plain' | |
+ c.string.should eq 'text/plain' | |
end | |
it "should just ignore illegal params like audio/x-midi;\r\n\sname=Part .exe" do | |
c = Mail::ContentTypeField.new("audio/x-midi;\r\n\sname=Part .exe") | |
- c.string.should == 'audio/x-midi' | |
- c.parameters['name'].should == nil | |
+ c.string.should eq 'audio/x-midi' | |
+ c.parameters['name'].should eq nil | |
end | |
it "should handle: rfc822; format=flowed; charset=iso-8859-15" do | |
c = Mail::ContentTypeField.new("rfc822; format=flowed; charset=iso-8859-15") | |
- c.string.should == 'text/plain' | |
- c.parameters['format'].should == 'flowed' | |
- c.parameters['charset'].should == 'iso-8859-15' | |
+ c.string.should eq 'text/plain' | |
+ c.parameters['format'].should eq 'flowed' | |
+ c.parameters['charset'].should eq 'iso-8859-15' | |
end | |
it "should just get the mime type if all else fails with some real garbage" do | |
c = Mail::ContentTypeField.new("text/html; format=flowed; charset=iso-8859-15 Mime-Version: 1.0") | |
- c.string.should == 'text/html' | |
+ c.string.should eq 'text/html' | |
end | |
end | |
diff --git a/spec/mail/fields/date_field_spec.rb b/spec/mail/fields/date_field_spec.rb | |
index dbd3acc..45a304b 100644 | |
--- a/spec/mail/fields/date_field_spec.rb | |
+++ b/spec/mail/fields/date_field_spec.rb | |
@@ -27,7 +27,7 @@ describe Mail::DateField do | |
end | |
it "should be able to tell the time" do | |
- Mail::DateField.new("12 Aug 2009 00:00:02 GMT").date_time.class.should == DateTime | |
+ Mail::DateField.new("12 Aug 2009 00:00:02 GMT").date_time.class.should eq DateTime | |
end | |
it "should mix in the CommonAddress module" do | |
@@ -36,16 +36,16 @@ describe Mail::DateField do | |
it "should accept a string with the field name" do | |
t = Mail::DateField.new('Date: 12 Aug 2009 00:00:02 GMT') | |
- t.name.should == 'Date' | |
- t.value.should == 'Wed, 12 Aug 2009 00:00:02 +0000' | |
- t.date_time.should == ::DateTime.parse('12 Aug 2009 00:00:02 GMT') | |
+ t.name.should eq 'Date' | |
+ t.value.should eq 'Wed, 12 Aug 2009 00:00:02 +0000' | |
+ t.date_time.should eq ::DateTime.parse('12 Aug 2009 00:00:02 GMT') | |
end | |
it "should accept a string without the field name" do | |
t = Mail::DateField.new('12 Aug 2009 00:00:02 GMT') | |
- t.name.should == 'Date' | |
- t.value.should == 'Wed, 12 Aug 2009 00:00:02 +0000' | |
- t.date_time.should == ::DateTime.parse('12 Aug 2009 00:00:02 GMT') | |
+ t.name.should eq 'Date' | |
+ t.value.should eq 'Wed, 12 Aug 2009 00:00:02 +0000' | |
+ t.date_time.should eq ::DateTime.parse('12 Aug 2009 00:00:02 GMT') | |
end | |
it "should accept nil as a value" do | |
@@ -55,23 +55,23 @@ describe Mail::DateField do | |
it "should allow us to encode an date field" do | |
field = Mail::DateField.new('12 Aug 2009 00:00:02 GMT') | |
- field.encoded.should == "Date: Wed, 12 Aug 2009 00:00:02 +0000\r\n" | |
+ field.encoded.should eq "Date: Wed, 12 Aug 2009 00:00:02 +0000\r\n" | |
end | |
it "should allow us to decode an address field" do | |
field = Mail::DateField.new('12 Aug 2009 00:00:02 GMT') | |
- field.decoded.should == "Wed, 12 Aug 2009 00:00:02 +0000" | |
+ field.decoded.should eq "Wed, 12 Aug 2009 00:00:02 +0000" | |
end | |
it "should be able to parse a really bad spacing example" do | |
field = Mail::DateField.new("Fri, 21 Nov 1997 09(comment): 55 : 06 -0600") | |
- field.decoded.should == "Fri, 21 Nov 1997 09:55:06 -0600" | |
+ field.decoded.should eq "Fri, 21 Nov 1997 09:55:06 -0600" | |
end | |
it "should give today's date if no date is specified" do | |
now = Time.now | |
Time.stub!(:now).and_return(now) | |
- Mail::DateField.new.date_time.should == ::DateTime.parse(now.to_s) | |
+ Mail::DateField.new.date_time.should eq ::DateTime.parse(now.to_s) | |
end | |
end | |
diff --git a/spec/mail/fields/envelope_spec.rb b/spec/mail/fields/envelope_spec.rb | |
index 7bf7a1c..7faf67f 100644 | |
--- a/spec/mail/fields/envelope_spec.rb | |
+++ b/spec/mail/fields/envelope_spec.rb | |
@@ -30,18 +30,18 @@ describe Mail::Envelope do | |
it "should return the envelope from element tree" do | |
envelope = Mail::Envelope.new('[email protected] Mon May 2 16:07:05 2005') | |
- envelope.tree.class.should == Treetop::Runtime::SyntaxNode | |
+ envelope.tree.class.should eq Treetop::Runtime::SyntaxNode | |
end | |
describe "accessor methods" do | |
it "should return the address" do | |
envelope = Mail::Envelope.new("[email protected] Mon Aug 17 00:39:21 2009") | |
- envelope.from.should == "[email protected]" | |
+ envelope.from.should eq "[email protected]" | |
end | |
it "should return the date_time" do | |
envelope = Mail::Envelope.new("[email protected] Mon Aug 17 00:39:21 2009") | |
- envelope.date.should == ::DateTime.parse("Mon Aug 17 00:39:21 2009") | |
+ envelope.date.should eq ::DateTime.parse("Mon Aug 17 00:39:21 2009") | |
end | |
end | |
diff --git a/spec/mail/fields/from_field_spec.rb b/spec/mail/fields/from_field_spec.rb | |
index 81b8799..f9b936a 100644 | |
--- a/spec/mail/fields/from_field_spec.rb | |
+++ b/spec/mail/fields/from_field_spec.rb | |
@@ -18,14 +18,14 @@ describe Mail::FromField do | |
it "should accept a string with the field name" do | |
t = Mail::FromField.new('From: Mikel Lindsaar <[email protected]>, "Bob Smith" <[email protected]>') | |
- t.name.should == 'From' | |
- t.value.should == 'Mikel Lindsaar <[email protected]>, "Bob Smith" <[email protected]>' | |
+ t.name.should eq 'From' | |
+ t.value.should eq 'Mikel Lindsaar <[email protected]>, "Bob Smith" <[email protected]>' | |
end | |
it "should accept a string without the field name" do | |
t = Mail::FromField.new('Mikel Lindsaar <[email protected]>, "Bob Smith" <[email protected]>') | |
- t.name.should == 'From' | |
- t.value.should == 'Mikel Lindsaar <[email protected]>, "Bob Smith" <[email protected]>' | |
+ t.name.should eq 'From' | |
+ t.value.should eq 'Mikel Lindsaar <[email protected]>, "Bob Smith" <[email protected]>' | |
end | |
end | |
@@ -35,55 +35,55 @@ describe Mail::FromField do | |
describe "instance methods" do | |
it "should return an address" do | |
t = Mail::FromField.new('Mikel Lindsaar <[email protected]>') | |
- t.formatted.should == ['Mikel Lindsaar <[email protected]>'] | |
+ t.formatted.should eq ['Mikel Lindsaar <[email protected]>'] | |
end | |
it "should return two addresses" do | |
t = Mail::FromField.new('Mikel Lindsaar <[email protected]>, Ada Lindsaar <[email protected]>') | |
- t.formatted.first.should == 'Mikel Lindsaar <[email protected]>' | |
- t.addresses.last.should == '[email protected]' | |
+ t.formatted.first.should eq 'Mikel Lindsaar <[email protected]>' | |
+ t.addresses.last.should eq '[email protected]' | |
end | |
it "should return one address and a group" do | |
t = Mail::FromField.new('[email protected], my_group: [email protected], [email protected];') | |
- t.addresses[0].should == '[email protected]' | |
- t.addresses[1].should == '[email protected]' | |
- t.addresses[2].should == '[email protected]' | |
+ t.addresses[0].should eq '[email protected]' | |
+ t.addresses[1].should eq '[email protected]' | |
+ t.addresses[2].should eq '[email protected]' | |
end | |
it "should return the formatted line on to_s" do | |
t = Mail::FromField.new('[email protected], my_group: [email protected], [email protected];') | |
- t.value.should == '[email protected], my_group: [email protected], [email protected];' | |
+ t.value.should eq '[email protected], my_group: [email protected], [email protected];' | |
end | |
it "should return the encoded line" do | |
t = Mail::FromField.new('[email protected], my_group: [email protected], [email protected];') | |
- t.encoded.should == "From: [email protected], \r\n\smy_group: [email protected], \r\n\[email protected];\r\n" | |
+ t.encoded.should eq "From: [email protected], \r\n\smy_group: [email protected], \r\n\[email protected];\r\n" | |
end | |
it "should return the encoded line" do | |
t = Mail::FromField.new("[email protected]") | |
- t.encoded.should == "From: [email protected]\r\n" | |
+ t.encoded.should eq "From: [email protected]\r\n" | |
end | |
it "should return the decoded line" do | |
t = Mail::FromField.new('[email protected], my_group: [email protected], [email protected];') | |
- t.decoded.should == "[email protected], my_group: [email protected], [email protected];" | |
+ t.decoded.should eq "[email protected], my_group: [email protected], [email protected];" | |
end | |
end | |
it "should handle non ascii" do | |
t = Mail::FromField.new('"Foo áëô îü" <[email protected]>') | |
- t.decoded.should == '"Foo áëô îü" <[email protected]>' | |
- t.encoded.should == "From: =?UTF-8?B?Rm9vIMOhw6vDtCDDrsO8?= <[email protected]>\r\n" | |
+ t.decoded.should eq '"Foo áëô îü" <[email protected]>' | |
+ t.encoded.should eq "From: =?UTF-8?B?Rm9vIMOhw6vDtCDDrsO8?= <[email protected]>\r\n" | |
end | |
it "should work without quotes" do | |
t = Mail::FromField.new('Foo áëô îü <[email protected]>') | |
- t.encoded.should == "From: Foo =?UTF-8?B?w6HDq8O0?= =?UTF-8?B?IMOuw7w=?= <[email protected]>\r\n" | |
- t.decoded.should == '"Foo áëô îü" <[email protected]>' | |
+ t.encoded.should eq "From: Foo =?UTF-8?B?w6HDq8O0?= =?UTF-8?B?IMOuw7w=?= <[email protected]>\r\n" | |
+ t.decoded.should eq '"Foo áëô îü" <[email protected]>' | |
end | |
end | |
diff --git a/spec/mail/fields/in_reply_to_field_spec.rb b/spec/mail/fields/in_reply_to_field_spec.rb | |
index 93c5629..a72473e 100644 | |
--- a/spec/mail/fields/in_reply_to_field_spec.rb | |
+++ b/spec/mail/fields/in_reply_to_field_spec.rb | |
@@ -18,42 +18,42 @@ describe Mail::InReplyToField do | |
it "should accept a string with the field name" do | |
t = Mail::InReplyToField.new('In-Reply-To: <[email protected]>') | |
- t.name.should == 'In-Reply-To' | |
- t.value.should == '<[email protected]>' | |
- t.message_id.should == '[email protected]' | |
+ t.name.should eq 'In-Reply-To' | |
+ t.value.should eq '<[email protected]>' | |
+ t.message_id.should eq '[email protected]' | |
end | |
it "should accept a string without the field name" do | |
t = Mail::InReplyToField.new('<[email protected]>') | |
- t.name.should == 'In-Reply-To' | |
- t.value.should == '<[email protected]>' | |
- t.message_id.should == '[email protected]' | |
+ t.name.should eq 'In-Reply-To' | |
+ t.value.should eq '<[email protected]>' | |
+ t.message_id.should eq '[email protected]' | |
end | |
it "should provide encoded" do | |
t = Mail::InReplyToField.new('<[email protected]>') | |
- t.encoded.should == "In-Reply-To: <[email protected]>\r\n" | |
+ t.encoded.should eq "In-Reply-To: <[email protected]>\r\n" | |
end | |
it "should handle many encoded message IDs" do | |
t = Mail::InReplyToField.new('<[email protected]> <[email protected]>') | |
- t.encoded.should == "In-Reply-To: <[email protected]> <[email protected]>\r\n" | |
+ t.encoded.should eq "In-Reply-To: <[email protected]> <[email protected]>\r\n" | |
end | |
it "should provide decoded" do | |
t = Mail::InReplyToField.new('<[email protected]>') | |
- t.decoded.should == "<[email protected]>" | |
+ t.decoded.should eq "<[email protected]>" | |
end | |
it "should handle many decoded message IDs" do | |
t = Mail::InReplyToField.new('<[email protected]> <[email protected]>') | |
- t.decoded.should == '<[email protected]> <[email protected]>' | |
+ t.decoded.should eq '<[email protected]> <[email protected]>' | |
end | |
it "should handle an empty value" do | |
t = Mail::InReplyToField.new('') | |
- t.name.should == 'In-Reply-To' | |
- t.decoded.should == nil | |
+ t.name.should eq 'In-Reply-To' | |
+ t.decoded.should eq nil | |
end | |
end | |
@@ -61,8 +61,8 @@ describe Mail::InReplyToField do | |
describe "handlign multiple message ids" do | |
it "should handle many message IDs" do | |
t = Mail::InReplyToField.new('<[email protected]> <[email protected]>') | |
- t.name.should == 'In-Reply-To' | |
- t.message_ids.should == ['[email protected]', '[email protected]'] | |
+ t.name.should eq 'In-Reply-To' | |
+ t.message_ids.should eq ['[email protected]', '[email protected]'] | |
end | |
end | |
end | |
diff --git a/spec/mail/fields/keywords_field_spec.rb b/spec/mail/fields/keywords_field_spec.rb | |
index b3ac783..dec15dd 100644 | |
--- a/spec/mail/fields/keywords_field_spec.rb | |
+++ b/spec/mail/fields/keywords_field_spec.rb | |
@@ -11,14 +11,14 @@ describe Mail::KeywordsField do | |
it "should accept a string with the field name" do | |
k = Mail::KeywordsField.new('Keywords: these are keywords, so there') | |
- k.name.should == 'Keywords' | |
- k.value.should == 'these are keywords, so there' | |
+ k.name.should eq 'Keywords' | |
+ k.value.should eq 'these are keywords, so there' | |
end | |
it "should accept a string with the field name" do | |
k = Mail::KeywordsField.new('these are keywords, so there') | |
- k.name.should == 'Keywords' | |
- k.value.should == 'these are keywords, so there' | |
+ k.name.should eq 'Keywords' | |
+ k.value.should eq 'these are keywords, so there' | |
end | |
end | |
@@ -26,27 +26,27 @@ describe Mail::KeywordsField do | |
describe "giving a list of keywords" do | |
it "should return a list of keywords" do | |
k = Mail::KeywordsField.new('these are keywords, so there') | |
- k.keywords.should == ['these are keywords', 'so there'] | |
+ k.keywords.should eq ['these are keywords', 'so there'] | |
end | |
it "should handle phrases" do | |
k = Mail::KeywordsField.new('"these, are keywords", so there') | |
- k.keywords.should == ['these, are keywords', 'so there'] | |
+ k.keywords.should eq ['these, are keywords', 'so there'] | |
end | |
it "should handle comments" do | |
k = Mail::KeywordsField.new('"these, are keywords", so there (This is an irrelevant comment)') | |
- k.keywords.should == ['these, are keywords', 'so there (This is an irrelevant comment)'] | |
+ k.keywords.should eq ['these, are keywords', 'so there (This is an irrelevant comment)'] | |
end | |
it "should handle comments" do | |
k = Mail::KeywordsField.new('"these, are keywords", so there (This is an irrelevant comment)') | |
- k.keywords.should == ['these, are keywords', 'so there (This is an irrelevant comment)'] | |
+ k.keywords.should eq ['these, are keywords', 'so there (This is an irrelevant comment)'] | |
end | |
it "should handle comments in quotes" do | |
k = Mail::KeywordsField.new('"these, are keywords (another comment to be ignored)", so there (This is an irrelevant comment)') | |
- k.keywords.should == ['these, are keywords (another comment to be ignored)', 'so there (This is an irrelevant comment)'] | |
+ k.keywords.should eq ['these, are keywords (another comment to be ignored)', 'so there (This is an irrelevant comment)'] | |
end | |
end | |
@@ -54,12 +54,12 @@ describe Mail::KeywordsField do | |
describe "encoding and decoding" do | |
it "should encode" do | |
k = Mail::KeywordsField.new('these are keywords, so there') | |
- k.encoded.should == "Keywords: these are keywords, so there\r\n" | |
+ k.encoded.should eq "Keywords: these are keywords, so there\r\n" | |
end | |
it "should decode" do | |
k = Mail::KeywordsField.new('these are keywords, so there') | |
- k.decoded.should == "these are keywords, so there" | |
+ k.decoded.should eq "these are keywords, so there" | |
end | |
end | |
diff --git a/spec/mail/fields/message_id_field_spec.rb b/spec/mail/fields/message_id_field_spec.rb | |
index 4489a38..6f26916 100644 | |
--- a/spec/mail/fields/message_id_field_spec.rb | |
+++ b/spec/mail/fields/message_id_field_spec.rb | |
@@ -62,21 +62,21 @@ describe Mail::MessageIdField do | |
it "should accept a string with the field name" do | |
m = Mail::MessageIdField.new('Message-ID: <[email protected]>') | |
- m.name.should == 'Message-ID' | |
- m.value.should == '<[email protected]>' | |
- m.message_id.should == '[email protected]' | |
+ m.name.should eq 'Message-ID' | |
+ m.value.should eq '<[email protected]>' | |
+ m.message_id.should eq '[email protected]' | |
end | |
it "should accept a string without the field name" do | |
m = Mail::MessageIdField.new('<[email protected]>') | |
- m.name.should == 'Message-ID' | |
- m.value.should == '<[email protected]>' | |
- m.message_id.should == '[email protected]' | |
+ m.name.should eq 'Message-ID' | |
+ m.value.should eq '<[email protected]>' | |
+ m.message_id.should eq '[email protected]' | |
end | |
it "should accept a nil value and generate a message_id" do | |
m = Mail::MessageIdField.new(nil) | |
- m.name.should == 'Message-ID' | |
+ m.name.should eq 'Message-ID' | |
m.value.should_not be_nil | |
end | |
@@ -86,17 +86,17 @@ describe Mail::MessageIdField do | |
it "should not accept a string with multiple message IDs but only return the first" do | |
m = Mail::MessageIdField.new('<[email protected]> <[email protected]>') | |
- m.name.should == 'Message-ID' | |
- m.to_s.should == '<[email protected]>' | |
- m.message_id.should == '[email protected]' | |
- m.message_ids.should == ['[email protected]'] | |
+ m.name.should eq 'Message-ID' | |
+ m.to_s.should eq '<[email protected]>' | |
+ m.message_id.should eq '[email protected]' | |
+ m.message_ids.should eq ['[email protected]'] | |
end | |
it "should change the message id if given a new message id" do | |
m = Mail::MessageIdField.new('<[email protected]>') | |
- m.to_s.should == '<[email protected]>' | |
+ m.to_s.should eq '<[email protected]>' | |
m.value = '<[email protected]>' | |
- m.to_s.should == '<[email protected]>' | |
+ m.to_s.should eq '<[email protected]>' | |
end | |
end | |
@@ -104,18 +104,18 @@ describe Mail::MessageIdField do | |
describe "instance methods" do | |
it "should provide to_s" do | |
m = Mail::MessageIdField.new('<[email protected]>') | |
- m.to_s.should == '<[email protected]>' | |
- m.message_id.to_s.should == '[email protected]' | |
+ m.to_s.should eq '<[email protected]>' | |
+ m.message_id.to_s.should eq '[email protected]' | |
end | |
it "should provide encoded" do | |
m = Mail::MessageIdField.new('<[email protected]>') | |
- m.encoded.should == "Message-ID: <[email protected]>\r\n" | |
+ m.encoded.should eq "Message-ID: <[email protected]>\r\n" | |
end | |
it "should provide decoded" do | |
m = Mail::MessageIdField.new('<[email protected]>') | |
- m.decoded.should == "<[email protected]>" | |
+ m.decoded.should eq "<[email protected]>" | |
end | |
it "should respond to :responsible_for?" do | |
@@ -141,7 +141,7 @@ describe Mail::MessageIdField do | |
describe "weird message IDs" do | |
it "should be able to parse <000701c874a6$3df7eaf0$b9e7c0d0$@[email protected]>" do | |
m = Mail::MessageIdField.new('<000701c874a6$3df7eaf0$b9e7c0d0$@[email protected]>') | |
- m.message_id.should == '000701c874a6$3df7eaf0$b9e7c0d0$@[email protected]' | |
+ m.message_id.should eq '000701c874a6$3df7eaf0$b9e7c0d0$@[email protected]' | |
end | |
end | |
end | |
diff --git a/spec/mail/fields/mime_version_field_spec.rb b/spec/mail/fields/mime_version_field_spec.rb | |
index 970a1d4..9a6b522 100644 | |
--- a/spec/mail/fields/mime_version_field_spec.rb | |
+++ b/spec/mail/fields/mime_version_field_spec.rb | |
@@ -88,14 +88,14 @@ describe Mail::MimeVersionField do | |
it "should accept a string with the field name" do | |
t = Mail::MimeVersionField.new('Mime-Version: 1.0') | |
- t.name.should == 'Mime-Version' | |
- t.value.should == '1.0' | |
+ t.name.should eq 'Mime-Version' | |
+ t.value.should eq '1.0' | |
end | |
it "should accept a string without the field name" do | |
t = Mail::MimeVersionField.new('1.0') | |
- t.name.should == 'Mime-Version' | |
- t.value.should == '1.0' | |
+ t.name.should eq 'Mime-Version' | |
+ t.value.should eq '1.0' | |
end | |
end | |
@@ -103,47 +103,47 @@ describe Mail::MimeVersionField do | |
describe "parsing a version string" do | |
it "should get a major value" do | |
t = Mail::MimeVersionField.new('1.0') | |
- t.major.should == 1 | |
+ t.major.should eq 1 | |
end | |
it "should get a minor value" do | |
t = Mail::MimeVersionField.new('1.0') | |
- t.minor.should == 0 | |
+ t.minor.should eq 0 | |
end | |
it "should get a version string" do | |
t = Mail::MimeVersionField.new('1.0') | |
- t.version.should == '1.0' | |
+ t.version.should eq '1.0' | |
end | |
it "should handle comments before the major version" do | |
t = Mail::MimeVersionField.new('(This is a comment) 1.0') | |
- t.version.should == '1.0' | |
+ t.version.should eq '1.0' | |
end | |
it "should handle comments before the major version without space" do | |
t = Mail::MimeVersionField.new('(This is a comment)1.0') | |
- t.version.should == '1.0' | |
+ t.version.should eq '1.0' | |
end | |
it "should handle comments after the major version without space" do | |
t = Mail::MimeVersionField.new('1(This is a comment).0') | |
- t.version.should == '1.0' | |
+ t.version.should eq '1.0' | |
end | |
it "should handle comments before the minor version without space" do | |
t = Mail::MimeVersionField.new('1.(This is a comment)0') | |
- t.version.should == '1.0' | |
+ t.version.should eq '1.0' | |
end | |
it "should handle comments after the minor version without space" do | |
t = Mail::MimeVersionField.new('1.0(This is a comment)') | |
- t.version.should == '1.0' | |
+ t.version.should eq '1.0' | |
end | |
it "should handle comments after the minor version" do | |
t = Mail::MimeVersionField.new('1.0 (This is a comment)') | |
- t.version.should == '1.0' | |
+ t.version.should eq '1.0' | |
end | |
it "should accept nil as a value" do | |
@@ -153,12 +153,12 @@ describe Mail::MimeVersionField do | |
it "should provide an encoded value" do | |
t = Mail::MimeVersionField.new('1.0 (This is a comment)') | |
- t.encoded.should == "Mime-Version: 1.0\r\n" | |
+ t.encoded.should eq "Mime-Version: 1.0\r\n" | |
end | |
it "should provide an decoded value" do | |
t = Mail::MimeVersionField.new('1.0 (This is a comment)') | |
- t.decoded.should == '1.0' | |
+ t.decoded.should eq '1.0' | |
end | |
end | |
diff --git a/spec/mail/fields/received_field_spec.rb b/spec/mail/fields/received_field_spec.rb | |
index 3b44280..8619038 100644 | |
--- a/spec/mail/fields/received_field_spec.rb | |
+++ b/spec/mail/fields/received_field_spec.rb | |
@@ -8,44 +8,44 @@ describe Mail::ReceivedField do | |
end | |
it "should be able to tell the time" do | |
- Mail::ReceivedField.new("Received: from localhost (localhost [127.0.0.1]) by xxx.xxxxx.com (Postfix) with ESMTP id 50FD3A96F for <[email protected]>; Tue, 10 May 2005 17:26:50 +0000 (GMT)").date_time.class.should == DateTime | |
+ Mail::ReceivedField.new("Received: from localhost (localhost [127.0.0.1]) by xxx.xxxxx.com (Postfix) with ESMTP id 50FD3A96F for <[email protected]>; Tue, 10 May 2005 17:26:50 +0000 (GMT)").date_time.class.should eq DateTime | |
end | |
it "should accept a string with the field name" do | |
t = Mail::ReceivedField.new('Received: from localhost (localhost [127.0.0.1]) by xxx.xxxxx.com (Postfix) with ESMTP id 50FD3A96F for <[email protected]>; Tue, 10 May 2005 17:26:50 +0000 (GMT)') | |
- t.name.should == 'Received' | |
- t.value.should == 'from localhost (localhost [127.0.0.1]) by xxx.xxxxx.com (Postfix) with ESMTP id 50FD3A96F for <[email protected]>; Tue, 10 May 2005 17:26:50 +0000 (GMT)' | |
- t.info.should == 'from localhost (localhost [127.0.0.1]) by xxx.xxxxx.com (Postfix) with ESMTP id 50FD3A96F for <[email protected]>' | |
- t.date_time.should == ::DateTime.parse('10 May 2005 17:26:50 +0000 (GMT)') | |
+ t.name.should eq 'Received' | |
+ t.value.should eq 'from localhost (localhost [127.0.0.1]) by xxx.xxxxx.com (Postfix) with ESMTP id 50FD3A96F for <[email protected]>; Tue, 10 May 2005 17:26:50 +0000 (GMT)' | |
+ t.info.should eq 'from localhost (localhost [127.0.0.1]) by xxx.xxxxx.com (Postfix) with ESMTP id 50FD3A96F for <[email protected]>' | |
+ t.date_time.should eq ::DateTime.parse('10 May 2005 17:26:50 +0000 (GMT)') | |
end | |
it "should accept a string without the field name" do | |
t = Mail::ReceivedField.new('from localhost (localhost [127.0.0.1]) by xxx.xxxxx.com (Postfix) with ESMTP id 50FD3A96F for <[email protected]>; Tue, 10 May 2005 17:26:50 +0000 (GMT)') | |
- t.name.should == 'Received' | |
- t.value.should == 'from localhost (localhost [127.0.0.1]) by xxx.xxxxx.com (Postfix) with ESMTP id 50FD3A96F for <[email protected]>; Tue, 10 May 2005 17:26:50 +0000 (GMT)' | |
- t.info.should == 'from localhost (localhost [127.0.0.1]) by xxx.xxxxx.com (Postfix) with ESMTP id 50FD3A96F for <[email protected]>' | |
- t.date_time.should == ::DateTime.parse('10 May 2005 17:26:50 +0000 (GMT)') | |
+ t.name.should eq 'Received' | |
+ t.value.should eq 'from localhost (localhost [127.0.0.1]) by xxx.xxxxx.com (Postfix) with ESMTP id 50FD3A96F for <[email protected]>; Tue, 10 May 2005 17:26:50 +0000 (GMT)' | |
+ t.info.should eq 'from localhost (localhost [127.0.0.1]) by xxx.xxxxx.com (Postfix) with ESMTP id 50FD3A96F for <[email protected]>' | |
+ t.date_time.should eq ::DateTime.parse('10 May 2005 17:26:50 +0000 (GMT)') | |
end | |
it "should provide an encoded value" do | |
t = Mail::ReceivedField.new('from localhost (localhost [127.0.0.1]) by xxx.xxxxx.com (Postfix) with ESMTP id 50FD3A96F for <[email protected]>; Tue, 10 May 2005 17:26:50 +0000 (GMT)') | |
- t.encoded.should == "Received: from localhost (localhost [127.0.0.1]) by xxx.xxxxx.com (Postfix) with ESMTP id 50FD3A96F for <[email protected]>; Tue, 10 May 2005 17:26:50 +0000\r\n" | |
+ t.encoded.should eq "Received: from localhost (localhost [127.0.0.1]) by xxx.xxxxx.com (Postfix) with ESMTP id 50FD3A96F for <[email protected]>; Tue, 10 May 2005 17:26:50 +0000\r\n" | |
end | |
it "should provide an encoded value with correct timezone" do | |
t = Mail::ReceivedField.new('from localhost (localhost [127.0.0.1]) by xxx.xxxxx.com (Postfix) with ESMTP id 50FD3A96F for <[email protected]>; Tue, 10 May 2005 17:26:50 -0500 (EST)') | |
- t.encoded.should == "Received: from localhost (localhost [127.0.0.1]) by xxx.xxxxx.com (Postfix) with ESMTP id 50FD3A96F for <[email protected]>; Tue, 10 May 2005 17:26:50 -0500\r\n" | |
+ t.encoded.should eq "Received: from localhost (localhost [127.0.0.1]) by xxx.xxxxx.com (Postfix) with ESMTP id 50FD3A96F for <[email protected]>; Tue, 10 May 2005 17:26:50 -0500\r\n" | |
end | |
it "should provide an decoded value" do | |
t = Mail::ReceivedField.new('from localhost (localhost [127.0.0.1]) by xxx.xxxxx.com (Postfix) with ESMTP id 50FD3A96F for <[email protected]>; Tue, 10 May 2005 17:26:50 +0000 (GMT)') | |
- t.decoded.should == 'from localhost (localhost [127.0.0.1]) by xxx.xxxxx.com (Postfix) with ESMTP id 50FD3A96F for <[email protected]>; Tue, 10 May 2005 17:26:50 +0000' | |
+ t.decoded.should eq 'from localhost (localhost [127.0.0.1]) by xxx.xxxxx.com (Postfix) with ESMTP id 50FD3A96F for <[email protected]>; Tue, 10 May 2005 17:26:50 +0000' | |
end | |
it "should handle a blank value" do | |
t = Mail::ReceivedField.new('') | |
- t.decoded.should == '' | |
- t.encoded.should == "Received: \r\n" | |
+ t.decoded.should eq '' | |
+ t.encoded.should eq "Received: \r\n" | |
end | |
end | |
diff --git a/spec/mail/fields/references_field_spec.rb b/spec/mail/fields/references_field_spec.rb | |
index 933c1db..165c2a3 100644 | |
--- a/spec/mail/fields/references_field_spec.rb | |
+++ b/spec/mail/fields/references_field_spec.rb | |
@@ -20,31 +20,31 @@ describe Mail::ReferencesField do | |
it "should accept a string with the field name" do | |
t = Mail::ReferencesField.new('References: <[email protected]>') | |
- t.name.should == 'References' | |
- t.value.should == '<[email protected]>' | |
- t.message_id.should == '[email protected]' | |
+ t.name.should eq 'References' | |
+ t.value.should eq '<[email protected]>' | |
+ t.message_id.should eq '[email protected]' | |
end | |
it "should accept a string without the field name" do | |
t = Mail::ReferencesField.new('<[email protected]>') | |
- t.name.should == 'References' | |
- t.value.should == '<[email protected]>' | |
- t.message_id.should == '[email protected]' | |
+ t.name.should eq 'References' | |
+ t.value.should eq '<[email protected]>' | |
+ t.message_id.should eq '[email protected]' | |
end | |
it "should accept multiple message ids" do | |
t = Mail::ReferencesField.new('<[email protected]> <[email protected]>') | |
- t.name.should == 'References' | |
- t.value.should == '<[email protected]> <[email protected]>' | |
- t.message_id.should == '[email protected]' | |
- t.message_ids.should == ['[email protected]', '[email protected]'] | |
- t.to_s.should == '<[email protected]> <[email protected]>' | |
+ t.name.should eq 'References' | |
+ t.value.should eq '<[email protected]> <[email protected]>' | |
+ t.message_id.should eq '[email protected]' | |
+ t.message_ids.should eq ['[email protected]', '[email protected]'] | |
+ t.to_s.should eq '<[email protected]> <[email protected]>' | |
end | |
it "should accept no message ids" do | |
t = Mail::ReferencesField.new('') | |
- t.name.should == 'References' | |
- t.decoded.should == nil | |
+ t.name.should eq 'References' | |
+ t.decoded.should eq nil | |
end | |
end | |
diff --git a/spec/mail/fields/reply_to_field_spec.rb b/spec/mail/fields/reply_to_field_spec.rb | |
index c10b6b7..8ef537a 100644 | |
--- a/spec/mail/fields/reply_to_field_spec.rb | |
+++ b/spec/mail/fields/reply_to_field_spec.rb | |
@@ -18,14 +18,14 @@ describe Mail::ReplyToField do | |
it "should accept a string with the field name" do | |
t = Mail::ReplyToField.new('Reply-To: Mikel Lindsaar <[email protected]>, "Bob Smith" <[email protected]>') | |
- t.name.should == 'Reply-To' | |
- t.value.should == 'Mikel Lindsaar <[email protected]>, "Bob Smith" <[email protected]>' | |
+ t.name.should eq 'Reply-To' | |
+ t.value.should eq 'Mikel Lindsaar <[email protected]>, "Bob Smith" <[email protected]>' | |
end | |
it "should accept a string without the field name" do | |
t = Mail::ReplyToField.new('Mikel Lindsaar <[email protected]>, "Bob Smith" <[email protected]>') | |
- t.name.should == 'Reply-To' | |
- t.value.should == 'Mikel Lindsaar <[email protected]>, "Bob Smith" <[email protected]>' | |
+ t.name.should eq 'Reply-To' | |
+ t.value.should eq 'Mikel Lindsaar <[email protected]>, "Bob Smith" <[email protected]>' | |
end | |
end | |
@@ -35,30 +35,30 @@ describe Mail::ReplyToField do | |
describe "instance methods" do | |
it "should return an address" do | |
t = Mail::ReplyToField.new('Mikel Lindsaar <[email protected]>') | |
- t.formatted.should == ['Mikel Lindsaar <[email protected]>'] | |
+ t.formatted.should eq ['Mikel Lindsaar <[email protected]>'] | |
end | |
it "should return two addresses" do | |
t = Mail::ReplyToField.new('Mikel Lindsaar <[email protected]>, Ada Lindsaar <[email protected]>') | |
- t.formatted.first.should == 'Mikel Lindsaar <[email protected]>' | |
- t.addresses.last.should == '[email protected]' | |
+ t.formatted.first.should eq 'Mikel Lindsaar <[email protected]>' | |
+ t.addresses.last.should eq '[email protected]' | |
end | |
it "should return one address and a group" do | |
t = Mail::ReplyToField.new('[email protected], my_group: [email protected], [email protected];') | |
- t.addresses[0].should == '[email protected]' | |
- t.addresses[1].should == '[email protected]' | |
- t.addresses[2].should == '[email protected]' | |
+ t.addresses[0].should eq '[email protected]' | |
+ t.addresses[1].should eq '[email protected]' | |
+ t.addresses[2].should eq '[email protected]' | |
end | |
it "should return the formatted line on to_s" do | |
t = Mail::ReplyToField.new('[email protected], my_group: [email protected], [email protected];') | |
- t.value.should == '[email protected], my_group: [email protected], [email protected];' | |
+ t.value.should eq '[email protected], my_group: [email protected], [email protected];' | |
end | |
it "should return the encoded line" do | |
t = Mail::ReplyToField.new('[email protected], my_group: [email protected], [email protected];') | |
- t.encoded.should == "Reply-To: [email protected], \r\n\smy_group: [email protected], \r\n\[email protected];\r\n" | |
+ t.encoded.should eq "Reply-To: [email protected], \r\n\smy_group: [email protected], \r\n\[email protected];\r\n" | |
end | |
end | |
diff --git a/spec/mail/fields/resent_bcc_field_spec.rb b/spec/mail/fields/resent_bcc_field_spec.rb | |
index 0c90653..76d1835 100644 | |
--- a/spec/mail/fields/resent_bcc_field_spec.rb | |
+++ b/spec/mail/fields/resent_bcc_field_spec.rb | |
@@ -17,14 +17,14 @@ describe Mail::ResentBccField do | |
it "should accept a string with the field name" do | |
t = Mail::ResentBccField.new('Resent-Bcc: Mikel Lindsaar <[email protected]>, "Bob Smith" <[email protected]>') | |
- t.name.should == 'Resent-Bcc' | |
- t.value.should == 'Mikel Lindsaar <[email protected]>, "Bob Smith" <[email protected]>' | |
+ t.name.should eq 'Resent-Bcc' | |
+ t.value.should eq 'Mikel Lindsaar <[email protected]>, "Bob Smith" <[email protected]>' | |
end | |
it "should accept a string without the field name" do | |
t = Mail::ResentBccField.new('Mikel Lindsaar <[email protected]>, "Bob Smith" <[email protected]>') | |
- t.name.should == 'Resent-Bcc' | |
- t.value.should == 'Mikel Lindsaar <[email protected]>, "Bob Smith" <[email protected]>' | |
+ t.name.should eq 'Resent-Bcc' | |
+ t.value.should eq 'Mikel Lindsaar <[email protected]>, "Bob Smith" <[email protected]>' | |
end | |
end | |
@@ -34,30 +34,30 @@ describe Mail::ResentBccField do | |
describe "instance methods" do | |
it "should return an address" do | |
t = Mail::ResentBccField.new('Mikel Lindsaar <[email protected]>') | |
- t.formatted.should == ['Mikel Lindsaar <[email protected]>'] | |
+ t.formatted.should eq ['Mikel Lindsaar <[email protected]>'] | |
end | |
it "should return two addresses" do | |
t = Mail::ResentBccField.new('Mikel Lindsaar <[email protected]>, Ada Lindsaar <[email protected]>') | |
- t.formatted.first.should == 'Mikel Lindsaar <[email protected]>' | |
- t.addresses.last.should == '[email protected]' | |
+ t.formatted.first.should eq 'Mikel Lindsaar <[email protected]>' | |
+ t.addresses.last.should eq '[email protected]' | |
end | |
it "should return one address and a group" do | |
t = Mail::ResentBccField.new('[email protected], my_group: [email protected], [email protected];') | |
- t.addresses[0].should == '[email protected]' | |
- t.addresses[1].should == '[email protected]' | |
- t.addresses[2].should == '[email protected]' | |
+ t.addresses[0].should eq '[email protected]' | |
+ t.addresses[1].should eq '[email protected]' | |
+ t.addresses[2].should eq '[email protected]' | |
end | |
it "should return the formatted line on to_s" do | |
t = Mail::ResentBccField.new('[email protected], my_group: [email protected], [email protected];') | |
- t.value.should == '[email protected], my_group: [email protected], [email protected];' | |
+ t.value.should eq '[email protected], my_group: [email protected], [email protected];' | |
end | |
it "should return the encoded line" do | |
t = Mail::ResentBccField.new('[email protected], my_group: [email protected], [email protected];') | |
- t.encoded.should == "Resent-Bcc: [email protected], \r\n\smy_group: [email protected], \r\n\[email protected];\r\n" | |
+ t.encoded.should eq "Resent-Bcc: [email protected], \r\n\smy_group: [email protected], \r\n\[email protected];\r\n" | |
end | |
end | |
diff --git a/spec/mail/fields/resent_cc_field_spec.rb b/spec/mail/fields/resent_cc_field_spec.rb | |
index 877c70e..03f252f 100644 | |
--- a/spec/mail/fields/resent_cc_field_spec.rb | |
+++ b/spec/mail/fields/resent_cc_field_spec.rb | |
@@ -17,14 +17,14 @@ describe Mail::ResentCcField do | |
it "should accept a string with the field name" do | |
t = Mail::ResentCcField.new('Resent-Cc: Mikel Lindsaar <[email protected]>, "Bob Smith" <[email protected]>') | |
- t.name.should == 'Resent-Cc' | |
- t.value.should == 'Mikel Lindsaar <[email protected]>, "Bob Smith" <[email protected]>' | |
+ t.name.should eq 'Resent-Cc' | |
+ t.value.should eq 'Mikel Lindsaar <[email protected]>, "Bob Smith" <[email protected]>' | |
end | |
it "should accept a string without the field name" do | |
t = Mail::ResentCcField.new('Mikel Lindsaar <[email protected]>, "Bob Smith" <[email protected]>') | |
- t.name.should == 'Resent-Cc' | |
- t.value.should == 'Mikel Lindsaar <[email protected]>, "Bob Smith" <[email protected]>' | |
+ t.name.should eq 'Resent-Cc' | |
+ t.value.should eq 'Mikel Lindsaar <[email protected]>, "Bob Smith" <[email protected]>' | |
end | |
end | |
@@ -34,30 +34,30 @@ describe Mail::ResentCcField do | |
describe "instance methods" do | |
it "should return an address" do | |
t = Mail::ResentCcField.new('Mikel Lindsaar <[email protected]>') | |
- t.formatted.should == ['Mikel Lindsaar <[email protected]>'] | |
+ t.formatted.should eq ['Mikel Lindsaar <[email protected]>'] | |
end | |
it "should return two addresses" do | |
t = Mail::ResentCcField.new('Mikel Lindsaar <[email protected]>, Ada Lindsaar <[email protected]>') | |
- t.formatted.first.should == 'Mikel Lindsaar <[email protected]>' | |
- t.addresses.last.should == '[email protected]' | |
+ t.formatted.first.should eq 'Mikel Lindsaar <[email protected]>' | |
+ t.addresses.last.should eq '[email protected]' | |
end | |
it "should return one address and a group" do | |
t = Mail::ResentCcField.new('[email protected], my_group: [email protected], [email protected];') | |
- t.addresses[0].should == '[email protected]' | |
- t.addresses[1].should == '[email protected]' | |
- t.addresses[2].should == '[email protected]' | |
+ t.addresses[0].should eq '[email protected]' | |
+ t.addresses[1].should eq '[email protected]' | |
+ t.addresses[2].should eq '[email protected]' | |
end | |
it "should return the formatted line on to_s" do | |
t = Mail::ResentCcField.new('[email protected], my_group: [email protected], [email protected];') | |
- t.value.should == '[email protected], my_group: [email protected], [email protected];' | |
+ t.value.should eq '[email protected], my_group: [email protected], [email protected];' | |
end | |
it "should return the encoded line" do | |
t = Mail::ResentCcField.new('[email protected], my_group: [email protected], [email protected];') | |
- t.encoded.should == "Resent-Cc: [email protected], \r\n\smy_group: [email protected], \r\n\[email protected];\r\n" | |
+ t.encoded.should eq "Resent-Cc: [email protected], \r\n\smy_group: [email protected], \r\n\[email protected];\r\n" | |
end | |
end | |
diff --git a/spec/mail/fields/resent_date_field_spec.rb b/spec/mail/fields/resent_date_field_spec.rb | |
index 37d38be..805cc9d 100644 | |
--- a/spec/mail/fields/resent_date_field_spec.rb | |
+++ b/spec/mail/fields/resent_date_field_spec.rb | |
@@ -7,7 +7,7 @@ describe Mail::ResentDateField do | |
end | |
it "should be able to tell the time" do | |
- Mail::ResentDateField.new("12 Aug 2009 00:00:02 GMT").date_time.class.should == DateTime | |
+ Mail::ResentDateField.new("12 Aug 2009 00:00:02 GMT").date_time.class.should eq DateTime | |
end | |
it "should mix in the CommonAddress module" do | |
@@ -16,24 +16,24 @@ describe Mail::ResentDateField do | |
it "should accept a string with the field name" do | |
t = Mail::ResentDateField.new('Resent-Date: 12 Aug 2009 00:00:02 GMT') | |
- t.name.should == 'Resent-Date' | |
- t.value.should == 'Wed, 12 Aug 2009 00:00:02 +0000' | |
- t.date_time.should == ::DateTime.parse('12 Aug 2009 00:00:02 GMT') | |
+ t.name.should eq 'Resent-Date' | |
+ t.value.should eq 'Wed, 12 Aug 2009 00:00:02 +0000' | |
+ t.date_time.should eq ::DateTime.parse('12 Aug 2009 00:00:02 GMT') | |
end | |
it "should accept a string without the field name" do | |
t = Mail::ResentDateField.new('12 Aug 2009 00:00:02 GMT') | |
- t.name.should == 'Resent-Date' | |
- t.value.should == 'Wed, 12 Aug 2009 00:00:02 +0000' | |
- t.date_time.should == ::DateTime.parse('12 Aug 2009 00:00:02 GMT') | |
+ t.name.should eq 'Resent-Date' | |
+ t.value.should eq 'Wed, 12 Aug 2009 00:00:02 +0000' | |
+ t.date_time.should eq ::DateTime.parse('12 Aug 2009 00:00:02 GMT') | |
end | |
it "should give today's date if no date is specified" do | |
now = Time.now | |
Time.stub!(:now).and_return(now) | |
t = Mail::ResentDateField.new | |
- t.name.should == 'Resent-Date' | |
- t.date_time.should == ::DateTime.parse(now.to_s) | |
+ t.name.should eq 'Resent-Date' | |
+ t.date_time.should eq ::DateTime.parse(now.to_s) | |
end | |
end | |
diff --git a/spec/mail/fields/resent_from_field_spec.rb b/spec/mail/fields/resent_from_field_spec.rb | |
index 88dc04b..3771c73 100644 | |
--- a/spec/mail/fields/resent_from_field_spec.rb | |
+++ b/spec/mail/fields/resent_from_field_spec.rb | |
@@ -17,14 +17,14 @@ describe Mail::ResentFromField do | |
it "should accept a string with the field name" do | |
t = Mail::ResentFromField.new('Resent-From: Mikel Lindsaar <[email protected]>, "Bob Smith" <[email protected]>') | |
- t.name.should == 'Resent-From' | |
- t.value.should == 'Mikel Lindsaar <[email protected]>, "Bob Smith" <[email protected]>' | |
+ t.name.should eq 'Resent-From' | |
+ t.value.should eq 'Mikel Lindsaar <[email protected]>, "Bob Smith" <[email protected]>' | |
end | |
it "should accept a string without the field name" do | |
t = Mail::ResentFromField.new('Mikel Lindsaar <[email protected]>, "Bob Smith" <[email protected]>') | |
- t.name.should == 'Resent-From' | |
- t.value.should == 'Mikel Lindsaar <[email protected]>, "Bob Smith" <[email protected]>' | |
+ t.name.should eq 'Resent-From' | |
+ t.value.should eq 'Mikel Lindsaar <[email protected]>, "Bob Smith" <[email protected]>' | |
end | |
end | |
@@ -34,30 +34,30 @@ describe Mail::ResentFromField do | |
describe "instance methods" do | |
it "should return an address" do | |
t = Mail::ResentFromField.new('Mikel Lindsaar <[email protected]>') | |
- t.formatted.should == ['Mikel Lindsaar <[email protected]>'] | |
+ t.formatted.should eq ['Mikel Lindsaar <[email protected]>'] | |
end | |
it "should return two addresses" do | |
t = Mail::ResentFromField.new('Mikel Lindsaar <[email protected]>, Ada Lindsaar <[email protected]>') | |
- t.formatted.first.should == 'Mikel Lindsaar <[email protected]>' | |
- t.addresses.last.should == '[email protected]' | |
+ t.formatted.first.should eq 'Mikel Lindsaar <[email protected]>' | |
+ t.addresses.last.should eq '[email protected]' | |
end | |
it "should return one address and a group" do | |
t = Mail::ResentFromField.new('[email protected], my_group: [email protected], [email protected];') | |
- t.addresses[0].should == '[email protected]' | |
- t.addresses[1].should == '[email protected]' | |
- t.addresses[2].should == '[email protected]' | |
+ t.addresses[0].should eq '[email protected]' | |
+ t.addresses[1].should eq '[email protected]' | |
+ t.addresses[2].should eq '[email protected]' | |
end | |
it "should return the formatted line on to_s" do | |
t = Mail::ResentFromField.new('[email protected], my_group: [email protected], [email protected];') | |
- t.value.should == '[email protected], my_group: [email protected], [email protected];' | |
+ t.value.should eq '[email protected], my_group: [email protected], [email protected];' | |
end | |
it "should return the encoded line" do | |
t = Mail::ResentFromField.new('[email protected], my_group: [email protected], [email protected];') | |
- t.encoded.should == "Resent-From: [email protected], \r\n\smy_group: [email protected], \r\n\[email protected];\r\n" | |
+ t.encoded.should eq "Resent-From: [email protected], \r\n\smy_group: [email protected], \r\n\[email protected];\r\n" | |
end | |
end | |
diff --git a/spec/mail/fields/resent_message_id_field_spec.rb b/spec/mail/fields/resent_message_id_field_spec.rb | |
index 7b1e9f9..2a8fefa 100644 | |
--- a/spec/mail/fields/resent_message_id_field_spec.rb | |
+++ b/spec/mail/fields/resent_message_id_field_spec.rb | |
@@ -9,16 +9,16 @@ describe Mail::ResentMessageIdField do | |
it "should accept a string with the field name" do | |
t = Mail::ResentMessageIdField.new('Resent-Message-ID: <[email protected]>') | |
- t.name.should == 'Resent-Message-ID' | |
- t.value.should == '<[email protected]>' | |
- t.message_id.should == '[email protected]' | |
+ t.name.should eq 'Resent-Message-ID' | |
+ t.value.should eq '<[email protected]>' | |
+ t.message_id.should eq '[email protected]' | |
end | |
it "should accept a string without the field name" do | |
t = Mail::ResentMessageIdField.new('<[email protected]>') | |
- t.name.should == 'Resent-Message-ID' | |
- t.value.should == '<[email protected]>' | |
- t.message_id.should == '[email protected]' | |
+ t.name.should eq 'Resent-Message-ID' | |
+ t.value.should eq '<[email protected]>' | |
+ t.message_id.should eq '[email protected]' | |
end | |
end | |
diff --git a/spec/mail/fields/resent_sender_field_spec.rb b/spec/mail/fields/resent_sender_field_spec.rb | |
index d73a5e5..534c4a4 100644 | |
--- a/spec/mail/fields/resent_sender_field_spec.rb | |
+++ b/spec/mail/fields/resent_sender_field_spec.rb | |
@@ -17,14 +17,14 @@ describe Mail::ResentSenderField do | |
it "should accept a string with the field name" do | |
t = Mail::ResentSenderField.new('Resent-Sender: Mikel Lindsaar <[email protected]>, "Bob Smith" <[email protected]>') | |
- t.name.should == 'Resent-Sender' | |
- t.value.should == 'Mikel Lindsaar <[email protected]>, "Bob Smith" <[email protected]>' | |
+ t.name.should eq 'Resent-Sender' | |
+ t.value.should eq 'Mikel Lindsaar <[email protected]>, "Bob Smith" <[email protected]>' | |
end | |
it "should accept a string without the field name" do | |
t = Mail::ResentSenderField.new('Mikel Lindsaar <[email protected]>, "Bob Smith" <[email protected]>') | |
- t.name.should == 'Resent-Sender' | |
- t.value.should == 'Mikel Lindsaar <[email protected]>, "Bob Smith" <[email protected]>' | |
+ t.name.should eq 'Resent-Sender' | |
+ t.value.should eq 'Mikel Lindsaar <[email protected]>, "Bob Smith" <[email protected]>' | |
end | |
end | |
@@ -34,22 +34,22 @@ describe Mail::ResentSenderField do | |
describe "instance methods" do | |
it "should return an address" do | |
t = Mail::ResentSenderField.new('Mikel Lindsaar <[email protected]>') | |
- t.formatted.should == ['Mikel Lindsaar <[email protected]>'] | |
+ t.formatted.should eq ['Mikel Lindsaar <[email protected]>'] | |
end | |
it "should return two addresses" do | |
t = Mail::ResentSenderField.new('Mikel Lindsaar <[email protected]>') | |
- t.address.to_s.should == 'Mikel Lindsaar <[email protected]>' | |
+ t.address.to_s.should eq 'Mikel Lindsaar <[email protected]>' | |
end | |
it "should return the formatted line on to_s" do | |
t = Mail::ResentSenderField.new('Mikel Lindsaar <[email protected]>') | |
- t.value.should == 'Mikel Lindsaar <[email protected]>' | |
+ t.value.should eq 'Mikel Lindsaar <[email protected]>' | |
end | |
it "should return the encoded line" do | |
t = Mail::ResentSenderField.new('Mikel Lindsaar <[email protected]>') | |
- t.encoded.should == "Resent-Sender: Mikel Lindsaar <[email protected]>\r\n" | |
+ t.encoded.should eq "Resent-Sender: Mikel Lindsaar <[email protected]>\r\n" | |
end | |
end | |
diff --git a/spec/mail/fields/resent_to_field_spec.rb b/spec/mail/fields/resent_to_field_spec.rb | |
index 5bb584b..023d95b 100644 | |
--- a/spec/mail/fields/resent_to_field_spec.rb | |
+++ b/spec/mail/fields/resent_to_field_spec.rb | |
@@ -17,14 +17,14 @@ describe Mail::ResentToField do | |
it "should accept a string with the field name" do | |
t = Mail::ResentToField.new('Resent-To: Mikel Lindsaar <[email protected]>, "Bob Smith" <[email protected]>') | |
- t.name.should == 'Resent-To' | |
- t.value.should == 'Mikel Lindsaar <[email protected]>, "Bob Smith" <[email protected]>' | |
+ t.name.should eq 'Resent-To' | |
+ t.value.should eq 'Mikel Lindsaar <[email protected]>, "Bob Smith" <[email protected]>' | |
end | |
it "should accept a string without the field name" do | |
t = Mail::ResentToField.new('Mikel Lindsaar <[email protected]>, "Bob Smith" <[email protected]>') | |
- t.name.should == 'Resent-To' | |
- t.value.should == 'Mikel Lindsaar <[email protected]>, "Bob Smith" <[email protected]>' | |
+ t.name.should eq 'Resent-To' | |
+ t.value.should eq 'Mikel Lindsaar <[email protected]>, "Bob Smith" <[email protected]>' | |
end | |
end | |
@@ -34,30 +34,30 @@ describe Mail::ResentToField do | |
describe "instance methods" do | |
it "should return an address" do | |
t = Mail::ResentToField.new('Mikel Lindsaar <[email protected]>') | |
- t.formatted.should == ['Mikel Lindsaar <[email protected]>'] | |
+ t.formatted.should eq ['Mikel Lindsaar <[email protected]>'] | |
end | |
it "should return two addresses" do | |
t = Mail::ResentToField.new('Mikel Lindsaar <[email protected]>, Ada Lindsaar <[email protected]>') | |
- t.formatted.first.should == 'Mikel Lindsaar <[email protected]>' | |
- t.addresses.last.should == '[email protected]' | |
+ t.formatted.first.should eq 'Mikel Lindsaar <[email protected]>' | |
+ t.addresses.last.should eq '[email protected]' | |
end | |
it "should return one address and a group" do | |
t = Mail::ResentToField.new('[email protected], my_group: [email protected], [email protected];') | |
- t.addresses[0].should == '[email protected]' | |
- t.addresses[1].should == '[email protected]' | |
- t.addresses[2].should == '[email protected]' | |
+ t.addresses[0].should eq '[email protected]' | |
+ t.addresses[1].should eq '[email protected]' | |
+ t.addresses[2].should eq '[email protected]' | |
end | |
it "should return the formatted line on to_s" do | |
t = Mail::ResentToField.new('[email protected], my_group: [email protected], [email protected];') | |
- t.value.should == '[email protected], my_group: [email protected], [email protected];' | |
+ t.value.should eq '[email protected], my_group: [email protected], [email protected];' | |
end | |
it "should return the encoded line" do | |
t = Mail::ResentToField.new('[email protected], my_group: [email protected], [email protected];') | |
- t.encoded.should == "Resent-To: [email protected], \r\n\smy_group: [email protected], \r\n\[email protected];\r\n" | |
+ t.encoded.should eq "Resent-To: [email protected], \r\n\smy_group: [email protected], \r\n\[email protected];\r\n" | |
end | |
end | |
diff --git a/spec/mail/fields/return_path_field_spec.rb b/spec/mail/fields/return_path_field_spec.rb | |
index 34dc8e2..bf73914 100644 | |
--- a/spec/mail/fields/return_path_field_spec.rb | |
+++ b/spec/mail/fields/return_path_field_spec.rb | |
@@ -3,17 +3,17 @@ require 'spec_helper' | |
describe Mail::ReturnPathField do | |
it "should allow you to specify a field" do | |
rp = Mail::ReturnPathField.new('Return-Path: [email protected]') | |
- rp.address.should == '[email protected]' | |
+ rp.address.should eq '[email protected]' | |
end | |
it "should encode the addr_spec in <>" do | |
rp = Mail::ReturnPathField.new('Return-Path: [email protected]') | |
- rp.encoded.should == "Return-Path: <[email protected]>\r\n" | |
+ rp.encoded.should eq "Return-Path: <[email protected]>\r\n" | |
end | |
it "should accept <>" do | |
rp = Mail::ReturnPathField.new('<>') | |
- rp.encoded.should == "Return-Path: <>\r\n" | |
+ rp.encoded.should eq "Return-Path: <>\r\n" | |
end | |
it "should set the return path" do | |
@@ -25,7 +25,7 @@ describe Mail::ReturnPathField do | |
message_id "<[email protected]>" | |
body "body" | |
end | |
- mail.return_path.should == "[email protected]" | |
+ mail.return_path.should eq "[email protected]" | |
end | |
it "should set the return path" do | |
@@ -38,7 +38,7 @@ describe Mail::ReturnPathField do | |
body "body" | |
end | |
encoded_mail = Mail.new(mail.encoded) | |
- encoded_mail.return_path.should == "[email protected]" | |
+ encoded_mail.return_path.should eq "[email protected]" | |
end | |
it "should wrap the return path addr_spec in <>" do | |
diff --git a/spec/mail/fields/sender_field_spec.rb b/spec/mail/fields/sender_field_spec.rb | |
index 8f67c2d..19ba74a 100644 | |
--- a/spec/mail/fields/sender_field_spec.rb | |
+++ b/spec/mail/fields/sender_field_spec.rb | |
@@ -17,14 +17,14 @@ describe Mail::SenderField do | |
it "should accept a string with the field name" do | |
t = Mail::SenderField.new('Sender: Mikel Lindsaar <[email protected]>, "Bob Smith" <[email protected]>') | |
- t.name.should == 'Sender' | |
- t.value.should == 'Mikel Lindsaar <[email protected]>, "Bob Smith" <[email protected]>' | |
+ t.name.should eq 'Sender' | |
+ t.value.should eq 'Mikel Lindsaar <[email protected]>, "Bob Smith" <[email protected]>' | |
end | |
it "should accept a string without the field name" do | |
t = Mail::SenderField.new('Mikel Lindsaar <[email protected]>, "Bob Smith" <[email protected]>') | |
- t.name.should == 'Sender' | |
- t.value.should == 'Mikel Lindsaar <[email protected]>, "Bob Smith" <[email protected]>' | |
+ t.name.should eq 'Sender' | |
+ t.value.should eq 'Mikel Lindsaar <[email protected]>, "Bob Smith" <[email protected]>' | |
end | |
end | |
@@ -34,22 +34,22 @@ describe Mail::SenderField do | |
describe "instance methods" do | |
it "should return an address" do | |
t = Mail::SenderField.new('Mikel Lindsaar <[email protected]>') | |
- t.formatted.should == ['Mikel Lindsaar <[email protected]>'] | |
+ t.formatted.should eq ['Mikel Lindsaar <[email protected]>'] | |
end | |
it "should return two addresses" do | |
t = Mail::SenderField.new('Mikel Lindsaar <[email protected]>') | |
- t.address.to_s.should == 'Mikel Lindsaar <[email protected]>' | |
+ t.address.to_s.should eq 'Mikel Lindsaar <[email protected]>' | |
end | |
it "should return the formatted line on to_s" do | |
t = Mail::SenderField.new('Mikel Lindsaar <[email protected]>') | |
- t.value.should == 'Mikel Lindsaar <[email protected]>' | |
+ t.value.should eq 'Mikel Lindsaar <[email protected]>' | |
end | |
it "should return the encoded line" do | |
t = Mail::SenderField.new('Mikel Lindsaar <[email protected]>') | |
- t.encoded.should == "Sender: Mikel Lindsaar <[email protected]>\r\n" | |
+ t.encoded.should eq "Sender: Mikel Lindsaar <[email protected]>\r\n" | |
end | |
end | |
diff --git a/spec/mail/fields/structured_field_spec.rb b/spec/mail/fields/structured_field_spec.rb | |
index a5fc0a6..935cafc 100644 | |
--- a/spec/mail/fields/structured_field_spec.rb | |
+++ b/spec/mail/fields/structured_field_spec.rb | |
@@ -22,12 +22,12 @@ describe Mail::StructuredField do | |
end | |
it "should provide access to the text of the field once set" do | |
- @field.value.should == "[email protected]" | |
+ @field.value.should eq "[email protected]" | |
end | |
it "should provide a means to change the value" do | |
@field.value = "[email protected]" | |
- @field.value.should == "[email protected]" | |
+ @field.value.should eq "[email protected]" | |
end | |
end | |
@@ -38,25 +38,25 @@ describe Mail::StructuredField do | |
end | |
it "should provide a to_s function that returns the decoded string" do | |
- @field.to_s.should == "[email protected]" | |
+ @field.to_s.should eq "[email protected]" | |
end | |
it "should return '' on to_s if there is no value" do | |
@field.value = nil | |
- @field.encoded.should == '' | |
+ @field.encoded.should eq '' | |
end | |
it "should give an encoded value ready to insert into an email" do | |
- @field.encoded.should == "From: [email protected]\r\n" | |
+ @field.encoded.should eq "From: [email protected]\r\n" | |
end | |
it "should return an empty string on encoded if it has no value" do | |
@field.value = nil | |
- @field.encoded.should == '' | |
+ @field.encoded.should eq '' | |
end | |
it "should return the field name and value in proper format when called to_s" do | |
- @field.encoded.should == "From: [email protected]\r\n" | |
+ @field.encoded.should eq "From: [email protected]\r\n" | |
end | |
end | |
@@ -69,4 +69,4 @@ describe Mail::StructuredField do | |
end | |
end | |
-end | |
\ No newline at end of file | |
+end | |
diff --git a/spec/mail/fields/to_field_spec.rb b/spec/mail/fields/to_field_spec.rb | |
index df43b11..5d7e809 100644 | |
--- a/spec/mail/fields/to_field_spec.rb | |
+++ b/spec/mail/fields/to_field_spec.rb | |
@@ -18,14 +18,14 @@ describe Mail::ToField do | |
it "should accept a string with the field name" do | |
t = Mail::ToField.new('To: Mikel Lindsaar <[email protected]>, "Bob Smith" <[email protected]>') | |
- t.name.should == 'To' | |
- t.value.should == 'Mikel Lindsaar <[email protected]>, "Bob Smith" <[email protected]>' | |
+ t.name.should eq 'To' | |
+ t.value.should eq 'Mikel Lindsaar <[email protected]>, "Bob Smith" <[email protected]>' | |
end | |
it "should accept a string without the field name" do | |
t = Mail::ToField.new('Mikel Lindsaar <[email protected]>, "Bob Smith" <[email protected]>') | |
- t.name.should == 'To' | |
- t.value.should == 'Mikel Lindsaar <[email protected]>, "Bob Smith" <[email protected]>' | |
+ t.name.should eq 'To' | |
+ t.value.should eq 'Mikel Lindsaar <[email protected]>, "Bob Smith" <[email protected]>' | |
end | |
end | |
@@ -35,50 +35,50 @@ describe Mail::ToField do | |
describe "instance methods" do | |
it "should return an address" do | |
t = Mail::ToField.new('Mikel Lindsaar <[email protected]>') | |
- t.formatted.should == ['Mikel Lindsaar <[email protected]>'] | |
+ t.formatted.should eq ['Mikel Lindsaar <[email protected]>'] | |
end | |
it "should return two addresses" do | |
t = Mail::ToField.new('Mikel Lindsaar <[email protected]>, Ada Lindsaar <[email protected]>') | |
- t.formatted.first.should == 'Mikel Lindsaar <[email protected]>' | |
- t.addresses.last.should == '[email protected]' | |
+ t.formatted.first.should eq 'Mikel Lindsaar <[email protected]>' | |
+ t.addresses.last.should eq '[email protected]' | |
end | |
it "should return one address and a group" do | |
t = Mail::ToField.new('[email protected], my_group: [email protected], [email protected];') | |
- t.addresses[0].should == '[email protected]' | |
- t.addresses[1].should == '[email protected]' | |
- t.addresses[2].should == '[email protected]' | |
+ t.addresses[0].should eq '[email protected]' | |
+ t.addresses[1].should eq '[email protected]' | |
+ t.addresses[2].should eq '[email protected]' | |
end | |
it "should return the formatted line on to_s" do | |
t = Mail::ToField.new('[email protected], my_group: [email protected], [email protected];') | |
- t.value.should == '[email protected], my_group: [email protected], [email protected];' | |
+ t.value.should eq '[email protected], my_group: [email protected], [email protected];' | |
end | |
it "should return the encoded line" do | |
t = Mail::ToField.new('[email protected], my_group: [email protected], [email protected];') | |
- t.encoded.should == "To: [email protected], \r\n\smy_group: [email protected], \r\n\[email protected];\r\n" | |
+ t.encoded.should eq "To: [email protected], \r\n\smy_group: [email protected], \r\n\[email protected];\r\n" | |
end | |
it "should return the decoded line" do | |
t = Mail::ToField.new('[email protected], my_group: [email protected], [email protected];') | |
- t.decoded.should == "[email protected], my_group: [email protected], [email protected];" | |
+ t.decoded.should eq "[email protected], my_group: [email protected], [email protected];" | |
end | |
it "should get multiple address out from a group list" do | |
t = Mail::ToField.new('[email protected], my_group: [email protected], [email protected];') | |
- t.addresses.should == ["[email protected]", "[email protected]", "[email protected]"] | |
+ t.addresses.should eq ["[email protected]", "[email protected]", "[email protected]"] | |
end | |
it "should handle commas in the address" do | |
t = Mail::ToField.new('"Long, stupid email address" <[email protected]>') | |
- t.addresses.should == ["[email protected]"] | |
+ t.addresses.should eq ["[email protected]"] | |
end | |
it "should handle commas in the address for multiple fields" do | |
t = Mail::ToField.new('"Long, stupid email address" <[email protected]>, "Another, really, really, long, stupid email address" <[email protected]>') | |
- t.addresses.should == ["[email protected]", "[email protected]"] | |
+ t.addresses.should eq ["[email protected]", "[email protected]"] | |
end | |
end | |
diff --git a/spec/mail/fields/unstructured_field_spec.rb b/spec/mail/fields/unstructured_field_spec.rb | |
index 48e39ef..5bfc36a 100644 | |
--- a/spec/mail/fields/unstructured_field_spec.rb | |
+++ b/spec/mail/fields/unstructured_field_spec.rb | |
@@ -22,12 +22,12 @@ describe Mail::UnstructuredField do | |
end | |
it "should provide access to the text of the field once set" do | |
- @field.value.should == "Hello Frank" | |
+ @field.value.should eq "Hello Frank" | |
end | |
it "should provide a means to change the value" do | |
@field.value = "Goodbye Frank" | |
- @field.value.should == "Goodbye Frank" | |
+ @field.value.should eq "Goodbye Frank" | |
end | |
end | |
@@ -38,59 +38,59 @@ describe Mail::UnstructuredField do | |
end | |
it "should provide a to_s function that returns the field name and value" do | |
- @field.value.should == "Hello Frank" | |
+ @field.value.should eq "Hello Frank" | |
end | |
it "should return '' on to_s if there is no value" do | |
@field.value = nil | |
- @field.encoded.should == '' | |
+ @field.encoded.should eq '' | |
end | |
it "should give an encoded value ready to insert into an email" do | |
- @field.encoded.should == "Subject: Hello Frank\r\n" | |
+ @field.encoded.should eq "Subject: Hello Frank\r\n" | |
end | |
it "should return nil on encoded if it has no value" do | |
@field.value = nil | |
- @field.encoded.should == '' | |
+ @field.encoded.should eq '' | |
end | |
it "should give an decoded value ready to insert into an email" do | |
- @field.decoded.should == "Hello Frank" | |
+ @field.decoded.should eq "Hello Frank" | |
end | |
it "should return a nil on decoded if it has no value" do | |
@field.value = nil | |
- @field.decoded.should == nil | |
+ @field.decoded.should eq nil | |
end | |
it "should just add the CRLF at the end of the line" do | |
@field = Mail::SubjectField.new("Subject: =?utf-8?Q?testing_testing_=D6=A4?=") | |
result = "Subject: =?UTF8?Q?testing_testing_=D6=A4?=\r\n" | |
- @field.encoded.gsub("UTF-8", "UTF8").should == result | |
- @field.decoded.should == "testing testing \326\244" | |
+ @field.encoded.gsub("UTF-8", "UTF8").should eq result | |
+ @field.decoded.should eq "testing testing \326\244" | |
end | |
it "should do encoded-words encoding correctly without extra equal sign" do | |
@field = Mail::SubjectField.new("testing testing æøå") | |
result = "Subject: =?UTF8?Q?testing_testing_=C3=A6=C3=B8=C3=A5?=\r\n" | |
- @field.encoded.gsub("UTF-8", "UTF8").should == result | |
- @field.decoded.should == "testing testing æøå" | |
+ @field.encoded.gsub("UTF-8", "UTF8").should eq result | |
+ @field.decoded.should eq "testing testing æøå" | |
end | |
it "should encode the space between two adjacent encoded-words" do | |
@field = Mail::SubjectField.new("Her er æ ø å") | |
result = "Subject: =?UTF8?Q?Her_er_=C3=A6_=C3=B8_=C3=A5?=\r\n" | |
- @field.encoded.gsub("UTF-8", "UTF8").should == result | |
- @field.decoded.should == "Her er æ ø å" | |
+ @field.encoded.gsub("UTF-8", "UTF8").should eq result | |
+ @field.decoded.should eq "Her er æ ø å" | |
end | |
it "should encode additional special characters inside encoded-word-encoded strings" do | |
string = %Q(Her er æ()<>@,;:\\"/[]?.=) | |
@field = Mail::SubjectField.new(string) | |
result = %Q(Subject: =?UTF8?Q?Her_er_=C3=A6=28=29<>@,;:\\=22/[]=3F.=3D?=\r\n) | |
- @field.encoded.gsub("UTF-8", "UTF8").should == result | |
- @field.decoded.should == string | |
+ @field.encoded.gsub("UTF-8", "UTF8").should eq result | |
+ @field.decoded.should eq string | |
end | |
end | |
@@ -98,13 +98,13 @@ describe Mail::UnstructuredField do | |
it "should not fold itself if it is 78 chracters long" do | |
@field = Mail::UnstructuredField.new("Subject", "This is a subject header message that is _exactly_ 78 characters....") | |
- @field.encoded.should == "Subject: This is a subject header message that is _exactly_ 78 characters....\r\n" | |
+ @field.encoded.should eq "Subject: This is a subject header message that is _exactly_ 78 characters....\r\n" | |
end | |
it "should fold itself if it is 79 chracters long" do | |
@field = Mail::UnstructuredField.new("Subject", "This is a subject header message that is absolutely 79 characters long") | |
result = "Subject: This is a subject header message that is absolutely 79 characters\r\n\slong\r\n" | |
- @field.encoded.should == result | |
+ @field.encoded.should eq result | |
end | |
it "should fold itself if it is 997 chracters long" do | |
@@ -137,8 +137,8 @@ describe Mail::UnstructuredField do | |
$KCODE = 'u' | |
end | |
result = "Subject: =?UTF8?Q?This_is_=E3=81=82_really_long_string_This_is_=E3=81=82?=\r\n\s=?UTF8?Q?_really_long_string_This_is_=E3=81=82_really_long_string_This_is?=\r\n\s=?UTF8?Q?_=E3=81=82_really_long_string_This_is_=E3=81=82_really_long_string?=\r\n" | |
- @field.encoded.gsub("UTF-8", "UTF8").should == result | |
- @field.decoded.should == string | |
+ @field.encoded.gsub("UTF-8", "UTF8").should eq result | |
+ @field.decoded.should eq string | |
$KCODE = @original if RUBY_VERSION < '1.9' | |
end | |
@@ -152,8 +152,8 @@ describe Mail::UnstructuredField do | |
$KCODE = 'u' | |
end | |
result = "X-SMTPAPI: {\"unique_args\": {\"mailing_id\":147,\"account_id\":2}, \"to\":\r\n\s[\"[email protected]\"], \"category\": \"mailing\", \"filters\": {\"domainkeys\":\r\n\s{\"settings\": {\"domain\":1,\"enable\":1}}}, \"sub\": {\"{{open_image_url}}\":\r\n\s[\"http://betaling.larspind.local/O/token/147/Mailing::FakeRecipient\"],\r\n\s\"{{name}}\": [\"[FIRST NAME]\"], \"{{signup_reminder}}\": [\"(her kommer til at\r\n\s=?UTF8?Q?st=C3=A5_hvorn=C3=A5r_folk_har_skrevet_sig_op_...=29=22],?=\r\n\s\"{{unsubscribe_url}}\":\r\n\s[\"http://betaling.larspind.local/U/token/147/Mailing::FakeRecipient\"],\r\n\s\"{{email}}\": [\"[email protected]\"], \"{{link:308}}\":\r\n\s[\"http://betaling.larspind.local/L/308/0/Mailing::FakeRecipient\"],\r\n\s\"{{confirm_url}}\": [\"\"], \"{{ref}}\": [\"[REF]\"]}}\r\n" | |
- @field.encoded.gsub("UTF-8", "UTF8").should == result | |
- @field.decoded.should == string | |
+ @field.encoded.gsub("UTF-8", "UTF8").should eq result | |
+ @field.decoded.should eq string | |
$KCODE = @original if RUBY_VERSION < '1.9' | |
end | |
@@ -163,14 +163,16 @@ describe Mail::UnstructuredField do | |
it "should encode an ascii string that has carriage returns if asked to" do | |
result = "Subject: =0Aasdf=0A\r\n" | |
@field = Mail::UnstructuredField.new("Subject", "\nasdf\n") | |
- @field.encoded.should == "Subject: =0Aasdf=0A\r\n" | |
+ @field.encoded.should eq "Subject: =0Aasdf=0A\r\n" | |
end | |
end | |
describe "iso-2022-jp Subject" do | |
- @field = Mail::UnstructuredField.new("Subject", "あいうえお") | |
- @field.charset = 'iso-2022-jp' | |
- expect = (RUBY_VERSION < '1.9') ? "Subject: =?ISO-2022-JP?Q?=E3=81=82=E3=81=84=E3=81=86=E3=81=88=E3=81=8A?=\r\n" : "Subject: =?ISO-2022-JP?Q?=1B$B$=22$$$&$=28$*=1B=28B?=\r\n" | |
- @field.encoded.should == expect | |
+ it "should encoded with ISO-2022-JP encoding" do | |
+ @field = Mail::UnstructuredField.new("Subject", "あいうえお") | |
+ @field.charset = 'iso-2022-jp' | |
+ expect = (RUBY_VERSION < '1.9') ? "Subject: =?ISO-2022-JP?Q?=E3=81=82=E3=81=84=E3=81=86=E3=81=88=E3=81=8A?=\r\n" : "Subject: =?ISO-2022-JP?Q?=1B$B$=22$$$&$=28$*=1B=28B?=\r\n" | |
+ @field.encoded.should eq expect | |
+ end | |
end | |
end | |
diff --git a/spec/mail/header_spec.rb b/spec/mail/header_spec.rb | |
index 8bbeb2c..24b8834 100644 | |
--- a/spec/mail/header_spec.rb | |
+++ b/spec/mail/header_spec.rb | |
@@ -19,7 +19,7 @@ describe Mail::Header do | |
it "should save away the raw source of the header that it is passed" do | |
header = Mail::Header.new("To: Mikel\r\nFrom: bob\r\n") | |
- header.raw_source.should == "To: Mikel\r\nFrom: bob\r\n" | |
+ header.raw_source.should eq "To: Mikel\r\nFrom: bob\r\n" | |
end | |
it "should say if it has a message_id field defined" do | |
@@ -44,13 +44,13 @@ describe Mail::Header do | |
it "should know it's own charset" do | |
header = Mail::Header.new("To: Mikel\r\nFrom: bob\r\nContent-ID: <[email protected]>") | |
- header.charset.should == nil | |
+ header.charset.should eq nil | |
end | |
it "should know it's own charset if set" do | |
header = Mail::Header.new | |
header['content-type'] = 'text/plain; charset=utf-8' | |
- header.charset.should == 'utf-8' | |
+ header.charset.should eq 'utf-8' | |
end | |
it "shouldn't die when queried for a charset and the content-type header is invalid" do | |
@@ -64,164 +64,164 @@ describe Mail::Header do | |
it "should recognise a bcc field" do | |
header = Mail::Header.new | |
header['bcc'] = '[email protected]' | |
- header['bcc'].field.class.should == Mail::BccField | |
+ header['bcc'].field.class.should eq Mail::BccField | |
end | |
it "should recognise a cc field" do | |
header = Mail::Header.new | |
header['cc'] = '[email protected]' | |
- header['cc'].field.class.should == Mail::CcField | |
+ header['cc'].field.class.should eq Mail::CcField | |
end | |
it "should recognise a content-description field" do | |
header = Mail::Header.new | |
header['content-description'] = 'Text' | |
- header['content-description'].field.class.should == Mail::ContentDescriptionField | |
+ header['content-description'].field.class.should eq Mail::ContentDescriptionField | |
end | |
it "should recognise a content-disposition field" do | |
header = Mail::Header.new | |
header['content-disposition'] = 'attachment; filename=File' | |
- header['content-disposition'].field.class.should == Mail::ContentDispositionField | |
+ header['content-disposition'].field.class.should eq Mail::ContentDispositionField | |
end | |
it "should recognise an inline content-disposition field" do | |
header = Mail::Header.new | |
header['content-disposition'] = 'inline' | |
- header['content-disposition'].field.class.should == Mail::ContentDispositionField | |
+ header['content-disposition'].field.class.should eq Mail::ContentDispositionField | |
end | |
it "should recognise a content-id field" do | |
header = Mail::Header.new | |
header['content-id'] = '<[email protected]>' | |
- header['content-id'].field.class.should == Mail::ContentIdField | |
+ header['content-id'].field.class.should eq Mail::ContentIdField | |
end | |
it "should recognise a content-transfer-encoding field" do | |
header = Mail::Header.new | |
header['content-transfer-encoding'] = '7bit' | |
- header['content-transfer-encoding'].field.class.should == Mail::ContentTransferEncodingField | |
+ header['content-transfer-encoding'].field.class.should eq Mail::ContentTransferEncodingField | |
end | |
it "should recognise a content-type field" do | |
header = Mail::Header.new | |
header['content-type'] = 'text/plain' | |
- header['content-type'].field.class.should == Mail::ContentTypeField | |
+ header['content-type'].field.class.should eq Mail::ContentTypeField | |
end | |
it "should recognise a date field" do | |
header = Mail::Header.new | |
header['date'] = 'Fri, 21 Nov 1997 09:55:06 -0600' | |
- header['date'].field.class.should == Mail::DateField | |
+ header['date'].field.class.should eq Mail::DateField | |
end | |
it "should recognise a from field" do | |
header = Mail::Header.new | |
header['from'] = '[email protected]' | |
- header['from'].field.class.should == Mail::FromField | |
+ header['from'].field.class.should eq Mail::FromField | |
end | |
it "should recognise a in-reply-to field" do | |
header = Mail::Header.new | |
header['in-reply-to'] = '<[email protected]>' | |
- header['in-reply-to'].field.class.should == Mail::InReplyToField | |
+ header['in-reply-to'].field.class.should eq Mail::InReplyToField | |
end | |
it "should recognise a keywords field" do | |
header = Mail::Header.new | |
header['keywords'] = 'mikel test lindsaar net' | |
- header['keywords'].field.class.should == Mail::KeywordsField | |
+ header['keywords'].field.class.should eq Mail::KeywordsField | |
end | |
it "should recognise a message-id field" do | |
header = Mail::Header.new | |
header['message-id'] = '<[email protected]>' | |
- header['message-id'].field.class.should == Mail::MessageIdField | |
+ header['message-id'].field.class.should eq Mail::MessageIdField | |
end | |
it "should recognise a mime-version field" do | |
header = Mail::Header.new | |
header['mime-version'] = '1.0' | |
- header['mime-version'].field.class.should == Mail::MimeVersionField | |
+ header['mime-version'].field.class.should eq Mail::MimeVersionField | |
end | |
it "should recognise a received field" do | |
header = Mail::Header.new | |
header['received'] = 'from xxx.xxxx.xxx by xxx.xxxx.xxx with ESMTP id C1B953B4CB6 for <[email protected]>; Tue, 10 May 2005 15:27:05 -0500' | |
- header['received'].field.class.should == Mail::ReceivedField | |
+ header['received'].field.class.should eq Mail::ReceivedField | |
end | |
it "should recognise a references field" do | |
header = Mail::Header.new | |
header['references'] = '<[email protected]>' | |
- header['references'].field.class.should == Mail::ReferencesField | |
+ header['references'].field.class.should eq Mail::ReferencesField | |
end | |
it "should recognise a reply-to field" do | |
header = Mail::Header.new | |
header['reply-to'] = '[email protected]' | |
- header['reply-to'].field.class.should == Mail::ReplyToField | |
+ header['reply-to'].field.class.should eq Mail::ReplyToField | |
end | |
it "should recognise a resent-bcc field" do | |
header = Mail::Header.new | |
header['resent-bcc'] = '[email protected]' | |
- header['resent-bcc'].field.class.should == Mail::ResentBccField | |
+ header['resent-bcc'].field.class.should eq Mail::ResentBccField | |
end | |
it "should recognise a resent-cc field" do | |
header = Mail::Header.new | |
header['resent-cc'] = '[email protected]' | |
- header['resent-cc'].field.class.should == Mail::ResentCcField | |
+ header['resent-cc'].field.class.should eq Mail::ResentCcField | |
end | |
it "should recognise a resent-date field" do | |
header = Mail::Header.new | |
header['resent-date'] = 'Fri, 21 Nov 1997 09:55:06 -0600' | |
- header['resent-date'].field.class.should == Mail::ResentDateField | |
+ header['resent-date'].field.class.should eq Mail::ResentDateField | |
end | |
it "should recognise a resent-from field" do | |
header = Mail::Header.new | |
header['resent-from'] = '[email protected]' | |
- header['resent-from'].field.class.should == Mail::ResentFromField | |
+ header['resent-from'].field.class.should eq Mail::ResentFromField | |
end | |
it "should recognise a resent-message-id field" do | |
header = Mail::Header.new | |
header['resent-message-id'] = '<[email protected]>' | |
- header['resent-message-id'].field.class.should == Mail::ResentMessageIdField | |
+ header['resent-message-id'].field.class.should eq Mail::ResentMessageIdField | |
end | |
it "should recognise a resent-sender field" do | |
header = Mail::Header.new | |
header['resent-sender'] = '[email protected]' | |
- header['resent-sender'].field.class.should == Mail::ResentSenderField | |
+ header['resent-sender'].field.class.should eq Mail::ResentSenderField | |
end | |
it "should recognise a resent-to field" do | |
header = Mail::Header.new | |
header['resent-to'] = '[email protected]' | |
- header['resent-to'].field.class.should == Mail::ResentToField | |
+ header['resent-to'].field.class.should eq Mail::ResentToField | |
end | |
it "should recognise a return-path field" do | |
header = Mail::Header.new | |
header['return-path'] = '<[email protected]>' | |
- header['return-path'].field.class.should == Mail::ReturnPathField | |
+ header['return-path'].field.class.should eq Mail::ReturnPathField | |
end | |
it "should recognise a sender field" do | |
header = Mail::Header.new | |
header['sender'] = '[email protected]' | |
- header['sender'].field.class.should == Mail::SenderField | |
+ header['sender'].field.class.should eq Mail::SenderField | |
end | |
it "should recognise a to field" do | |
header = Mail::Header.new | |
header['to'] = '[email protected]' | |
- header['to'].field.class.should == Mail::ToField | |
+ header['to'].field.class.should eq Mail::ToField | |
end | |
it "should maintain header case" do | |
@@ -238,12 +238,12 @@ describe Mail::Header do | |
it "should split the header into separate fields" do | |
header = Mail::Header.new("To: Mikel\r\nFrom: bob\r\n") | |
- header.fields.length.should == 2 | |
+ header.fields.length.should eq 2 | |
end | |
it "should not split a wrapped header in two" do | |
header = Mail::Header.new("To: mikel lindsaar\r\n\s<mikel@lindsaar>\r\nFrom: bob\r\nSubject: This is\r\n a long\r\n\s \t \t \t badly formatted \r\n \t\t \t field") | |
- header.fields.length.should == 3 | |
+ header.fields.length.should eq 3 | |
end | |
# Header fields are lines composed of a field name, followed by a colon | |
@@ -269,38 +269,38 @@ describe Mail::Header do | |
it "should split each field into an name and value" do | |
header = Mail::Header.new("To: Mikel\r\nFrom: bob\r\n") | |
- header.fields[0].name.should == "From" | |
- header.fields[0].value.should == "bob" | |
- header.fields[1].name.should == "To" | |
- header.fields[1].value.should == "Mikel" | |
+ header.fields[0].name.should eq "From" | |
+ header.fields[0].value.should eq "bob" | |
+ header.fields[1].name.should eq "To" | |
+ header.fields[1].value.should eq "Mikel" | |
end | |
it "should split each field into an name and value - even if whitespace is missing" do | |
header = Mail::Header.new("To: Mikel\r\nFrom:bob\r\n") | |
- header.fields[0].name.should == "From" | |
- header.fields[0].value.should == "bob" | |
- header.fields[1].name.should == "To" | |
- header.fields[1].value.should == "Mikel" | |
+ header.fields[0].name.should eq "From" | |
+ header.fields[0].value.should eq "bob" | |
+ header.fields[1].name.should eq "To" | |
+ header.fields[1].value.should eq "Mikel" | |
end | |
it "should preserve the order of the fields it is given" do | |
header = Mail::Header.new | |
header.fields = ['From: [email protected]', 'To: [email protected]', 'Subject: This is a badly formed email'] | |
- header.fields[0].name.should == 'From' | |
- header.fields[1].name.should == 'To' | |
- header.fields[2].name.should == 'Subject' | |
+ header.fields[0].name.should eq 'From' | |
+ header.fields[1].name.should eq 'To' | |
+ header.fields[2].name.should eq 'Subject' | |
end | |
it "should allow you to reference each field and value by literal string name" do | |
header = Mail::Header.new("To: Mikel\r\nFrom: bob\r\n") | |
- header['To'].value.should == "Mikel" | |
- header['From'].value.should == "bob" | |
+ header['To'].value.should eq "Mikel" | |
+ header['From'].value.should eq "bob" | |
end | |
it "should return an array of fields if there is more than one match" do | |
header = Mail::Header.new | |
header.fields = ['From: [email protected]', 'X-Mail-SPAM: 15', 'X-Mail-SPAM: 23'] | |
- header['X-Mail-SPAM'].map { |x| x.value }.should == ['15', '23'] | |
+ header['X-Mail-SPAM'].map { |x| x.value }.should eq ['15', '23'] | |
end | |
it "should return nil if no value in the header" do | |
@@ -311,74 +311,82 @@ describe Mail::Header do | |
it "should add a new field if the field does not exist" do | |
header = Mail::Header.new("To: Mikel\r\nFrom: bob\r\n") | |
header['Subject'] = "G'Day!" | |
- header['Subject'].value.should == "G'Day!" | |
+ header['Subject'].value.should eq "G'Day!" | |
end | |
it "should allow you to pass in an array of raw fields" do | |
header = Mail::Header.new | |
header.fields = ['From: [email protected]', 'To: [email protected]'] | |
- header['To'].value.should == '[email protected]' | |
- header['From'].value.should == '[email protected]' | |
+ header['To'].value.should eq '[email protected]' | |
+ header['From'].value.should eq '[email protected]' | |
end | |
it "should reset the value of a single-only field if it already exists" do | |
header = Mail::Header.new("To: Mikel\r\nFrom: bob\r\n") | |
header['To'] = 'George' | |
- header['To'].value.should == "George" | |
+ header['To'].value.should eq "George" | |
end | |
it "should allow you to delete a field by setting it to nil" do | |
header = Mail::Header.new | |
header.fields = ['To: [email protected]'] | |
- header.fields.length.should == 1 | |
+ header.fields.length.should eq 1 | |
header['To'] = nil | |
- header.fields.length.should == 0 | |
+ header.fields.length.should eq 0 | |
end | |
it "should delete all matching fields found if there are multiple options" do | |
header = Mail::Header.new | |
header.fields = ['X-SPAM: 1000', 'X-SPAM: 20'] | |
header['X-SPAM'] = nil | |
- header.fields.length.should == 0 | |
+ header.fields.length.should eq 0 | |
+ end | |
+ | |
+ it "should delete only matching fields found" do | |
+ header = Mail::Header.new | |
+ header.fields = ['X-SPAM: 1000', 'X-AUTHOR: Steve'] | |
+ header['X-SPAM'] = nil | |
+ header['X-AUTHOR'].should_not be_nil | |
+ header.fields.length.should eq 1 | |
end | |
# Handle empty X-Optional header from Microsoft Exchange | |
it "should handle an empty X-* header value" do | |
header = Mail::Header.new("X-MS-TNEF-Correlator:\r\n") | |
- header.fields.length.should == 1 | |
- header['X-MS-TNEF-Correlator'].decoded.should == nil | |
- header['X-MS-TNEF-Correlator'].encoded.should == "X-MS-TNEF-Correlator: \r\n" | |
+ header.fields.length.should eq 1 | |
+ header['X-MS-TNEF-Correlator'].decoded.should eq nil | |
+ header['X-MS-TNEF-Correlator'].encoded.should eq "X-MS-TNEF-Correlator: \r\n" | |
end | |
it "should accept X- option fields from MS-Exchange" do | |
header = Mail::Header.new("X-Ms-Has-Attach:\r\nX-MS-TNEF-Correlator: \r\n") | |
- header.fields.length.should == 2 | |
- header['X-Ms-Has-Attach'].decoded.should == nil | |
- header['X-Ms-Has-Attach'].encoded.should == "X-Ms-Has-Attach: \r\n" | |
- header['X-MS-TNEF-Correlator'].decoded.should == nil | |
- header['X-MS-TNEF-Correlator'].encoded.should == "X-MS-TNEF-Correlator: \r\n" | |
+ header.fields.length.should eq 2 | |
+ header['X-Ms-Has-Attach'].decoded.should eq nil | |
+ header['X-Ms-Has-Attach'].encoded.should eq "X-Ms-Has-Attach: \r\n" | |
+ header['X-MS-TNEF-Correlator'].decoded.should eq nil | |
+ header['X-MS-TNEF-Correlator'].encoded.should eq "X-MS-TNEF-Correlator: \r\n" | |
end | |
it "should return nil if asked for the value of a non existent field" do | |
header = Mail::Header.new | |
- header['Bobs-Field'].should == nil | |
+ header['Bobs-Field'].should eq nil | |
end | |
it "should allow you to replace a from field" do | |
header = Mail::Header.new | |
- header['From'].should == nil | |
+ header['From'].should eq nil | |
header['From'] = '[email protected]' | |
- header['From'].decoded.should == '[email protected]' | |
+ header['From'].decoded.should eq '[email protected]' | |
header['From'] = '[email protected]' | |
- header['From'].decoded.should == '[email protected]' | |
+ header['From'].decoded.should eq '[email protected]' | |
end | |
it "should maintain the class of the field" do | |
header = Mail::Header.new | |
header['From'] = '[email protected]' | |
- header['From'].field.class.should == Mail::FromField | |
+ header['From'].field.class.should eq Mail::FromField | |
header['From'] = '[email protected]' | |
- header['From'].field.class.should == Mail::FromField | |
+ header['From'].field.class.should eq Mail::FromField | |
end | |
end | |
@@ -386,12 +394,12 @@ describe Mail::Header do | |
it "should unfold a header" do | |
header = Mail::Header.new("To: Mikel,\r\n Lindsaar, Bob") | |
- header['To'].value.should == 'Mikel, Lindsaar, Bob' | |
+ header['To'].value.should eq 'Mikel, Lindsaar, Bob' | |
end | |
it "should remove multiple spaces during unfolding a header" do | |
header = Mail::Header.new("To: Mikel,\r\n Lindsaar, Bob") | |
- header['To'].value.should == 'Mikel, Lindsaar, Bob' | |
+ header['To'].value.should eq 'Mikel, Lindsaar, Bob' | |
end | |
it "should handle a crazy long folded header" do | |
@@ -403,7 +411,7 @@ Received: from [127.0.220.158] (helo=fg-out-1718.google.com) | |
for [email protected]; Thu, 05 Jun 2008 10:53:29 -0700 | |
HERE | |
header = Mail::Header.new(header_text.gsub(/\n/, "\r\n")) | |
- header['Received'].value.should == 'from [127.0.220.158] (helo=fg-out-1718.google.com) by smtp.totallyrandom.com with esmtp (Exim 4.68) (envelope-from <[email protected]>) id 1K4JeQ-0005Nd-Ij for [email protected]; Thu, 05 Jun 2008 10:53:29 -0700' | |
+ header['Received'].value.should eq 'from [127.0.220.158] (helo=fg-out-1718.google.com) by smtp.totallyrandom.com with esmtp (Exim 4.68) (envelope-from <[email protected]>) id 1K4JeQ-0005Nd-Ij for [email protected]; Thu, 05 Jun 2008 10:53:29 -0700' | |
end | |
it "should convert all lonesome LFs to CRLF" do | |
@@ -415,7 +423,7 @@ Received: from [127.0.220.158] (helo=fg-out-1718.google.com) | |
for [email protected]; Thu, 05 Jun 2008 10:53:29 -0700 | |
HERE | |
header = Mail::Header.new(header_text.gsub(/\n/, "\n")) | |
- header['Received'].value.should == 'from [127.0.220.158] (helo=fg-out-1718.google.com) by smtp.totallyrandom.com with esmtp (Exim 4.68) (envelope-from <[email protected]>) id 1K4JeQ-0005Nd-Ij for [email protected]; Thu, 05 Jun 2008 10:53:29 -0700' | |
+ header['Received'].value.should eq 'from [127.0.220.158] (helo=fg-out-1718.google.com) by smtp.totallyrandom.com with esmtp (Exim 4.68) (envelope-from <[email protected]>) id 1K4JeQ-0005Nd-Ij for [email protected]; Thu, 05 Jun 2008 10:53:29 -0700' | |
end | |
it "should convert all lonesome CRs to CRLF" do | |
@@ -427,7 +435,7 @@ Received: from [127.0.220.158] (helo=fg-out-1718.google.com) | |
for [email protected]; Thu, 05 Jun 2008 10:53:29 -0700 | |
HERE | |
header = Mail::Header.new(header_text.gsub(/\n/, "\r")) | |
- header['Received'].value.should == 'from [127.0.220.158] (helo=fg-out-1718.google.com) by smtp.totallyrandom.com with esmtp (Exim 4.68) (envelope-from <[email protected]>) id 1K4JeQ-0005Nd-Ij for [email protected]; Thu, 05 Jun 2008 10:53:29 -0700' | |
+ header['Received'].value.should eq 'from [127.0.220.158] (helo=fg-out-1718.google.com) by smtp.totallyrandom.com with esmtp (Exim 4.68) (envelope-from <[email protected]>) id 1K4JeQ-0005Nd-Ij for [email protected]; Thu, 05 Jun 2008 10:53:29 -0700' | |
end | |
end | |
@@ -436,11 +444,11 @@ HERE | |
it "should collect up any of its fields' errors" do | |
header = Mail::Header.new("Content-Transfer-Encoding: vlad\r\nReply-To: a b b") | |
header.errors.should_not be_blank | |
- header.errors.size.should == 2 | |
- header.errors[0][0].should == 'Content-Transfer-Encoding' | |
- header.errors[0][1].should == 'vlad' | |
- header.errors[1][0].should == 'Reply-To' | |
- header.errors[1][1].should == 'a b b' | |
+ header.errors.size.should eq 2 | |
+ header.errors[0][0].should eq 'Content-Transfer-Encoding' | |
+ header.errors[0][1].should eq 'vlad' | |
+ header.errors[1][0].should eq 'Reply-To' | |
+ header.errors[1][1].should eq 'a b b' | |
end | |
end | |
@@ -450,7 +458,7 @@ HERE | |
header = Mail::Header.new | |
header[field] = "Thu, 05 Jun 2008 10:53:29 -0700" | |
header[field] = "Mon, 15 Nov 2010 11:05:29 -1100" | |
- header[field].value.should == "Mon, 15 Nov 2010 11:05:29 -1100" | |
+ header[field].value.should eq "Mon, 15 Nov 2010 11:05:29 -1100" | |
end | |
end | |
@@ -459,7 +467,7 @@ HERE | |
header = Mail::Header.new | |
header[field] = "[email protected]" | |
header[field] = "[email protected]" | |
- header[field].value.should == "[email protected]" | |
+ header[field].value.should eq "[email protected]" | |
end | |
end | |
@@ -475,7 +483,7 @@ HERE | |
header = Mail::Header.new | |
header[field] = "1234" | |
header[field] = "5678" | |
- header[field].map { |x| x.value }.should == ["1234", "5678"] | |
+ header[field].map { |x| x.value }.should eq ["1234", "5678"] | |
end | |
end | |
@@ -483,9 +491,9 @@ HERE | |
header = Mail::Header.new | |
header.fields = ['X-Mail-SPAM: 15', 'X-Mail-SPAM: 20'] | |
header['X-Mail-SPAM'] = '10000' | |
- header['X-Mail-SPAM'].map { |x| x.value }.should == ['15', '20', '10000'] | |
+ header['X-Mail-SPAM'].map { |x| x.value }.should eq ['15', '20', '10000'] | |
header['X-Mail-SPAM'] = nil | |
- header['X-Mail-SPAM'].should == nil | |
+ header['X-Mail-SPAM'].should eq nil | |
end | |
end | |
@@ -503,18 +511,18 @@ TRACEHEADER | |
end | |
it "should instantiate one trace field object per header" do | |
- @traced_header.fields.length.should == 5 | |
+ @traced_header.fields.length.should eq 5 | |
end | |
it "should add a new received header after the other received headers if they exist" do | |
@traced_header['To'] = "Mikel" | |
@traced_header['Received'] = "from agw2 by xxx.xxxx.xxx; Sun, 8 May 2005 12:30:13 -0500" | |
- @traced_header.fields[0].addresses.should == ['[email protected]'] | |
- @traced_header.fields[1].info.should == 'from xxx.xxxx.xxx by xxx.xxxx.xxx with ESMTP id 6AAEE3B4D23 for <[email protected]>' | |
- @traced_header.fields[2].info.should == 'from xxx.xxxx.xxx by xxx.xxxx.xxx with ESMTP id j48HUC213279 for <[email protected]>' | |
- @traced_header.fields[3].info.should == 'from conversion-xxx.xxxx.xxx.net by xxx.xxxx.xxx id <[email protected]> for <[email protected]>' | |
- @traced_header.fields[5].info.should == "from agw2 by xxx.xxxx.xxx" | |
- @traced_header.fields[6].field.class.should == Mail::ToField | |
+ @traced_header.fields[0].addresses.should eq ['[email protected]'] | |
+ @traced_header.fields[1].info.should eq 'from xxx.xxxx.xxx by xxx.xxxx.xxx with ESMTP id 6AAEE3B4D23 for <[email protected]>' | |
+ @traced_header.fields[2].info.should eq 'from xxx.xxxx.xxx by xxx.xxxx.xxx with ESMTP id j48HUC213279 for <[email protected]>' | |
+ @traced_header.fields[3].info.should eq 'from conversion-xxx.xxxx.xxx.net by xxx.xxxx.xxx id <[email protected]> for <[email protected]>' | |
+ @traced_header.fields[5].info.should eq "from agw2 by xxx.xxxx.xxx" | |
+ @traced_header.fields[6].field.class.should eq Mail::ToField | |
end | |
end | |
@@ -523,7 +531,7 @@ TRACEHEADER | |
it "should output a parsed version of itself to US-ASCII on encoded and tidy up and sort correctly" do | |
header = Mail::Header.new("To: Mikel\r\n\sLindsaar <[email protected]>\r\nFrom: bob\r\n\s<[email protected]>\r\nSubject: This is\r\n a long\r\n\s \t \t \t badly formatted \r\n \t\t \t field") | |
result = "From: bob <[email protected]>\r\nTo: Mikel Lindsaar <[email protected]>\r\nSubject: This is a long badly formatted field\r\n" | |
- header.encoded.should == result | |
+ header.encoded.should eq result | |
end | |
end | |
@@ -556,32 +564,32 @@ TRACEHEADER | |
describe "mime version handling" do | |
it "should return the mime version of the email" do | |
header = Mail::Header.new("Mime-Version: 1.0") | |
- header['mime-version'].value.should == '1.0' | |
+ header['mime-version'].value.should eq '1.0' | |
end | |
it "should return nil if no mime-version header field" do | |
header = Mail::Header.new('To: bob') | |
- header['mime_version'].should == nil | |
+ header['mime_version'].should eq nil | |
end | |
it "should return the transfer-encoding of the email" do | |
header = Mail::Header.new("Content-Transfer-Encoding: Base64") | |
- header['content-transfer-encoding'].value.should == 'Base64' | |
+ header['content-transfer-encoding'].value.should eq 'Base64' | |
end | |
it "should return nil if no transfer-encoding header field" do | |
header = Mail::Header.new | |
- header['content-transfer-encoding'].should == nil | |
+ header['content-transfer-encoding'].should eq nil | |
end | |
it "should return the content-description of the email" do | |
header = Mail::Header.new("Content-Description: This is a description") | |
- header['Content-Description'].value.should == 'This is a description' | |
+ header['Content-Description'].value.should eq 'This is a description' | |
end | |
it "should return nil if no content-description header field" do | |
header = Mail::Header.new | |
- header['Content-Description'].should == nil | |
+ header['Content-Description'].should eq nil | |
end | |
end | |
diff --git a/spec/mail/mail_spec.rb b/spec/mail/mail_spec.rb | |
index 24840c1..a8bc238 100644 | |
--- a/spec/mail/mail_spec.rb | |
+++ b/spec/mail/mail_spec.rb | |
@@ -8,7 +8,7 @@ describe "mail" do | |
end | |
it "should be able to make a new email" do | |
- Mail.new.class.should == Mail::Message | |
+ Mail.new.class.should eq Mail::Message | |
end | |
it "should accept headers and body" do | |
@@ -19,16 +19,16 @@ describe "mail" do | |
subject 'Hello there Mikel' | |
body 'This is a body of text' | |
end | |
- message.from.should == ['[email protected]'] | |
- message.to.should == ['[email protected]'] | |
- message.subject.should == 'Hello there Mikel' | |
- message.body.to_s.should == 'This is a body of text' | |
+ message.from.should eq ['[email protected]'] | |
+ message.to.should eq ['[email protected]'] | |
+ message.subject.should eq 'Hello there Mikel' | |
+ message.body.to_s.should eq 'This is a body of text' | |
end | |
it "should read a file" do | |
wrap_method = Mail.read(fixture('emails', 'plain_emails', 'raw_email.eml')).to_s | |
file_method = Mail.new(File.read(fixture('emails', 'plain_emails', 'raw_email.eml'))).to_s | |
- wrap_method.should == file_method | |
+ wrap_method.should eq file_method | |
end | |
-end | |
\ No newline at end of file | |
+end | |
diff --git a/spec/mail/message_spec.rb b/spec/mail/message_spec.rb | |
index a0a811f..31691f4 100644 | |
--- a/spec/mail/message_spec.rb | |
+++ b/spec/mail/message_spec.rb | |
@@ -10,7 +10,7 @@ describe Mail::Message do | |
describe "initialization" do | |
it "should instantiate empty" do | |
- Mail::Message.new.class.should == Mail::Message | |
+ Mail::Message.new.class.should eq Mail::Message | |
end | |
it "should return a basic email" do | |
@@ -18,15 +18,15 @@ describe Mail::Message do | |
mail = Mail.new(mail.to_s) | |
mail.date.should_not be_blank | |
mail.message_id.should_not be_blank | |
- mail.mime_version.should == "1.0" | |
- mail.content_type.should == "text/plain" | |
- mail.content_transfer_encoding.should == "7bit" | |
+ mail.mime_version.should eq "1.0" | |
+ mail.content_type.should eq "text/plain" | |
+ mail.content_transfer_encoding.should eq "7bit" | |
mail.subject.should be_blank | |
mail.body.should be_blank | |
end | |
it "should instantiate with a string" do | |
- Mail::Message.new(basic_email).class.should == Mail::Message | |
+ Mail::Message.new(basic_email).class.should eq Mail::Message | |
end | |
it "should allow us to pass it a block" do | |
@@ -34,14 +34,14 @@ describe Mail::Message do | |
from '[email protected]' | |
to '[email protected]' | |
end | |
- mail.from.should == ['[email protected]'] | |
- mail.to.should == ['[email protected]'] | |
+ mail.from.should eq ['[email protected]'] | |
+ mail.to.should eq ['[email protected]'] | |
end | |
it "should initialize a body and header class even if called with nothing to begin with" do | |
mail = Mail::Message.new | |
- mail.header.class.should == Mail::Header | |
- mail.body.class.should == Mail::Body | |
+ mail.header.class.should eq Mail::Header | |
+ mail.body.class.should eq Mail::Body | |
end | |
it "should not report basic emails as bounced" do | |
@@ -52,6 +52,11 @@ describe Mail::Message do | |
doing { Mail::Message.new(File.read(fixture('emails', 'plain_emails', 'basic_email.eml'))) }.should_not raise_error | |
end | |
+ it "should be able to parse an email with @ in display name" do | |
+ message = Mail::Message.new(File.read(fixture('emails', 'plain_emails', 'raw_email_with_at_display_name.eml'))) | |
+ message.to.should eq ["[email protected]", "[email protected]", "[email protected]"] | |
+ end | |
+ | |
it "should be able to parse an email with only blank lines as body" do | |
doing { Mail::Message.new(File.read(fixture('emails', 'error_emails', 'missing_body.eml'))) }.should_not raise_error | |
end | |
@@ -101,14 +106,14 @@ describe Mail::Message do | |
it "should read in an email message and basically parse it" do | |
mail = Mail::Message.new(File.read(fixture('emails', 'plain_emails', 'basic_email.eml'))) | |
- mail.to.should == ["[email protected]"] | |
+ mail.to.should eq ["[email protected]"] | |
end | |
it "should not fail parsing message with caps in content_type" do | |
mail = Mail::Message.new(File.read(fixture('emails', 'plain_emails', 'mix_caps_content_type.eml'))) | |
- mail.content_type.should == 'text/plain; charset=iso-8859-1' | |
- mail.main_type.should == 'text' | |
- mail.sub_type.should == 'plain' | |
+ mail.content_type.should eq 'text/plain; charset=iso-8859-1' | |
+ mail.main_type.should eq 'text' | |
+ mail.sub_type.should eq 'plain' | |
end | |
it "should be able to pass an empty reply-to header" do | |
@@ -116,24 +121,57 @@ describe Mail::Message do | |
mail.in_reply_to.should be_blank | |
end | |
- it "should allow serializing to YAML" do | |
- yaml = Mail::Message.new(:to => '[email protected]', :cc => '[email protected]', :bcc => '[email protected]', :body => 'body', :subject => 'subject').to_yaml | |
- yaml_output = YAML.load(yaml) | |
- yaml_output['Mime-Version'].should == "1.0" | |
- yaml_output['Cc'].should == "[email protected]" | |
- yaml_output['Subject'].should == "subject" | |
- yaml_output['body'].should == "body" | |
- yaml_output['Bcc'].should == "[email protected]" | |
- yaml_output['Content-Transfer-Encoding'].should == "7bit" | |
- yaml_output['Message-ID'].should =~ /<.+@.+>/ | |
- yaml_output['Content-Type'].should == "text/plain" | |
- yaml_output['To'].should == "[email protected]" | |
- yaml_output['Date'].should_not == '' | |
- end | |
+ describe "YAML serialization" do | |
+ before(:each) do | |
+ @yaml_mail = Mail::Message.new(:to => '[email protected]', | |
+ :cc => '[email protected]', | |
+ :bcc => '[email protected]', | |
+ :body => 'body', | |
+ :subject => 'subject') | |
+ @smtp_settings = { :address=>"smtp.somewhere.net", | |
+ :port=>"587", :domain=>"somewhere.net", :user_name=>"[email protected]", | |
+ :password=>"password", :authentication=>:plain, :enable_starttls_auto => true, | |
+ :openssl_verify_mode => nil, :ssl=>nil, :tls=>nil } | |
+ @yaml_mail.delivery_method :smtp, @smtp_settings | |
+ end | |
+ | |
+ it "should serialize the basic information to YAML" do | |
+ yaml = @yaml_mail.to_yaml | |
+ yaml_output = YAML.load(yaml) | |
+ yaml_output['headers']['To'].should eq "[email protected]" | |
+ yaml_output['headers']['Cc'].should eq "[email protected]" | |
+ yaml_output['headers']['Subject'].should eq "subject" | |
+ yaml_output['headers']['Bcc'].should eq "[email protected]" | |
+ yaml_output['@body_raw'].should eq "body" | |
+ yaml_output['@delivery_method'].should_not be_blank | |
+ end | |
+ | |
+ it "should deserialize after serializing" do | |
+ deserialized = Mail::Message.from_yaml(@yaml_mail.to_yaml) | |
+ deserialized.should eq @yaml_mail | |
+ deserialized.delivery_method.settings.should eq @smtp_settings | |
+ end | |
+ | |
+ it "should serialize a Message with a custom delivery_handler" do | |
+ @yaml_mail.delivery_handler = DeliveryAgent | |
+ yaml = @yaml_mail.to_yaml | |
+ yaml_output = YAML.load(yaml) | |
+ yaml_output['delivery_handler'].should eq "DeliveryAgent" | |
+ end | |
+ | |
+ it "should load a serialized delivery handler" do | |
+ @yaml_mail.delivery_handler = DeliveryAgent | |
+ deserialized = Mail::Message.from_yaml(@yaml_mail.to_yaml) | |
+ deserialized.delivery_handler.should eq DeliveryAgent | |
+ end | |
- it "should deserialize after serializing" do | |
- message = Mail::Message.new(:to => '[email protected]', :cc => '[email protected]', :bcc => '[email protected]', :body => 'body', :subject => 'subject') | |
- Mail::Message.from_yaml(message.to_yaml).should == message | |
+ it "should not deserialize a delivery_handler that does not exist" do | |
+ yaml = @yaml_mail.to_yaml | |
+ yaml_hash = YAML.load(yaml) | |
+ yaml_hash['delivery_handler'] = "NotARealClass" | |
+ deserialized = Mail::Message.from_yaml(yaml_hash.to_yaml) | |
+ deserialized.delivery_handler.should be_nil | |
+ end | |
end | |
end | |
@@ -144,31 +182,31 @@ describe Mail::Message do | |
it "should strip off the envelope from field if present" do | |
message = Mail::Message.new(File.read(fixture('emails', 'plain_emails', 'raw_email.eml'))) | |
- message.envelope_from.should == "[email protected]" | |
- message.envelope_date.should == ::DateTime.parse("Mon May 2 16:07:05 2005") | |
+ message.envelope_from.should eq "[email protected]" | |
+ message.envelope_date.should eq ::DateTime.parse("Mon May 2 16:07:05 2005") | |
end | |
it "should strip off the envelope from field if present" do | |
message = Mail::Message.new(File.read(fixture('emails', 'plain_emails', 'raw_email.eml'))) | |
- message.raw_envelope.should == "[email protected] Mon May 2 16:07:05 2005" | |
- message.from.should == ["[email protected]"] | |
+ message.raw_envelope.should eq "[email protected] Mon May 2 16:07:05 2005" | |
+ message.from.should eq ["[email protected]"] | |
end | |
it "should not cause any problems if there is no envelope from present" do | |
message = Mail::Message.new(File.read(fixture('emails', 'plain_emails', 'basic_email.eml'))) | |
- message.from.should == ["[email protected]"] | |
+ message.from.should eq ["[email protected]"] | |
end | |
it "should ignore a plain text body that starts with ^From" do | |
m = Mail::Message.new("From: [email protected]\r\n\r\nThis is a way to break mail by putting\r\nFrom at the start of a body\r\nor elsewhere.") | |
m.from.should_not be_nil | |
- m.from.should == ['[email protected]'] | |
+ m.from.should eq ['[email protected]'] | |
end | |
it "should handle a multipart message that has ^From in it" do | |
m = Mail::Message.new(File.read(fixture('emails', 'error_emails', 'cant_parse_from.eml'))) | |
m.from.should_not be_nil | |
- m.from.should == ["[email protected]"] | |
+ m.from.should eq ["[email protected]"] | |
m.should be_multipart | |
end | |
@@ -178,17 +216,17 @@ describe Mail::Message do | |
it "should accept some email text to parse and return an email" do | |
mail = Mail::Message.new(basic_email) | |
- mail.class.should == Mail::Message | |
+ mail.class.should eq Mail::Message | |
end | |
it "should set a raw source instance variable to equal the passed in message" do | |
mail = Mail::Message.new(basic_email) | |
- mail.raw_source.should == basic_email.strip | |
+ mail.raw_source.should eq basic_email.strip | |
end | |
it "should set the raw source instance variable to '' if no message is passed in" do | |
mail = Mail::Message.new | |
- mail.raw_source.should == "" | |
+ mail.raw_source.should eq "" | |
end | |
it "should give the header class the header to parse" do | |
@@ -236,14 +274,14 @@ describe Mail::Message do | |
it "should allow for whitespace at the start of the email" do | |
mail = Mail.new("\r\n\r\nFrom: mikel\r\n\r\nThis is the body") | |
- mail.from.should == ['mikel'] | |
- mail.body.to_s.should == 'This is the body' | |
+ mail.from.should eq ['mikel'] | |
+ mail.body.to_s.should eq 'This is the body' | |
end | |
it "should read in an email message with the word 'From' in it multiple times and parse it" do | |
mail = Mail::Message.new(File.read(fixture('emails', 'mime_emails', 'two_from_in_message.eml'))) | |
mail.to.should_not be_nil | |
- mail.to.should == ["[email protected]"] | |
+ mail.to.should eq ["[email protected]"] | |
end | |
end | |
@@ -257,21 +295,21 @@ describe Mail::Message do | |
end | |
it "should allow you to grab field objects if you really want to" do | |
- @mail.header_fields.class.should == Mail::FieldList | |
+ @mail.header_fields.class.should eq Mail::FieldList | |
end | |
it "should give you back the fields in the header" do | |
@mail['bar'] = 'abcd' | |
- @mail.header_fields.length.should == 1 | |
+ @mail.header_fields.length.should eq 1 | |
@mail['foo'] = '4321' | |
- @mail.header_fields.length.should == 2 | |
+ @mail.header_fields.length.should eq 2 | |
end | |
it "should delete a field if it is set to nil" do | |
@mail['foo'] = '4321' | |
- @mail.header_fields.length.should == 1 | |
+ @mail.header_fields.length.should eq 1 | |
@mail['foo'] = nil | |
- @mail.header_fields.length.should == 0 | |
+ @mail.header_fields.length.should eq 0 | |
end | |
end | |
@@ -284,32 +322,32 @@ describe Mail::Message do | |
it "should return the to field" do | |
@mail.to = "mikel" | |
- @mail.to.should == ["mikel"] | |
+ @mail.to.should eq ["mikel"] | |
end | |
it "should return the from field" do | |
@mail.from = "bob" | |
- @mail.from.should == ["bob"] | |
+ @mail.from.should eq ["bob"] | |
end | |
it "should return the subject" do | |
@mail.subject = "Hello!" | |
- @mail.subject.should == "Hello!" | |
+ @mail.subject.should eq "Hello!" | |
end | |
it "should return the body decoded with to_s" do | |
@mail.body "email message\r\n" | |
- @mail.body.to_s.should == "email message\n" | |
+ @mail.body.to_s.should eq "email message\n" | |
end | |
it "should return the body encoded if asked for" do | |
@mail.body "email message\r\n" | |
- @mail.body.encoded.should == "email message\r\n" | |
+ @mail.body.encoded.should eq "email message\r\n" | |
end | |
it "should return the body decoded if asked for" do | |
@mail.body "email message\r\n" | |
- @mail.body.decoded.should == "email message\n" | |
+ @mail.body.decoded.should eq "email message\n" | |
end | |
end | |
@@ -321,32 +359,32 @@ describe Mail::Message do | |
it "should return the to field" do | |
@mail.to "mikel" | |
- @mail.to.should == ["mikel"] | |
+ @mail.to.should eq ["mikel"] | |
end | |
it "should return the from field" do | |
@mail.from "bob" | |
- @mail.from.should == ["bob"] | |
+ @mail.from.should eq ["bob"] | |
end | |
it "should return the subject" do | |
@mail.subject "Hello!" | |
- @mail.subject.should == "Hello!" | |
+ @mail.subject.should eq "Hello!" | |
end | |
it "should return the body decoded with to_s" do | |
@mail.body "email message\r\n" | |
- @mail.body.to_s.should == "email message\n" | |
+ @mail.body.to_s.should eq "email message\n" | |
end | |
it "should return the body encoded if asked for" do | |
@mail.body "email message\r\n" | |
- @mail.body.encoded.should == "email message\r\n" | |
+ @mail.body.encoded.should eq "email message\r\n" | |
end | |
it "should return the body decoded if asked for" do | |
@mail.body "email message\r\n" | |
- @mail.body.decoded.should == "email message\n" | |
+ @mail.body.decoded.should eq "email message\n" | |
end | |
end | |
@@ -362,12 +400,12 @@ describe Mail::Message do | |
it "should allow you to read arbitrary headers" do | |
@mail['foo'] = 1234 | |
- @mail['foo'].value.to_s.should == '1234' | |
+ @mail['foo'].value.to_s.should eq '1234' | |
end | |
it "should instantiate a new Header" do | |
@mail['foo'] = 1234 | |
- @mail.header_fields.first.class.should == Mail::Field | |
+ @mail.header_fields.first.class.should eq Mail::Field | |
end | |
end | |
@@ -375,19 +413,19 @@ describe Mail::Message do | |
it "should allow you to replace a from field" do | |
mail = Mail.new | |
- mail.from.should == nil | |
+ mail.from.should eq nil | |
mail.from = '[email protected]' | |
- mail.from.should == ['[email protected]'] | |
+ mail.from.should eq ['[email protected]'] | |
mail.from = '[email protected]' | |
- mail.from.should == ['[email protected]'] | |
+ mail.from.should eq ['[email protected]'] | |
end | |
it "should maintain the class of the field" do | |
mail = Mail.new | |
mail.from = '[email protected]' | |
- mail[:from].field.class.should == Mail::FromField | |
+ mail[:from].field.class.should eq Mail::FromField | |
mail.from = '[email protected]' | |
- mail[:from].field.class.should == Mail::FromField | |
+ mail[:from].field.class.should eq Mail::FromField | |
end | |
end | |
@@ -425,34 +463,34 @@ describe Mail::Message do | |
body 'This is a body of text' | |
end | |
- message.bcc.should == ['[email protected]'] | |
- message.cc.should == ['[email protected]'] | |
- message.comments.should == 'this is a comment' | |
- message.date.should == DateTime.parse('12 Aug 2009 00:00:01 GMT') | |
- message.from.should == ['[email protected]'] | |
- message.in_reply_to.should == '1234@in_reply_to.lindsaar.net' | |
- message.keywords.should == ["test", "of the new mail", "system"] | |
- message.message_id.should == '1234@message_id.lindsaar.net' | |
- message.received.date_time.should == DateTime.parse('12 Aug 2009 00:00:02 GMT') | |
- message.references.should == '[email protected]' | |
- message.reply_to.should == ['[email protected]'] | |
- message.resent_bcc.should == ['[email protected]'] | |
- message.resent_cc.should == ['[email protected]'] | |
- message.resent_date.should == DateTime.parse('12 Aug 2009 00:00:03 GMT') | |
- message.resent_from.should == ['[email protected]'] | |
- message.resent_message_id.should == '1234@resent_message_id.lindsaar.net' | |
- message.resent_sender.should == ['[email protected]'] | |
- message.resent_to.should == ['[email protected]'] | |
- message.sender.should == '[email protected]' | |
- message.subject.should == 'Hello there Mikel' | |
- message.to.should == ['[email protected]'] | |
- message.content_type.should == 'text/plain; charset=UTF-8' | |
- message.content_transfer_encoding.should == '7bit' | |
- message.content_description.should == 'This is a test' | |
- message.content_disposition.should == 'attachment; filename=File' | |
- message.content_id.should == '<1234@message_id.lindsaar.net>' | |
- message.mime_version.should == '1.0' | |
- message.body.to_s.should == 'This is a body of text' | |
+ message.bcc.should eq ['[email protected]'] | |
+ message.cc.should eq ['[email protected]'] | |
+ message.comments.should eq 'this is a comment' | |
+ message.date.should eq DateTime.parse('12 Aug 2009 00:00:01 GMT') | |
+ message.from.should eq ['[email protected]'] | |
+ message.in_reply_to.should eq '1234@in_reply_to.lindsaar.net' | |
+ message.keywords.should eq ["test", "of the new mail", "system"] | |
+ message.message_id.should eq '1234@message_id.lindsaar.net' | |
+ message.received.date_time.should eq DateTime.parse('12 Aug 2009 00:00:02 GMT') | |
+ message.references.should eq '[email protected]' | |
+ message.reply_to.should eq ['[email protected]'] | |
+ message.resent_bcc.should eq ['[email protected]'] | |
+ message.resent_cc.should eq ['[email protected]'] | |
+ message.resent_date.should eq DateTime.parse('12 Aug 2009 00:00:03 GMT') | |
+ message.resent_from.should eq ['[email protected]'] | |
+ message.resent_message_id.should eq '1234@resent_message_id.lindsaar.net' | |
+ message.resent_sender.should eq ['[email protected]'] | |
+ message.resent_to.should eq ['[email protected]'] | |
+ message.sender.should eq '[email protected]' | |
+ message.subject.should eq 'Hello there Mikel' | |
+ message.to.should eq ['[email protected]'] | |
+ message.content_type.should eq 'text/plain; charset=UTF-8' | |
+ message.content_transfer_encoding.should eq '7bit' | |
+ message.content_description.should eq 'This is a test' | |
+ message.content_disposition.should eq 'attachment; filename=File' | |
+ message.content_id.should eq '<1234@message_id.lindsaar.net>' | |
+ message.mime_version.should eq '1.0' | |
+ message.body.to_s.should eq 'This is a body of text' | |
end | |
it "should accept them in assignment form" do | |
@@ -486,34 +524,34 @@ describe Mail::Message do | |
message.mime_version = '1.0' | |
message.body = 'This is a body of text' | |
- message.bcc.should == ['[email protected]'] | |
- message.cc.should == ['[email protected]'] | |
- message.comments.should == 'this is a comment' | |
- message.date.should == DateTime.parse('12 Aug 2009 00:00:01 GMT') | |
- message.from.should == ['[email protected]'] | |
- message.in_reply_to.should == '1234@in_reply_to.lindsaar.net' | |
- message.keywords.should == ["test", "of the new mail", "system"] | |
- message.message_id.should == '1234@message_id.lindsaar.net' | |
- message.received.date_time.should == DateTime.parse('12 Aug 2009 00:00:02 GMT') | |
- message.references.should == '[email protected]' | |
- message.reply_to.should == ['[email protected]'] | |
- message.resent_bcc.should == ['[email protected]'] | |
- message.resent_cc.should == ['[email protected]'] | |
- message.resent_date.should == DateTime.parse('12 Aug 2009 00:00:03 GMT') | |
- message.resent_from.should == ['[email protected]'] | |
- message.resent_message_id.should == '1234@resent_message_id.lindsaar.net' | |
- message.resent_sender.should == ['[email protected]'] | |
- message.resent_to.should == ['[email protected]'] | |
- message.sender.should == '[email protected]' | |
- message.subject.should == 'Hello there Mikel' | |
- message.to.should == ['[email protected]'] | |
- message.content_type.should == 'text/plain; charset=UTF-8' | |
- message.content_transfer_encoding.should == '7bit' | |
- message.content_description.should == 'This is a test' | |
- message.content_disposition.should == 'attachment; filename=File' | |
- message.content_id.should == '<1234@message_id.lindsaar.net>' | |
- message.mime_version.should == '1.0' | |
- message.body.to_s.should == 'This is a body of text' | |
+ message.bcc.should eq ['[email protected]'] | |
+ message.cc.should eq ['[email protected]'] | |
+ message.comments.should eq 'this is a comment' | |
+ message.date.should eq DateTime.parse('12 Aug 2009 00:00:01 GMT') | |
+ message.from.should eq ['[email protected]'] | |
+ message.in_reply_to.should eq '1234@in_reply_to.lindsaar.net' | |
+ message.keywords.should eq ["test", "of the new mail", "system"] | |
+ message.message_id.should eq '1234@message_id.lindsaar.net' | |
+ message.received.date_time.should eq DateTime.parse('12 Aug 2009 00:00:02 GMT') | |
+ message.references.should eq '[email protected]' | |
+ message.reply_to.should eq ['[email protected]'] | |
+ message.resent_bcc.should eq ['[email protected]'] | |
+ message.resent_cc.should eq ['[email protected]'] | |
+ message.resent_date.should eq DateTime.parse('12 Aug 2009 00:00:03 GMT') | |
+ message.resent_from.should eq ['[email protected]'] | |
+ message.resent_message_id.should eq '1234@resent_message_id.lindsaar.net' | |
+ message.resent_sender.should eq ['[email protected]'] | |
+ message.resent_to.should eq ['[email protected]'] | |
+ message.sender.should eq '[email protected]' | |
+ message.subject.should eq 'Hello there Mikel' | |
+ message.to.should eq ['[email protected]'] | |
+ message.content_type.should eq 'text/plain; charset=UTF-8' | |
+ message.content_transfer_encoding.should eq '7bit' | |
+ message.content_description.should eq 'This is a test' | |
+ message.content_disposition.should eq 'attachment; filename=File' | |
+ message.content_id.should eq '<1234@message_id.lindsaar.net>' | |
+ message.mime_version.should eq '1.0' | |
+ message.body.to_s.should eq 'This is a body of text' | |
end | |
it "should accept them in key, value form as symbols" do | |
@@ -547,34 +585,34 @@ describe Mail::Message do | |
message[:mime_version]= '1.0' | |
message[:body] = 'This is a body of text' | |
- message.bcc.should == ['[email protected]'] | |
- message.cc.should == ['[email protected]'] | |
- message.comments.should == 'this is a comment' | |
- message.date.should == DateTime.parse('12 Aug 2009 00:00:01 GMT') | |
- message.from.should == ['[email protected]'] | |
- message.in_reply_to.should == '1234@in_reply_to.lindsaar.net' | |
- message.keywords.should == ["test", "of the new mail", "system"] | |
- message.message_id.should == '1234@message_id.lindsaar.net' | |
- message.received.date_time.should == DateTime.parse('12 Aug 2009 00:00:02 GMT') | |
- message.references.should == '[email protected]' | |
- message.reply_to.should == ['[email protected]'] | |
- message.resent_bcc.should == ['[email protected]'] | |
- message.resent_cc.should == ['[email protected]'] | |
- message.resent_date.should == DateTime.parse('12 Aug 2009 00:00:03 GMT') | |
- message.resent_from.should == ['[email protected]'] | |
- message.resent_message_id.should == '1234@resent_message_id.lindsaar.net' | |
- message.resent_sender.should == ['[email protected]'] | |
- message.resent_to.should == ['[email protected]'] | |
- message.sender.should == '[email protected]' | |
- message.subject.should == 'Hello there Mikel' | |
- message.to.should == ['[email protected]'] | |
- message.content_type.should == 'text/plain; charset=UTF-8' | |
- message.content_transfer_encoding.should == '7bit' | |
- message.content_description.should == 'This is a test' | |
- message.content_disposition.should == 'attachment; filename=File' | |
- message.content_id.should == '<1234@message_id.lindsaar.net>' | |
- message.mime_version.should == '1.0' | |
- message.body.to_s.should == 'This is a body of text' | |
+ message.bcc.should eq ['[email protected]'] | |
+ message.cc.should eq ['[email protected]'] | |
+ message.comments.should eq 'this is a comment' | |
+ message.date.should eq DateTime.parse('12 Aug 2009 00:00:01 GMT') | |
+ message.from.should eq ['[email protected]'] | |
+ message.in_reply_to.should eq '1234@in_reply_to.lindsaar.net' | |
+ message.keywords.should eq ["test", "of the new mail", "system"] | |
+ message.message_id.should eq '1234@message_id.lindsaar.net' | |
+ message.received.date_time.should eq DateTime.parse('12 Aug 2009 00:00:02 GMT') | |
+ message.references.should eq '[email protected]' | |
+ message.reply_to.should eq ['[email protected]'] | |
+ message.resent_bcc.should eq ['[email protected]'] | |
+ message.resent_cc.should eq ['[email protected]'] | |
+ message.resent_date.should eq DateTime.parse('12 Aug 2009 00:00:03 GMT') | |
+ message.resent_from.should eq ['[email protected]'] | |
+ message.resent_message_id.should eq '1234@resent_message_id.lindsaar.net' | |
+ message.resent_sender.should eq ['[email protected]'] | |
+ message.resent_to.should eq ['[email protected]'] | |
+ message.sender.should eq '[email protected]' | |
+ message.subject.should eq 'Hello there Mikel' | |
+ message.to.should eq ['[email protected]'] | |
+ message.content_type.should eq 'text/plain; charset=UTF-8' | |
+ message.content_transfer_encoding.should eq '7bit' | |
+ message.content_description.should eq 'This is a test' | |
+ message.content_disposition.should eq 'attachment; filename=File' | |
+ message.content_id.should eq '<1234@message_id.lindsaar.net>' | |
+ message.mime_version.should eq '1.0' | |
+ message.body.to_s.should eq 'This is a body of text' | |
end | |
it "should accept them in key, value form as strings" do | |
@@ -608,34 +646,34 @@ describe Mail::Message do | |
message['mime_version'] = '1.0' | |
message['body'] = 'This is a body of text' | |
- message.bcc.should == ['[email protected]'] | |
- message.cc.should == ['[email protected]'] | |
- message.comments.should == 'this is a comment' | |
- message.date.should == DateTime.parse('12 Aug 2009 00:00:01 GMT') | |
- message.from.should == ['[email protected]'] | |
- message.in_reply_to.should == '1234@in_reply_to.lindsaar.net' | |
- message.keywords.should == ["test", "of the new mail", "system"] | |
- message.message_id.should == '1234@message_id.lindsaar.net' | |
- message.received.date_time.should == DateTime.parse('12 Aug 2009 00:00:02 GMT') | |
- message.references.should == '[email protected]' | |
- message.reply_to.should == ['[email protected]'] | |
- message.resent_bcc.should == ['[email protected]'] | |
- message.resent_cc.should == ['[email protected]'] | |
- message.resent_date.should == DateTime.parse('12 Aug 2009 00:00:03 GMT') | |
- message.resent_from.should == ['[email protected]'] | |
- message.resent_message_id.should == '1234@resent_message_id.lindsaar.net' | |
- message.resent_sender.should == ['[email protected]'] | |
- message.resent_to.should == ['[email protected]'] | |
- message.sender.should == '[email protected]' | |
- message.subject.should == 'Hello there Mikel' | |
- message.to.should == ['[email protected]'] | |
- message.content_type.should == 'text/plain; charset=UTF-8' | |
- message.content_transfer_encoding.should == '7bit' | |
- message.content_description.should == 'This is a test' | |
- message.content_disposition.should == 'attachment; filename=File' | |
- message.content_id.should == '<1234@message_id.lindsaar.net>' | |
- message.mime_version.should == '1.0' | |
- message.body.to_s.should == 'This is a body of text' | |
+ message.bcc.should eq ['[email protected]'] | |
+ message.cc.should eq ['[email protected]'] | |
+ message.comments.should eq 'this is a comment' | |
+ message.date.should eq DateTime.parse('12 Aug 2009 00:00:01 GMT') | |
+ message.from.should eq ['[email protected]'] | |
+ message.in_reply_to.should eq '1234@in_reply_to.lindsaar.net' | |
+ message.keywords.should eq ["test", "of the new mail", "system"] | |
+ message.message_id.should eq '1234@message_id.lindsaar.net' | |
+ message.received.date_time.should eq DateTime.parse('12 Aug 2009 00:00:02 GMT') | |
+ message.references.should eq '[email protected]' | |
+ message.reply_to.should eq ['[email protected]'] | |
+ message.resent_bcc.should eq ['[email protected]'] | |
+ message.resent_cc.should eq ['[email protected]'] | |
+ message.resent_date.should eq DateTime.parse('12 Aug 2009 00:00:03 GMT') | |
+ message.resent_from.should eq ['[email protected]'] | |
+ message.resent_message_id.should eq '1234@resent_message_id.lindsaar.net' | |
+ message.resent_sender.should eq ['[email protected]'] | |
+ message.resent_to.should eq ['[email protected]'] | |
+ message.sender.should eq '[email protected]' | |
+ message.subject.should eq 'Hello there Mikel' | |
+ message.to.should eq ['[email protected]'] | |
+ message.content_type.should eq 'text/plain; charset=UTF-8' | |
+ message.content_transfer_encoding.should eq '7bit' | |
+ message.content_description.should eq 'This is a test' | |
+ message.content_disposition.should eq 'attachment; filename=File' | |
+ message.content_id.should eq '<1234@message_id.lindsaar.net>' | |
+ message.mime_version.should eq '1.0' | |
+ message.body.to_s.should eq 'This is a body of text' | |
end | |
it "should accept them as a hash with symbols" do | |
@@ -670,34 +708,34 @@ describe Mail::Message do | |
:body => 'This is a body of text' | |
}) | |
- message.bcc.should == ['[email protected]'] | |
- message.cc.should == ['[email protected]'] | |
- message.comments.should == 'this is a comment' | |
- message.date.should == DateTime.parse('12 Aug 2009 00:00:01 GMT') | |
- message.from.should == ['[email protected]'] | |
- message.in_reply_to.should == '1234@in_reply_to.lindsaar.net' | |
- message.keywords.should == ["test", "of the new mail", "system"] | |
- message.message_id.should == '1234@message_id.lindsaar.net' | |
- message.received.date_time.should == DateTime.parse('12 Aug 2009 00:00:02 GMT') | |
- message.references.should == '[email protected]' | |
- message.reply_to.should == ['[email protected]'] | |
- message.resent_bcc.should == ['[email protected]'] | |
- message.resent_cc.should == ['[email protected]'] | |
- message.resent_date.should == DateTime.parse('12 Aug 2009 00:00:03 GMT') | |
- message.resent_from.should == ['[email protected]'] | |
- message.resent_message_id.should == '1234@resent_message_id.lindsaar.net' | |
- message.resent_sender.should == ['[email protected]'] | |
- message.resent_to.should == ['[email protected]'] | |
- message.sender.should == '[email protected]' | |
- message.subject.should == 'Hello there Mikel' | |
- message.to.should == ['[email protected]'] | |
- message.content_type.should == 'text/plain; charset=UTF-8' | |
- message.content_transfer_encoding.should == '7bit' | |
- message.content_description.should == 'This is a test' | |
- message.content_disposition.should == 'attachment; filename=File' | |
- message.content_id.should == '<1234@message_id.lindsaar.net>' | |
- message.mime_version.should == '1.0' | |
- message.body.to_s.should == 'This is a body of text' | |
+ message.bcc.should eq ['[email protected]'] | |
+ message.cc.should eq ['[email protected]'] | |
+ message.comments.should eq 'this is a comment' | |
+ message.date.should eq DateTime.parse('12 Aug 2009 00:00:01 GMT') | |
+ message.from.should eq ['[email protected]'] | |
+ message.in_reply_to.should eq '1234@in_reply_to.lindsaar.net' | |
+ message.keywords.should eq ["test", "of the new mail", "system"] | |
+ message.message_id.should eq '1234@message_id.lindsaar.net' | |
+ message.received.date_time.should eq DateTime.parse('12 Aug 2009 00:00:02 GMT') | |
+ message.references.should eq '[email protected]' | |
+ message.reply_to.should eq ['[email protected]'] | |
+ message.resent_bcc.should eq ['[email protected]'] | |
+ message.resent_cc.should eq ['[email protected]'] | |
+ message.resent_date.should eq DateTime.parse('12 Aug 2009 00:00:03 GMT') | |
+ message.resent_from.should eq ['[email protected]'] | |
+ message.resent_message_id.should eq '1234@resent_message_id.lindsaar.net' | |
+ message.resent_sender.should eq ['[email protected]'] | |
+ message.resent_to.should eq ['[email protected]'] | |
+ message.sender.should eq '[email protected]' | |
+ message.subject.should eq 'Hello there Mikel' | |
+ message.to.should eq ['[email protected]'] | |
+ message.content_type.should eq 'text/plain; charset=UTF-8' | |
+ message.content_transfer_encoding.should eq '7bit' | |
+ message.content_description.should eq 'This is a test' | |
+ message.content_disposition.should eq 'attachment; filename=File' | |
+ message.content_id.should eq '<1234@message_id.lindsaar.net>' | |
+ message.mime_version.should eq '1.0' | |
+ message.body.to_s.should eq 'This is a body of text' | |
end | |
it "should accept them as a hash with strings" do | |
@@ -732,46 +770,46 @@ describe Mail::Message do | |
'body' => 'This is a body of text' | |
}) | |
- message.bcc.should == ['[email protected]'] | |
- message.cc.should == ['[email protected]'] | |
- message.comments.should == 'this is a comment' | |
- message.date.should == DateTime.parse('12 Aug 2009 00:00:01 GMT') | |
- message.from.should == ['[email protected]'] | |
- message.in_reply_to.should == '1234@in_reply_to.lindsaar.net' | |
- message.keywords.should == ["test", "of the new mail", "system"] | |
- message.message_id.should == '1234@message_id.lindsaar.net' | |
- message.received.date_time.should == DateTime.parse('12 Aug 2009 00:00:02 GMT') | |
- message.references.should == '[email protected]' | |
- message.reply_to.should == ['[email protected]'] | |
- message.resent_bcc.should == ['[email protected]'] | |
- message.resent_cc.should == ['[email protected]'] | |
- message.resent_date.should == DateTime.parse('12 Aug 2009 00:00:03 GMT') | |
- message.resent_from.should == ['[email protected]'] | |
- message.resent_message_id.should == '1234@resent_message_id.lindsaar.net' | |
- message.resent_sender.should == ['[email protected]'] | |
- message.resent_to.should == ['[email protected]'] | |
- message.sender.should == '[email protected]' | |
- message.subject.should == 'Hello there Mikel' | |
- message.to.should == ['[email protected]'] | |
- message.content_type.should == 'text/plain; charset=UTF-8' | |
- message.content_transfer_encoding.should == '7bit' | |
- message.content_description.should == 'This is a test' | |
- message.content_disposition.should == 'attachment; filename=File' | |
- message.content_id.should == '<1234@message_id.lindsaar.net>' | |
- message.mime_version.should == '1.0' | |
- message.body.to_s.should == 'This is a body of text' | |
+ message.bcc.should eq ['[email protected]'] | |
+ message.cc.should eq ['[email protected]'] | |
+ message.comments.should eq 'this is a comment' | |
+ message.date.should eq DateTime.parse('12 Aug 2009 00:00:01 GMT') | |
+ message.from.should eq ['[email protected]'] | |
+ message.in_reply_to.should eq '1234@in_reply_to.lindsaar.net' | |
+ message.keywords.should eq ["test", "of the new mail", "system"] | |
+ message.message_id.should eq '1234@message_id.lindsaar.net' | |
+ message.received.date_time.should eq DateTime.parse('12 Aug 2009 00:00:02 GMT') | |
+ message.references.should eq '[email protected]' | |
+ message.reply_to.should eq ['[email protected]'] | |
+ message.resent_bcc.should eq ['[email protected]'] | |
+ message.resent_cc.should eq ['[email protected]'] | |
+ message.resent_date.should eq DateTime.parse('12 Aug 2009 00:00:03 GMT') | |
+ message.resent_from.should eq ['[email protected]'] | |
+ message.resent_message_id.should eq '1234@resent_message_id.lindsaar.net' | |
+ message.resent_sender.should eq ['[email protected]'] | |
+ message.resent_to.should eq ['[email protected]'] | |
+ message.sender.should eq '[email protected]' | |
+ message.subject.should eq 'Hello there Mikel' | |
+ message.to.should eq ['[email protected]'] | |
+ message.content_type.should eq 'text/plain; charset=UTF-8' | |
+ message.content_transfer_encoding.should eq '7bit' | |
+ message.content_description.should eq 'This is a test' | |
+ message.content_disposition.should eq 'attachment; filename=File' | |
+ message.content_id.should eq '<1234@message_id.lindsaar.net>' | |
+ message.mime_version.should eq '1.0' | |
+ message.body.to_s.should eq 'This is a body of text' | |
end | |
it "should let you set custom headers with a :headers => {hash}" do | |
message = Mail.new(:headers => {'custom-header' => 'mikel'}) | |
- message['custom-header'].decoded.should == 'mikel' | |
+ message['custom-header'].decoded.should eq 'mikel' | |
end | |
it "should assign the body to a part on creation" do | |
message = Mail.new do | |
part({:content_type=>"multipart/alternative", :content_disposition=>"inline", :body=>"Nothing to see here."}) | |
end | |
- message.parts.first.body.decoded.should == "Nothing to see here." | |
+ message.parts.first.body.decoded.should eq "Nothing to see here." | |
end | |
it "should not overwrite bodies on creation" do | |
@@ -780,27 +818,27 @@ describe Mail::Message do | |
p.part :content_type => "text/html", :body => "<b>test</b> HTML<br/>" | |
end | |
end | |
- message.parts.first.parts[0].body.decoded.should == "Nothing to see here." | |
- message.parts.first.parts[1].body.decoded.should == "<b>test</b> HTML<br/>" | |
+ message.parts.first.parts[0].body.decoded.should eq "Nothing to see here." | |
+ message.parts.first.parts[1].body.decoded.should eq "<b>test</b> HTML<br/>" | |
message.encoded.should match %r{Nothing to see here\.} | |
message.encoded.should match %r{<b>test</b> HTML<br/>} | |
end | |
it "should allow you to init on an array of addresses from a hash" do | |
mail = Mail.new(:to => ['[email protected]', 'Mikel <[email protected]>']) | |
- mail.to.should == ['[email protected]', '[email protected]'] | |
+ mail.to.should eq ['[email protected]', '[email protected]'] | |
end | |
it "should allow you to init on an array of addresses directly" do | |
mail = Mail.new | |
mail.to = ['[email protected]', 'Mikel <[email protected]>'] | |
- mail.to.should == ['[email protected]', '[email protected]'] | |
+ mail.to.should eq ['[email protected]', '[email protected]'] | |
end | |
it "should allow you to init on an array of addresses directly" do | |
mail = Mail.new | |
mail[:to] = ['[email protected]', 'Mikel <[email protected]>'] | |
- mail.to.should == ['[email protected]', '[email protected]'] | |
+ mail.to.should eq ['[email protected]', '[email protected]'] | |
end | |
end | |
@@ -869,7 +907,7 @@ describe Mail::Message do | |
it "should add a body part if it is missing" do | |
mail = Mail.new | |
mail.to_s | |
- mail.body.class.should == Mail::Body | |
+ mail.body.class.should eq Mail::Body | |
end | |
end | |
@@ -1064,20 +1102,20 @@ describe Mail::Message do | |
it "should be able to set a content type with an array and hash" do | |
mail = Mail.new | |
mail.content_type = ["text", "plain", { :charset => 'US-ASCII' }] | |
- mail[:content_type].encoded.should == %Q[Content-Type: text/plain;\r\n\scharset=US-ASCII\r\n] | |
- mail.content_type_parameters.should == {"charset" => "US-ASCII"} | |
+ mail[:content_type].encoded.should eq %Q[Content-Type: text/plain;\r\n\scharset=US-ASCII\r\n] | |
+ mail.content_type_parameters.should eql({"charset" => "US-ASCII"}) | |
end | |
it "should be able to set a content type with an array and hash with a non-usascii field" do | |
mail = Mail.new | |
mail.content_type = ["text", "plain", { :charset => 'UTF-8' }] | |
- mail[:content_type].encoded.should == %Q[Content-Type: text/plain;\r\n\scharset=UTF-8\r\n] | |
- mail.content_type_parameters.should == {"charset" => "UTF-8"} | |
+ mail[:content_type].encoded.should eq %Q[Content-Type: text/plain;\r\n\scharset=UTF-8\r\n] | |
+ mail.content_type_parameters.should eql({"charset" => "UTF-8"}) | |
end | |
it "should allow us to specify a content type in a block" do | |
mail = Mail.new { content_type ["text", "plain", { "charset" => "UTF-8" }] } | |
- mail.content_type_parameters.should == {"charset" => "UTF-8"} | |
+ mail.content_type_parameters.should eql({"charset" => "UTF-8"}) | |
end | |
end | |
@@ -1164,7 +1202,7 @@ describe Mail::Message do | |
content_transfer_encoding 'base64' | |
body "VGhlIGJvZHk=\n" | |
end | |
- mail.decoded.should == "The body" | |
+ mail.decoded.should eq "The body" | |
end | |
describe "decoding bodies" do | |
@@ -1173,8 +1211,8 @@ describe Mail::Message do | |
mail = Mail.new do | |
body "The=3Dbody" | |
end | |
- mail.body.decoded.should == "The=3Dbody" | |
- mail.body.encoded.should == "The=3Dbody" | |
+ mail.body.decoded.should eq "The=3Dbody" | |
+ mail.body.encoded.should eq "The=3Dbody" | |
end | |
it "should change a body on decode if given an encoding type to decode" do | |
@@ -1182,8 +1220,8 @@ describe Mail::Message do | |
content_transfer_encoding 'quoted-printable' | |
body "The=3Dbody" | |
end | |
- mail.body.decoded.should == "The=body" | |
- mail.body.encoded.should == "The=3Dbody=\r\n" | |
+ mail.body.decoded.should eq "The=body" | |
+ mail.body.encoded.should eq "The=3Dbody=\r\n" | |
end | |
it "should change a body on decode if given an encoding type to decode" do | |
@@ -1191,17 +1229,47 @@ describe Mail::Message do | |
content_transfer_encoding 'base64' | |
body "VGhlIGJvZHk=\n" | |
end | |
- mail.body.decoded.should == "The body" | |
- mail.body.encoded.should == "VGhlIGJvZHk=\r\n" | |
+ mail.body.decoded.should eq "The body" | |
+ mail.body.encoded.should eq "VGhlIGJvZHk=\r\n" | |
end | |
end | |
end | |
+ describe "text messages" do | |
+ def message_with_iso_8859_1_charset | |
+ "From: [email protected]\r\n"+ | |
+ "Content-Type: text/plain; charset=iso-8859-1\r\n"+ | |
+ "Content-Transfer-Encoding: quoted-printable\r\n"+ | |
+ "Date: Tue, 27 Sep 2011 16:59:48 +0100 (BST)\r\n"+ | |
+ "Subject: test\r\n\r\n"+ | |
+ "Am=E9rica" | |
+ end | |
+ | |
+ before(:each) do | |
+ @message = Mail.new(message_with_iso_8859_1_charset) | |
+ end | |
+ | |
+ it "should be decoded using content type charset" do | |
+ @message.decoded.should eq "América" | |
+ end | |
+ | |
+ it "should respond true to text?" do | |
+ @message.text?.should eq true | |
+ end | |
+ | |
+ end | |
+ | |
describe "helper methods" do | |
describe "==" do | |
+ before(:each) do | |
+ # Ensure specs don't randomly fail due to messages being generated 1 second apart | |
+ time = Time.now | |
+ DateTime.should_receive(:now).twice.and_return(time) | |
+ end | |
+ | |
it "should be implemented" do | |
doing { Mail.new == Mail.new }.should_not raise_error | |
end | |
@@ -1209,47 +1277,47 @@ describe Mail::Message do | |
it "should ignore the message id value if both have a nil message id" do | |
m1 = Mail.new("To: [email protected]\r\nSubject: Yo!\r\n\r\nHello there") | |
m2 = Mail.new("To: [email protected]\r\nSubject: Yo!\r\n\r\nHello there") | |
- m1.should == m2 | |
+ m1.should eq m2 | |
end | |
it "should ignore the message id value if self has a nil message id" do | |
m1 = Mail.new("To: [email protected]\r\nSubject: Yo!\r\n\r\nHello there") | |
m2 = Mail.new("To: [email protected]\r\nMessage-ID: <[email protected]>\r\nSubject: Yo!\r\n\r\nHello there") | |
- m1.should == m2 | |
+ m1.should eq m2 | |
end | |
it "should ignore the message id value if other has a nil message id" do | |
m1 = Mail.new("To: [email protected]\r\nMessage-ID: <[email protected]>\r\nSubject: Yo!\r\n\r\nHello there") | |
m2 = Mail.new("To: [email protected]\r\nSubject: Yo!\r\n\r\nHello there") | |
- m1.should == m2 | |
+ m1.should eq m2 | |
end | |
it "should not be == if both emails have different Message IDs" do | |
m1 = Mail.new("To: [email protected]\r\nMessage-ID: <[email protected]>\r\nSubject: Yo!\r\n\r\nHello there") | |
m2 = Mail.new("To: [email protected]\r\nMessage-ID: <[email protected]>\r\nSubject: Yo!\r\n\r\nHello there") | |
- m1.should_not == m2 | |
+ m1.should_not eq m2 | |
end | |
it "should preserve the message id of self if set" do | |
m1 = Mail.new("To: [email protected]\r\nMessage-ID: <[email protected]>\r\nSubject: Yo!\r\n\r\nHello there") | |
m2 = Mail.new("To: [email protected]\r\nSubject: Yo!\r\n\r\nHello there") | |
m1 == m2 | |
- m1.message_id.should == '[email protected]' | |
+ m1.message_id.should eq '[email protected]' | |
end | |
it "should preserve the message id of other if set" do | |
m1 = Mail.new("To: [email protected]\r\nSubject: Yo!\r\n\r\nHello there") | |
m2 = Mail.new("To: [email protected]\r\nMessage-ID: <[email protected]>\r\nSubject: Yo!\r\n\r\nHello there") | |
m1 == m2 | |
- m2.message_id.should == '[email protected]' | |
+ m2.message_id.should eq '[email protected]' | |
end | |
it "should preserve the message id of both if set" do | |
m1 = Mail.new("To: [email protected]\r\nMessage-ID: <[email protected]>\r\nSubject: Yo!\r\n\r\nHello there") | |
m2 = Mail.new("To: [email protected]\r\nMessage-ID: <[email protected]>\r\nSubject: Yo!\r\n\r\nHello there") | |
m1 == m2 | |
- m1.message_id.should == '[email protected]' | |
- m2.message_id.should == '[email protected]' | |
+ m1.message_id.should eq '[email protected]' | |
+ m2.message_id.should eq '[email protected]' | |
end | |
end | |
@@ -1261,7 +1329,7 @@ describe Mail::Message do | |
mail2 = Mail.new do | |
date(now - 10) # Make mail2 10 seconds 'older' | |
end | |
- [mail2, mail1].sort.should == [mail2, mail1] | |
+ [mail2, mail1].sort.should eq [mail2, mail1] | |
end | |
it "should have a destinations method" do | |
@@ -1270,66 +1338,66 @@ describe Mail::Message do | |
cc '[email protected]' | |
bcc '[email protected]' | |
end | |
- mail.destinations.length.should == 3 | |
+ mail.destinations.length.should eq 3 | |
end | |
it "should have a from_addrs method" do | |
mail = Mail.new do | |
from '[email protected]' | |
end | |
- mail.from_addrs.length.should == 1 | |
+ mail.from_addrs.length.should eq 1 | |
end | |
it "should have a from_addrs method that is empty if nil" do | |
mail = Mail.new do | |
end | |
- mail.from_addrs.length.should == 0 | |
+ mail.from_addrs.length.should eq 0 | |
end | |
it "should have a to_addrs method" do | |
mail = Mail.new do | |
to '[email protected]' | |
end | |
- mail.to_addrs.length.should == 1 | |
+ mail.to_addrs.length.should eq 1 | |
end | |
it "should have a to_addrs method that is empty if nil" do | |
mail = Mail.new do | |
end | |
- mail.to_addrs.length.should == 0 | |
+ mail.to_addrs.length.should eq 0 | |
end | |
it "should have a cc_addrs method" do | |
mail = Mail.new do | |
cc '[email protected]' | |
end | |
- mail.cc_addrs.length.should == 1 | |
+ mail.cc_addrs.length.should eq 1 | |
end | |
it "should have a cc_addrs method that is empty if nil" do | |
mail = Mail.new do | |
end | |
- mail.cc_addrs.length.should == 0 | |
+ mail.cc_addrs.length.should eq 0 | |
end | |
it "should have a bcc_addrs method" do | |
mail = Mail.new do | |
bcc '[email protected]' | |
end | |
- mail.bcc_addrs.length.should == 1 | |
+ mail.bcc_addrs.length.should eq 1 | |
end | |
it "should have a bcc_addrs method that is empty if nil" do | |
mail = Mail.new do | |
end | |
- mail.bcc_addrs.length.should == 0 | |
+ mail.bcc_addrs.length.should eq 0 | |
end | |
it "should give destinations even if some of the fields are blank" do | |
mail = Mail.new do | |
to '[email protected]' | |
end | |
- mail.destinations.length.should == 1 | |
+ mail.destinations.length.should eq 1 | |
end | |
it "should be able to encode with only one destination" do | |
@@ -1357,11 +1425,11 @@ describe Mail::Message do | |
end | |
mail.parts.first.should be_multipart | |
- mail.parts.first.parts.length.should == 2 | |
- mail.parts.first.parts[0][:content_type].string.should == "text/plain" | |
- mail.parts.first.parts[0].body.decoded.should == "test text\nline #2" | |
- mail.parts.first.parts[1][:content_type].string.should == "text/html" | |
- mail.parts.first.parts[1].body.decoded.should == "<b>test</b> HTML<br/>\nline #2" | |
+ mail.parts.first.parts.length.should eq 2 | |
+ mail.parts.first.parts[0][:content_type].string.should eq "text/plain" | |
+ mail.parts.first.parts[0].body.decoded.should eq "test text\nline #2" | |
+ mail.parts.first.parts[1][:content_type].string.should eq "text/html" | |
+ mail.parts.first.parts[1].body.decoded.should eq "<b>test</b> HTML<br/>\nline #2" | |
end | |
end | |
@@ -1369,7 +1437,7 @@ describe Mail::Message do | |
it "should return self after delivery" do | |
mail = Mail.new | |
mail.perform_deliveries = false | |
- mail.deliver.should == mail | |
+ mail.deliver.should eq mail | |
end | |
class DeliveryAgent | |
@@ -1435,7 +1503,7 @@ describe Mail::Message do | |
InterceptorAgent.intercept = true | |
mail.deliver | |
InterceptorAgent.intercept = false | |
- mail.to.should == ['[email protected]'] | |
+ mail.to.should eq ['[email protected]'] | |
end | |
end | |
@@ -1444,11 +1512,11 @@ describe Mail::Message do | |
it "should collect up any of its fields' errors" do | |
mail = Mail.new("Content-Transfer-Encoding: vlad\r\nReply-To: a b b\r\n") | |
mail.errors.should_not be_blank | |
- mail.errors.size.should == 2 | |
- mail.errors[0][0].should == 'Content-Transfer-Encoding' | |
- mail.errors[0][1].should == 'vlad' | |
- mail.errors[1][0].should == 'Reply-To' | |
- mail.errors[1][1].should == 'a b b' | |
+ mail.errors.size.should eq 2 | |
+ mail.errors[0][0].should eq 'Content-Transfer-Encoding' | |
+ mail.errors[0][1].should eq 'vlad' | |
+ mail.errors[1][0].should eq 'Reply-To' | |
+ mail.errors[1][1].should eq 'a b b' | |
end | |
end | |
@@ -1463,9 +1531,9 @@ describe Mail::Message do | |
describe "parsing emails with non usascii in the header" do | |
it "should work" do | |
mail = Mail.new('From: "Foo áëô îü" <[email protected]>') | |
- mail.from.should == ['[email protected]'] | |
- mail[:from].decoded.should == '"Foo áëô îü" <[email protected]>' | |
- mail[:from].encoded.should == "From: =?UTF-8?B?Rm9vIMOhw6vDtCDDrsO8?= <[email protected]>\r\n" | |
+ mail.from.should eq ['[email protected]'] | |
+ mail[:from].decoded.should eq '"Foo áëô îü" <[email protected]>' | |
+ mail[:from].encoded.should eq "From: =?UTF-8?B?Rm9vIMOhw6vDtCDDrsO8?= <[email protected]>\r\n" | |
end | |
end | |
@@ -1479,10 +1547,10 @@ describe Mail::Message do | |
p.add_part(Mail::Part.new(:content_type => 'text/plain', :body => 'PLAIN TEXT')) | |
mail.add_part(p) | |
mail.encoded | |
- mail.parts[0].mime_type.should == "multipart/alternative" | |
- mail.parts[0].parts[0].mime_type.should == "text/plain" | |
- mail.parts[0].parts[1].mime_type.should == "text/html" | |
- mail.parts[1].mime_type.should == "image/png" | |
+ mail.parts[0].mime_type.should eq "multipart/alternative" | |
+ mail.parts[0].parts[0].mime_type.should eq "text/plain" | |
+ mail.parts[0].parts[1].mime_type.should eq "text/html" | |
+ mail.parts[1].mime_type.should eq "image/png" | |
end | |
end | |
@@ -1500,6 +1568,24 @@ describe Mail::Message do | |
end | |
+ describe "without_attachments!" do | |
+ it "should delete all attachments" do | |
+ emails_with_attachments = ['content_disposition', 'content_location', | |
+ 'pdf', 'with_encoded_name', 'with_quoted_filename'] | |
+ | |
+ emails_with_attachments.each { |email| | |
+ mail = Mail.read(fixture(File.join('emails', 'attachment_emails', "attachment_#{email}.eml"))) | |
+ mail_length_with_attachments = mail.to_s.length | |
+ mail.has_attachments?.should be_true | |
+ mail.without_attachments! | |
+ | |
+ mail_length_without_attachments = mail.to_s.length | |
+ mail_length_without_attachments.should < mail_length_with_attachments | |
+ mail.has_attachments?.should be_false | |
+ } | |
+ end | |
+ end | |
+ | |
describe "replying" do | |
describe "to a basic message" do | |
@@ -1513,33 +1599,33 @@ describe Mail::Message do | |
end | |
it "should be in-reply-to the original message" do | |
- @mail.reply.in_reply_to.should == '[email protected]' | |
+ @mail.reply.in_reply_to.should eq '[email protected]' | |
end | |
it "should reference the original message" do | |
- @mail.reply.references.should == '[email protected]' | |
+ @mail.reply.references.should eq '[email protected]' | |
end | |
it "should RE: the original subject" do | |
- @mail.reply.subject.should == 'RE: Testing 123' | |
+ @mail.reply.subject.should eq 'RE: Testing 123' | |
end | |
it "should be sent to the original sender" do | |
- @mail.reply.to.should == ['[email protected]'] | |
- @mail.reply[:to].to_s.should == 'Mikel Lindsaar <[email protected]>' | |
+ @mail.reply.to.should eq ['[email protected]'] | |
+ @mail.reply[:to].to_s.should eq 'Mikel Lindsaar <[email protected]>' | |
end | |
it "should be sent from the original recipient" do | |
- @mail.reply.from.should == ['[email protected]'] | |
- @mail.reply[:from].to_s.should == 'Mikel Lindsaar <[email protected]>' | |
+ @mail.reply.from.should eq ['[email protected]'] | |
+ @mail.reply[:from].to_s.should eq 'Mikel Lindsaar <[email protected]>' | |
end | |
it "should accept args" do | |
- @mail.reply(:from => 'Donald Ball <[email protected]>').from.should == ['[email protected]'] | |
+ @mail.reply(:from => 'Donald Ball <[email protected]>').from.should eq ['[email protected]'] | |
end | |
it "should accept a block" do | |
- @mail.reply { from('Donald Ball <[email protected]>') }.from.should == ['[email protected]'] | |
+ @mail.reply { from('Donald Ball <[email protected]>') }.from.should eq ['[email protected]'] | |
end | |
end | |
@@ -1551,7 +1637,7 @@ describe Mail::Message do | |
end | |
it "should be sent to the reply-to address" do | |
- @mail.reply[:to].to_s.should == '"Mary Smith: Personal Account" <[email protected]>' | |
+ @mail.reply[:to].to_s.should eq '"Mary Smith: Personal Account" <[email protected]>' | |
end | |
end | |
@@ -1563,7 +1649,7 @@ describe Mail::Message do | |
end | |
it "should be sent from the first to address" do | |
- @mail.reply[:from].to_s.should == 'Mary Smith <[email protected]>' | |
+ @mail.reply[:from].to_s.should eq 'Mary Smith <[email protected]>' | |
end | |
end | |
@@ -1575,15 +1661,15 @@ describe Mail::Message do | |
end | |
it "should be in-reply-to the original message" do | |
- @mail.reply.in_reply_to.should == '[email protected]' | |
+ @mail.reply.in_reply_to.should eq '[email protected]' | |
end | |
it "should append to the original's references list" do | |
- @mail.reply[:references].message_ids.should == ['[email protected]', '[email protected]', '[email protected]'] | |
+ @mail.reply[:references].message_ids.should eq ['[email protected]', '[email protected]', '[email protected]'] | |
end | |
it "should not append another RE:" do | |
- @mail.reply.subject.should == "Re: Test reply email" | |
+ @mail.reply.subject.should eq "Re: Test reply email" | |
end | |
end | |
@@ -1598,7 +1684,7 @@ describe Mail::Message do | |
end | |
it "should have a references consisting of the in-reply-to and message_id fields" do | |
- @mail.reply[:references].message_ids.should == ['[email protected]', '[email protected]'] | |
+ @mail.reply[:references].message_ids.should eq ['[email protected]', '[email protected]'] | |
end | |
end | |
diff --git a/spec/mail/mime_messages_spec.rb b/spec/mail/mime_messages_spec.rb | |
index b20d9b7..6ec6576 100644 | |
--- a/spec/mail/mime_messages_spec.rb | |
+++ b/spec/mail/mime_messages_spec.rb | |
@@ -7,53 +7,53 @@ describe "MIME Emails" do | |
it "should read a mime version from an email" do | |
mail = Mail.new("Mime-Version: 1.0") | |
- mail.mime_version.should == '1.0' | |
+ mail.mime_version.should eq '1.0' | |
end | |
it "should return nil if the email has no mime version" do | |
mail = Mail.new("To: bob") | |
- mail.mime_version.should == nil | |
+ mail.mime_version.should eq nil | |
end | |
it "should read the content-transfer-encoding" do | |
mail = Mail.new("Content-Transfer-Encoding: quoted-printable") | |
- mail.content_transfer_encoding.should == 'quoted-printable' | |
+ mail.content_transfer_encoding.should eq 'quoted-printable' | |
end | |
it "should read the content-description" do | |
mail = Mail.new("Content-Description: This is a description") | |
- mail.content_description.should == 'This is a description' | |
+ mail.content_description.should eq 'This is a description' | |
end | |
it "should return the content-type" do | |
mail = Mail.new("Content-Type: text/plain") | |
- mail.mime_type.should == 'text/plain' | |
+ mail.mime_type.should eq 'text/plain' | |
end | |
it "should return the charset" do | |
mail = Mail.new("Content-Type: text/plain; charset=utf-8") | |
- mail.charset.should == 'utf-8' | |
+ mail.charset.should eq 'utf-8' | |
end | |
it "should allow you to set the charset" do | |
mail = Mail.new | |
mail.charset = 'utf-8' | |
- mail.charset.should == 'utf-8' | |
+ mail.charset.should eq 'utf-8' | |
end | |
it "should return the main content-type" do | |
mail = Mail.new("Content-Type: text/plain") | |
- mail.main_type.should == 'text' | |
+ mail.main_type.should eq 'text' | |
end | |
it "should return the sub content-type" do | |
mail = Mail.new("Content-Type: text/plain") | |
- mail.sub_type.should == 'plain' | |
+ mail.sub_type.should eq 'plain' | |
end | |
it "should return the content-type parameters" do | |
mail = Mail.new("Content-Type: text/plain; charset=US-ASCII; format=flowed") | |
- mail.content_type_parameters.should == {"charset" => 'US-ASCII', "format" => 'flowed'} | |
+ mail.content_type_parameters.should eql({"charset" => 'US-ASCII', "format" => 'flowed'}) | |
end | |
it "should recognize a multipart email" do | |
@@ -68,31 +68,31 @@ describe "MIME Emails" do | |
it "should not report the email as :attachment?" do | |
mail = Mail.read(fixture(File.join('emails', 'attachment_emails', 'attachment_pdf.eml'))) | |
- mail.attachment?.should == false | |
+ mail.attachment?.should eq false | |
end | |
it "should report the email as :attachment?" do | |
mail = Mail.read(fixture(File.join('emails', 'attachment_emails', 'attachment_only_email.eml'))) | |
- mail.attachment?.should == true | |
+ mail.attachment?.should eq true | |
end | |
it "should recognize an attachment part" do | |
mail = Mail.read(fixture(File.join('emails', 'attachment_emails', 'attachment_pdf.eml'))) | |
mail.should_not be_attachment | |
- mail.parts[0].attachment?.should == false | |
- mail.parts[1].attachment?.should == true | |
+ mail.parts[0].attachment?.should eq false | |
+ mail.parts[1].attachment?.should eq true | |
end | |
it "should give how may (top level) parts there are" do | |
mail = Mail.read(fixture('emails', 'mime_emails', 'raw_email7.eml')) | |
- mail.parts.length.should == 2 | |
+ mail.parts.length.should eq 2 | |
end | |
it "should give the content_type of each part" do | |
mail = Mail.read(fixture('emails', 'mime_emails', 'raw_email11.eml')) | |
- mail.mime_type.should == 'multipart/alternative' | |
- mail.parts[0].mime_type.should == 'text/plain' | |
- mail.parts[1].mime_type.should == 'text/enriched' | |
+ mail.mime_type.should eq 'multipart/alternative' | |
+ mail.parts[0].mime_type.should eq 'text/plain' | |
+ mail.parts[1].mime_type.should eq 'text/enriched' | |
end | |
it "should report the mail :has_attachments?" do | |
@@ -122,12 +122,12 @@ describe "MIME Emails" do | |
it "should know what it's boundary is if it is a multipart document" do | |
mail = Mail.new('Content-Type: multipart/mixed; boundary="--==Boundary"') | |
- mail.boundary.should == "--==Boundary" | |
+ mail.boundary.should eq "--==Boundary" | |
end | |
it "should return nil if there is no content-type defined" do | |
mail = Mail.new | |
- mail.boundary.should == nil | |
+ mail.boundary.should eq nil | |
end | |
it "should allow you to assign a text part" do | |
@@ -140,7 +140,7 @@ describe "MIME Emails" do | |
mail = Mail.new | |
text_mail = Mail.new("This is Text") | |
mail.text_part = text_mail | |
- mail.text_part.should == text_mail | |
+ mail.text_part.should eq text_mail | |
end | |
it "should allow you to assign a html part" do | |
@@ -153,7 +153,7 @@ describe "MIME Emails" do | |
mail = Mail.new | |
html_mail = Mail.new("<b>This is HTML</b>") | |
mail.html_part = html_mail | |
- mail.html_part.should == html_mail | |
+ mail.html_part.should eq html_mail | |
end | |
it "should add the html part and text part" do | |
@@ -165,9 +165,9 @@ describe "MIME Emails" do | |
content_type = "text/html; charset=US-ASCII" | |
body = "<b>This is HTML</b>" | |
end | |
- mail.parts.length.should == 2 | |
- mail.parts.first.class.should == Mail::Part | |
- mail.parts.last.class.should == Mail::Part | |
+ mail.parts.length.should eq 2 | |
+ mail.parts.first.class.should eq Mail::Part | |
+ mail.parts.last.class.should eq Mail::Part | |
end | |
it "should set the content type to multipart/alternative if you use the html_part and text_part helpers" do | |
@@ -222,19 +222,19 @@ describe "MIME Emails" do | |
end | |
end | |
mail.should be_multipart | |
- mail.parts.length.should == 2 | |
- mail.text_part.class.should == Mail::Part | |
- mail.text_part.body.to_s.should == 'This is plain text' | |
- mail.html_part.class.should == Mail::Part | |
- mail.html_part.body.to_s.should == '<h1>This is HTML</h1>' | |
+ mail.parts.length.should eq 2 | |
+ mail.text_part.class.should eq Mail::Part | |
+ mail.text_part.body.to_s.should eq 'This is plain text' | |
+ mail.html_part.class.should eq Mail::Part | |
+ mail.html_part.body.to_s.should eq '<h1>This is HTML</h1>' | |
end | |
it "should detect an html_part in an existing email" do | |
m = Mail.new(:content_type => 'multipart/alternative') | |
m.add_part(Mail::Part.new(:content_type => 'text/html', :body => 'HTML TEXT')) | |
m.add_part(Mail::Part.new(:content_type => 'text/plain', :body => 'PLAIN TEXT')) | |
- m.text_part.body.decoded.should == 'PLAIN TEXT' | |
- m.html_part.body.decoded.should == 'HTML TEXT' | |
+ m.text_part.body.decoded.should eq 'PLAIN TEXT' | |
+ m.html_part.body.decoded.should eq 'HTML TEXT' | |
end | |
it "should detect a text_part in an existing email with plain text attachment" do | |
@@ -242,8 +242,8 @@ describe "MIME Emails" do | |
m.add_file(fixture('attachments', 'てすと.txt')) | |
m.add_part(Mail::Part.new(:content_type => 'text/html', :body => 'HTML TEXT')) | |
m.add_part(Mail::Part.new(:content_type => 'text/plain', :body => 'PLAIN TEXT')) | |
- m.text_part.body.decoded.should == 'PLAIN TEXT' | |
- m.html_part.body.decoded.should == 'HTML TEXT' | |
+ m.text_part.body.decoded.should eq 'PLAIN TEXT' | |
+ m.html_part.body.decoded.should eq 'HTML TEXT' | |
end | |
it "should detect an html_part in a multi level mime email" do | |
@@ -254,8 +254,8 @@ describe "MIME Emails" do | |
p.add_part(Mail::Part.new(:content_type => 'text/plain', :body => 'PLAIN TEXT')) | |
m.add_part(p) | |
m.add_part(a) | |
- m.text_part.body.decoded.should == 'PLAIN TEXT' | |
- m.html_part.body.decoded.should == 'HTML TEXT' | |
+ m.text_part.body.decoded.should eq 'PLAIN TEXT' | |
+ m.html_part.body.decoded.should eq 'HTML TEXT' | |
end | |
it "should only the first part on a stupidly overly complex email" do | |
@@ -278,8 +278,8 @@ describe "MIME Emails" do | |
d.add_part(Mail::Part.new(:content_type => 'text/plain', :body => 'PLAIN 3 TEXT')) | |
b.add_part(d) | |
- m.text_part.body.decoded.should == 'PLAIN TEXT' | |
- m.html_part.body.decoded.should == 'HTML TEXT' | |
+ m.text_part.body.decoded.should eq 'PLAIN TEXT' | |
+ m.html_part.body.decoded.should eq 'HTML TEXT' | |
end | |
end | |
@@ -288,15 +288,15 @@ describe "MIME Emails" do | |
it "should return an array of attachments" do | |
mail = Mail.read(fixture('emails', 'attachment_emails', 'attachment_content_disposition.eml')) | |
- mail.attachments.length.should == 1 | |
- mail.attachments.first.filename.should == 'hello.rb' | |
+ mail.attachments.length.should eq 1 | |
+ mail.attachments.first.filename.should eq 'hello.rb' | |
end | |
it "should return an array of attachments" do | |
mail = Mail.read(fixture('emails', 'mime_emails', 'raw_email_with_nested_attachment.eml')) | |
- mail.attachments.length.should == 2 | |
- mail.attachments[0].filename.should == 'byo-ror-cover.png' | |
- mail.attachments[1].filename.should == 'smime.p7s' | |
+ mail.attachments.length.should eq 2 | |
+ mail.attachments[0].filename.should eq 'byo-ror-cover.png' | |
+ mail.attachments[1].filename.should eq 'smime.p7s' | |
end | |
end | |
@@ -307,32 +307,32 @@ describe "MIME Emails" do | |
mail = Mail::Message.new | |
mail.text_part { body("log message goes here") } | |
mail.add_file(fixture('attachments', 'test.png')) | |
- mail.mime_type.should == 'multipart/mixed' | |
+ mail.mime_type.should eq 'multipart/mixed' | |
end | |
it "should set to multipart/mixed if you add an attachment and then a text part" do | |
mail = Mail::Message.new | |
mail.add_file(fixture('attachments', 'test.png')) | |
mail.text_part { body("log message goes here") } | |
- mail.mime_type.should == 'multipart/mixed' | |
+ mail.mime_type.should eq 'multipart/mixed' | |
end | |
it "should add a part given a filename" do | |
mail = Mail::Message.new | |
mail.add_file(fixture('attachments', 'test.png')) | |
- mail.parts.length.should == 1 # First part is an empty text body | |
+ mail.parts.length.should eq 1 # First part is an empty text body | |
end | |
it "should give the part the right content type" do | |
mail = Mail::Message.new | |
mail.add_file(fixture('attachments', 'test.png')) | |
- mail.parts.first[:content_type].content_type.should == 'image/png' | |
+ mail.parts.first[:content_type].content_type.should eq 'image/png' | |
end | |
it "should return attachment objects" do | |
mail = Mail::Message.new | |
mail.add_file(fixture('attachments', 'test.png')) | |
- mail.attachments.first.class.should == Mail::Part | |
+ mail.attachments.first.class.should eq Mail::Part | |
end | |
it "should be return an aray of attachments" do | |
@@ -345,8 +345,8 @@ describe "MIME Emails" do | |
add_file fixture('attachments', 'test.pdf') | |
add_file fixture('attachments', 'test.zip') | |
end | |
- mail.attachments.length.should == 4 | |
- mail.attachments.each { |a| a.class.should == Mail::Part } | |
+ mail.attachments.length.should eq 4 | |
+ mail.attachments.each { |a| a.class.should eq Mail::Part } | |
end | |
it "should return the filename of each attachment" do | |
@@ -359,10 +359,10 @@ describe "MIME Emails" do | |
add_file fixture('attachments', 'test.pdf') | |
add_file fixture('attachments', 'test.zip') | |
end | |
- mail.attachments[0].filename.should == 'test.png' | |
- mail.attachments[1].filename.should == 'test.jpg' | |
- mail.attachments[2].filename.should == 'test.pdf' | |
- mail.attachments[3].filename.should == 'test.zip' | |
+ mail.attachments[0].filename.should eq 'test.png' | |
+ mail.attachments[1].filename.should eq 'test.jpg' | |
+ mail.attachments[2].filename.should eq 'test.pdf' | |
+ mail.attachments[3].filename.should eq 'test.zip' | |
end | |
it "should return the type/subtype of each attachment" do | |
@@ -375,10 +375,10 @@ describe "MIME Emails" do | |
add_file fixture('attachments', 'test.pdf') | |
add_file fixture('attachments', 'test.zip') | |
end | |
- mail.attachments[0].mime_type.should == 'image/png' | |
- mail.attachments[1].mime_type.should == 'image/jpeg' | |
- mail.attachments[2].mime_type.should == 'application/pdf' | |
- mail.attachments[3].mime_type.should == 'application/zip' | |
+ mail.attachments[0].mime_type.should eq 'image/png' | |
+ mail.attachments[1].mime_type.should eq 'image/jpeg' | |
+ mail.attachments[2].mime_type.should eq 'application/pdf' | |
+ mail.attachments[3].mime_type.should eq 'application/zip' | |
end | |
it "should return the content of each attachment" do | |
@@ -394,21 +394,21 @@ describe "MIME Emails" do | |
if RUBY_VERSION >= '1.9' | |
tripped = mail.attachments[0].decoded | |
original = File.read(fixture('attachments', 'test.png')).force_encoding(Encoding::BINARY) | |
- tripped.should == original | |
+ tripped.should eq original | |
tripped = mail.attachments[1].decoded | |
original = File.read(fixture('attachments', 'test.jpg')).force_encoding(Encoding::BINARY) | |
- tripped.should == original | |
+ tripped.should eq original | |
tripped = mail.attachments[2].decoded | |
original = File.read(fixture('attachments', 'test.pdf')).force_encoding(Encoding::BINARY) | |
- tripped.should == original | |
+ tripped.should eq original | |
tripped = mail.attachments[3].decoded | |
original = File.read(fixture('attachments', 'test.zip')).force_encoding(Encoding::BINARY) | |
- tripped.should == original | |
+ tripped.should eq original | |
else | |
- mail.attachments[0].decoded.should == File.read(fixture('attachments', 'test.png')) | |
- mail.attachments[1].decoded.should == File.read(fixture('attachments', 'test.jpg')) | |
- mail.attachments[2].decoded.should == File.read(fixture('attachments', 'test.pdf')) | |
- mail.attachments[3].decoded.should == File.read(fixture('attachments', 'test.zip')) | |
+ mail.attachments[0].decoded.should eq File.read(fixture('attachments', 'test.png')) | |
+ mail.attachments[1].decoded.should eq File.read(fixture('attachments', 'test.jpg')) | |
+ mail.attachments[2].decoded.should eq File.read(fixture('attachments', 'test.pdf')) | |
+ mail.attachments[3].decoded.should eq File.read(fixture('attachments', 'test.zip')) | |
end | |
end | |
@@ -423,9 +423,9 @@ describe "MIME Emails" do | |
if RUBY_VERSION >= '1.9' | |
tripped = mail.attachments[0].decoded | |
original = File.read(fixture('attachments', 'test.png')).force_encoding(Encoding::BINARY) | |
- tripped.should == original | |
+ tripped.should eq original | |
else | |
- mail.attachments[0].decoded.should == File.read(fixture('attachments', 'test.png')) | |
+ mail.attachments[0].decoded.should eq File.read(fixture('attachments', 'test.png')) | |
end | |
end | |
@@ -437,10 +437,10 @@ describe "MIME Emails" do | |
body "Attached" | |
add_file fixture('attachments', 'test.png') | |
end | |
- m.attachments.length.should == 1 | |
- m.parts.length.should == 2 | |
- m.parts[0].body.should == "Attached" | |
- m.parts[1].filename.should == "test.png" | |
+ m.attachments.length.should eq 1 | |
+ m.parts.length.should eq 2 | |
+ m.parts[0].body.should eq "Attached" | |
+ m.parts[1].filename.should eq "test.png" | |
end | |
it "should allow you to add a body as text part if you have added a file" do | |
@@ -451,9 +451,9 @@ describe "MIME Emails" do | |
add_file fixture('attachments', 'test.png') | |
body "Attached" | |
end | |
- m.parts.length.should == 2 | |
- m.parts.first[:content_type].content_type.should == 'image/png' | |
- m.parts.last[:content_type].content_type.should == 'text/plain' | |
+ m.parts.length.should eq 2 | |
+ m.parts.first[:content_type].content_type.should eq 'image/png' | |
+ m.parts.last[:content_type].content_type.should eq 'text/plain' | |
end | |
it "should allow you to add a body as text part if you have added a file and not truncate after newlines - issue 208" do | |
@@ -465,10 +465,10 @@ describe "MIME Emails" do | |
body "First Line\n\nSecond Line\n\nThird Line\n\n" | |
#Note: trailing \n\n is stripped off by Mail::Part initialization | |
end | |
- m.parts.length.should == 2 | |
- m.parts.first[:content_type].content_type.should == 'image/png' | |
- m.parts.last[:content_type].content_type.should == 'text/plain' | |
- m.parts.last.to_s.should match /^First Line\r\n\r\nSecond Line\r\n\r\nThird Line/ | |
+ m.parts.length.should eq 2 | |
+ m.parts.first[:content_type].content_type.should eq 'image/png' | |
+ m.parts.last[:content_type].content_type.should eq 'text/plain' | |
+ m.parts.last.to_s.should match(/^First Line\r\n\r\nSecond Line\r\n\r\nThird Line/) | |
end | |
it "should not raise a warning if there is a charset defined and there are non ascii chars in the body" do | |
diff --git a/spec/mail/multipart_report_spec.rb b/spec/mail/multipart_report_spec.rb | |
index 660aa9e..f177dba 100644 | |
--- a/spec/mail/multipart_report_spec.rb | |
+++ b/spec/mail/multipart_report_spec.rb | |
@@ -52,23 +52,23 @@ describe "multipart/report emails" do | |
end | |
it "should say action 'delayed'" do | |
- @mail.action.should == 'delayed' | |
+ @mail.action.should eq 'delayed' | |
end | |
it "should give a final recipient" do | |
- @mail.final_recipient.should == 'RFC822; [email protected]' | |
+ @mail.final_recipient.should eq 'RFC822; [email protected]' | |
end | |
it "should give an error code" do | |
- @mail.error_status.should == '4.2.2' | |
+ @mail.error_status.should eq '4.2.2' | |
end | |
it "should give a diagostic code" do | |
- @mail.diagnostic_code.should == 'SMTP; 452 4.2.2 <[email protected]>... Mailbox full' | |
+ @mail.diagnostic_code.should eq 'SMTP; 452 4.2.2 <[email protected]>... Mailbox full' | |
end | |
it "should give a remote-mta" do | |
- @mail.remote_mta.should == 'DNS; mail.oooooooo.com.au' | |
+ @mail.remote_mta.should eq 'DNS; mail.oooooooo.com.au' | |
end | |
it "should be retryable" do | |
@@ -87,23 +87,23 @@ describe "multipart/report emails" do | |
end | |
it "should say action 'failed'" do | |
- @mail.action.should == 'failed' | |
+ @mail.action.should eq 'failed' | |
end | |
it "should give a final recipient" do | |
- @mail.final_recipient.should == 'RFC822; [email protected]' | |
+ @mail.final_recipient.should eq 'RFC822; [email protected]' | |
end | |
it "should give an error code" do | |
- @mail.error_status.should == '5.3.0' | |
+ @mail.error_status.should eq '5.3.0' | |
end | |
it "should give a diagostic code" do | |
- @mail.diagnostic_code.should == 'SMTP; 553 5.3.0 <[email protected]>... Unknown E-Mail Address' | |
+ @mail.diagnostic_code.should eq 'SMTP; 553 5.3.0 <[email protected]>... Unknown E-Mail Address' | |
end | |
it "should give a remote-mta" do | |
- @mail.remote_mta.should == 'DNS; mail.zzzzzz.com' | |
+ @mail.remote_mta.should eq 'DNS; mail.zzzzzz.com' | |
end | |
it "should be retryable" do | |
diff --git a/spec/mail/network/delivery_methods/exim_spec.rb b/spec/mail/network/delivery_methods/exim_spec.rb | |
deleted file mode 100644 | |
index fae7c10..0000000 | |
--- a/spec/mail/network/delivery_methods/exim_spec.rb | |
+++ /dev/null | |
@@ -1,161 +0,0 @@ | |
-# encoding: utf-8 | |
-require 'spec_helper' | |
- | |
-describe "exim delivery agent" do | |
- | |
- before(:each) do | |
- # Reset all defaults back to original state | |
- Mail.defaults do | |
- delivery_method :smtp, { :address => "localhost", | |
- :port => 25, | |
- :domain => 'localhost.localdomain', | |
- :user_name => nil, | |
- :password => nil, | |
- :authentication => nil, | |
- :enable_starttls_auto => true } | |
- end | |
- end | |
- | |
- it "should send an email using exim" do | |
- Mail.defaults do | |
- delivery_method :exim | |
- end | |
- | |
- mail = Mail.new do | |
- from '[email protected]' | |
- to '[email protected], [email protected]' | |
- subject 'invalid RFC2822' | |
- end | |
- | |
- Mail::Exim.should_receive(:call).with('/usr/sbin/exim', | |
- '-i -t -f "[email protected]"', | |
- '[email protected] [email protected]', | |
- mail) | |
- mail.deliver! | |
- end | |
- | |
- describe "return path" do | |
- | |
- it "should send an email with a return-path using exim" do | |
- Mail.defaults do | |
- delivery_method :exim | |
- end | |
- | |
- mail = Mail.new do | |
- to "[email protected]" | |
- from "[email protected]" | |
- sender "[email protected]" | |
- subject "Can't set the return-path" | |
- return_path "[email protected]" | |
- message_id "<[email protected]>" | |
- body "body" | |
- end | |
- | |
- Mail::Exim.should_receive(:call).with('/usr/sbin/exim', | |
- '-i -t -f "[email protected]"', | |
- '[email protected]', | |
- mail) | |
- | |
- mail.deliver | |
- | |
- end | |
- | |
- it "should use the sender address is no return path is specified" do | |
- Mail.defaults do | |
- delivery_method :exim | |
- end | |
- | |
- mail = Mail.new do | |
- to "[email protected]" | |
- from "[email protected]" | |
- sender "[email protected]" | |
- subject "Can't set the return-path" | |
- message_id "<[email protected]>" | |
- body "body" | |
- end | |
- | |
- Mail::Exim.should_receive(:call).with('/usr/sbin/exim', | |
- '-i -t -f "[email protected]"', | |
- '[email protected]', | |
- mail) | |
- | |
- mail.deliver | |
- end | |
- | |
- it "should use the from address is no return path or sender are specified" do | |
- Mail.defaults do | |
- delivery_method :exim | |
- end | |
- | |
- mail = Mail.new do | |
- to "[email protected]" | |
- from "[email protected]" | |
- subject "Can't set the return-path" | |
- message_id "<[email protected]>" | |
- body "body" | |
- end | |
- | |
- Mail::Exim.should_receive(:call).with('/usr/sbin/exim', | |
- '-i -t -f "[email protected]"', | |
- '[email protected]', | |
- mail) | |
- mail.deliver | |
- end | |
- | |
- it "should escape the return path address" do | |
- Mail.defaults do | |
- delivery_method :exim | |
- end | |
- | |
- mail = Mail.new do | |
- to '[email protected]' | |
- from '"from+suffix test"@test.lindsaar.net' | |
- subject 'Can\'t set the return-path' | |
- message_id '<[email protected]>' | |
- body 'body' | |
- end | |
- | |
- Mail::Exim.should_receive(:call).with('/usr/sbin/exim', | |
- '-i -t -f "\"from+suffix test\"@test.lindsaar.net"', | |
- '[email protected]', | |
- mail) | |
- mail.deliver | |
- end | |
- end | |
- | |
- it "should still send an email if the settings have been set to nil" do | |
- Mail.defaults do | |
- delivery_method :exim, :arguments => nil | |
- end | |
- | |
- mail = Mail.new do | |
- from '[email protected]' | |
- to '[email protected], [email protected]' | |
- subject 'invalid RFC2822' | |
- end | |
- | |
- Mail::Exim.should_receive(:call).with('/usr/sbin/exim', | |
- '-f "[email protected]"', | |
- '[email protected] [email protected]', | |
- mail) | |
- mail.deliver! | |
- end | |
- | |
- it "should escape evil haxxor attemptes" do | |
- Mail.defaults do | |
- delivery_method :exim, :arguments => nil | |
- end | |
- | |
- mail = Mail.new do | |
- from '"foo\";touch /tmp/PWNED;\""@blah.com' | |
- to '[email protected]' | |
- subject 'invalid RFC2822' | |
- end | |
- | |
- Mail::Exim.should_receive(:call).with('/usr/sbin/exim', | |
- "-f \"\\\"foo\\\\\\\"\\;touch /tmp/PWNED\\;\\\\\\\"\\\"@blah.com\"", | |
- '[email protected]', | |
- mail) | |
- mail.deliver! | |
- end | |
-end | |
diff --git a/spec/mail/network/delivery_methods/file_delivery_spec.rb b/spec/mail/network/delivery_methods/file_delivery_spec.rb | |
index 73adb64..2c96039 100644 | |
--- a/spec/mail/network/delivery_methods/file_delivery_spec.rb | |
+++ b/spec/mail/network/delivery_methods/file_delivery_spec.rb | |
@@ -39,7 +39,7 @@ describe "SMTP Delivery Method" do | |
delivery = File.join(Mail.delivery_method.settings[:location], '[email protected]') | |
- File.read(delivery).should == mail.encoded | |
+ File.read(delivery).should eq mail.encoded | |
end | |
it "should send multiple emails to multiple files" do | |
@@ -56,8 +56,8 @@ describe "SMTP Delivery Method" do | |
delivery_one = File.join(Mail.delivery_method.settings[:location], '[email protected]') | |
delivery_two = File.join(Mail.delivery_method.settings[:location], '[email protected]') | |
- File.read(delivery_one).should == mail.encoded | |
- File.read(delivery_two).should == mail.encoded | |
+ File.read(delivery_one).should eq mail.encoded | |
+ File.read(delivery_two).should eq mail.encoded | |
end | |
it "should only create files based on the addr_spec of the destination" do | |
@@ -74,21 +74,6 @@ describe "SMTP Delivery Method" do | |
File.exists?(delivery).should be_true | |
end | |
- it "should use the base name of the file name to prevent file system traversal" do | |
- Mail.defaults do | |
- delivery_method :file, :location => tmpdir | |
- end | |
- | |
- Mail.deliver do | |
- from '[email protected]' | |
- to '../../../../../../../../../../../tmp/pwn' | |
- subject 'evil hacker' | |
- end | |
- | |
- delivery = File.join(Mail.delivery_method.settings[:location], 'pwn') | |
- File.exists?(delivery).should be_true | |
- end | |
- | |
end | |
end | |
diff --git a/spec/mail/network/delivery_methods/sendmail_spec.rb b/spec/mail/network/delivery_methods/sendmail_spec.rb | |
index 09a3541..27abe41 100644 | |
--- a/spec/mail/network/delivery_methods/sendmail_spec.rb | |
+++ b/spec/mail/network/delivery_methods/sendmail_spec.rb | |
@@ -101,9 +101,29 @@ describe "sendmail delivery agent" do | |
mail) | |
mail.deliver | |
end | |
- | |
+ | |
+ it "should escape the return path address" do | |
+ Mail.defaults do | |
+ delivery_method :sendmail | |
+ end | |
+ | |
+ mail = Mail.new do | |
+ to '[email protected]' | |
+ from '"from+suffix test"@test.lindsaar.net' | |
+ subject 'Can\'t set the return-path' | |
+ message_id '<[email protected]>' | |
+ body 'body' | |
+ end | |
+ | |
+ Mail::Sendmail.should_receive(:call).with('/usr/sbin/sendmail', | |
+ '-i -t -f "\"from+suffix test\"@test.lindsaar.net"', | |
+ '[email protected]', | |
+ mail) | |
+ mail.deliver | |
+ end | |
end | |
+ | |
it "should still send an email if the settings have been set to nil" do | |
Mail.defaults do | |
delivery_method :sendmail, :arguments => nil | |
@@ -121,22 +141,4 @@ describe "sendmail delivery agent" do | |
mail) | |
mail.deliver! | |
end | |
- | |
- it "should escape evil haxxor attemptes" do | |
- Mail.defaults do | |
- delivery_method :sendmail, :arguments => nil | |
- end | |
- | |
- mail = Mail.new do | |
- from '"foo\";touch /tmp/PWNED;\""@blah.com' | |
- to '"foo\";touch /tmp/PWNED;\""@blah.com' | |
- subject 'invalid RFC2822' | |
- end | |
- | |
- Mail::Sendmail.should_receive(:call).with('/usr/sbin/sendmail', | |
- "-f \"\\\"foo\\\\\\\"\\;touch /tmp/PWNED\\;\\\\\\\"\\\"@blah.com\"", | |
- "\\\"foo\\\\\\\"\\;touch /tmp/PWNED\\;\\\\\\\"\\\"@blah.com", | |
- mail) | |
- mail.deliver! | |
- end | |
end | |
diff --git a/spec/mail/network/delivery_methods/smtp_connection_spec.rb b/spec/mail/network/delivery_methods/smtp_connection_spec.rb | |
index e1aac20..e8f19c7 100644 | |
--- a/spec/mail/network/delivery_methods/smtp_connection_spec.rb | |
+++ b/spec/mail/network/delivery_methods/smtp_connection_spec.rb | |
@@ -21,9 +21,9 @@ describe "SMTP Delivery Method" do | |
subject 'invalid RFC2822' | |
end | |
- MockSMTP.deliveries[0][0].should == mail.encoded | |
- MockSMTP.deliveries[0][1].should == mail.from[0] | |
- MockSMTP.deliveries[0][2].should == mail.destinations | |
+ MockSMTP.deliveries[0][0].should eq mail.encoded | |
+ MockSMTP.deliveries[0][1].should eq mail.from[0] | |
+ MockSMTP.deliveries[0][2].should eq mail.destinations | |
end | |
it "should be able to return actual SMTP protocol response" do | |
@@ -39,7 +39,7 @@ describe "SMTP Delivery Method" do | |
end | |
response = mail.deliver! | |
- response.should eql 'OK' | |
+ response.should eq 'OK' | |
end | |
diff --git a/spec/mail/network/delivery_methods/smtp_spec.rb b/spec/mail/network/delivery_methods/smtp_spec.rb | |
index a7655cd..a548366 100644 | |
--- a/spec/mail/network/delivery_methods/smtp_spec.rb | |
+++ b/spec/mail/network/delivery_methods/smtp_spec.rb | |
@@ -13,7 +13,10 @@ describe "SMTP Delivery Method" do | |
:password => nil, | |
:authentication => nil, | |
:enable_starttls_auto => true, | |
- :openssl_verify_mode => nil } | |
+ :openssl_verify_mode => nil, | |
+ :tls => nil, | |
+ :ssl => nil | |
+ } | |
end | |
MockSMTP.clear_deliveries | |
end | |
@@ -28,9 +31,9 @@ describe "SMTP Delivery Method" do | |
subject 'invalid RFC2822' | |
end | |
- MockSMTP.deliveries[0][0].should == mail.encoded | |
- MockSMTP.deliveries[0][1].should == mail.from[0] | |
- MockSMTP.deliveries[0][2].should == mail.destinations | |
+ MockSMTP.deliveries[0][0].should eq mail.encoded | |
+ MockSMTP.deliveries[0][1].should eq mail.from[0] | |
+ MockSMTP.deliveries[0][2].should eq mail.destinations | |
end | |
it "should be able to send itself" do | |
@@ -42,9 +45,9 @@ describe "SMTP Delivery Method" do | |
mail.deliver! | |
- MockSMTP.deliveries[0][0].should == mail.encoded | |
- MockSMTP.deliveries[0][1].should == mail.from[0] | |
- MockSMTP.deliveries[0][2].should == mail.destinations | |
+ MockSMTP.deliveries[0][0].should eq mail.encoded | |
+ MockSMTP.deliveries[0][1].should eq mail.from[0] | |
+ MockSMTP.deliveries[0][2].should eq mail.destinations | |
end | |
it "should be able to return actual SMTP protocol response" do | |
@@ -59,7 +62,7 @@ describe "SMTP Delivery Method" do | |
end | |
response = mail.deliver! | |
- response.should eql 'OK' | |
+ response.should eq 'OK' | |
end | |
end | |
@@ -106,6 +109,47 @@ describe "SMTP Delivery Method" do | |
end | |
end | |
+ describe "enabling ssl" do | |
+ def redefine_verify_none(new_value) | |
+ OpenSSL::SSL.send(:remove_const, :VERIFY_NONE) | |
+ OpenSSL::SSL.send(:const_set, :VERIFY_NONE, new_value) | |
+ end | |
+ | |
+ it "should use OpenSSL::SSL::VERIFY_NONE if a context" do | |
+ | |
+ # config can't be setup until redefined | |
+ redefine_verify_none(OpenSSL::SSL::SSLContext.new) | |
+ Mail.defaults do | |
+ delivery_method :smtp, :address => 'smtp.mockup.com', :port => 587, :tls => true | |
+ end | |
+ | |
+ mail = Mail.deliver do | |
+ from '[email protected]' | |
+ to '[email protected]' | |
+ subject 'invalid RFC2822' | |
+ end | |
+ | |
+ doing { mail.deliver! }.should_not raise_error(TypeError) | |
+ end | |
+ | |
+ it "should ignore OpenSSL::SSL::VERIFY_NONE if it is 0" do | |
+ | |
+ # config can't be setup until redefined | |
+ redefine_verify_none(0) | |
+ Mail.defaults do | |
+ delivery_method :smtp, :address => 'smtp.mockup.com', :port => 587, :tls => true | |
+ end | |
+ | |
+ mail = Mail.deliver do | |
+ from '[email protected]' | |
+ to '[email protected]' | |
+ subject 'invalid RFC2822' | |
+ end | |
+ | |
+ doing { mail.deliver! }.should_not raise_error(TypeError) | |
+ end | |
+ end | |
+ | |
describe "return path" do | |
it "should use the return path if specified" do | |
@@ -118,7 +162,7 @@ describe "SMTP Delivery Method" do | |
message_id "<[email protected]>" | |
body "body" | |
end | |
- MockSMTP.deliveries[0][1].should == "[email protected]" | |
+ MockSMTP.deliveries[0][1].should eq "[email protected]" | |
end | |
it "should use the sender address is no return path is specified" do | |
@@ -130,7 +174,7 @@ describe "SMTP Delivery Method" do | |
message_id "<[email protected]>" | |
body "body" | |
end | |
- MockSMTP.deliveries[0][1].should == "[email protected]" | |
+ MockSMTP.deliveries[0][1].should eq "[email protected]" | |
end | |
it "should use the from address is no return path or sender is specified" do | |
@@ -141,7 +185,7 @@ describe "SMTP Delivery Method" do | |
message_id "<[email protected]>" | |
body "body" | |
end | |
- MockSMTP.deliveries[0][1].should == "[email protected]" | |
+ MockSMTP.deliveries[0][1].should eq "[email protected]" | |
end | |
end | |
diff --git a/spec/mail/network/delivery_methods/test_mailer_spec.rb b/spec/mail/network/delivery_methods/test_mailer_spec.rb | |
index 3c9cb6e..6a843fb 100644 | |
--- a/spec/mail/network/delivery_methods/test_mailer_spec.rb | |
+++ b/spec/mail/network/delivery_methods/test_mailer_spec.rb | |
@@ -34,8 +34,8 @@ describe "Mail::TestMailer" do | |
body 'hello' | |
end | |
mail.deliver | |
- Mail::TestMailer.deliveries.length.should == 1 | |
- Mail::TestMailer.deliveries.first.should == mail | |
+ Mail::TestMailer.deliveries.length.should eq 1 | |
+ Mail::TestMailer.deliveries.first.should eq mail | |
end | |
it "should clear the deliveries when told to" do | |
@@ -49,7 +49,7 @@ describe "Mail::TestMailer" do | |
body 'hello' | |
end | |
mail.deliver | |
- Mail::TestMailer.deliveries.length.should == 1 | |
+ Mail::TestMailer.deliveries.length.should eq 1 | |
Mail::TestMailer.deliveries.clear | |
Mail::TestMailer.deliveries.should be_empty | |
end | |
diff --git a/spec/mail/network/retriever_methods/imap_spec.rb b/spec/mail/network/retriever_methods/imap_spec.rb | |
index e07e5b9..7a0710c 100644 | |
--- a/spec/mail/network/retriever_methods/imap_spec.rb | |
+++ b/spec/mail/network/retriever_methods/imap_spec.rb | |
@@ -21,7 +21,7 @@ describe "IMAP Retriever" do | |
Mail.all do |message| | |
messages << message | |
end | |
- messages.map { |m| m.raw_source }.sort.should == MockIMAP.examples.map { |m| m.attr['RFC822']}.sort | |
+ messages.map { |m| m.raw_source }.sort.should eq MockIMAP.examples.map { |m| m.attr['RFC822']}.sort | |
MockIMAP.should be_disconnected | |
end | |
@@ -29,7 +29,7 @@ describe "IMAP Retriever" do | |
MockIMAP.should be_disconnected | |
messages = Mail.all | |
- messages.map { |m| m.raw_source }.sort.should == MockIMAP.examples.map { |m| m.attr['RFC822']}.sort | |
+ messages.map { |m| m.raw_source }.sort.should eq MockIMAP.examples.map { |m| m.attr['RFC822']}.sort | |
MockIMAP.should be_disconnected | |
end | |
@@ -43,8 +43,8 @@ describe "IMAP Retriever" do | |
messages << message | |
uids << uid | |
end | |
- messages.map { |m| m.raw_source }.sort.should == MockIMAP.examples.map { |m| m.attr['RFC822']}.sort | |
- uids.sort.should == MockIMAP.examples.map { |m| m.number }.sort | |
+ messages.map { |m| m.raw_source }.sort.should eq MockIMAP.examples.map { |m| m.attr['RFC822']}.sort | |
+ uids.sort.should eq MockIMAP.examples.map { |m| m.number }.sort | |
MockIMAP.should be_disconnected | |
end | |
@@ -53,58 +53,58 @@ describe "IMAP Retriever" do | |
describe "find and options" do | |
it "should handle the :count option" do | |
messages = Mail.find(:count => :all, :what => :last, :order => :asc) | |
- messages.map { |m| m.raw_source }.should == MockIMAP.examples.map { |m| m.attr['RFC822'] } | |
+ messages.map { |m| m.raw_source }.should eq MockIMAP.examples.map { |m| m.attr['RFC822'] } | |
message = Mail.find(:count => 1, :what => :last) | |
- message.raw_source.should == MockIMAP.examples.last.attr['RFC822'] | |
+ message.raw_source.should eq MockIMAP.examples.last.attr['RFC822'] | |
messages = Mail.find(:count => 2, :what => :last, :order => :asc) | |
- messages[0..1].map { |m| m.raw_source }.should == MockIMAP.examples.map { |m| m.attr['RFC822'] }[-2..-1] | |
+ messages[0..1].map { |m| m.raw_source }.should eq MockIMAP.examples.map { |m| m.attr['RFC822'] }[-2..-1] | |
end | |
it "should handle the :what option" do | |
messages = Mail.find(:count => :all, :what => :last) | |
- messages.map { |m| m.raw_source }.should == MockIMAP.examples.map { |m| m.attr['RFC822'] } | |
+ messages.map { |m| m.raw_source }.should eq MockIMAP.examples.map { |m| m.attr['RFC822'] } | |
messages = Mail.find(:count => 2, :what => :first, :order => :asc) | |
- messages.map { |m| m.raw_source }.should == MockIMAP.examples.map { |m| m.attr['RFC822'] }[0..1] | |
+ messages.map { |m| m.raw_source }.should eq MockIMAP.examples.map { |m| m.attr['RFC822'] }[0..1] | |
end | |
it "should handle the :order option" do | |
messages = Mail.find(:order => :desc, :count => 5, :what => :last) | |
- messages.map { |m| m.raw_source }.should == MockIMAP.examples.map { |m| m.attr['RFC822'] }[-5..-1].reverse | |
+ messages.map { |m| m.raw_source }.should eq MockIMAP.examples.map { |m| m.attr['RFC822'] }[-5..-1].reverse | |
messages = Mail.find(:order => :asc, :count => 5, :what => :last) | |
- messages.map { |m| m.raw_source }.should == MockIMAP.examples.map { |m| m.attr['RFC822'] }[-5..-1] | |
+ messages.map { |m| m.raw_source }.should eq MockIMAP.examples.map { |m| m.attr['RFC822'] }[-5..-1] | |
end | |
it "should handle the :mailbox option" do | |
messages = Mail.find(:mailbox => 'SOME-RANDOM-MAILBOX') | |
- MockIMAP.mailbox.should == 'SOME-RANDOM-MAILBOX' | |
+ MockIMAP.mailbox.should eq 'SOME-RANDOM-MAILBOX' | |
end | |
it "should find the last 10 messages by default" do | |
messages = Mail.find | |
- messages.size.should == 10 | |
+ messages.size.should eq 10 | |
end | |
it "should search the mailbox 'INBOX' by default" do | |
messages = Mail.find | |
- MockIMAP.mailbox.should == 'INBOX' | |
+ MockIMAP.mailbox.should eq 'INBOX' | |
end | |
it "should handle the delete_after_find_option" do | |
Mail.find(:delete_after_find => false) | |
- MockIMAP.examples.size.should == 20 | |
+ MockIMAP.examples.size.should eq 20 | |
Mail.find(:delete_after_find => true) | |
- MockIMAP.examples.size.should == 10 | |
+ MockIMAP.examples.size.should eq 10 | |
Mail.find(:delete_after_find => true) { |message| } | |
- MockIMAP.examples.size.should == 10 | |
+ MockIMAP.examples.size.should eq 10 | |
end | |
it "should handle the find_and_delete method" do | |
Mail.find_and_delete(:count => 15) | |
- MockIMAP.examples.size.should == 5 | |
+ MockIMAP.examples.size.should eq 5 | |
end | |
end | |
@@ -114,12 +114,12 @@ describe "IMAP Retriever" do | |
messages = Mail.last(:count => 5) | |
messages.should be_instance_of(Array) | |
- messages.map { |m| m.raw_source }.should == MockIMAP.examples.map { |m| m.attr['RFC822']}[-5..-1] | |
+ messages.map { |m| m.raw_source }.should eq MockIMAP.examples.map { |m| m.attr['RFC822']}[-5..-1] | |
end | |
it "should find the last received message" do | |
message = Mail.last | |
- message.raw_source.should == MockIMAP.examples.last.attr['RFC822'] | |
+ message.raw_source.should eq MockIMAP.examples.last.attr['RFC822'] | |
end | |
end | |
@@ -128,12 +128,12 @@ describe "IMAP Retriever" do | |
messages = Mail.first(:count => 5) | |
messages.should be_instance_of(Array) | |
- messages.map { |m| m.raw_source }.should == MockIMAP.examples.map { |m| m.attr['RFC822']}[0..4] | |
+ messages.map { |m| m.raw_source }.should eq MockIMAP.examples.map { |m| m.attr['RFC822']}[0..4] | |
end | |
it "should find the first received message" do | |
message = Mail.first | |
- message.raw_source.should == MockIMAP.examples.first.attr['RFC822'] | |
+ message.raw_source.should eq MockIMAP.examples.first.attr['RFC822'] | |
end | |
end | |
@@ -141,8 +141,8 @@ describe "IMAP Retriever" do | |
it "should find all messages" do | |
messages = Mail.all | |
- messages.size.should == MockIMAP.examples.size | |
- messages.map { |m| m.raw_source }.should == MockIMAP.examples.map { |m| m.attr['RFC822'] } | |
+ messages.size.should eq MockIMAP.examples.size | |
+ messages.map { |m| m.raw_source }.should eq MockIMAP.examples.map { |m| m.attr['RFC822'] } | |
end | |
end | |
@@ -153,7 +153,7 @@ describe "IMAP Retriever" do | |
Net::IMAP.should_receive(:encode_utf7).once | |
Mail.delete_all | |
- MockIMAP.examples.size.should == 0 | |
+ MockIMAP.examples.size.should eq 0 | |
end | |
end | |
@@ -174,16 +174,16 @@ describe "IMAP Retriever" do | |
options = retrievable.send(:validate_options, {}) | |
options[:count].should_not be_blank | |
- options[:count].should == 10 | |
+ options[:count].should eq 10 | |
options[:order].should_not be_blank | |
- options[:order].should == :asc | |
+ options[:order].should eq :asc | |
options[:what].should_not be_blank | |
- options[:what].should == :first | |
+ options[:what].should eq :first | |
options[:mailbox].should_not be_blank | |
- options[:mailbox].should == 'INBOX' | |
+ options[:mailbox].should eq 'INBOX' | |
end | |
it "should not replace given configuration" do | |
retrievable = Mail::IMAP.new({}) | |
@@ -195,16 +195,16 @@ describe "IMAP Retriever" do | |
}) | |
options[:count].should_not be_blank | |
- options[:count].should == 2 | |
+ options[:count].should eq 2 | |
options[:order].should_not be_blank | |
- options[:order].should == :asc | |
+ options[:order].should eq :asc | |
options[:what].should_not be_blank | |
- options[:what].should == :first | |
+ options[:what].should eq :first | |
options[:mailbox].should_not be_blank | |
- options[:mailbox].should == 'some/mail/box' | |
+ options[:mailbox].should eq 'some/mail/box' | |
end | |
it "should ensure utf7 conversion for mailbox names" do | |
retrievable = Mail::IMAP.new({}) | |
@@ -213,7 +213,7 @@ describe "IMAP Retriever" do | |
options = retrievable.send(:validate_options, { | |
:mailbox => 'UTF8_STRING' | |
}) | |
- options[:mailbox].should == 'UTF7_STRING' | |
+ options[:mailbox].should eq 'UTF7_STRING' | |
end | |
end | |
diff --git a/spec/mail/network/retriever_methods/pop3_spec.rb b/spec/mail/network/retriever_methods/pop3_spec.rb | |
index e572457..18045f9 100644 | |
--- a/spec/mail/network/retriever_methods/pop3_spec.rb | |
+++ b/spec/mail/network/retriever_methods/pop3_spec.rb | |
@@ -25,7 +25,7 @@ describe "POP3 Retriever" do | |
messages << message | |
end | |
- messages.map { |m| m.raw_source }.sort.should == MockPOP3.popmails.map { |p| p.pop }.sort | |
+ messages.map { |m| m.raw_source }.sort.should eq MockPOP3.popmails.map { |p| p.pop }.sort | |
MockPOP3.should_not be_started | |
end | |
@@ -37,7 +37,7 @@ describe "POP3 Retriever" do | |
messages << message | |
end | |
- messages.map { |m| m.raw_source }.sort.should == MockPOP3.popmails.map { |p| p.pop }.sort | |
+ messages.map { |m| m.raw_source }.sort.should eq MockPOP3.popmails.map { |p| p.pop }.sort | |
MockPOP3.should_not be_started | |
end | |
@@ -47,35 +47,35 @@ describe "POP3 Retriever" do | |
it "should handle the :count option" do | |
messages = Mail.find(:count => :all, :what => :last, :order => :asc) | |
- messages.map { |m| m.raw_source }.sort.should == MockPOP3.popmails.map { |p| p.pop } | |
+ messages.map { |m| m.raw_source }.sort.should eq MockPOP3.popmails.map { |p| p.pop } | |
message = Mail.find(:count => 1, :what => :last) | |
- message.raw_source.should == MockPOP3.popmails.map { |p| p.pop }.last | |
+ message.raw_source.should eq MockPOP3.popmails.map { |p| p.pop }.last | |
messages = Mail.find(:count => 2, :what => :last, :order => :asc) | |
- messages[0..1].collect {|m| m.raw_source}.should == MockPOP3.popmails.map { |p| p.pop }[-2..-1] | |
+ messages[0..1].collect {|m| m.raw_source}.should eq MockPOP3.popmails.map { |p| p.pop }[-2..-1] | |
end | |
it "should handle the :what option" do | |
messages = Mail.find(:count => :all, :what => :last) | |
- messages.map { |m| m.raw_source }.sort.should == MockPOP3.popmails.map { |p| p.pop } | |
+ messages.map { |m| m.raw_source }.sort.should eq MockPOP3.popmails.map { |p| p.pop } | |
messages = Mail.find(:count => 2, :what => :first, :order => :asc) | |
- messages.map { |m| m.raw_source }.should == MockPOP3.popmails.map { |p| p.pop }[0..1] | |
+ messages.map { |m| m.raw_source }.should eq MockPOP3.popmails.map { |p| p.pop }[0..1] | |
end | |
it "should handle the :order option" do | |
messages = Mail.find(:order => :desc, :count => 5, :what => :last) | |
- messages.map { |m| m.raw_source }.should == MockPOP3.popmails.map { |p| p.pop }[-5..-1].reverse | |
+ messages.map { |m| m.raw_source }.should eq MockPOP3.popmails.map { |p| p.pop }[-5..-1].reverse | |
messages = Mail.find(:order => :asc, :count => 5, :what => :last) | |
- messages.map { |m| m.raw_source }.should == MockPOP3.popmails.map { |p| p.pop }[-5..-1] | |
+ messages.map { |m| m.raw_source }.should eq MockPOP3.popmails.map { |p| p.pop }[-5..-1] | |
end | |
it "should find the last 10 messages by default" do | |
messages = Mail.find | |
- messages.size.should == 10 | |
+ messages.size.should eq 10 | |
end | |
it "should handle the delete_after_find option" do | |
@@ -105,14 +105,14 @@ describe "POP3 Retriever" do | |
messages = Mail.last(:count => 5) | |
messages.should be_instance_of(Array) | |
- messages.map { |m| m.raw_source }.should == MockPOP3.popmails.map { |p| p.pop }[-5..-1] | |
+ messages.map { |m| m.raw_source }.should eq MockPOP3.popmails.map { |p| p.pop }[-5..-1] | |
end | |
it "should find the last received message" do | |
message = Mail.last | |
message.should be_instance_of(Mail::Message) | |
- message.raw_source.should == MockPOP3.popmails.last.pop | |
+ message.raw_source.should eq MockPOP3.popmails.last.pop | |
end | |
end | |
@@ -123,14 +123,14 @@ describe "POP3 Retriever" do | |
messages = Mail.first(:count => 5) | |
messages.should be_instance_of(Array) | |
- messages.map { |m| m.raw_source }.should == MockPOP3.popmails.map { |p| p.pop }[0..4] | |
+ messages.map { |m| m.raw_source }.should eq MockPOP3.popmails.map { |p| p.pop }[0..4] | |
end | |
it "should find the first received message" do | |
message = Mail.first | |
message.should be_instance_of(Mail::Message) | |
- message.raw_source.should == MockPOP3.popmails.first.pop | |
+ message.raw_source.should eq MockPOP3.popmails.first.pop | |
end | |
end | |
@@ -140,8 +140,8 @@ describe "POP3 Retriever" do | |
it "should find all messages" do | |
messages = Mail.all | |
- messages.size.should == MockPOP3.popmails.size | |
- messages.map { |m| m.raw_source }.should == MockPOP3.popmails.map { |p| p.pop } | |
+ messages.size.should eq MockPOP3.popmails.size | |
+ messages.map { |m| m.raw_source }.should eq MockPOP3.popmails.map { |p| p.pop } | |
end | |
end | |
@@ -151,7 +151,7 @@ describe "POP3 Retriever" do | |
messages = Mail.all | |
Mail.delete_all | |
- MockPOP3.popmails.size.should == 0 | |
+ MockPOP3.popmails.size.should eq 0 | |
end | |
end | |
@@ -173,13 +173,13 @@ describe "POP3 Retriever" do | |
options = retrievable.send(:validate_options, {}) | |
options[:count].should_not be_blank | |
- options[:count].should == 10 | |
+ options[:count].should eq 10 | |
options[:order].should_not be_blank | |
- options[:order].should == :asc | |
+ options[:order].should eq :asc | |
options[:what].should_not be_blank | |
- options[:what].should == :first | |
+ options[:what].should eq :first | |
end | |
it "should not replace given configuration" do | |
@@ -191,13 +191,13 @@ describe "POP3 Retriever" do | |
}) | |
options[:count].should_not be_blank | |
- options[:count].should == 2 | |
+ options[:count].should eq 2 | |
options[:order].should_not be_blank | |
- options[:order].should == :asc | |
+ options[:order].should eq :asc | |
options[:what].should_not be_blank | |
- options[:what].should == :first | |
+ options[:what].should eq :first | |
end | |
end | |
diff --git a/spec/mail/network/retriever_methods/test_retriever_spec.rb b/spec/mail/network/retriever_methods/test_retriever_spec.rb | |
index c89a7df..c7eb62d 100644 | |
--- a/spec/mail/network/retriever_methods/test_retriever_spec.rb | |
+++ b/spec/mail/network/retriever_methods/test_retriever_spec.rb | |
@@ -19,13 +19,13 @@ describe "Test Retriever" do | |
end | |
it "should return all emails without a block" do | |
- Mail.all.should == @emails | |
+ Mail.all.should eq @emails | |
end | |
it "should return all emails with a block" do | |
messages = [] | |
Mail.all { |message| messages << message } | |
- messages.should == @emails | |
+ messages.should eq @emails | |
end | |
end | |
@@ -37,27 +37,27 @@ describe "Test Retriever" do | |
end | |
it "should handle the :count option" do | |
- Mail.find(:count => :all).should == @emails | |
- Mail.find(:count => 1).should == @emails.first | |
- Mail.find(:count => 5).should == @emails[0, 5] | |
+ Mail.find(:count => :all).should eq @emails | |
+ Mail.find(:count => 1).should eq @emails.first | |
+ Mail.find(:count => 5).should eq @emails[0, 5] | |
end | |
it "should handle the :order option" do | |
- Mail.find(:order => :asc).should == @emails | |
- Mail.find(:order => :desc).should == @emails.reverse | |
+ Mail.find(:order => :asc).should eq @emails | |
+ Mail.find(:order => :desc).should eq @emails.reverse | |
end | |
it "should handle the :what option" do | |
- Mail.find(:what => :first).should == @emails | |
- Mail.find(:what => :first, :count => 5).should == @emails[0, 5] | |
- Mail.find(:what => :last).should == @emails | |
- Mail.find(:what => :last, :count => 5).should == @emails[10, 5] | |
+ Mail.find(:what => :first).should eq @emails | |
+ Mail.find(:what => :first, :count => 5).should eq @emails[0, 5] | |
+ Mail.find(:what => :last).should eq @emails | |
+ Mail.find(:what => :last, :count => 5).should eq @emails[10, 5] | |
end | |
it "should handle the :delete_after_find option" do | |
- Mail.find(:delete_after_find => false).should == @emails | |
- Mail.find(:delete_after_find => false).should == @emails | |
- Mail.find(:delete_after_find => true).should == @emails | |
+ Mail.find(:delete_after_find => false).should eq @emails | |
+ Mail.find(:delete_after_find => false).should eq @emails | |
+ Mail.find(:delete_after_find => true).should eq @emails | |
Mail.find(:delete_after_find => false).should be_empty | |
end | |
@@ -71,7 +71,7 @@ describe "Test Retriever" do | |
end | |
i += 1 | |
end | |
- Mail.all.should == messages | |
+ Mail.all.should eq messages | |
end | |
end | |
diff --git a/spec/mail/network_spec.rb b/spec/mail/network_spec.rb | |
index 8f221b0..26648ee 100644 | |
--- a/spec/mail/network_spec.rb | |
+++ b/spec/mail/network_spec.rb | |
@@ -32,59 +32,61 @@ describe "Mail" do | |
Mail.defaults do | |
delivery_method :smtp | |
end | |
- Mail.delivery_method.class.should == Mail::SMTP | |
+ Mail.delivery_method.class.should eq Mail::SMTP | |
end | |
it "should default to settings for smtp" do | |
- Mail.delivery_method.class.should == Mail::SMTP | |
- Mail.delivery_method.settings.should == { :address => "localhost", | |
+ Mail.delivery_method.class.should eq Mail::SMTP | |
+ Mail.delivery_method.settings.should eql({:address => "localhost", | |
:port => 25, | |
:domain => 'localhost.localdomain', | |
:user_name => nil, | |
:password => nil, | |
:authentication => nil, | |
:enable_starttls_auto => true, | |
- :openssl_verify_mode => nil } | |
+ :openssl_verify_mode => nil, | |
+ :ssl => nil, | |
+ :tls => nil }) | |
end | |
it "should set the retriever method" do | |
Mail.defaults do | |
retriever_method :pop3 | |
end | |
- Mail.retriever_method.class.should == Mail::POP3 | |
+ Mail.retriever_method.class.should eq Mail::POP3 | |
end | |
it "should default to settings for pop3" do | |
- Mail.retriever_method.class.should == Mail::POP3 | |
- Mail.retriever_method.settings.should == { :address => "localhost", | |
+ Mail.retriever_method.class.should eq Mail::POP3 | |
+ Mail.retriever_method.settings.should eql({:address => "localhost", | |
:port => 110, | |
:user_name => nil, | |
:password => nil, | |
:authentication => nil, | |
- :enable_ssl => true } | |
+ :enable_ssl => true }) | |
end | |
it "should allow us to overwrite anything we need on SMTP" do | |
Mail.defaults do | |
delivery_method :smtp, :port => 999 | |
end | |
- Mail.delivery_method.settings[:address].should == 'localhost' | |
- Mail.delivery_method.settings[:port].should == 999 | |
+ Mail.delivery_method.settings[:address].should eq 'localhost' | |
+ Mail.delivery_method.settings[:port].should eq 999 | |
end | |
it "should allow us to overwrite anything we need on POP3" do | |
Mail.defaults do | |
retriever_method :pop3, :address => 'foo.bar.com' | |
end | |
- Mail.retriever_method.settings[:address].should == 'foo.bar.com' | |
- Mail.retriever_method.settings[:port].should == 110 | |
+ Mail.retriever_method.settings[:address].should eq 'foo.bar.com' | |
+ Mail.retriever_method.settings[:port].should eq 110 | |
end | |
it "should allow you to pass in your own delivery method" do | |
Mail.defaults do | |
delivery_method MyDelivery | |
end | |
- Mail.delivery_method.class.should == MyDelivery | |
+ Mail.delivery_method.class.should eq MyDelivery | |
end | |
it "should ask the custom delivery agent for it's settings" do | |
@@ -94,14 +96,14 @@ describe "Mail" do | |
Mail.defaults do | |
delivery_method MyDelivery | |
end | |
- Mail.delivery_method.settings.should == {:these_are => :settings} | |
+ Mail.delivery_method.settings.should eql({:these_are => :settings}) | |
end | |
it "should allow you to pass in your own retriever method" do | |
Mail.defaults do | |
retriever_method MyRetriever | |
end | |
- Mail.retriever_method.class.should == MyRetriever | |
+ Mail.retriever_method.class.should eq MyRetriever | |
end | |
it "should ask the custom retriever agent for it's settings" do | |
@@ -111,7 +113,7 @@ describe "Mail" do | |
Mail.defaults do | |
retriever_method MyRetriever | |
end | |
- Mail.retriever_method.settings.should == {:these_are => :settings} | |
+ Mail.retriever_method.settings.should eql({:these_are => :settings}) | |
end | |
end | |
@@ -120,39 +122,39 @@ describe "Mail" do | |
it "should copy the defaults defined by Mail.defaults" do | |
mail = Mail.new | |
- mail.delivery_method.class.should == Mail::SMTP | |
+ mail.delivery_method.class.should eq Mail::SMTP | |
end | |
it "should be able to change the delivery_method" do | |
mail = Mail.new | |
mail.delivery_method :file | |
- mail.delivery_method.class.should == Mail::FileDelivery | |
+ mail.delivery_method.class.should eq Mail::FileDelivery | |
end | |
it "should be able to change the delivery_method and pass in settings" do | |
mail = Mail.new | |
tmpdir = File.expand_path('../../../tmp/mail', __FILE__) | |
mail.delivery_method :file, :location => tmpdir | |
- mail.delivery_method.class.should == Mail::FileDelivery | |
- mail.delivery_method.settings.should == {:location => tmpdir} | |
+ mail.delivery_method.class.should eq Mail::FileDelivery | |
+ mail.delivery_method.settings.should eql({:location => tmpdir}) | |
end | |
it "should not change the default when it changes the delivery_method" do | |
mail1 = Mail.new | |
mail2 = Mail.new | |
mail1.delivery_method :file | |
- Mail.delivery_method.class.should == Mail::SMTP | |
- mail1.delivery_method.class.should == Mail::FileDelivery | |
- mail2.delivery_method.class.should == Mail::SMTP | |
+ Mail.delivery_method.class.should eq Mail::SMTP | |
+ mail1.delivery_method.class.should eq Mail::FileDelivery | |
+ mail2.delivery_method.class.should eq Mail::SMTP | |
end | |
it "should not change the default settings when it changes the delivery_method settings" do | |
mail1 = Mail.new | |
mail2 = Mail.new | |
mail1.delivery_method :smtp, :address => 'my.own.address' | |
- Mail.delivery_method.settings[:address].should == 'localhost' | |
- mail1.delivery_method.settings[:address].should == 'my.own.address' | |
- mail2.delivery_method.settings[:address].should == 'localhost' | |
+ Mail.delivery_method.settings[:address].should eq 'localhost' | |
+ mail1.delivery_method.settings[:address].should eq 'my.own.address' | |
+ mail2.delivery_method.settings[:address].should eq 'localhost' | |
end | |
end | |
@@ -184,9 +186,9 @@ describe "Mail" do | |
# add_file 'New Header Image', '/somefile.png' | |
end | |
- MockSMTP.deliveries[0][0].should == message.encoded | |
- MockSMTP.deliveries[0][1].should == "[email protected]" | |
- MockSMTP.deliveries[0][2].should == ["[email protected]"] | |
+ MockSMTP.deliveries[0][0].should eq message.encoded | |
+ MockSMTP.deliveries[0][1].should eq "[email protected]" | |
+ MockSMTP.deliveries[0][2].should eq ["[email protected]"] | |
end | |
it "should deliver itself" do | |
@@ -200,9 +202,9 @@ describe "Mail" do | |
message.deliver! | |
- MockSMTP.deliveries[0][0].should == message.encoded | |
- MockSMTP.deliveries[0][1].should == "[email protected]" | |
- MockSMTP.deliveries[0][2].should == ["[email protected]"] | |
+ MockSMTP.deliveries[0][0].should eq message.encoded | |
+ MockSMTP.deliveries[0][1].should eq "[email protected]" | |
+ MockSMTP.deliveries[0][2].should eq ["[email protected]"] | |
end | |
end | |
@@ -221,7 +223,8 @@ describe "Mail" do | |
class MyDeliveryHandler | |
def deliver_mail(mail) | |
- yield | |
+ postman = MyDeliveryMethod.new | |
+ postman.deliver!(mail) | |
end | |
end | |
@@ -290,7 +293,7 @@ describe "Mail" do | |
it "should tell it's observers that it was told to deliver an email even if it is using a delivery_handler" do | |
Mail.register_observer(MyObserver) | |
- @message.delivery_handler = MyDeliveryHandler.new | |
+ @message.delivery_handler = MyYieldingDeliveryHandler.new | |
@message.perform_deliveries = false | |
MyObserver.should_receive(:delivered_email).with(@message).once | |
@message.deliver | |
@@ -318,31 +321,31 @@ describe "Mail" do | |
describe "delivery_handler" do | |
it "should allow you to hand off performing the actual delivery to another object" do | |
- delivery_handler = MyDeliveryHandler.new | |
+ delivery_handler = MyYieldingDeliveryHandler.new | |
delivery_handler.should_receive(:deliver_mail).with(@message).exactly(:once) | |
@message.delivery_handler = delivery_handler | |
@message.deliver | |
end | |
it "mail should be told to :deliver once and then :deliver! once by the delivery handler" do | |
- @message.delivery_handler = MyDeliveryHandler.new | |
+ @message.delivery_handler = MyYieldingDeliveryHandler.new | |
@message.should_receive(:do_delivery).exactly(:once) | |
@message.deliver | |
end | |
it "mail only call it's delivery_method once" do | |
- @message.delivery_handler = MyDeliveryHandler.new | |
+ @message.delivery_handler = MyYieldingDeliveryHandler.new | |
@message.should_receive(:delivery_method).exactly(:once).and_return(Mail::TestMailer.new({})) | |
@message.deliver | |
end | |
it "mail should not catch any exceptions when using a delivery_handler" do | |
- @message.delivery_handler = MyDeliveryHandler.new | |
+ @message.delivery_handler = MyYieldingDeliveryHandler.new | |
@message.should_receive(:delivery_method).and_raise(Exception) | |
doing { @message.deliver }.should raise_error(Exception) | |
end | |
- it "mail should not modify the Mail.deliveries object if using a delivery_handler" do | |
+ it "mail should not modify the Mail.deliveries object if using a delivery_handler that does not append to deliveries" do | |
@message.delivery_handler = MyDeliveryHandler.new | |
doing { @message.deliver }.should_not change(Mail::TestMailer, :deliveries) | |
end | |
diff --git a/spec/mail/parsers/content_transfer_encoding_parser_spec.rb b/spec/mail/parsers/content_transfer_encoding_parser_spec.rb | |
index 28beed6..b7db93c 100644 | |
--- a/spec/mail/parsers/content_transfer_encoding_parser_spec.rb | |
+++ b/spec/mail/parsers/content_transfer_encoding_parser_spec.rb | |
@@ -12,7 +12,7 @@ describe "ContentTransferEncodingParser" do | |
text = "quoted-printable" | |
a = Mail::ContentTransferEncodingParser.new | |
a.parse(text).should_not be_nil | |
- a.parse(text).encoding.text_value.should == 'quoted-printable' | |
+ a.parse(text).encoding.text_value.should eq 'quoted-printable' | |
end | |
describe "trailing semi colons" do | |
@@ -21,28 +21,28 @@ describe "ContentTransferEncodingParser" do | |
text = "quoted-printable;" | |
a = Mail::ContentTransferEncodingParser.new | |
a.parse(text).should_not be_nil | |
- a.parse(text).encoding.text_value.should == 'quoted-printable' | |
+ a.parse(text).encoding.text_value.should eq 'quoted-printable' | |
end | |
it "should parse with pre white space" do | |
text = 'quoted-printable ;' | |
a = Mail::ContentTransferEncodingParser.new | |
a.parse(text).should_not be_nil | |
- a.parse(text).encoding.text_value.should == 'quoted-printable' | |
+ a.parse(text).encoding.text_value.should eq 'quoted-printable' | |
end | |
it "should parse with trailing white space" do | |
text = 'quoted-printable; ' | |
a = Mail::ContentTransferEncodingParser.new | |
a.parse(text).should_not be_nil | |
- a.parse(text).encoding.text_value.should == 'quoted-printable' | |
+ a.parse(text).encoding.text_value.should eq 'quoted-printable' | |
end | |
it "should parse with pre and trailing white space" do | |
text = 'quoted-printable ; ' | |
a = Mail::ContentTransferEncodingParser.new | |
a.parse(text).should_not be_nil | |
- a.parse(text).encoding.text_value.should == 'quoted-printable' | |
+ a.parse(text).encoding.text_value.should eq 'quoted-printable' | |
end | |
end | |
@@ -51,7 +51,7 @@ describe "ContentTransferEncodingParser" do | |
text = 'x-my-token' | |
a = Mail::ContentTransferEncodingParser.new | |
a.parse(text).should_not be_nil | |
- a.parse(text).encoding.text_value.should == 'x-my-token' | |
+ a.parse(text).encoding.text_value.should eq 'x-my-token' | |
end | |
end | |
@@ -60,14 +60,14 @@ describe "ContentTransferEncodingParser" do | |
text = '8bits' | |
a = Mail::ContentTransferEncodingParser.new | |
a.parse(text).should_not be_nil | |
- a.parse(text).encoding.text_value.should == '8bit' | |
+ a.parse(text).encoding.text_value.should eq '8bit' | |
end | |
it "should convert 7bits to 7bit" do | |
text = '7bits' | |
a = Mail::ContentTransferEncodingParser.new | |
a.parse(text).should_not be_nil | |
- a.parse(text).encoding.text_value.should == '7bit' | |
+ a.parse(text).encoding.text_value.should eq '7bit' | |
end | |
end | |
end | |
diff --git a/spec/mail/part_spec.rb b/spec/mail/part_spec.rb | |
index 4f50664..4c019f0 100644 | |
--- a/spec/mail/part_spec.rb | |
+++ b/spec/mail/part_spec.rb | |
@@ -15,7 +15,7 @@ describe Mail::Part do | |
content_id "<thisis@acontentid>" | |
body "This is Text" | |
end | |
- part.content_id.should == "<thisis@acontentid>" | |
+ part.content_id.should eq "<thisis@acontentid>" | |
end | |
it "should return an inline content_id" do | |
@@ -23,9 +23,9 @@ describe Mail::Part do | |
content_id "<thisis@acontentid>" | |
body "This is Text" | |
end | |
- part.cid.should == "thisis@acontentid" | |
+ part.cid.should eq "thisis@acontentid" | |
STDERR.should_receive(:puts).with("Part#inline_content_id is deprecated, please call Part#cid instead") | |
- part.inline_content_id.should == "thisis@acontentid" | |
+ part.inline_content_id.should eq "thisis@acontentid" | |
end | |
@@ -34,9 +34,9 @@ describe Mail::Part do | |
content_id "<thi%%sis@acontentid>" | |
body "This is Text" | |
end | |
- part.cid.should == "thi%25%25sis@acontentid" | |
+ part.cid.should eq "thi%25%25sis@acontentid" | |
STDERR.should_receive(:puts).with("Part#inline_content_id is deprecated, please call Part#cid instead") | |
- part.inline_content_id.should == "thi%25%25sis@acontentid" | |
+ part.inline_content_id.should eq "thi%25%25sis@acontentid" | |
end | |
it "should add a content_id if there is none and is asked for an inline_content_id" do | |
@@ -117,23 +117,23 @@ ENDPART | |
end | |
it "should say action 'delayed'" do | |
- @delivery_report.action.should == 'failed' | |
+ @delivery_report.action.should eq 'failed' | |
end | |
it "should give a final recipient" do | |
- @delivery_report.final_recipient.should == 'RFC822; [email protected]' | |
+ @delivery_report.final_recipient.should eq 'RFC822; [email protected]' | |
end | |
it "should give an error code" do | |
- @delivery_report.error_status.should == '5.3.0' | |
+ @delivery_report.error_status.should eq '5.3.0' | |
end | |
it "should give a diagostic code" do | |
- @delivery_report.diagnostic_code.should == 'SMTP; 553 5.3.0 <[email protected]>... Unknown E-Mail Address' | |
+ @delivery_report.diagnostic_code.should eq 'SMTP; 553 5.3.0 <[email protected]>... Unknown E-Mail Address' | |
end | |
it "should give a remote-mta" do | |
- @delivery_report.remote_mta.should == 'DNS; mail.zzzzzz.com' | |
+ @delivery_report.remote_mta.should eq 'DNS; mail.zzzzzz.com' | |
end | |
it "should be retryable" do | |
@@ -146,8 +146,8 @@ ENDPART | |
plain_text = "First Line\n\nSecond Line\n\nThird Line\n\n" | |
#Note: trailing \n\n is stripped off by Mail::Part initialization | |
part = Mail::Part.new(plain_text) | |
- part[:content_type].content_type.should == 'text/plain' | |
- part.to_s.should match /^First Line\r\n\r\nSecond Line\r\n\r\nThird Line/ | |
+ part[:content_type].content_type.should eq 'text/plain' | |
+ part.to_s.should match(/^First Line\r\n\r\nSecond Line\r\n\r\nThird Line/) | |
end | |
end | |
diff --git a/spec/mail/parts_list_spec.rb b/spec/mail/parts_list_spec.rb | |
index 53cac51..8a943d9 100644 | |
--- a/spec/mail/parts_list_spec.rb | |
+++ b/spec/mail/parts_list_spec.rb | |
@@ -7,7 +7,7 @@ describe "PartsList" do | |
p = Mail::PartsList.new | |
p << 2 | |
p << 1 | |
- p.sort.class.should == Mail::PartsList | |
+ p.sort.class.should eq Mail::PartsList | |
end | |
it "should not fail if we do not have a content_type" do | |
diff --git a/spec/mail/round_tripping_spec.rb b/spec/mail/round_tripping_spec.rb | |
index dbc1637..08db45a 100644 | |
--- a/spec/mail/round_tripping_spec.rb | |
+++ b/spec/mail/round_tripping_spec.rb | |
@@ -7,8 +7,8 @@ describe "Round Tripping" do | |
mail = Mail.new('Subject: FooBar') | |
mail.body "This is Text" | |
parsed_mail = Mail.new(mail.to_s) | |
- parsed_mail.subject.to_s.should == "FooBar" | |
- parsed_mail.body.to_s.should == "This is Text" | |
+ parsed_mail.subject.to_s.should eq "FooBar" | |
+ parsed_mail.body.to_s.should eq "This is Text" | |
end | |
it "should round trip a html multipart email" do | |
@@ -21,11 +21,11 @@ describe "Round Tripping" do | |
body "<b>This is HTML</b>" | |
end | |
parsed_mail = Mail.new(mail.to_s) | |
- parsed_mail.mime_type.should == 'multipart/alternative' | |
- parsed_mail.boundary.should == mail.boundary | |
- parsed_mail.parts.length.should == 2 | |
- parsed_mail.parts[0].body.to_s.should == "This is Text" | |
- parsed_mail.parts[1].body.to_s.should == "<b>This is HTML</b>" | |
+ parsed_mail.mime_type.should eq 'multipart/alternative' | |
+ parsed_mail.boundary.should eq mail.boundary | |
+ parsed_mail.parts.length.should eq 2 | |
+ parsed_mail.parts[0].body.to_s.should eq "This is Text" | |
+ parsed_mail.parts[1].body.to_s.should eq "<b>This is HTML</b>" | |
end | |
it "should round trip an email" do | |
@@ -38,7 +38,7 @@ describe "Round Tripping" do | |
bcc "[email protected]" | |
date Time.local(2009, 11, 6) | |
end | |
- Mail.new(initial.encoded).encoded.should == initial.encoded | |
+ Mail.new(initial.encoded).encoded.should eq initial.encoded | |
end | |
-end | |
\ No newline at end of file | |
+end | |
diff --git a/spec/mail/utilities_spec.rb b/spec/mail/utilities_spec.rb | |
index 5336b82..5bea74c 100644 | |
--- a/spec/mail/utilities_spec.rb | |
+++ b/spec/mail/utilities_spec.rb | |
@@ -24,16 +24,16 @@ describe "Utilities Module" do | |
describe "quoting" do | |
it "should return true if a string is token safe" do | |
- quote_token('.abc').should == '.abc' | |
+ quote_token('.abc').should eq '.abc' | |
end | |
it "should return false if a string is token safe" do | |
- quote_token('?=abc').should == '"?=abc"' | |
+ quote_token('?=abc').should eq '"?=abc"' | |
end | |
it "should work with mb_chars" do | |
- quote_token('.abc'.mb_chars).should == '.abc' | |
- quote_token('?=abc'.mb_chars).should == '"?=abc"' | |
+ quote_token('.abc'.mb_chars).should eq '.abc' | |
+ quote_token('?=abc'.mb_chars).should eq '"?=abc"' | |
end | |
end | |
@@ -58,26 +58,26 @@ describe "Utilities Module" do | |
describe "quoting" do | |
it "should return true if a string is token safe" do | |
- quote_atom('?=abc').should == '?=abc' | |
+ quote_atom('?=abc').should eq '?=abc' | |
end | |
it "should return false if a string is token safe" do | |
- quote_atom('.abc').should == '".abc"' | |
+ quote_atom('.abc').should eq '".abc"' | |
end | |
it "should work with mb_chars" do | |
- quote_atom('?=abc'.mb_chars).should == '?=abc' | |
- quote_atom('.abc'.mb_chars).should == '".abc"' | |
+ quote_atom('?=abc'.mb_chars).should eq '?=abc' | |
+ quote_atom('.abc'.mb_chars).should eq '".abc"' | |
end | |
it "should work with mb_chars" do | |
- quote_atom('?=abc'.mb_chars).should == '?=abc' | |
- quote_atom('.abc'.mb_chars).should == '".abc"' | |
+ quote_atom('?=abc'.mb_chars).should eq '?=abc' | |
+ quote_atom('.abc'.mb_chars).should eq '".abc"' | |
end | |
it "should quote white space" do | |
- quote_atom('ab abc'.mb_chars).should == '"ab abc"' | |
- quote_atom("a\sb\ta\r\nbc".mb_chars).should == %{"a\sb\ta\r\nbc"} | |
+ quote_atom('ab abc'.mb_chars).should eq '"ab abc"' | |
+ quote_atom("a\sb\ta\r\nbc".mb_chars).should eq %{"a\sb\ta\r\nbc"} | |
end | |
end | |
@@ -87,19 +87,19 @@ describe "Utilities Module" do | |
it "should escape parens" do | |
test = 'This is not (escaped)' | |
result = 'This is not \(escaped\)' | |
- escape_paren(test).should == result | |
+ escape_paren(test).should eq result | |
end | |
it "should not double escape parens" do | |
test = 'This is not \(escaped\)' | |
result = 'This is not \(escaped\)' | |
- escape_paren(test).should == result | |
+ escape_paren(test).should eq result | |
end | |
it "should escape all parens" do | |
test = 'This is not \()escaped(\)' | |
result = 'This is not \(\)escaped\(\)' | |
- escape_paren(test).should == result | |
+ escape_paren(test).should eq result | |
end | |
end | |
@@ -109,25 +109,25 @@ describe "Utilities Module" do | |
it "should work" do | |
test = '(This is a string)' | |
result = 'This is a string' | |
- unparen(test).should == result | |
+ unparen(test).should eq result | |
end | |
it "should work without parens" do | |
test = 'This is a string' | |
result = 'This is a string' | |
- unparen(test).should == result | |
+ unparen(test).should eq result | |
end | |
it "should work using ActiveSupport mb_chars" do | |
test = '(This is a string)'.mb_chars | |
result = 'This is a string' | |
- unparen(test).should == result | |
+ unparen(test).should eq result | |
end | |
it "should work without parens using ActiveSupport mb_chars" do | |
test = 'This is a string'.mb_chars | |
result = 'This is a string' | |
- unparen(test).should == result | |
+ unparen(test).should eq result | |
end | |
end | |
@@ -137,25 +137,25 @@ describe "Utilities Module" do | |
it "should work" do | |
test = '<This is a string>' | |
result = 'This is a string' | |
- unbracket(test).should == result | |
+ unbracket(test).should eq result | |
end | |
it "should work without brackets" do | |
test = 'This is a string' | |
result = 'This is a string' | |
- unbracket(test).should == result | |
+ unbracket(test).should eq result | |
end | |
it "should work using ActiveSupport mb_chars" do | |
test = '<This is a string>'.mb_chars | |
result = 'This is a string' | |
- unbracket(test).should == result | |
+ unbracket(test).should eq result | |
end | |
it "should work without parens using ActiveSupport mb_chars" do | |
test = 'This is a string'.mb_chars | |
result = 'This is a string' | |
- unbracket(test).should == result | |
+ unbracket(test).should eq(result) | |
end | |
end | |
@@ -164,25 +164,25 @@ describe "Utilities Module" do | |
it "should quote a phrase if it is unsafe" do | |
test = 'this.needs quoting' | |
result = '"this.needs quoting"' | |
- dquote(test).should == result | |
+ dquote(test).should eq result | |
end | |
it "should properly quote a string, even if quoted but not escaped properly" do | |
test = '"this needs "escaping"' | |
result = '"this needs \"escaping"' | |
- dquote(test).should == result | |
+ dquote(test).should eq result | |
end | |
it "should quote correctly a phrase with an escaped quote in it" do | |
test = 'this needs \"quoting' | |
result = '"this needs \"quoting"' | |
- dquote(test).should == result | |
+ dquote(test).should eq result | |
end | |
it "should quote correctly a phrase with an escaped backslash followed by an escaped quote in it" do | |
test = 'this needs \\\"quoting' | |
result = '"this needs \\\"quoting"' | |
- dquote(test).should == result | |
+ dquote(test).should eq result | |
end | |
end | |
@@ -191,61 +191,61 @@ describe "Utilities Module" do | |
it "should parenthesize a phrase" do | |
test = 'this.needs parenthesizing' | |
result = '(this.needs parenthesizing)' | |
- paren(test).should == result | |
+ paren(test).should eq result | |
end | |
it "should properly parenthesize a string, and escape properly" do | |
test = 'this needs (escaping' | |
result = '(this needs \(escaping)' | |
- paren(test).should == result | |
+ paren(test).should eq result | |
end | |
it "should properly parenthesize a string, and escape properly (other way)" do | |
test = 'this needs )escaping' | |
result = '(this needs \)escaping)' | |
- paren(test).should == result | |
+ paren(test).should eq result | |
end | |
it "should properly parenthesize a string, even if parenthesized but not escaped properly" do | |
test = '(this needs (escaping)' | |
result = '(this needs \(escaping)' | |
- paren(test).should == result | |
+ paren(test).should eq result | |
end | |
it "should properly parenthesize a string, even if parenthesized but not escaped properly (other way)" do | |
test = '(this needs )escaping)' | |
result = '(this needs \)escaping)' | |
- paren(test).should == result | |
+ paren(test).should eq result | |
end | |
it "should parenthesize correctly a phrase with an escaped parentheses in it" do | |
test = 'this needs \(parenthesizing' | |
result = '(this needs \(parenthesizing)' | |
- paren(test).should == result | |
+ paren(test).should eq result | |
end | |
it "should parenthesize correctly a phrase with an escaped parentheses in it (other way)" do | |
test = 'this needs \)parenthesizing' | |
result = '(this needs \)parenthesizing)' | |
- paren(test).should == result | |
+ paren(test).should eq result | |
end | |
it "should parenthesize correctly a phrase with an escaped backslash followed by an escaped parentheses in it" do | |
test = 'this needs \\\(parenthesizing' | |
result = '(this needs \\\(parenthesizing)' | |
- paren(test).should == result | |
+ paren(test).should eq result | |
end | |
it "should parenthesize correctly a phrase with an escaped backslash followed by an escaped parentheses in it (other way)" do | |
test = 'this needs \\\)parenthesizing' | |
result = '(this needs \\\)parenthesizing)' | |
- paren(test).should == result | |
+ paren(test).should eq result | |
end | |
it "should parenthesize correctly a phrase with a set of parentheses" do | |
test = 'this (needs) parenthesizing' | |
result = '(this \(needs\) parenthesizing)' | |
- paren(test).should == result | |
+ paren(test).should eq result | |
end | |
end | |
@@ -255,72 +255,74 @@ describe "Utilities Module" do | |
it "should bracketize a phrase" do | |
test = 'this.needs bracketizing' | |
result = '<this.needs bracketizing>' | |
- bracket(test).should == result | |
+ bracket(test).should eq result | |
end | |
it "should properly bracketize a string, and escape properly" do | |
test = 'this needs <escaping' | |
result = '<this needs \<escaping>' | |
- bracket(test).should == result | |
+ bracket(test).should eq result | |
end | |
it "should properly bracketize a string, and escape properly (other way)" do | |
test = 'this needs >escaping' | |
result = '<this needs \>escaping>' | |
- bracket(test).should == result | |
+ bracket(test).should eq result | |
end | |
it "should properly bracketize a string, even if bracketized but not escaped properly" do | |
test = '<this needs <escaping>' | |
result = '<this needs \<escaping>' | |
- bracket(test).should == result | |
+ bracket(test).should eq result | |
end | |
it "should properly bracketize a string, even if bracketized but not escaped properly (other way)" do | |
test = '<this needs >escaping>' | |
result = '<this needs \>escaping>' | |
- bracket(test).should == result | |
+ bracket(test).should eq result | |
end | |
it "should bracketize correctly a phrase with an escaped brackets in it" do | |
test = 'this needs \<bracketizing' | |
result = '<this needs \<bracketizing>' | |
- bracket(test).should == result | |
+ bracket(test).should eq result | |
end | |
it "should bracketize correctly a phrase with an escaped brackets in it (other way)" do | |
test = 'this needs \>bracketizing' | |
result = '<this needs \>bracketizing>' | |
- bracket(test).should == result | |
+ bracket(test).should eq result | |
end | |
it "should bracketize correctly a phrase with an escaped backslash followed by an escaped brackets in it" do | |
test = 'this needs \\\<bracketizing' | |
result = '<this needs \\\<bracketizing>' | |
- bracket(test).should == result | |
+ bracket(test).should eq result | |
end | |
it "should bracketize correctly a phrase with an escaped backslash followed by an escaped brackets in it (other way)" do | |
test = 'this needs \\\>bracketizing' | |
result = '<this needs \\\>bracketizing>' | |
- bracket(test).should == result | |
+ bracket(test).should eq result | |
end | |
it "should bracketize correctly a phrase with a set of brackets" do | |
test = 'this <needs> bracketizing' | |
result = '<this \<needs\> bracketizing>' | |
- bracket(test).should == result | |
+ bracket(test).should eq result | |
end | |
end | |
describe "url escaping" do | |
+ uri_parser = URI.const_defined?(:Parser) ? URI::Parser.new : URI | |
+ | |
it "should have a wrapper on URI.escape" do | |
- uri_escape("@?@!").should == URI.escape("@?@!") | |
+ uri_escape("@?@!").should eq uri_parser.escape("@?@!") | |
end | |
it "should have a wrapper on URI.unescape" do | |
- uri_unescape("@?@!").should == URI.unescape("@?@!") | |
+ uri_unescape("@?@!").should eq uri_parser.unescape("@?@!") | |
end | |
end | |
diff --git a/spec/matchers_spec.rb b/spec/matchers_spec.rb | |
new file mode 100644 | |
index 0000000..21eb9ad | |
--- /dev/null | |
+++ b/spec/matchers_spec.rb | |
@@ -0,0 +1,130 @@ | |
+require File.join(File.dirname(File.expand_path(__FILE__)), 'spec_helper') | |
+ | |
+describe "have_sent_email" do | |
+ include Mail::Matchers | |
+ | |
+ def send_test_email | |
+ Mail.deliver do | |
+ from '[email protected]' | |
+ to ['[email protected]', '[email protected]'] | |
+ subject 'The facts you requested' | |
+ body 'Here are the facts you requested. One-onethousand, two-onethousand.' | |
+ end | |
+ end | |
+ | |
+ before(:all) do | |
+ $old_delivery_method = Mail.delivery_method | |
+ | |
+ Mail.defaults do | |
+ delivery_method :test | |
+ end | |
+ end | |
+ | |
+ after(:all) do | |
+ # Although this breaks encapsulation, it's the easiest way to ensure | |
+ # that the delivery method is _exactly_ what it was before we started | |
+ # messing with it. | |
+ | |
+ Mail::Configuration.instance.instance_variable_set(:@delivery_method, $old_delivery_method) | |
+ end | |
+ | |
+ context "without any modifiers" do | |
+ context "when no e-mail has been sent" do | |
+ before(:each) do | |
+ Mail::TestMailer.deliveries.clear | |
+ Mail::TestMailer.deliveries.should be_empty | |
+ end | |
+ | |
+ it { should_not have_sent_email } | |
+ end | |
+ | |
+ context "when e-mail has been sent" do | |
+ before(:each) do | |
+ send_test_email | |
+ Mail::TestMailer.deliveries.should_not be_empty | |
+ end | |
+ | |
+ it { should have_sent_email } | |
+ end | |
+ end | |
+ | |
+ context "with #from" do | |
+ context "and a matching sender" do | |
+ it { should have_sent_email.from('[email protected]') } | |
+ end | |
+ | |
+ context "and a non-matching sender" do | |
+ it { should_not have_sent_email.from('[email protected]') } | |
+ end | |
+ end | |
+ | |
+ context "with #to" do | |
+ context "and a matching recipient" do | |
+ it { should have_sent_email.to('[email protected]') } | |
+ it { should have_sent_email.to('[email protected]') } | |
+ it { should have_sent_email.to('[email protected]').to('[email protected]') } | |
+ it { should have_sent_email.to(['[email protected]', '[email protected]']) } | |
+ end | |
+ | |
+ context "and a non-matching recipient" do | |
+ it { should_not have_sent_email.to('[email protected]') } | |
+ end | |
+ end | |
+ | |
+ context "with #subject" do | |
+ context "and a matching subject" do | |
+ it { should have_sent_email.with_subject('The facts you requested') } | |
+ end | |
+ | |
+ context "and a non-matching subject" do | |
+ it { should_not have_sent_email.with_subject('facts you requested') } | |
+ it { should_not have_sent_email.with_subject('the facts you') } | |
+ it { should_not have_sent_email.with_subject('outright lies') } | |
+ end | |
+ end | |
+ | |
+ context "with #subject_matching" do | |
+ context "and a matching subject" do | |
+ it { should have_sent_email.matching_subject(/(facts|fiction) you requested/) } | |
+ end | |
+ | |
+ context "and a non-matching subject" do | |
+ it { should_not have_sent_email.matching_subject(/The \d+ facts you requested/) } | |
+ end | |
+ end | |
+ | |
+ context "with #with_body" do | |
+ context "and a matching body" do | |
+ it { should have_sent_email.with_body('Here are the facts you requested. One-onethousand, two-onethousand.') } | |
+ end | |
+ | |
+ context "and a non-matching body" do | |
+ it { should_not have_sent_email.with_body('Here are the facts you requested.') } | |
+ it { should_not have_sent_email.with_body('are the facts you requested. One-onethousand') } | |
+ it { should_not have_sent_email.with_body('Be kind to your web-footed friends, for a duck may be somebody\'s mother') } | |
+ end | |
+ end | |
+ | |
+ context "with #matching_body" do | |
+ context "and a matching body" do | |
+ it { should have_sent_email.matching_body(/one-?one(hundred|thousand)/i) } | |
+ end | |
+ | |
+ context "and a non-matching body" do | |
+ it { should_not have_sent_email.matching_body(/\d+-onethousand/) } | |
+ end | |
+ end | |
+ | |
+ context "with a huge chain of modifiers" do | |
+ it do | |
+ should have_sent_email. | |
+ from('[email protected]'). | |
+ to('[email protected]'). | |
+ to('[email protected]'). | |
+ with_subject('The facts you requested'). | |
+ matching_subject(/facts (I|you)/). | |
+ with_body('Here are the facts you requested. One-onethousand, two-onethousand.'). | |
+ matching_body(/(I|you) request/) | |
+ end | |
+ end | |
+end | |
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb | |
index bf13af0..4a06512 100644 | |
--- a/spec/spec_helper.rb | |
+++ b/spec/spec_helper.rb | |
@@ -10,14 +10,20 @@ unless defined?(SPEC_ROOT) | |
SPEC_ROOT = File.join(File.dirname(__FILE__)) | |
end | |
+require 'rspec' | |
require File.join(File.dirname(__FILE__), 'matchers', 'break_down_to') | |
require 'mail' | |
-Spec::Runner.configure do |config| | |
- config.include(CustomMatchers) | |
+RSpec.configure do |c| | |
+ c.mock_with :rspec | |
+ c.include(CustomMatchers) | |
end | |
+# NOTE: We set the KCODE manually here in 1.8.X because upgrading to rspec-2.8.0 caused it | |
+# to default to "NONE" (Why!?). | |
+$KCODE='UTF8' if RUBY_VERSION < '1.9' | |
+ | |
def fixture(*name) | |
File.join(SPEC_ROOT, 'fixtures', name) | |
end | |
@@ -221,6 +227,10 @@ class MockIMAP | |
@@mailbox = mailbox | |
end | |
+ def examine(mailbox) | |
+ select(mailbox) | |
+ end | |
+ | |
def uid_search(keys, charset=nil) | |
[*(0..@@examples.size - 1)] | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment