script/generate mailerでgenerateされるテストコードの@expectedはTMailのインスタンスらしく、生すぎなことがあります。
というわけで、お手軽にテストする方法をぐぐりました。

via http://sablog.com/archives/2006/03/14/how-to-test-actionmailer-in-ruby-on-rails

rails>>
class SampleMailerTest < ActionMailer::TestCase
tests SampleMailer

def setup
# テスト時に配送したメールの配列を保存する。
ActionMailer::Base.deliveries = []
end

def test_welcome
to = "satoko@s21g.com"
sender = to
sender_name = "satoko"

SampleMailer.deliver_welcome(to, sender, sender_name)
assert !ActionMailer::Base.deliveries.empty?

sent = ActionMailer::Base.deliveries.first
assert_equal [to], sent.to
assert_equal "expected title", sent.subject
assert sent.body =~ /^Recommended by #{sender_name}. Enjoy!$/

end
end
<<--

###Refs
http://wota.jp/ac/?date=20050731

posted by satoko satoko on Tue 22 Apr 2008 at 16:34 with 0 comments
Contents rssrss
NSAssertやNSLogを無効にする:-DNS_BLOCK_ASSERTIONS=1とNS_BLOCK_ASSERTIONS
GDBでview.frameを表示させる
Core Animationについてのリンク集
[iPhone] new BSDライセンスについてライセンス引用のメモ
Implementing a Container View Controller in UIViewController Class Reference
UITableView用のNSIndexPathの作り方
Xcodeのテンプレート、View-based ApplicationとWindow-based Applicationの違い
CopyOnSelectのLion対応
Xcode4のCode Snippetsを別のPCに移動する+gitで管理する
[iPhone] Singleton: iOS4以降はGCDのdispatch_onceを使う
Tags
iphone開発gitIBInterfaceBuilderiOSSIMBLSnippetsterminaltwitterxcodeXcode4
Comments rssrss
guest guest: Muchos turistas buscan la mejor forma de llegar a ... 05/30 03:19
guest guest: San Antonio de Areco es conocido como la cuna de l... 05/27 19:47
guest guest: Optimizar el tiempo durante un viaje de negocios e... 05/18 00:46
guest guest: Para muchos turistas, el transporte publico y la l... 05/15 18:22
Services from s21g
アンテナショップめぐり
東京にある全国のアンテナショップ、イベント、特産品を地図や条件から探せるサービスです。
YOMU Web小説リーダー
YOMUは、Web小説の読み上げに特化したiPhoneアプリです。
補助探
公開されている補助金・助成金情報を集約し、条件に合う制度を探しやすくするサービスです。
jotter.me
個人開発者のためのホスティング一体型ノートサービス
ハンドミラー
iPhone向けの手鏡アプリ