如何在gem中使用rspec rails helper方法 - 在rails安装之外

时间:2012-02-06 17:27:29

标签: ruby-on-rails ruby rspec rubygems tdd

我有一个我正在研究的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版本。

0 个答案:

没有答案