Closed aeonaut closed 3 years ago
Just went on a fact-finding mission about this.
If we use the bundled Rescue and binstubs, rescue rspec
won't use bin/rspec
. That's because Bundler, before loading Rescue, adds components to the path re-prioritizing the installed rspec
over the bin/rspec
. So we get the non-springified Rspec.
If we use rescue bin/rspec
, the case in bin/rescue
, which uses a regex for /^rspec/
, won't run. Meaning Rescue isn't activated.
Ideally we would detect if we are using Spring/a binstub and somehow run that instead of the non-spring rspec
I looked into making a spring command for Rescue, but it appears even if we load spring and call rspec
, Spring won't be loaded for the nested command. (Feel free to double check this, I didn't invest the time in understanding how Spring worked exactly)
The monkeypatch that appears to be working is to let /bin/rescue
detect when rspec is ran even prefixed by bin/
or other. It's a bit ugly, but appears to be working:
diff --git a/bin/rescue b/bin/rescue
index b9856d3..2449b4e 100755
--- a/bin/rescue
+++ b/bin/rescue
@@ -34,12 +34,15 @@ when '-i'
when /\A-/
puts USAGE
exit
-when 'rails'
- ENV['PRY_RESCUE_RAILS'] = 'true'
- exec(*ARGV)
-when /^re?spec|rake$/
- ENV['SPEC_OPTS'] = "#{ENV['SPEC_OPTS']} -r pry-rescue/rspec"
- exec(*ARGV)
+else
+ case File.basename(ARGV[0] || "")
+ when 'rails'
+ ENV['PRY_RESCUE_RAILS'] = 'true'
+ exec(*ARGV)
+ when /^re?spec|rake$/
+ ENV['SPEC_OPTS'] = "#{ENV['SPEC_OPTS']} -r pry-rescue/rspec"
+ exec(*ARGV)
+ end
end
Having the same problem, but I am not having any luck working around it per joallards patch
I installed pry-rescue from https://github.com/joallard/pry-rescue.git but I still see the same issue i.e. if I use bin/rspec spring works, but rescue does not.
@catmando The good stuff is on the bin-rspec
branch
Hmm, I'm not having any problems with using the spring binstub with rescue. At least now that I have pry-stack_explorer
installed (#98, but that's a different symptom than you're describing here)...
Is this still a problem for you with current versions of these gems, or can this issue be closed?
I use Spring and thus have a Spring-generated
bin/rspec
stub. I have./bin
at the front of my path, so normally just a normalrspec path/to/file
uses this binstub. Problem is, Rescue doesn't work correctly with the binstub. Here's what happens:Option 1 uses the Spring binstub and takes 7 seconds; Option 2 apparently does not use the binstub, because it takes 10+ seconds. Option 1 looks pretty good -- except that Rescue doesn't actually work. The test fails without opening a pry session. (Rescue works as expected in Option 2).
So at the moment doesn't look like I can use both Rescue and Spring together. Ideas?