I am following a tutorial of Rails and I have a few pages that I am adding some tests for.
I am trying to use help_path instead of :help in my pages_controller_test :
test "should get help" do
get help_path
assert_response :success
assert_select "title", "Help | #{@base_title}"
end
I added this line in my routes.rb file :
get '/help', to: 'pages#help'
But I get this error :
1) Error: PagesControllerTest#test_should_get_help: ActionController::UrlGenerationError: No route matches {:action=>"/help", :controller=>"pages"} test/controllers/pages_controller_test.rb:62:in `block in '
I have tried a few solutions but none of them solved my issue. I've also tried using this line instead :
match '/home' => 'main_pages#home', :as => :home
But it didn't work either.
My rails version is : 4.2.4 My Ruby version is : ruby 2.1.9p490 (2016-03-30 revision 54437) [x86_64-linux-gnu]
Output of $rake routes :
Prefix Verb URI Pattern Controller#Action
root GET / pages#home
help GET /help(.:format) pages#help
courses GET /courses(.:format) pages#courses
programs GET /programs(.:format) pages#programs
schools GET /schools(.:format) pages#schools
dashboard GET /dashboard(.:format) pages#dashboard
profile GET /profile(.:format) pages#profile
account GET /account(.:format) pages#account
signout GET /signout(.:format) pages#signout
EDIT : I can use help_path .. etc in my html code without any issue, but in the test it gives that error. Thank you :)
'help'
and'home'
instead). Also, runrake routes
to view all your routes. - vichroutes.rb
? - Sebastian Palma