vendredi 31 juillet 2015

RSpec - ActiveRecord::RecordNotFound when testing templates

I'm trying to test that my templates are rendering but can't seem to figure out why its not registering the ID of my stubbed instance. What do I have to do to get a correct path?

describe RestaurantsController do
  let(:restaurant) { FactoryGirl.build_stubbed(:restaurant) }

  describe "GET #show" do
    before { get :show, id: restaurant.id }
    it { should render_template('show') }
  end
end

Error:

1) RestaurantsController GET #show 
     Failure/Error: before { get :show, id: restaurant.id }
     ActiveRecord::RecordNotFound:
       Couldn't find Restaurant

Aucun commentaire:

Enregistrer un commentaire