2011-09-22 4 views
3

ActionMailer 스펙에서이 라인들을 어떻게 테스트하고 있습니까? 그런Rails ActionMailer의 기본값 테스트

default 'HEADER' => Proc.new { "information" }, 
    :cc => "[email protected]", 
    :from => "[email protected]", 
    :to => "[email protected]" 
+0

기본 머리글 및 전자 메일 필드를 테스트하는 것에 대해 걱정할 필요가 없습니다. 해당 필드에 대한 테스트 메일 범위를 확인합니다. 헤더를 추가하는 중이라면, 컨트롤러 테스트에서 헤더 해시를 체크하거나,'--head'와 함께 컬을 사용하여 원시 출력을 검사 할 수 있다고 생각합니다. –

답변

1

뭔가 :

# notifier_spec.rb 
require "spec_helper" 

describe Notifier do 
    describe "welcome" do 
    let(:user) { Factory :user } 
    let(:mail) { Notifier.welcome(user) } 

    it "renders the headers" do 
     mail.content_type.should eq('text/plain; charset=UTF-8') 
     mail.subject.should eq("Welcome") 
     mail.cc.should eq(["[email protected]"]) 
     mail.from.should eq(["[email protected]"]) 
     mail.to.should eq([user.email]) 
    end 

    it "renders the body" do 
     mail.body.encoded.should match("Hi") 
    end 
    end 
end 

Ryan Bates (= 전체 분차 사람들이) 그것을 수행하는 방법이다.