2010-12-12 13 views
0

私はapplication_helper.rbに簡単なヘルパーメソッドを持っています。これは私がテストしようとしているもので、なぜ私の仕様が失敗したのか理解できません。私は以下のコードを含んでいます。 specは期待される ""を得て、そして健全性は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を行うときに、それが取得できるように、それはどこかに保存し、文字列を返しません。