ConradIrwin / pry-rescue

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

Require RSpec only when not loaded yet #93

Closed tombruijn closed 8 years ago

tombruijn commented 9 years ago

This PR fixes issue #87

It checks if rspec is already loaded and if so does not require it.

In issue #87 I use the rspec-rails and don't have the rspec gem in my bundle. Bundler already requires the rspec-rails gem and loads rspec-core, which actually contains (most of) the rspec gem.

An alternative solution would be the following below, but I chose not to do this because you also check if Capybara loaded the same way as in this PR

 require 'pry-rescue'
-require 'rspec'
+begin
+  require 'rspec'
+rescue LoadError
+  require 'rspec/core'
+end
iloveitaly commented 8 years ago

@ConradIrwin This fixes the issue for me on rails5 + rspec 3.5.0. Could we merge this in and cut a new release?

ConradIrwin commented 8 years ago

This is very peculiar, I was under the impression that when you require the same thing twice it should be a no-op the second time. Happy to merge this if you're sure that's what fixed it

iloveitaly commented 8 years ago

@ConradIrwin Awesome, thanks! Any chance of pushing a new release to rubygems?

ConradIrwin commented 8 years ago

DoneSent via SuperhumanOn Fri, May 20, 2016 at 11:00 AM, Michael Bianconotifications@github.comwrote:@ConradIrwin Awesome, thanks! Any chance of pushing a new release to rubygems

—You are receiving this because you were mentioned.Reply to this email directly or view it on GitHub