ConradIrwin / pry-rescue

Start a pry session whenever something goes wrong.
MIT License
852 stars 49 forks source link

pry-rescue 1.4.0 with RSpec 2.14.7 does not launch a pry session on thrown exceptions #62

Closed ghost closed 10 years ago

ghost commented 10 years ago

My spec/spec_helper.rb and ~/.pryrc - https://gist.github.com/ddd/9214949 My installed pry gems - https://gist.github.com/9214904

I've an issue I don't understand. I have require 'pry-rescue/rspec in my spec/spec_helper.rb file. I run a known failing test (I'm missing a template, which throws the exception ActionView::MissingTemplate), but a pry session is never opened up.

I'm following along with http://youtu.be/D9j_Mf91M0I which is Conrad's REPL-driven development talk at RubyConf 2013.

It just reports the error like RSpec normally does. I'm executing the following command:

bundle exec rescue rspec spec/controllers/users_controller_spec.rb

Since I'm calling it with rescue, shouldn't Pry be opening a pry session when the missing template exception is thrown? This happens regardless of bundle exec

ghost commented 10 years ago

The spec file in question is as follows:

require 'spec_helper'

describe UsersController do

  subject(:user) { FactoryGirl.build(:user) }

  describe "GET 'new'" do
    it "returns http success" do
      get 'new'
      response.should be_success
    end
  end

  describe "POST 'create'" do
    it "creates a new user" do
      expect {
        permit_all_parameters do
          post :create, {:user => FactoryGirl.attributes_for(:user), signed: true}, session
        end
      }.to change{User.count}.by(1)
    end
  end

  describe "GET 'edit'" do
    it "edits a user" do
      user.save!
      get :edit, id: user.to_param
      response.should be_success
    end
  end

  describe "PATCH 'update'", js: true do
    it "updates a user" do
      user.save!

      expect {
        permit_all_parameters do
          user.update_attributes(full_name: "Some Updated User")
          patch :update, { id: user.to_param, signed: true}, session
        end
      }.to change{user.reload && user.full_name}.to("Some Updated User")
    end
  end

  describe "DELETE 'destroy'" do
    it "deletes a user" do
      user.save!
      delete :destroy, id: user.to_param

      expect { change(User, :count).by(-1) }
      expect(response).to redirect_to(users_path)
      expect(flash[:notice]).to eq("User successfully deleted!")
    end
  end

end

And the output is as follows:

∵ rescue rspec spec/controllers/users_controller_spec.rb 
Run options: include {:wip=>true}

All examples were filtered out; ignoring {:wip=>true}

UsersController
  GET 'new'
    returns http success
  POST 'create'
    creates a new user
  GET 'edit'
    edits a user
  PATCH 'update'
    updates a user
  DELETE 'destroy'
    deletes a user (FAILED - 1)

Failures:

  1) UsersController DELETE 'destroy' deletes a user
     Failure/Error: delete :destroy, id: user.to_param
     ActionView::MissingTemplate:
       Missing template users/destroy, application/destroy with {:locale=>[:en], :formats=>[:html], :handlers=>[:erb, :builder, :raw, :ruby, :jbuilder, :coffee]}. Searched in:                                                                                                                           
         * "#<RSpec::Rails::ViewRendering::EmptyTemplatePathSetDecorator:0x00000009d80ac8>"
     # ./spec/controllers/users_controller_spec.rb:49:in `block (3 levels) in <top (required)>'

Finished in 1.02 seconds
5 examples, 1 failure

Failed examples:

rspec ./spec/controllers/users_controller_spec.rb:47 # UsersController DELETE 'destroy' deletes a user
artofhuman commented 10 years ago

I have same problem with rspec 2.14.7, on 2.12.2 version pry-rescue works.

indirect commented 10 years ago

I'm having the same problem with pry-rescue 1.4.0 on rspec 3.0.0.beta2. Will it ever be possible to auto-pry on test failures again? :((

felixbuenemann commented 10 years ago

Same issue as #49