Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does render_views do in rspec?

I'm new to rspec and fairly new to rails. When writing test cases for controllers I've noticed render_views used often. What does this do and what happens if I don't call it?

like image 272
SundayMonday Avatar asked Jan 27 '12 00:01

SundayMonday


2 Answers

it renders the view's in the controller spec. If you don't put render_views, the views won't render, that means the controller is called but after it returns the views are not rendered. Controller tests will run faster, as they won't have to render the view, but you might miss bugs in the view.

like image 177
daniel Avatar answered Oct 26 '22 06:10

daniel


It's about isolation. The idea is that you don't want your controller specs failing because there is a syntax error in the view, which should cause a request spec or a view spec to fail. If you're not writing request specs or view specs, or Cucumber features, then render_views can help you from a test-coverage perspective.

like image 22
David Chelimsky Avatar answered Oct 26 '22 07:10

David Chelimsky