我在 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