You need to explicitly specify the specifications of your controller so that you display the views for this to work. Update your specification to look like this:
require 'spec_helper' describe PostsController do render_views
This is described in the rspec readme . See rspec-rails oucum for "render_views" for a more detailed overview.
Just one word of caution with this. There are reasons why this behavior is not default:
- Perhaps you are confusing the two issues by checking views simultaneously with controllers. Ryan Bigg (see Comments) suggests that your tests be better analyzed as integration tests, which usually live in
spec/integration rather than spec/controller . - Rendering views can significantly slow down your tests.
... Without saying that you should not do this, just say that you should understand why you are.
Hope this helps.
source share