0
我在application_helper.rb中有一個簡單的幫助方法,我試圖測試,並且不能爲我的生活弄清楚爲什麼我的規範失敗。我已經包含下面的代碼。該規範打印出預期的「」無零,而理智respon_to?檢查打印號碼。我錯過了什麼?Rspec測試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