samedi 1 août 2015

Rendering partials in subdirectories using RSpec and Shoulda Matchers

I'm using RSpec and Shoulda Matchers to test that my templates are rendering properly. One particular partial is nested in an additional directory within my view template:

Show Template

...
<%= render "restaurants/menu_partials/dish_categories" %>

Now in my spec file for my controller I try to test using the method, render_template

it { should render_template(partial: "restaurants/menu_partials/dish_categories") }

But get this error:

  1) RestaurantsController GET #show should render template matcher [:partial, "restaurants/menu_partials/dish_categories"]
     Failure/Error: it { should render_template(partial: 'restaurants/menu_partials/dish_categories') }
       expecting partial <restaurants/menu_partials/dish_categories> but action rendered <[]>.
       Expected {} to include "restaurants/menu_partials/dish_categories".

What am I doing wrong?

Aucun commentaire:

Enregistrer un commentaire