![](/img/trans.png)
[英]The site is working perfect but I've got an error when I run “bundle exec rake test”
[英]Error when I run bundle exec in terminal
当我运行bundle exec rake test
它在终端中出现错误。 这一步似乎无法通过
# 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
测试代码的第一行应为:
class StaticPagesControllerTest < ActionController::TestCase
它是ActionController-不是ApplicationController。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.