debug: debugger and binding.b are blocking in rspec, and not binding.pry for instance

Your environment

  • ruby -v: ruby 3.0.2p107 (2021-07-07 revision 0db68f0233) [x86_64-darwin20]
  • rdbg -v: rdbg 1.3.4

Describe the bug

When I do debugger or binding.b in my tests it blocks the background requests

To Reproduce

For instance:

require "rails_helper"

RSpec.describe "Approvals" do
  let!(:user) { create(:user) }
  let!(:approved_user) { create(:user) }

  before { create(:event, :approved, user: approved_user) }

  it "can approve events" do
    system_login_as(user)
    binding.b
  end
end

Expected behavior

Requests are not blocked, like what binding.pry does

Additional context

I’m using the preload, maybe that’s related

About this issue

  • Original URL
  • State: open
  • Created 5 years ago
  • Reactions: 3
  • Comments: 17 (13 by maintainers)

Most upvoted comments

Hello! I’d like to reopen this conversation. We’d like to migrate our codebase from pry-byebug to debug, but this issue is the last thing holding us back.

Putting a breakpoint in a system test, in order to stop at a specific step, but still be able to play with our SPA (only the capybara thread being blocked), is an important part of our workflow. Unfortunately, it’s currently impossible with debug.

Maybe also worth to mention others cases where it could be interesting, like https://github.com/Shopify/ruby-lsp-rails/issues/29.

@ko1 do you think that the proposal of @st0012 , could be concidered?