ruby - Rails test can't find route when it clearly exists? -
okay, tired, , new rails possibly missing super basic. anyways, started new project , implementing controller static pages. wrote unit tests make sure routes correct (there 4 far). 3 of them pass fourth gives me error message:
1) error: staticpagescontrollertest#test_terms_of_service_should_return_success: actioncontroller::urlgenerationerror: no route matches {:action=>"terms", :controller=>"static_pages "} test/controllers/static_pages_controller_test.rb:18:in `block in <class:staticpagescontrollertes t>'
its saying can't find route. however, when rake routes exists:
/about(.:format) static_pages#about contact /contact(.:format) static_pages#contact privacy /privacy(.:format) static_pages#privacy terms /terms(.:format) static_pages#terms_of_service
here part of routes.rb:
'about' => 'static_pages#about' 'contact' => 'static_pages#contact' 'privacy' => 'static_pages#privacy' 'terms' => 'static_pages#terms_of_service'
and here code test failing:
test "terms_of_service should return success" 'terms' assert_response :success assert_select 'title', "terms of service" end
i can visit localhost:3000/terms directly in browser , works. idea going on here?
controller tests don't test routes, test actions. want:
get 'terms_of_service'
Comments
Post a Comment