diff options
author | The Bundler Bot <bot@bundler.io> | 2017-02-21 02:04:10 +0000 |
---|---|---|
committer | Samuel Giddins <segiddins@segiddins.me> | 2017-02-22 11:54:12 +1100 |
commit | c6f3a9465c0dfc1ae3cc766b5d1f8399a26813d6 (patch) | |
tree | d1a85a06012ea1568fd509b110376f6cdc27542b | |
parent | 240eafd9b060b41f700615ae1a9184b50c5ee58a (diff) | |
download | bundler-c6f3a9465c0dfc1ae3cc766b5d1f8399a26813d6.tar.gz |
Auto merge of #5436 - okkez:fix-frozen-string-literal-error-with-rubygems-2.6.8, r=segiddins
Use empty array when `spec_settings` returns `nil`
If use bundler 1.14.4 with rubygems 2.6.8 and
`Bundler.settings["build.#{spec.name}"]` returns `nil` then we get
error "can't modify frozen literal string" from [rubygems](https://github.com/rubygems/rubygems/blob/v2.6.8/lib/rubygems/ext/rake_builder.rb#L13).
RubyGems 2.6.8 is the default version for Ruby2.4.0.
See also https://github.com/sickill/rainbow/issues/48
(cherry picked from commit ea4926a54030871cf1b5af15e05043f837f2e7fd)
-rw-r--r-- | lib/bundler/installer/gem_installer.rb | 2 | ||||
-rw-r--r-- | spec/bundler/installer/gem_installer_spec.rb | 27 |
2 files changed, 28 insertions, 1 deletions
diff --git a/lib/bundler/installer/gem_installer.rb b/lib/bundler/installer/gem_installer.rb index 0589d14e40..10e7c7fcd7 100644 --- a/lib/bundler/installer/gem_installer.rb +++ b/lib/bundler/installer/gem_installer.rb @@ -52,7 +52,7 @@ module Bundler end def install - spec.source.install(spec, :force => force, :ensure_builtin_gems_cached => standalone, :build_args => [spec_settings]) + spec.source.install(spec, :force => force, :ensure_builtin_gems_cached => standalone, :build_args => Array(spec_settings)) end def install_with_settings diff --git a/spec/bundler/installer/gem_installer_spec.rb b/spec/bundler/installer/gem_installer_spec.rb new file mode 100644 index 0000000000..de5189eecd --- /dev/null +++ b/spec/bundler/installer/gem_installer_spec.rb @@ -0,0 +1,27 @@ +# frozen_string_literal: true +require "spec_helper" +require "bundler/installer/gem_installer" + +RSpec.describe Bundler::GemInstaller do + let(:installer) { instance_double("Installer") } + let(:spec_source) { instance_double("SpecSource") } + let(:spec) { instance_double("Specification", :name => "dummy", :version => "0.0.1", :loaded_from => "dummy", :source => spec_source) } + + subject { described_class.new(spec, installer) } + + context "spec_settings is nil" do + it "invokes install method with empty build_args", :rubygems => ">= 2" do + allow(spec_source).to receive(:install).with(spec, :force => false, :ensure_builtin_gems_cached => false, :build_args => []) + subject.install_from_spec + end + end + + context "spec_settings is build option" do + it "invokes install method with build_args", :rubygems => ">= 2" do + allow(Bundler.settings).to receive(:[]).with(:bin) + allow(Bundler.settings).to receive(:[]).with("build.dummy").and_return("--with-dummy-config=dummy") + allow(spec_source).to receive(:install).with(spec, :force => false, :ensure_builtin_gems_cached => false, :build_args => ["--with-dummy-config=dummy"]) + subject.install_from_spec + end + end +end |