如何测试app / helpers / application_helper.rb中的帮助方法?
我在我的文件test / unit / helpers / application_helper_test.rb中有这段代码
require 'test_helper'
class ApplicationHelperTest < ActionView::TestCase
test "category" do
assert categories_collection
end
end
但是我得到了这个错误“NameError:undefined local variable or method`categors_collection'”
答案 0 :(得分:5)
试试这个:
require File.dirname(__FILE__) + '/../test_helper'
require 'application_helper'
class ApplicationHelperTest < Test::Unit::TestCase
include ApplicationHelper
def "category" do
assert categories_collection
end
end