Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Steps to reproduce bug in rspec-rails

Steps to reproduce bug in rspec-rails.

When render_views is enabled globally, it cannot be disabled with a local render_views(false) call.

Create rails project with rspec-rails, a simple controller with one action

rails new reproduce_bug
cd reproduce_bug
echo 'gem "rspec-rails"' >> Gemfile
rails g rspec:install
rails g controller bugs show

Configure RSpec to enable render_views globally, but disable for the show-action spec.

Edit spec/spec_helper.rb, add config.render_views inside the RSpec.configure block.

Edit spec/controllers/bugs_controller_spec.rb, add render_views false inside describe "GET 'show'" block.

Make the view blow up.

Edit app/views/bugs/show.html.erb, add <% raise "It's a trap!" %>

Watch the show-action spec fail

rspec spec/controllers/bugs_controller_spec.rb

1) BugsController GET 'show' returns http success
   Failure/Error: get 'show'
     It's a trap!
require 'spec_helper'
describe BugsController do
describe "GET 'show'" do
render_views false
it "returns http success" do
get 'show'
response.should be_success
<% raise "It's a trap!" %>
<p>Find me in app/views/bugs/show.html.erb</p>
# This file is copied to spec/ when you run 'rails generate rspec:install'
ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
require 'rspec/autorun'
RSpec.configure do |config|
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment