メールを受信する(テスト編)

■テストコード
まず、mail.txtを作成。参照:http://i.loveruby.net/ja/projects/tmail/doc/basics.html


▼最初にプロンプトからrunnerを使ってみよう。
C:\Rails\app\trunk>ruby script/runner 'MailHandler.receive(STDIN.read)' < mail.txt

※この時、mail.txtはRAILS_ROOTにあるとする。この例ではapp/trunk/mail.txt


ユニットテスト

 def test_receive
    MailHandler.receive(File.new(File.dirname(__FILE__) + '/../mail_template/mail.txt',"r").read)
  end


■参考
http://d.hatena.ne.jp/omochist/20060828
http://www.fdiary.net/ml/rails/msg/883
http://www.fdiary.net/ml/rails/msg/884
http://www.kbmj.com/~shinya/rails_seminar/slides/#(49)