Permalink
Browse files

Add a basic test. Move out sending the mail to a method.

  • Loading branch information...
1 parent 1b59666 commit eae2f84db8ac5869b40b73ecb27361e73fdd67b5 Andy Atkinson committed Mar 2, 2012
Showing with 21 additions and 4 deletions.
  1. +3 −2 lib/minimail/mail.rb
  2. +1 −2 minimail.gemspec
  3. +17 −0 test/minimail_test.rb
@@ -8,13 +8,14 @@ def initialize(params = {})
@subject = params[:subject] || ""
@body = params[:body] || ""
@attachments = encode_attachments? && params[:attachments] ? process_attachments(params[:attachments]) : nil
-
+ end
+
+ def send
if @attachments
IO.popen("echo #{@body} | (#{@attachments}) | #{mail_command} -s '#{@subject}' #{@recipients}")
else
IO.popen("echo #{@body} | #{mail_command} -s '#{@subject}' #{@recipients}")
end
-
end
def mail_command
View
@@ -19,6 +19,5 @@ Gem::Specification.new do |s|
s.require_paths = ["lib"]
# specify any dependencies here; for example:
- # s.add_development_dependency "rspec"
- # s.add_runtime_dependency "rest-client"
+ s.add_development_dependency "minitest"
end
View
@@ -0,0 +1,17 @@
+require 'rubygems'
+require 'minitest/autorun'
+
+$:.unshift File.expand_path("../../lib", __FILE__)
+require 'minimail'
+
+class MinimailTest < MiniTest::Unit::TestCase
+ def test_that_a_minimail_can_be_initialized_with_attributes
+ subject = "Check this out!"
+ recipients = "jane@gmail.com"
+ body = "Very cool"
+ mail = Mail.new(:subject => subject, :recipients => recipients, :body => body)
+ assert_equal subject, mail.subject
+ assert_equal recipients, mail.recipients
+ assert_equal body, mail.body
+ end
+end

0 comments on commit eae2f84

Please sign in to comment.