diff options
Diffstat (limited to 'spec/bundler/commands/install_spec.rb')
-rw-r--r-- | spec/bundler/commands/install_spec.rb | 56 |
1 files changed, 50 insertions, 6 deletions
diff --git a/spec/bundler/commands/install_spec.rb b/spec/bundler/commands/install_spec.rb index 00a277a826..412000341f 100644 --- a/spec/bundler/commands/install_spec.rb +++ b/spec/bundler/commands/install_spec.rb @@ -334,11 +334,15 @@ RSpec.describe "bundle install with gem sources" do gem "rack" G - expect(err).to include("Your Gemfile has no gem server sources") + expect(err).to include("This Gemfile does not include an explicit global source. " \ + "Not using an explicit global source may result in a different lockfile being generated depending on " \ + "the gems you have installed locally before bundler is run." \ + "Instead, define a global source in your Gemfile like this: source \"https://rubygems.org\".") end it "creates a Gemfile.lock on a blank Gemfile" do install_gemfile <<-G + source "#{file_uri_for(gem_repo1)}" G expect(File.exist?(bundled_app_lock)).to eq(true) @@ -448,7 +452,7 @@ RSpec.describe "bundle install with gem sources" do expect(last_command.stdboth).not_to match(/Error Report/i) expect(err).to include("An error occurred while installing ajp-rails (0.0.0), and Bundler cannot continue."). - and include("Make sure that `gem install ajp-rails -v '0.0.0' --source '#{file_uri_for(gem_repo2)}/'` succeeds before bundling.") + and include("Bundler::APIResponseInvalidDependenciesError") end it "doesn't blow up when the local .bundle/config is empty" do @@ -482,6 +486,7 @@ RSpec.describe "bundle install with gem sources" do install_gemfile <<-G, :raise_on_error => false ::RUBY_VERSION = '2.0.1' ruby '~> 2.2' + source "#{file_uri_for(gem_repo1)}" G expect(err).to include("Your Ruby version is 2.0.1, but your Gemfile specified ~> 2.2") end @@ -493,12 +498,14 @@ RSpec.describe "bundle install with gem sources" do ::RUBY_VERSION = '2.1.3' ::RUBY_PATCHLEVEL = 100 ruby '~> 2.1.0' + source "#{file_uri_for(gem_repo1)}" G end it "writes current Ruby version to Gemfile.lock" do lockfile_should_be <<-L GEM + remote: #{file_uri_for(gem_repo1)}/ specs: PLATFORMS @@ -519,10 +526,12 @@ RSpec.describe "bundle install with gem sources" do ::RUBY_VERSION = '2.2.3' ::RUBY_PATCHLEVEL = 100 ruby '~> 2.2.0' + source "#{file_uri_for(gem_repo1)}" G lockfile_should_be <<-L GEM + remote: #{file_uri_for(gem_repo1)}/ specs: PLATFORMS @@ -540,6 +549,7 @@ RSpec.describe "bundle install with gem sources" do it "does not crash when unlocking" do gemfile <<-G + source "#{file_uri_for(gem_repo1)}" ruby '>= 2.1.0' G @@ -558,6 +568,7 @@ RSpec.describe "bundle install with gem sources" do build_lib "foo" gemfile = <<-G + source "#{file_uri_for(gem_repo1)}" gem 'foo', :path => "#{lib_path("foo-1.0")}" G File.open("#{root_dir}/Gemfile", "w") do |file| @@ -574,6 +585,7 @@ RSpec.describe "bundle install with gem sources" do build_lib "foo", :path => root_dir gemfile = <<-G + source "#{file_uri_for(gem_repo1)}" gemspec G File.open("#{root_dir}/Gemfile", "w") do |file| @@ -585,16 +597,48 @@ RSpec.describe "bundle install with gem sources" do end describe "when requesting a quiet install via --quiet" do - it "should be quiet" do + it "should be quiet if there are no warnings" do bundle "config set force_ruby_platform true" gemfile <<-G + source "#{file_uri_for(gem_repo1)}" gem 'rack' G - bundle :install, :quiet => true, :raise_on_error => false - expect(err).to include("Could not find gem 'rack'") - expect(err).to_not include("Your Gemfile has no gem server sources") + bundle :install, :quiet => true + expect(out).to be_empty + expect(err).to be_empty + end + + it "should still display warnings and errors" do + bundle "config set force_ruby_platform true" + + create_file("install_with_warning.rb", <<~RUBY) + require "#{lib_dir}/bundler" + require "#{lib_dir}/bundler/cli" + require "#{lib_dir}/bundler/cli/install" + + module RunWithWarning + def run + super + rescue + Bundler.ui.warn "BOOOOO" + raise + end + end + + Bundler::CLI::Install.prepend(RunWithWarning) + RUBY + + gemfile <<-G + source "#{file_uri_for(gem_repo1)}" + gem 'non-existing-gem' + G + + bundle :install, :quiet => true, :raise_on_error => false, :env => { "RUBYOPT" => "-r#{bundled_app("install_with_warning.rb")}" } + expect(out).to be_empty + expect(err).to include("Could not find gem 'non-existing-gem'") + expect(err).to include("BOOOOO") end end |