Ruby on rails 3 gem中的specview助手
我正在编写一个rails 3 railtie,它定义了一些视图助手。现在我想知道如何规范视图助手方法,因为我无法实例化模块。我已经找了很多书,读了很多书,但就是没法用 查看\u helper\u spec.rbRuby on rails 3 gem中的specview助手,ruby-on-rails-3,rspec,view-helpers,Ruby On Rails 3,Rspec,View Helpers,我正在编写一个rails 3 railtie,它定义了一些视图助手。现在我想知道如何规范视图助手方法,因为我无法实例化模块。我已经找了很多书,读了很多书,但就是没法用 查看\u helper\u spec.rb require 'spec_helper' module MyRailtie describe ViewHelper, :type => :helper do describe "style_tag" do it "should return a style t
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对任何东西都不起作用
gempec要求rspec和rspec-rails-gems处于开发/测试模式。我想我找到了解决方案(一想到它,就很明显)。只需将其粘贴在规格的顶部:
require 'action_view'
require 'active_support'
include ViewHelper
include ActionView::Helpers
我正在寻找一个测试rails视图帮助器方法的解决方案……你找到了吗?我在寻找同样的答案