Skip to content

Conversation

@mensfeld
Copy link
Collaborator

@mensfeld mensfeld commented Dec 26, 2025

Summary

  • Use Bundler.with_unbundled_env to wrap spec execution to prevent bundler state pollution between test runs
  • Clear RUBYOPT in the env to prevent automatic bundler/setup loading from CI or previous tests

Problem

After Rails integration tests run (which use bundle install --standalone with different gem versions), subsequent non-Rails tests would fail because bundler was picking up cached configuration from the Rails test bundle. This manifested as errors like:

Could not find activejob-7.2.3, activesupport-7.2.3, benchmark-0.5.0 in locally installed gems

The root Gemfile has activejob 8.0.1, but bundler was looking for 7.2.3 from the Rails 7.2 integration test.

Test plan

  • CI will run integration tests on all Ruby versions (3.2, 3.3, 3.4, 4.0)
  • Tests that previously failed after Rails tests should now pass

Summary by CodeRabbit

  • Tests
    • Enhanced integration test runner to prevent bundler environment pollution across tests, improving test reliability and consistency.

✏️ Tip: You can customize this high-level summary in your review settings.

Use Bundler.with_unbundled_env to wrap spec execution to prevent
bundler state pollution between test runs. This fixes issues where
non-Rails tests would fail after Rails integration tests because
bundler was using cached configuration from the Rails test bundle.

Also clear RUBYOPT in the env to prevent automatic bundler/setup
loading from CI or previous tests.
@coderabbitai
Copy link

coderabbitai bot commented Dec 26, 2025

📝 Walkthrough

Walkthrough

Modifies the integration test runner to introduce Bundler isolation by requiring Bundler at the top level, clearing the RUBYOPT environment variable, and wrapping test execution with Bundler.with_unbundled_env to prevent gem and version leakage between consecutive tests.

Changes

Cohort / File(s) Summary
Bundler Isolation in Integration Test Runner
bin/integrations
Adds Bundler require statement; clears RUBYOPT environment variable for clean test context; wraps test execution with Bundler.with_unbundled_env to isolate bundler state across test runs and prevent gem/version pollution from standalone bundle setups

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 A bundler's dream, so clean and bright,
No gems shall leak from left to right,
With unbundled paths, we test with care,
Each spec runs fresh in its own lair! 🌿

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically summarizes the main change: fixing bundler environment isolation in integration tests, which directly addresses the core issue described in the PR objectives.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix-integration-bundler-isolation

📜 Recent review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ccdca7f and e301625.

📒 Files selected for processing (1)
  • bin/integrations
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (8)
  • GitHub Check: Integrations (3.3)
  • GitHub Check: Integrations (3.2)
  • GitHub Check: Integrations (4.0)
  • GitHub Check: Integrations (3.4)
  • GitHub Check: Integrations (3.4)
  • GitHub Check: Integrations (3.2)
  • GitHub Check: Integrations (3.3)
  • GitHub Check: Integrations (4.0)
🔇 Additional comments (3)
bin/integrations (3)

13-13: LGTM! Necessary addition for bundler isolation.

This require statement enables the use of Bundler.with_unbundled_env for proper test isolation.


92-97: LGTM! Clean environment setup for test isolation.

The environment configuration correctly:

  • Clears RUBYOPT to prevent automatic bundler/setup loading from CI or previous tests
  • Sets RAILS_ENV to 'test' for Rails integration tests
  • Points to the appropriate Gemfile

This addresses the root cause of bundler state pollution described in the PR objectives.


137-144: LGTM! Proper bundler isolation implemented.

The use of Bundler.with_unbundled_env effectively prevents bundler state pollution between test runs, which is the core fix for the issue where tests failed after Rails integration tests with different gem versions.

The clear comment explains the rationale and the specific scenario (Rails standalone bundles) that this addresses.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@mensfeld mensfeld merged commit fd99df8 into main Dec 26, 2025
21 checks passed
@mensfeld mensfeld deleted the fix-integration-bundler-isolation branch December 26, 2025 19:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants