从Capybara rquest规范访问视图助手方法

时间:2012-11-27 04:06:18

标签: ruby-on-rails ruby rspec capybara

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

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 方法。

1 个答案:

答案 0 :(得分:11)

您只需要在describe块中包含相关的帮助程序模块,它将在所有嵌套规范中提供:

describe "something" do
  include RequestSpecHelper
  include ApplicationHelper

  ...
end