2014-04-28 109 views
1

當我試圖找到test_helper文件時,我的測試失敗。無法找到我的test_helper文件(LoadError)

我的文件:

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 
+1

難道說'test_helper.rb'是你試圖運行上面的文件_not_一個文件夾? –

+0

'test_helper'位於哪裏,你在哪裏訪問它? –

回答

0

沒有必要做這個:

require File.dirname(__FILE__) + '/../test_helper' 

在測試文件的頂部就require 'test_helper',並添加-Itest選項來運行測試。 (假設test_helper.rb中位於測試/目錄下)