2010-12-12 3 views
0

나는 test_helper.rb에서 간단한 도우미 메서드를 사용하여 테스트를하고 있으며 내 생애 동안 내 사양이 실패한 이유를 알 수 없습니다. 아래 코드를 포함 시켰습니다. spec은 예상되는 "nil"을 출력하고 "sanity respond_to"는 출력합니까? 확인 번호를 확인하십시오. 내가 뭘 놓치고 있니?Rspec testing application_helper.rb

require 'spec_helper' 

describe ApplicationHelper do 
    describe "#tagline" do 
    specify { helper.tagline('text').should == '<div class="tagline"><p>text</p></div>' } 
    p helper.respond_to?(:tagline) ? "yes" : "no" 
    end 
end 


------ 

module ApplicationHelper 
    def tagline(text) 
    content_for(:tagline) { %Q(<div class="tagline"><p>#{text}</p></div>).html_safe } 
    end 
end 

답변

1

content_for 그것은 어딘가에 저장하고, 문자열을 반환하지 않습니다 당신이 yield :tagline을 할 때 검색 할 수 있도록.