DEV: Add pry-byebug and optionally require pry behind a ENV var for better spec debugging (#9984)

DEV: Add pry-byebug and optionally require pry behind a ENV var for better spec debugging (#9984)

We removed pry-nav a while back because it is not up to date with pry but it is super useful. Luckily pry-byebug is here to save us all from Satan’s power.

To get this to work you need to add the following to your $HOME/.pryrc file.

if defined?(PryByebug)
  Pry.commands.alias_command 'c', 'continue'
  Pry.commands.alias_command 's', 'step'
  Pry.commands.alias_command 'n', 'next'
  Pry.commands.alias_command 'f', 'finish'
end

Pry::Commands.command /^$/, "repeat last command" do
  pry_instance.run_command Pry.history.to_a.last
end

The require-ing of pry, pry-rails, and pry-byebug in specs is controlled by the IMPROVED_SPEC_DEBUGGING flag (disabled by default).

diff --git a/Gemfile b/Gemfile
index da983fa..b708152 100644
--- a/Gemfile
+++ b/Gemfile
@@ -112,6 +112,7 @@ gem 'oj'
 gem 'pg'
 gem 'mini_sql'
 gem 'pry-rails', require: false
+gem 'pry-byebug', require: false
 gem 'r2', require: false
 gem 'rake'
 
diff --git a/Gemfile.lock b/Gemfile.lock
index 2c64a4b..0aeb34d 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -267,6 +267,9 @@ GEM
     pry (0.13.1)
       coderay (~> 1.1)
       method_source (~> 1.0)
+    pry-byebug (3.9.0)
+      byebug (~> 11.0)
+      pry (~> 0.13.0)
     pry-rails (0.3.9)
       pry (>= 0.10.4)
     public_suffix (4.0.5)
@@ -516,6 +519,7 @@ DEPENDENCIES
   onebox
   parallel_tests
   pg
+  pry-byebug
   pry-rails
   puma
   r2
diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb
index 256de29..dd4879d 100644
--- a/spec/rails_helper.rb
+++ b/spec/rails_helper.rb
@@ -8,6 +8,12 @@ end
 require 'rubygems'
 require 'rbtrace'
 
+if ENV['IMPROVED_SPEC_DEBUGGING']
+  require 'pry'
+  require 'pry-byebug'
+  require 'pry-rails'
+end
+
 # Loading more in this block will cause your tests to run faster. However,
 # if you change any configuration or code from libraries loaded here, you'll
 # need to restart spork for it take effect.

GitHub sha: e84ffb48

This commit appears in #9984 which was merged by martin.

Hello @martin-brennan

What’s the reason behind not requiring these by default on development/test envs? When doing plugins or customizations these pry and pry-byebug come really handy.

@orlando I didn’t want to require this for everyone at first until I had a consensus of what people wanted internally. This is no longer gated behind the env var!