mardi 21 juillet 2015

UrlGenerationError when running RSpec Test

I'm trying to run a test that ensures my show template is rendered for 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 its saying when there is indeed 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

Aucun commentaire:

Enregistrer un commentaire