2015-09-05 95 views
1

當我運行bundle exec rake test時,它在終端中出現錯誤。它似乎無法通過這一步當我在終端中運行軟件包exec時出錯

# Running: 

.......EEE....... 

Finished in 0.420936s, 40.3862 runs/s, 61.7672 assertions/s. 

    1) Error: 
StaticPagesControllerTest#test_should_get_help: 
NameError: uninitialized constant ApplicationController::TestCase 
    app/controllers/static_pages_controller.rb:1:in `<top (required)>' 


    2) Error: 
StaticPagesControllerTest#test_should_get_home: 
NameError: uninitialized constant ApplicationController::TestCase 
    app/controllers/static_pages_controller.rb:1:in `<top (required)>' 


    3) Error: 
StaticPagesControllerTest#test_should_get_about: 
NameError: uninitialized constant ApplicationController::TestCase 
    app/controllers/static_pages_controller.rb:1:in `<top (required)>' 

17 runs, 26 assertions, 0 failures, 3 errors, 0 skips 

我試圖解決問題的代碼,但還沒有拿出一個解決方案。

class StaticPagesControllerTest < ActionController::TestCase 

    test "should get home" do 
    get :home 
    assert_response :success 
    assert_select "title", "Home | Ruby on Rails Tutorial Sample App" 
    end 

    test "should get help" do 
    get :help 
    assert_response :success 
    assert_select "title", "Help | Ruby on Rails Tutorial Sample App" 
    end 

    test "should get about" do 
    get :about 
    assert_response :success 
    assert_select "title", "About | Ruby on Rails Tutorial Sample App" 

    end 

end 

回答

0

你的第一行測試代碼應該是:

class StaticPagesControllerTest < ActionController::TestCase 

這ActionController的 - 不是ApplicationController的。

相關問題