Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Pony.mail, sends an email via net::smtp to localhost

  • Loading branch information...
commit fc9175ad9c2e2b78249c073904ad2cf0c267b402 0 parents
Adam Wiggins authored September 23, 2008
23  Rakefile
... ...
@@ -0,0 +1,23 @@
  1
+require 'rake'
  2
+require 'spec/rake/spectask'
  3
+
  4
+desc "Run all specs"
  5
+Spec::Rake::SpecTask.new('spec') do |t|
  6
+	t.spec_files = FileList['spec/*_spec.rb']
  7
+end
  8
+
  9
+desc "Print specdocs"
  10
+Spec::Rake::SpecTask.new(:doc) do |t|
  11
+	t.spec_opts = ["--format", "specdoc", "--dry-run"]
  12
+	t.spec_files = FileList['spec/*_spec.rb']
  13
+end
  14
+
  15
+desc "Run all examples with RCov"
  16
+Spec::Rake::SpecTask.new('rcov') do |t|
  17
+	t.spec_files = FileList['spec/*_spec.rb']
  18
+	t.rcov = true
  19
+	t.rcov_opts = ['--exclude', 'examples']
  20
+end
  21
+
  22
+task :default => :spec
  23
+
9  lib/pony.rb
... ...
@@ -0,0 +1,9 @@
  1
+require 'net/smtp'
  2
+
  3
+module Pony
  4
+	def self.mail(to, body)
  5
+		Net::SMTP.start('localhost') do |smtp|
  6
+			smtp.sendmail(body, 'pony@unknown', [ to ])
  7
+		end
  8
+	end
  9
+end
4  spec/base.rb
... ...
@@ -0,0 +1,4 @@
  1
+require 'rubygems'
  2
+require 'spec'
  3
+
  4
+require File.dirname(__FILE__) + '/../lib/pony'
10  spec/pony_spec.rb
... ...
@@ -0,0 +1,10 @@
  1
+require File.dirname(__FILE__) + '/base'
  2
+
  3
+describe Pony do
  4
+	it "sends an email via Net::SMTP" do
  5
+		smtp = mock('net::smtp object')
  6
+		Net::SMTP.should_receive(:start).with('localhost').and_yield(smtp)
  7
+		smtp.should_receive(:sendmail).with('Hello, Joe!', 'pony@unknown', [ 'joe@example.com' ])
  8
+		Pony.mail('joe@example.com', 'Hello, Joe!')
  9
+	end
  10
+end

0 notes on commit fc9175a

Please sign in to comment.
Something went wrong with that request. Please try again.