我的应用程序助手中有视图助手方法:
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 方法。
答案 0 :(得分:11)
您只需要在describe
块中包含相关的帮助程序模块,它将在所有嵌套规范中提供:
describe "something" do
include RequestSpecHelper
include ApplicationHelper
...
end