From bb1b229685cc5acb18f6bba71830bb9df3110fe1 Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Fri, 1 May 2026 11:27:22 +0900 Subject: [ruby/rubygems] Add overrides attribute to Bundler::Definition Reserve a slot on Definition for the upcoming Gemfile `override` DSL. This commit only stores the data; the DSL entry point and the resolver hookup come in later commits. https://github.com/ruby/rubygems/commit/6fb2bf90fe Co-Authored-By: Claude Opus 4.7 (1M context) --- lib/bundler/definition.rb | 4 +++- spec/bundler/bundler/definition_spec.rb | 18 ++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/lib/bundler/definition.rb b/lib/bundler/definition.rb index a620475c18..2435479f94 100644 --- a/lib/bundler/definition.rb +++ b/lib/bundler/definition.rb @@ -10,13 +10,14 @@ module Bundler attr_accessor :no_lock end - attr_writer :lockfile + attr_writer :lockfile, :overrides attr_reader( :dependencies, :locked_checksums, :locked_deps, :locked_gems, + :overrides, :platforms, :ruby_version, :lockfile, @@ -88,6 +89,7 @@ module Bundler @specs = nil @ruby_version = ruby_version @gemfiles = gemfiles + @overrides = [] @lockfile = lockfile @lockfile_contents = String.new diff --git a/spec/bundler/bundler/definition_spec.rb b/spec/bundler/bundler/definition_spec.rb index 8c7d5667ac..8c4a5a0331 100644 --- a/spec/bundler/bundler/definition_spec.rb +++ b/spec/bundler/bundler/definition_spec.rb @@ -3,6 +3,24 @@ require "bundler/definition" RSpec.describe Bundler::Definition do + describe "#overrides" do + before do + allow(Bundler::SharedHelpers).to receive(:find_gemfile) { bundled_app_gemfile } + end + + subject { Bundler::Definition.new(bundled_app_lock, [], Bundler::SourceList.new, {}) } + + it "defaults to an empty array" do + expect(subject.overrides).to eq([]) + end + + it "is writable" do + override = Bundler::Override.new("rails", :version, ">= 8.0") + subject.overrides = [override] + expect(subject.overrides).to eq([override]) + end + end + describe "#lock" do before do allow(Bundler::SharedHelpers).to receive(:find_gemfile) { bundled_app_gemfile } -- cgit v1.2.3