我有一个我正在研究的gem,它依赖于rails来运行。具体来说,gem包含一个'helper'方法,该方法使用'content_tag'调用来构建将用于构建rails视图的输出。
如何编写实例化足够的rails基础结构的帮助程序规范,以便能够使用rspec-rails使用'helper'前缀来测试代码?
以下是我想要的一个例子:
describe "when this helper is called" do
it "it works correctly" do
helper.my_helper_method(data, custom_options = {}).should == "whatever"
end
end
我正在运行rails 3.1并且不介意让gem需要3.1作为最小的rails版本。