ruby on rails 5 - By filling in the code marked FILL_IN in Listing 3.42, write a test for the root route -
adding root route in listing 3.41 leads creation of rails helper called root_url (in analogy helpers static_pages_home_url). filling in code marked fill_in in listing 3.42, write test root route.
listing 3.41: setting root route home page. config/routes.rb rails.application.routes.draw root 'static_pages#home' end listing 3.42: test root route. green test/controllers/static_pages_controller_test.rb require 'test_helper' class staticpagescontrollertest < actiondispatch::integrationtest test "should root" fill_in assert_response fill_in end end
what should fill_in? tried static_pages_root_url, root_url.
rails test fails. f failure: staticpagescontrollertest#test_should_get_root [/home/ubuntu/workspace/sample_app/test/controllers/static_pages_controller_test.rb:12]: <root | ruby on rails tutorial sample app> expected <home | ruby on rails tutorial sample app>.. expected 0 >= 1. e error: staticpagescontrollertest#test_should_get_root: argumenterror: invalid response name: root_url test/controllers/static_pages_controller_test.rb:11:in `block in <class:staticpagescontrollertest>'
try with:
test "should root" '/' assert_response :success end
more info on http://guides.rubyonrails.org/testing.html#implementing-an-integration-test
Comments
Post a Comment