Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create helper to access Bundler.rubygems specs #2906

Merged
merged 7 commits into from
Oct 15, 2024
Merged

Create helper to access Bundler.rubygems specs #2906

merged 7 commits into from
Oct 15, 2024

Conversation

kaylareopelle
Copy link
Contributor

This PR resolves a bug reported in #2885 to protect against scenarios where the version of Bundler used does not support Bundler.rubygems.installed_specs and needs to use Bundler.rubygems.all_specs to determine whether the third-party gem, newrelic-grape is installed in the environment.

Resolves #2885

Bundler version 2.5.12 deprecated all_specs and added installed_specs.
To support newer Bundler versions, try to use installed_specs first,
then fall back to all_specs.
All callers expect this to be an array, so return an array if Bundler
isn't defined.

This consolidates the way the rubygems specs are accessed across
the multiple places we use them.
@kaylareopelle kaylareopelle changed the title Update newrelic-grape check logic Create helper to access Bundler.rubygems specs Oct 14, 2024
end

def test_rubygems_specs_works_with_all_specs_when_installed_specs_is_absent
Bundler.rubygems.stub(:respond_to?, nil) do
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't understand why, but Rubies 2.6 and below don't like the third argument for a stub in this scenario. However, they're fine with it in the test above. 🤷

Copy link
Contributor

Choose a reason for hiding this comment

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

My guess is that the older Rubies are given an older Minitest. Wanting to use 3 arguments was the primary reason for the introduction of our skip_unless_minitest5_or_above helper.

@kaylareopelle kaylareopelle marked this pull request as ready for review October 15, 2024 00:01
Copy link

SimpleCov Report

Coverage Threshold
Line 93.79% 93%
Branch 69.64% 50%

end

def test_rubygems_specs_works_with_all_specs_when_installed_specs_is_absent
Bundler.rubygems.stub(:respond_to?, nil) do
Copy link
Contributor

Choose a reason for hiding this comment

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

My guess is that the older Rubies are given an older Minitest. Wanting to use 3 arguments was the primary reason for the introduction of our skip_unless_minitest5_or_above helper.

@kaylareopelle kaylareopelle merged commit ac76aab into dev Oct 15, 2024
34 checks passed
@kaylareopelle kaylareopelle deleted the acinarius branch October 15, 2024 23:19
patrickarnett pushed a commit to patrickarnett/newrelic-ruby-agent that referenced this pull request Oct 17, 2024
Create helper to access Bundler.rubygems specs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Code Complete/Done
Development

Successfully merging this pull request may close these issues.

Deprecated Bundler::RubygemsIntegration#all_specs method
2 participants