UrlGenerationError when running RSpec Test
I am trying to run a test that makes sure my template is show
displayed in a restaurant. After running the test, I get:
1) RestaurantsController GET #show
Failure/Error: before { get :show }
ActionController::UrlGenerationError:
No route matches {:action=>"show", :controller=>"restaurants"}
Not sure why his saying when there really is a route for showing restaurants:
restaurants GET /restaurants(.:format) restaurants#index
POST /restaurants(.:format) restaurants#create
new_restaurant GET /restaurants/new(.:format) restaurants#new
edit_restaurant GET /restaurants/:id/edit(.:format) restaurants#edit
restaurant GET /restaurants/:id(.:format) restaurants#show
PATCH /restaurants/:id(.:format) restaurants#update
PUT /restaurants/:id(.:format) restaurants#update
DELETE /restaurants/:id(.:format) restaurants#destroy
Test
require "rails_helper"
describe RestaurantsController do
describe "GET #show" do
before { get :show }
it { should render_template("show") }
end
end
+3
source to share