Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

getting Rspec view specs to render application layout

So we have a variety of view specs in our project:

https://github.com/tansaku/LocalSupport/blob/master/spec/views/organizations/index.html.erb_spec.rb

but we are having trouble with testing javascript generated by the gmap4rails gem. I think I've tracked the issue down to the problem that the view specs don't appear to render the application layout.

We have a separate view spec for the application layout, which works, and that renders the application layout fine. However when we run view specs the application layout code is not getting rendered.

Any help on this much appreciated

like image 864
Sam Joseph Avatar asked Jul 09 '13 13:07

Sam Joseph


1 Answers

I was just about to post this and then saw the second answer to How do I test the title of a page from an RSpec view spec? which is about a different problem, but allowed me to come up with the solution which is to explicitly render the layout in the spec:

render template: "organizations/index", layout: "layouts/application"
like image 145
Sam Joseph Avatar answered Sep 23 '22 09:09

Sam Joseph