diff options
| author | Chris HasiĆski <krzysztof.hasinski@gmail.com> | 2026-01-08 01:13:38 +0100 |
|---|---|---|
| committer | Hiroshi SHIBATA <hsbt@ruby-lang.org> | 2026-01-08 13:15:29 +0900 |
| commit | 768862868472fb1800e556effb0e37be2fbaec52 (patch) | |
| tree | b82c39a1e6d993f3838cd6834af10be5a83b1765 /test | |
| parent | 080d66beca71d6cc290a8be4acd49e5a70594f9c (diff) | |
Fix incorrect bundled gems warning for hyphenated gem names
When requiring a file like "benchmark/ips", the warning system would
incorrectly warn about the "benchmark" gem not being a default gem,
even when the user has "benchmark-ips" (a separate third-party gem)
in their Gemfile.
The fix checks if a hyphenated version of the require path exists in
the bundle specs before issuing a warning. For example, requiring
"benchmark/ips" now checks for both "benchmark" and "benchmark-ips"
in the Gemfile.
[Bug #21828]
Diffstat (limited to 'test')
| -rw-r--r-- | test/test_bundled_gems.rb | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/test/test_bundled_gems.rb b/test/test_bundled_gems.rb index 19546dd296..6e25df9b01 100644 --- a/test/test_bundled_gems.rb +++ b/test/test_bundled_gems.rb @@ -32,4 +32,17 @@ class TestBundlerGem < Gem::TestCase assert Gem::BUNDLED_GEMS.warning?(path, specs: {}) assert_nil Gem::BUNDLED_GEMS.warning?(path, specs: {}) end + + def test_no_warning_for_hyphenated_gem + # When benchmark-ips gem is in specs, requiring "benchmark/ips" should not warn + # about the benchmark gem (Bug #21828) + assert_nil Gem::BUNDLED_GEMS.warning?("benchmark/ips", specs: {"benchmark-ips" => true}) + end + + def test_warning_without_hyphenated_gem + # When benchmark-ips is NOT in specs, requiring "benchmark/ips" should warn + warning = Gem::BUNDLED_GEMS.warning?("benchmark/ips", specs: {}) + assert warning + assert_match(/benchmark/, warning) + end end |
