Skip to content

Commit 674ed3f

Browse files
hsbtclaude
andcommitted
Test that a parse failure restores Bundler root
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent 7077f08 commit 674ed3f

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

test/rubygems/test_gem_request_set.rb

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -615,6 +615,26 @@ def rs.require(*)
615615
Bundler.instance_variable_set(:@root, previous_root)
616616
end
617617

618+
def test_load_lockfile_restores_bundler_root_when_parsing_fails
619+
require "bundler"
620+
621+
previous_root = Bundler.instance_variable_get(:@root)
622+
Bundler.instance_variable_set(:@root, Pathname.new(File.join(@tempdir, "elsewhere")))
623+
624+
File.open "gem.deps.rb.lock", "w" do |io|
625+
io.puts "<<<<<<< HEAD"
626+
end
627+
628+
assert_raise Bundler::LockfileError do
629+
Gem::RequestSet.new.load_lockfile "gem.deps.rb.lock"
630+
end
631+
632+
assert_equal Pathname.new(File.join(@tempdir, "elsewhere")),
633+
Bundler.instance_variable_get(:@root)
634+
ensure
635+
Bundler.instance_variable_set(:@root, previous_root)
636+
end
637+
618638
def test_load_gemdeps_with_missing_lockfile
619639
rs = Gem::RequestSet.new
620640

0 commit comments

Comments
 (0)