Skip to content

Conversation

@ydah
Copy link
Contributor

@ydah ydah commented Dec 25, 2025

Overview

Fixes test failure when running with Bundler 4.0+ by skipping a test that validates behavior for old Bundler versions that no longer applies.

Problem

The test test_rubygems_specs_works_with_all_specs_when_installed_specs_is_absent was failing with Bundler 4.0.3+ because:

  • Bundler 4.0 removed Bundler.rubygems.all_specs in favor of Bundler.rubygems.installed_specs
  • The test was attempting to simulate old Bundler behavior by stubbing respond_to? and then calling all_specs
  • Since all_specs no longer exists in Bundler 4.0+, this raises a Bundler::RemovedError

Solution

Added a skip condition to the test when running with Bundler 4.0+, as the scenario it tests (old Bundler without installed_specs) is no longer relevant for modern Bundler versions.

The implementation code in lib/new_relic/helper.rb already handles this correctly by:

  1. First checking if installed_specs is available (Bundler 2.5.12+)
  2. Falling back to all_specs only for very old Bundler versions

Before contributing, please read our contributing guidelines and code of conduct.

Submitter Checklist:

  • Include a link to the related GitHub issue, if applicable
  • [-] Add new tests for your change, if applicable

Testing

The agent includes a suite of unit and functional tests which should be used to
verify your changes don't break existing functionality. These tests will run with
GitHub Actions when a pull request is made. More details on running the tests locally can be found
here for our unit tests,
and here for our functional tests.
For most contributions it is strongly recommended to add additional tests which
exercise your changes.

Reviewer Checklist

  • Perform code review
  • Confirm all checks passed
  • Open a separate PR to add a CHANGELOG entry

## Summary
Fixes test failure when running with Bundler 4.0+ by skipping a test that validates behavior for old Bundler versions that no longer applies.

## Problem
The test `test_rubygems_specs_works_with_all_specs_when_installed_specs_is_absent` was failing with Bundler 4.0.3+ because:
- Bundler 4.0 removed `Bundler.rubygems.all_specs` in favor of `Bundler.rubygems.installed_specs`
- The test was attempting to simulate old Bundler behavior by stubbing `respond_to?` and then calling `all_specs`
- Since `all_specs` no longer exists in Bundler 4.0+, this raises a `Bundler::RemovedError`

## Solution
Added a skip condition to the test when running with Bundler 4.0+, as the scenario it tests (old Bundler without `installed_specs`) is no longer relevant for modern Bundler versions.

The implementation code in `lib/new_relic/helper.rb` already handles this correctly by:
1. First checking if `installed_specs` is available (Bundler 2.5.12+)
2. Falling back to `all_specs` only for very old Bundler versions
@ydah ydah requested a review from a team as a code owner December 25, 2025 18:11
@CLAassistant
Copy link

CLAassistant commented Dec 25, 2025

CLA assistant check
All committers have signed the CLA.

@github-actions github-actions bot added the community To tag external issues and PRs submitted by the community label Dec 25, 2025
Copy link
Contributor

@hannahramadan hannahramadan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for both catching and fixing this test!

@hannahramadan hannahramadan merged commit aac35ef into newrelic:dev Dec 31, 2025
97 of 107 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

community To tag external issues and PRs submitted by the community

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants