2015-09-05 72 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的。

相关问题