我正在编写一个定义了一些视图助手的 rails 3 railtie。现在我想知道如何指定视图辅助方法,因为我无法实例化模块。我已经搜索并阅读了很多,但我无法让它工作。
view_helper_spec.rb
require 'spec_helper'
module MyRailtie
describe ViewHelper, :type => :helper do
describe "style_tag" do
it "should return a style tag with inline css" do
helper.style_tag("body{background:#ff0}").should ==
body{background:#ff0}
EOT
end
end
end
end
它总是抱怨没有定义“助手”。似乎 :type => :helper 没有任何作用。
gemspec 在开发/测试模式下需要 rspec 和 rspec-rails gem。