Skip to content
This repository has been archived by the owner on Apr 14, 2021. It is now read-only.

Allow to bundle exec default gems #6963

Merged
2 commits merged into from
Apr 1, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions lib/bundler/rubygems_integration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,15 @@ def replace_entrypoints(specs)
h
end

Bundler.rubygems.default_stubs.each do |stub|
default_spec = stub.to_spec
default_spec_name = default_spec.name
next if specs_by_name.key?(default_spec_name)

specs << default_spec
specs_by_name[default_spec_name] = default_spec
end

replace_gem(specs, specs_by_name)
stub_rubygems(specs)
replace_bin_path(specs, specs_by_name)
Expand Down Expand Up @@ -848,6 +857,16 @@ def find_name(name)
end
end

if Gem::Specification.respond_to?(:default_stubs)
def default_stubs
Gem::Specification.default_stubs("*.gemspec")
end
else
def default_stubs
Gem::Specification.send(:default_stubs, "*.gemspec")
end
end

def use_gemdeps(gemfile)
ENV["BUNDLE_GEMFILE"] ||= File.expand_path(gemfile)
require "bundler/gemdeps"
Expand Down
77 changes: 77 additions & 0 deletions spec/commands/exec_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,83 @@
end
end

context "with default gems" do
let(:system_gems_to_install) { [] }

let(:default_irb_version) { ruby "gem 'irb', '< 999999'; require 'irb'; puts IRB::VERSION" }

context "when not specified in Gemfile" do
before do
skip "irb isn't a default gem" if default_irb_version.empty?

install_gemfile ""
end

it "uses version provided by ruby" do
bundle! "exec irb --version"

expect(out).to include(default_irb_version)
expect(last_command.stderr).to be_empty
end
end

context "when specified in Gemfile directly" do
let(:specified_irb_version) { "0.9.6" }

before do
skip "irb isn't a default gem" if default_irb_version.empty?

build_repo2 do
build_gem "irb", specified_irb_version do |s|
s.executables = "irb"
end
end

install_gemfile <<-G
source "file://#{gem_repo2}"
gem "irb", "#{specified_irb_version}"
G
end

it "uses version specified" do
bundle! "exec irb --version"

expect(out).to include(specified_irb_version)
expect(last_command.stderr).to be_empty
end
end

context "when specified in Gemfile indirectly" do
let(:indirect_irb_version) { "0.9.6" }

before do
skip "irb isn't a default gem" if default_irb_version.empty?

build_repo2 do
build_gem "irb", indirect_irb_version do |s|
s.executables = "irb"
end

build_gem "gem_depending_on_old_irb" do |s|
s.add_dependency "irb", indirect_irb_version
end
end

install_gemfile <<-G
source "file://#{gem_repo2}"
gem "gem_depending_on_old_irb"
G

bundle! "exec irb --version"
end

it "uses resolved version" do
expect(out).to include(indirect_irb_version)
expect(last_command.stderr).to be_empty
end
end
end

it "handles gems installed with --without" do
install_gemfile <<-G, forgotten_command_line_options(:without => "middleware")
source "file://#{gem_repo1}"
Expand Down