4

我的应用程序助手中有视图助手方法:

module ApplicationHelper
 def formatted_something(something)
   "Hello, #{something}"
 end
end

我想在我的请求规范中访问该方法:

require "spec_helper"

describe "something" do
  include RequestSpecHelper

  it "should display blogs list" do
    visit something_url
    page.should have_content formatted_something(@something.something)
  end
end

它找不到formatted_something方法。

4

1 回答 1

11

你只需要在你的describe块中包含相关的帮助模块,它将在所有嵌套规范中可用:

describe "something" do
  include RequestSpecHelper
  include ApplicationHelper

  ...
end
于 2012-11-27T04:25:39.847 回答