- 
                Notifications
    You must be signed in to change notification settings 
- Fork 139
Open
Description
Your environment
- ruby -v: ruby 3.3.7
- rdbg -v: 1.11.0
Describe the bug
The debug gem's method in debug/source_repository.rb:38 calls File.exist?, which interferes with RSpec mocks that stub this method for specific file paths. This causes test failures with mock expectation errors when the debug gem is loaded during test execution.
To Reproduce
system('gem install bundler') unless Gem::Specification::find_all_by_name('bundler').any?
require 'bundler/inline'
gemfile(true) do
  source 'https://rubygems.org'
  gem 'rspec'
  gem 'debug', '~> 1.11.0'
end
require 'rspec'
require 'debug'
class MyClass
  def check_if_file_exist?(path)
    File.exist?(path)
  end
end
RSpec.describe "debug gem + File.exist? conflict" do
  let(:target_path) { "config/session_store.yml" }
  let(:my_class) { MyClass.new }
  before do
    allow(File).to receive(:exist?).with(target_path).and_return(true)
  end
  it "stubs File.exist? and avoids debug interference" do
    result = my_class.check_if_file_exist?(target_path)
    expect(result).to be true
  end
end
RSpec::Core::Runner.run([])Expected behavior
A clear and concise description of what you expected to happen.
- The test should pass
Metadata
Metadata
Assignees
Labels
No labels