尝试查找test_helper文件时,我的测试失败。
我的档案:
require File.dirname(__FILE__) + '/../test_helper'
require 'admin/supplier_controller'
#Re-raise errors caugth by the controller
class Admin::SupplierController; def rescue_action(e) raise e end; end
class Admin::SupplierControllerTest < ActionController::TestCase
fixtures :suppliers
def setup
@controller = Admin::SupplierController.new
@request = ActionController::TestRequest.new
@response = ActionController::TestResponse.new
end
def test_new
get :new
assert_template 'admin/supplier/new'
assert_tag 'h1', :content => 'Create new supplier'
assert_tag 'form', :attributes => {:action => '/admin/supplier/create'}
end
end
答案 0 :(得分:0)
无需这样做:
require File.dirname(__FILE__) + '/../test_helper'
只需在测试文件顶部require 'test_helper'
,然后添加-Itest
选项即可运行测试。 (假设test_helper.rb位于test /目录中)