Skip to content

Commit 4fc7e5e

Browse files
hsbtclaude
andcommitted
Fix credential store tests under ruby-core and JRuby
The config file test referenced Gem::CredentialStore before anything required it, which only worked when another test loaded the constant first, so it failed under ruby-core's test-all where the load order differs. Require it directly. The macOS backend test expected Open3 to raise Errno::ENOENT for a missing security binary, but JRuby reports a failure status instead of raising, so assert only that no credential comes back either way. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent 676e4ec commit 4fc7e5e

2 files changed

Lines changed: 15 additions & 4 deletions

File tree

test/rubygems/test_gem_config_file.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
require_relative "helper"
44
require "rubygems/config_file"
5+
require "rubygems/credential_store"
56

67
class TestGemConfigFile < Gem::TestCase
78
def setup

test/rubygems/test_gem_credential_store_macos_backend.rb

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -147,14 +147,24 @@ def test_delete_all_returns_false_on_error
147147
end
148148
end
149149

150-
def test_get_raises_when_command_missing
150+
def test_get_returns_no_credential_when_command_missing
151151
empty_dir = File.join(@tempdir, "empty-bin")
152152
FileUtils.mkdir_p(empty_dir)
153153

154+
# A missing security binary must not yield a credential. MRI raises
155+
# Errno::ENOENT from Open3; other implementations (JRuby) report a
156+
# failure status instead of raising, so accept either and assert only
157+
# that nothing is returned. Gem::CredentialStore#get traps the error
158+
# class either way.
154159
with_env(ENV.to_h.merge("PATH" => empty_dir)) do
155-
assert_raise(Errno::ENOENT) do
156-
Gem::CredentialStore::MacOSBackend.get("rubygems", "example.org")
157-
end
160+
result =
161+
begin
162+
Gem::CredentialStore::MacOSBackend.get("rubygems", "example.org")
163+
rescue StandardError
164+
nil
165+
end
166+
167+
assert_nil result
158168
end
159169
end
160170

0 commit comments

Comments
 (0)