Rails test cannot find a route when it clearly exists?
Ok, so I'm tired and new to rails, so maybe I missed something super basic. Anyway, I've just started a new project and am implementing a simple controller for static pages. Wrote some unit tests to make sure all my routes are correct (there are only 4 so far). Three of them go through, but the fourth gives me this 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>'
His utterance cannot find a route. However, when I type in the routes, it clearly exists:
about GET /about(.:format) static_pages#about
contact GET /contact(.:format) static_pages#contact
privacy GET /privacy(.:format) static_pages#privacy
terms GET /terms(.:format) static_pages#terms_of_service
Here is this portion of the .rb routes:
get 'about' => 'static_pages#about'
get 'contact' => 'static_pages#contact'
get 'privacy' => 'static_pages#privacy'
get 'terms' => 'static_pages#terms_of_service'
and here is the code for the test that fails:
test "terms_of_service should return success" do
get 'terms'
assert_response :success
assert_select 'title', "Terms Of Service"
end
I can visit localhost: 3000 / terms directly in the browser and it works. Any idea what's going on here?
+3
source to share