Debug gem conflict with rspec mocks
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 45/100
Hướng nghiên cứu
Start with lib/debug/source_repository.rb:38 and run the Ruby 3.3.7 reproduction from the issue with debug 1.11.0 and RSpec. Trace how the File.exist? call interacts with the configured mock. Done means the reproduction passes without mock expectation errors while preserving the source repository behavior.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Your environment
ruby -v: ruby 3.3.7rdbg -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
- Ngôn ngữ chính
- Ruby
- Star
- 1.3k
- Fork
- 146
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của ruby/debug
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 68/100
-
Support exceptionOptions in setExceptionBreakpoints to catch arbitrary exception classes via DAP Đang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 55/100
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 45/100
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 52/100
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
Issue tương tự
-
SyncEm always forwards a dummy block, so wrapped methods lose their no-block/Enumerator behavior Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
endoflife-date/endoflife.date#11086 ·
-
internal
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
Kong/developer.konghq.com#7322 ·
-
bug P2
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100