summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorhsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2019-04-14 06:01:35 +0000
committerhsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2019-04-14 06:01:35 +0000
commit68ddd4d300e9a88737c4f37af74e1a0312949b2f (patch)
tree787e1e83d76934ce039eb336995a8d5bb53a89e6 /spec
parentd636809c057432e8d42abe30c6c6785eb0721d77 (diff)
Merge Bundler 2.1.0.pre.1 as developed version from upstream.
https://github.com/bundler/bundler/commit/a53709556b95a914e874b22ed2116a46b0528852 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67539 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'spec')
-rw-r--r--spec/bundler/bundler/bundler_spec.rb16
-rw-r--r--spec/bundler/bundler/cli_spec.rb12
-rw-r--r--spec/bundler/bundler/definition_spec.rb49
-rw-r--r--spec/bundler/bundler/dsl_spec.rb94
-rw-r--r--spec/bundler/bundler/fetcher/compact_index_spec.rb2
-rw-r--r--spec/bundler/bundler/fetcher/downloader_spec.rb12
-rw-r--r--spec/bundler/bundler/friendly_errors_spec.rb17
-rw-r--r--spec/bundler/bundler/gem_helper_spec.rb27
-rw-r--r--spec/bundler/bundler/installer/gem_installer_spec.rb15
-rw-r--r--spec/bundler/bundler/mirror_spec.rb4
-rw-r--r--spec/bundler/bundler/plugin/index_spec.rb11
-rw-r--r--spec/bundler/bundler/plugin/installer_spec.rb35
-rw-r--r--spec/bundler/bundler/plugin_spec.rb23
-rw-r--r--spec/bundler/bundler/rubygems_integration_spec.rb22
-rw-r--r--spec/bundler/bundler/settings_spec.rb4
-rw-r--r--spec/bundler/bundler/shared_helpers_spec.rb8
-rw-r--r--spec/bundler/bundler/source/git/git_proxy_spec.rb32
-rw-r--r--spec/bundler/bundler/source/rubygems/remote_spec.rb24
-rw-r--r--spec/bundler/bundler/source_list_spec.rb16
-rw-r--r--spec/bundler/bundler/ssl_certs/certificate_manager_spec.rb140
-rw-r--r--spec/bundler/bundler/stub_specification_spec.rb10
-rw-r--r--spec/bundler/bundler/ui/shell_spec.rb12
-rw-r--r--spec/bundler/bundler/ui_spec.rb4
-rw-r--r--spec/bundler/bundler/vendored_persistent_spec.rb3
-rw-r--r--spec/bundler/bundler/version_ranges_spec.rb3
-rw-r--r--spec/bundler/cache/cache_path_spec.rb2
-rw-r--r--spec/bundler/cache/gems_spec.rb14
-rw-r--r--spec/bundler/cache/git_spec.rb10
-rw-r--r--spec/bundler/cache/path_spec.rb2
-rw-r--r--spec/bundler/cache/platform_spec.rb2
-rw-r--r--spec/bundler/commands/add_spec.rb32
-rw-r--r--spec/bundler/commands/binstubs_spec.rb78
-rw-r--r--spec/bundler/commands/check_spec.rb20
-rw-r--r--spec/bundler/commands/clean_spec.rb79
-rw-r--r--spec/bundler/commands/config_spec.rb237
-rw-r--r--spec/bundler/commands/console_spec.rb6
-rw-r--r--spec/bundler/commands/exec_spec.rb211
-rw-r--r--spec/bundler/commands/help_spec.rb11
-rw-r--r--spec/bundler/commands/info_spec.rb118
-rw-r--r--spec/bundler/commands/init_spec.rb102
-rw-r--r--spec/bundler/commands/inject_spec.rb10
-rw-r--r--spec/bundler/commands/install_spec.rb46
-rw-r--r--spec/bundler/commands/licenses_spec.rb11
-rw-r--r--spec/bundler/commands/list_spec.rb83
-rw-r--r--spec/bundler/commands/lock_spec.rb54
-rw-r--r--spec/bundler/commands/newgem_spec.rb54
-rw-r--r--spec/bundler/commands/open_spec.rb6
-rw-r--r--spec/bundler/commands/outdated_spec.rb50
-rw-r--r--spec/bundler/commands/package_spec.rb24
-rw-r--r--spec/bundler/commands/pristine_spec.rb16
-rw-r--r--spec/bundler/commands/remove_spec.rb52
-rw-r--r--spec/bundler/commands/show_spec.rb102
-rw-r--r--spec/bundler/commands/update_spec.rb76
-rw-r--r--spec/bundler/commands/viz_spec.rb2
-rw-r--r--spec/bundler/install/allow_offline_install_spec.rb10
-rw-r--r--spec/bundler/install/binstubs_spec.rb21
-rw-r--r--spec/bundler/install/bundler_spec.rb14
-rw-r--r--spec/bundler/install/deploy_spec.rb126
-rw-r--r--spec/bundler/install/failure_spec.rb19
-rw-r--r--spec/bundler/install/gemfile/gemspec_spec.rb123
-rw-r--r--spec/bundler/install/gemfile/git_spec.rb206
-rw-r--r--spec/bundler/install/gemfile/groups_spec.rb8
-rw-r--r--spec/bundler/install/gemfile/lockfile_spec.rb2
-rw-r--r--spec/bundler/install/gemfile/path_spec.rb40
-rw-r--r--spec/bundler/install/gemfile/platform_spec.rb11
-rw-r--r--spec/bundler/install/gemfile/ruby_spec.rb2
-rw-r--r--spec/bundler/install/gemfile/sources_spec.rb147
-rw-r--r--spec/bundler/install/gemfile/specific_platform_spec.rb2
-rw-r--r--spec/bundler/install/gemfile_spec.rb27
-rw-r--r--spec/bundler/install/gems/compact_index_spec.rb44
-rw-r--r--spec/bundler/install/gems/dependency_api_spec.rb28
-rw-r--r--spec/bundler/install/gems/flex_spec.rb12
-rw-r--r--spec/bundler/install/gems/mirror_spec.rb4
-rw-r--r--spec/bundler/install/gems/native_extensions_spec.rb45
-rw-r--r--spec/bundler/install/gems/post_install_spec.rb4
-rw-r--r--spec/bundler/install/gems/resolving_spec.rb37
-rw-r--r--spec/bundler/install/gems/standalone_spec.rb6
-rw-r--r--spec/bundler/install/gems/sudo_spec.rb18
-rw-r--r--spec/bundler/install/gemspecs_spec.rb19
-rw-r--r--spec/bundler/install/git_spec.rb2
-rw-r--r--spec/bundler/install/global_cache_spec.rb10
-rw-r--r--spec/bundler/install/path_spec.rb16
-rw-r--r--spec/bundler/install/post_bundle_message_spec.rb14
-rw-r--r--spec/bundler/install/process_lock_spec.rb2
-rw-r--r--spec/bundler/install/redownload_spec.rb14
-rw-r--r--spec/bundler/install/security_policy_spec.rb13
-rw-r--r--spec/bundler/install/yanked_spec.rb14
-rw-r--r--spec/bundler/lock/lockfile_bundler_1_spec.rb1386
-rw-r--r--spec/bundler/lock/lockfile_spec.rb288
-rw-r--r--spec/bundler/other/bundle_ruby_spec.rb155
-rw-r--r--spec/bundler/other/cli_dispatch_spec.rb2
-rw-r--r--spec/bundler/other/compatibility_guard_spec.rb9
-rw-r--r--spec/bundler/other/ext_spec.rb7
-rw-r--r--spec/bundler/other/major_deprecation_spec.rb473
-rw-r--r--spec/bundler/other/platform_spec.rb28
-rw-r--r--spec/bundler/other/ssl_cert_spec.rb18
-rw-r--r--spec/bundler/plugins/command_spec.rb4
-rw-r--r--spec/bundler/plugins/install_spec.rb58
-rw-r--r--spec/bundler/plugins/list_spec.rb60
-rw-r--r--spec/bundler/plugins/source/example_spec.rb16
-rw-r--r--spec/bundler/quality_es_spec.rb70
-rw-r--r--spec/bundler/quality_spec.rb39
-rw-r--r--spec/bundler/realworld/dependency_api_spec.rb4
-rw-r--r--spec/bundler/realworld/double_check_spec.rb2
-rw-r--r--spec/bundler/realworld/edgecases_spec.rb61
-rw-r--r--spec/bundler/realworld/gemfile_source_header_spec.rb6
-rw-r--r--spec/bundler/realworld/mirror_probe_spec.rb18
-rw-r--r--spec/bundler/realworld/parallel_spec.rb14
-rw-r--r--spec/bundler/resolver/basic_spec.rb8
-rw-r--r--spec/bundler/runtime/executable_spec.rb17
-rw-r--r--spec/bundler/runtime/gem_tasks_spec.rb2
-rw-r--r--spec/bundler/runtime/inline_spec.rb29
-rw-r--r--spec/bundler/runtime/platform_spec.rb4
-rw-r--r--spec/bundler/runtime/require_spec.rb32
-rw-r--r--spec/bundler/runtime/setup_spec.rb178
-rw-r--r--spec/bundler/runtime/with_clean_env_spec.rb151
-rw-r--r--spec/bundler/runtime/with_unbundled_env_spec.rb241
-rw-r--r--spec/bundler/spec_helper.rb48
-rw-r--r--spec/bundler/support/artifice/compact_index.rb12
-rw-r--r--spec/bundler/support/artifice/compact_index_api_missing.rb2
-rw-r--r--spec/bundler/support/artifice/compact_index_rate_limited.rb48
-rw-r--r--spec/bundler/support/artifice/endpoint.rb2
-rw-r--r--spec/bundler/support/artifice/endpoint_api_missing.rb2
-rw-r--r--spec/bundler/support/artifice/vcr.rb7
-rw-r--r--spec/bundler/support/builders.rb12
-rw-r--r--spec/bundler/support/helpers.rb72
-rw-r--r--spec/bundler/support/indexes.rb4
-rw-r--r--spec/bundler/support/less_than_proc.rb20
-rw-r--r--spec/bundler/support/matchers.rb50
-rw-r--r--spec/bundler/support/path.rb2
-rw-r--r--spec/bundler/support/platforms.rb5
-rw-r--r--spec/bundler/support/requirement_checker.rb11
-rw-r--r--spec/bundler/support/rubygems_ext.rb42
-rw-r--r--spec/bundler/update/gemfile_spec.rb25
-rw-r--r--spec/bundler/update/gems/post_install_spec.rb6
-rw-r--r--spec/bundler/update/git_spec.rb24
-rw-r--r--spec/bundler/update/redownload_spec.rb16
137 files changed, 3126 insertions, 3829 deletions
diff --git a/spec/bundler/bundler/bundler_spec.rb b/spec/bundler/bundler/bundler_spec.rb
index 194d6752b2..e33c8dc606 100644
--- a/spec/bundler/bundler/bundler_spec.rb
+++ b/spec/bundler/bundler/bundler_spec.rb
@@ -1,4 +1,3 @@
-# encoding: utf-8
# frozen_string_literal: true
require "bundler"
@@ -313,10 +312,9 @@ EOF
let(:bundle_path) { Pathname("#{tmpdir}/bundle") }
def clear_cached_requires_sudo
- # Private in ruby 1.8.7
return unless Bundler.instance_variable_defined?(:@requires_sudo_ran)
- Bundler.send(:remove_instance_variable, :@requires_sudo_ran)
- Bundler.send(:remove_instance_variable, :@requires_sudo)
+ Bundler.remove_instance_variable(:@requires_sudo_ran)
+ Bundler.remove_instance_variable(:@requires_sudo)
end
before do
@@ -383,14 +381,8 @@ EOF
after do
FileUtils.rm_rf("tmp/vendor/bundle")
FileUtils.rm_rf("tmp/vendor/bin_dir")
- if Bundler.respond_to?(:remove_instance_variable)
- Bundler.remove_instance_variable(:@requires_sudo_ran)
- Bundler.remove_instance_variable(:@requires_sudo)
- else
- # TODO: Remove these code when Bundler drops Ruby 1.8.7 support
- Bundler.send(:remove_instance_variable, :@requires_sudo_ran)
- Bundler.send(:remove_instance_variable, :@requires_sudo)
- end
+ Bundler.remove_instance_variable(:@requires_sudo_ran)
+ Bundler.remove_instance_variable(:@requires_sudo)
end
context "writable paths" do
it "should return false and display nothing" do
diff --git a/spec/bundler/bundler/cli_spec.rb b/spec/bundler/bundler/cli_spec.rb
index 9a2591ac96..6a505358d1 100644
--- a/spec/bundler/bundler/cli_spec.rb
+++ b/spec/bundler/bundler/cli_spec.rb
@@ -60,11 +60,11 @@ RSpec.describe "bundle executable" do
G
bundle :install, :env => { "RUBYGEMS_GEMDEPS" => "foo" }
- expect(out).to include("RUBYGEMS_GEMDEPS")
- expect(out).to include("conflict with Bundler")
+ expect(err).to include("RUBYGEMS_GEMDEPS")
+ expect(err).to include("conflict with Bundler")
bundle :install, :env => { "RUBYGEMS_GEMDEPS" => "" }
- expect(out).not_to include("RUBYGEMS_GEMDEPS")
+ expect(err).not_to include("RUBYGEMS_GEMDEPS")
end
end
@@ -97,7 +97,7 @@ RSpec.describe "bundle executable" do
let(:bundler_version) { "1.1" }
let(:latest_version) { nil }
before do
- bundle! "config --global disable_version_check false"
+ bundle! "config set --global disable_version_check false"
simulate_bundler_version(bundler_version)
if latest_version
@@ -132,13 +132,13 @@ To install the latest version, run `gem install bundler`
end
context "and disable_version_check is set" do
- before { bundle! "config disable_version_check true" }
+ before { bundle! "config set disable_version_check true" }
include_examples "no warning"
end
context "running a parseable command" do
it "prints no warning" do
- bundle! "config --parseable foo"
+ bundle! "config get --parseable foo"
expect(last_command.stdboth).to eq ""
bundle "platform --ruby"
diff --git a/spec/bundler/bundler/definition_spec.rb b/spec/bundler/bundler/definition_spec.rb
index a27c5b0a54..f048728a9f 100644
--- a/spec/bundler/bundler/definition_spec.rb
+++ b/spec/bundler/bundler/definition_spec.rb
@@ -88,17 +88,17 @@ RSpec.describe Bundler::Definition do
expect(out).to match(/re-resolving dependencies/)
lockfile_should_be <<-G
- GEM
- remote: file://localhost#{gem_repo1}/
- specs:
- rack (1.0.0)
-
PATH
remote: #{lib_path("foo")}
specs:
foo (1.0)
rack (= 1.0)
+ GEM
+ remote: file://localhost#{gem_repo1}/
+ specs:
+ rack (1.0.0)
+
PLATFORMS
#{lockfile_platforms}
@@ -110,7 +110,7 @@ RSpec.describe Bundler::Definition do
G
end
- it "for a path gem with deps and no changes", :bundler => "< 3" do
+ it "for a path gem with deps and no changes" do
build_lib "foo", "1.0", :path => lib_path("foo") do |s|
s.add_dependency "rack", "1.0"
s.add_development_dependency "net-ssh", "1.0"
@@ -137,43 +137,6 @@ RSpec.describe Bundler::Definition do
rack (1.0.0)
PLATFORMS
- ruby
-
- DEPENDENCIES
- foo!
-
- BUNDLED WITH
- #{Bundler::VERSION}
- G
- end
-
- it "for a path gem with deps and no changes", :bundler => "3" do
- build_lib "foo", "1.0", :path => lib_path("foo") do |s|
- s.add_dependency "rack", "1.0"
- s.add_development_dependency "net-ssh", "1.0"
- end
-
- install_gemfile <<-G
- source "file://localhost#{gem_repo1}"
- gem "foo", :path => "#{lib_path("foo")}"
- G
-
- bundle :check, :env => { "DEBUG" => 1 }
-
- expect(out).to match(/using resolution from the lockfile/)
- lockfile_should_be <<-G
- GEM
- remote: file://localhost#{gem_repo1}/
- specs:
- rack (1.0.0)
-
- PATH
- remote: #{lib_path("foo")}
- specs:
- foo (1.0)
- rack (= 1.0)
-
- PLATFORMS
#{lockfile_platforms}
DEPENDENCIES
diff --git a/spec/bundler/bundler/dsl_spec.rb b/spec/bundler/bundler/dsl_spec.rb
index d6bd9ad0a0..a17bfd4938 100644
--- a/spec/bundler/bundler/dsl_spec.rb
+++ b/spec/bundler/bundler/dsl_spec.rb
@@ -27,25 +27,58 @@ RSpec.describe Bundler::Dsl do
context "github_https feature flag" do
it "is true when github.https is true" do
- bundle "config github.https true"
- expect(Bundler.feature_flag.github_https?).to eq "true"
+ bundle "config set github.https true"
+ expect(Bundler.feature_flag.github_https?).to eq true
end
end
- context "default hosts (git, gist)", :bundler => "< 3" do
- context "when github.https config is true" do
- before { bundle "config github.https true" }
- it "converts :github to :git using https" do
- subject.gem("sparks", :github => "indirect/sparks")
- github_uri = "https://github.com/indirect/sparks.git"
+ shared_examples_for "the github DSL" do |protocol|
+ context "when full repo is used" do
+ let(:repo) { "indirect/sparks" }
+
+ it "converts :github to URI using #{protocol}" do
+ subject.gem("sparks", :github => repo)
+ github_uri = "#{protocol}://github.com/#{repo}.git"
expect(subject.dependencies.first.source.uri).to eq(github_uri)
end
end
- it "converts :github to :git" do
- subject.gem("sparks", :github => "indirect/sparks")
- github_uri = "git://github.com/indirect/sparks.git"
- expect(subject.dependencies.first.source.uri).to eq(github_uri)
+ context "when shortcut repo is used" do
+ let(:repo) { "rails" }
+
+ it "converts :github to URI using #{protocol}" do
+ subject.gem("sparks", :github => repo)
+ github_uri = "#{protocol}://github.com/#{repo}/#{repo}.git"
+ expect(subject.dependencies.first.source.uri).to eq(github_uri)
+ end
+ end
+ end
+
+ context "default hosts (git, gist)" do
+ context "when github.https config is true" do
+ before { bundle "config set github.https true" }
+
+ it_behaves_like "the github DSL", "https"
+ end
+
+ context "when github.https config is false", :bundler => "2" do
+ before { bundle "config set github.https false" }
+
+ it_behaves_like "the github DSL", "git"
+ end
+
+ context "when github.https config is false", :bundler => "3" do
+ before { bundle "config set github.https false" }
+
+ pending "should show a proper message about the removed setting"
+ end
+
+ context "by default", :bundler => "2" do
+ it_behaves_like "the github DSL", "https"
+ end
+
+ context "by default", :bundler => "3" do
+ it_behaves_like "the github DSL", "https"
end
it "converts numeric :gist to :git" do
@@ -60,12 +93,6 @@ RSpec.describe Bundler::Dsl do
expect(subject.dependencies.first.source.uri).to eq(github_uri)
end
- it "converts 'rails' to 'rails/rails'" do
- subject.gem("rails", :github => "rails")
- github_uri = "git://github.com/rails/rails.git"
- expect(subject.dependencies.first.source.uri).to eq(github_uri)
- end
-
it "converts :bitbucket to :git" do
subject.gem("not-really-a-gem", :bitbucket => "mcorp/flatlab-rails")
bitbucket_uri = "https://mcorp@bitbucket.org/mcorp/flatlab-rails.git"
@@ -79,7 +106,7 @@ RSpec.describe Bundler::Dsl do
end
end
- context "default git sources", :bundler => "3" do
+ context "default git sources", :bundler => "4" do
it "has none" do
expect(subject.instance_variable_get(:@git_sources)).to eq({})
end
@@ -253,13 +280,39 @@ RSpec.describe Bundler::Dsl do
end
subject.dependencies.each do |d|
- expect(d.source.uri).to eq("git://github.com/spree/spree.git")
+ expect(d.source.uri).to eq("https://github.com/spree/spree.git")
end
end
end
describe "#github", :bundler => "3" do
it "from github" do
+ spree_gems = %w[spree_core spree_api spree_backend]
+ subject.github "spree" do
+ spree_gems.each {|spree_gem| subject.send :gem, spree_gem }
+ end
+
+ subject.dependencies.each do |d|
+ expect(d.source.uri).to eq("https://github.com/spree/spree.git")
+ end
+ end
+ end
+
+ describe "#github", :bundler => "3" do
+ it "from github" do
+ spree_gems = %w[spree_core spree_api spree_backend]
+ subject.github "spree" do
+ spree_gems.each {|spree_gem| subject.send :gem, spree_gem }
+ end
+
+ subject.dependencies.each do |d|
+ expect(d.source.uri).to eq("https://github.com/spree/spree.git")
+ end
+ end
+ end
+
+ describe "#github", :bundler => "4" do
+ it "from github" do
expect do
spree_gems = %w[spree_core spree_api spree_backend]
subject.github "spree" do
@@ -272,7 +325,6 @@ RSpec.describe Bundler::Dsl do
describe "syntax errors" do
it "will raise a Bundler::GemfileError" do
- skip "this is failing with ruby 2.7 after r67226. consider merging https://github.com/bundler/bundler/pull/7038 or fixing this test."
gemfile "gem 'foo', :path => /unquoted/string/syntax/error"
expect { Bundler::Dsl.evaluate(bundled_app("Gemfile"), nil, true) }.
to raise_error(Bundler::GemfileError, /There was an error parsing `Gemfile`:( compile error -)? unknown regexp options - trg. Bundler cannot continue./)
diff --git a/spec/bundler/bundler/fetcher/compact_index_spec.rb b/spec/bundler/bundler/fetcher/compact_index_spec.rb
index e0f58766ea..5a2d22193a 100644
--- a/spec/bundler/bundler/fetcher/compact_index_spec.rb
+++ b/spec/bundler/bundler/fetcher/compact_index_spec.rb
@@ -44,7 +44,7 @@ RSpec.describe Bundler::Fetcher::CompactIndex do
end
end
- context "when OpenSSL is FIPS-enabled", :ruby => ">= 2.0.0" do
+ context "when OpenSSL is FIPS-enabled" do
def remove_cached_md5_availability
return unless Bundler::SharedHelpers.instance_variable_defined?(:@md5_available)
Bundler::SharedHelpers.remove_instance_variable(:@md5_available)
diff --git a/spec/bundler/bundler/fetcher/downloader_spec.rb b/spec/bundler/bundler/fetcher/downloader_spec.rb
index c9b4fa662a..07b507266b 100644
--- a/spec/bundler/bundler/fetcher/downloader_spec.rb
+++ b/spec/bundler/bundler/fetcher/downloader_spec.rb
@@ -88,7 +88,17 @@ RSpec.describe Bundler::Fetcher::Downloader do
let(:http_response) { Net::HTTPNotFound.new("1.1", 404, "Not Found") }
it "should raise a Bundler::Fetcher::FallbackError with Net::HTTPNotFound" do
- expect { subject.fetch(uri, options, counter) }.to raise_error(Bundler::Fetcher::FallbackError, "Net::HTTPNotFound")
+ expect { subject.fetch(uri, options, counter) }.
+ to raise_error(Bundler::Fetcher::FallbackError, "Net::HTTPNotFound: http://www.uri-to-fetch.com/api/v2/endpoint")
+ end
+
+ context "when the there are credentials provided in the request" do
+ let(:uri) { URI("http://username:password@www.uri-to-fetch.com/api/v2/endpoint") }
+
+ it "should raise a Bundler::Fetcher::FallbackError that doesn't contain the password" do
+ expect { subject.fetch(uri, options, counter) }.
+ to raise_error(Bundler::Fetcher::FallbackError, "Net::HTTPNotFound: http://username@www.uri-to-fetch.com/api/v2/endpoint")
+ end
end
end
diff --git a/spec/bundler/bundler/friendly_errors_spec.rb b/spec/bundler/bundler/friendly_errors_spec.rb
index 2a1be491ef..4ca1e543c1 100644
--- a/spec/bundler/bundler/friendly_errors_spec.rb
+++ b/spec/bundler/bundler/friendly_errors_spec.rb
@@ -16,22 +16,7 @@ RSpec.describe Bundler, "friendly errors" do
FileUtils.rm(Gem.configuration.config_file_name)
end
- it "reports a relevant friendly error message", :ruby => ">= 1.9", :rubygems => "< 2.5.0" do
- gemfile <<-G
- source "file://#{gem_repo1}"
- gem "rack"
- G
-
- bundle :install, :env => { "DEBUG" => true }
-
- expect(out).to include("Your RubyGems configuration")
- expect(out).to include("invalid YAML syntax")
- expect(out).to include("Psych::SyntaxError")
- expect(out).not_to include("ERROR REPORT TEMPLATE")
- expect(exitstatus).to eq(25) if exitstatus
- end
-
- it "reports a relevant friendly error message", :ruby => ">= 1.9", :rubygems => ">= 2.5.0" do
+ it "reports a relevant friendly error message" do
gemfile <<-G
source "file://#{gem_repo1}"
gem "rack"
diff --git a/spec/bundler/bundler/gem_helper_spec.rb b/spec/bundler/bundler/gem_helper_spec.rb
index a627129fe3..dc982c6ee7 100644
--- a/spec/bundler/bundler/gem_helper_spec.rb
+++ b/spec/bundler/bundler/gem_helper_spec.rb
@@ -29,15 +29,6 @@ RSpec.describe Bundler::GemHelper do
end
context "interpolates the name" do
- before do
- # Remove exception that prevents public pushes on older RubyGems versions
- if Gem::Version.new(Gem::VERSION) < Gem::Version.new("2.0")
- content = File.read(app_gemspec_path)
- content.sub!(/raise "RubyGems 2\.0 or newer.*/, "")
- File.open(app_gemspec_path, "w") {|f| f.write(content) }
- end
- end
-
it "when there is only one gemspec" do
expect(subject.gemspec.name).to eq(app_name)
end
@@ -72,7 +63,7 @@ RSpec.describe Bundler::GemHelper do
let(:app_version) { "0.1.0" }
let(:app_gem_dir) { app_path.join("pkg") }
let(:app_gem_path) { app_gem_dir.join("#{app_name}-#{app_version}.gem") }
- let(:app_gemspec_content) { remove_push_guard(File.read(app_gemspec_path)) }
+ let(:app_gemspec_content) { File.read(app_gemspec_path) }
before(:each) do
content = app_gemspec_content.gsub("TODO: ", "")
@@ -81,14 +72,6 @@ RSpec.describe Bundler::GemHelper do
File.open(app_gemspec_path, "w") {|file| file << content }
end
- def remove_push_guard(gemspec_content)
- # Remove exception that prevents public pushes on older RubyGems versions
- if Gem::Version.new(Gem::VERSION) < Gem::Version.new("2.0")
- gemspec_content.sub!(/raise "RubyGems 2\.0 or newer.*/, "")
- end
- gemspec_content
- end
-
it "uses a shell UI for output" do
expect(Bundler.ui).to be_a(Bundler::UI::Shell)
end
@@ -198,6 +181,7 @@ RSpec.describe Bundler::GemHelper do
`git init`
`git config user.email "you@example.com"`
`git config user.name "name"`
+ `git config commit.gpgsign false`
`git config push.default simple`
end
@@ -225,11 +209,12 @@ RSpec.describe Bundler::GemHelper do
end
context "succeeds" do
+ let(:repo) { build_git("foo", :bare => true) }
+
before do
- Dir.chdir(gem_repo1) { `git init --bare` }
Dir.chdir(app_path) do
- `git remote add origin file://#{gem_repo1}`
- `git commit -a -m "initial commit"`
+ sys_exec("git remote add origin file://#{repo.path}")
+ sys_exec('git commit -a -m "initial commit"')
end
end
diff --git a/spec/bundler/bundler/installer/gem_installer_spec.rb b/spec/bundler/bundler/installer/gem_installer_spec.rb
index 7340a3acc0..8f8d1c6d15 100644
--- a/spec/bundler/bundler/installer/gem_installer_spec.rb
+++ b/spec/bundler/bundler/installer/gem_installer_spec.rb
@@ -10,14 +10,14 @@ RSpec.describe Bundler::GemInstaller do
subject { described_class.new(spec, installer) }
context "spec_settings is nil" do
- it "invokes install method with empty build_args", :rubygems => ">= 2" do
+ it "invokes install method with empty build_args" 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
+ it "invokes install method with build_args" do
allow(Bundler.settings).to receive(:[]).with(:bin)
allow(Bundler.settings).to receive(:[]).with(:inline)
allow(Bundler.settings).to receive(:[]).with(:forget_cli_options)
@@ -26,4 +26,15 @@ RSpec.describe Bundler::GemInstaller do
subject.install_from_spec
end
end
+
+ context "spec_settings is build option with spaces" do
+ it "invokes install method with build_args" do
+ allow(Bundler.settings).to receive(:[]).with(:bin)
+ allow(Bundler.settings).to receive(:[]).with(:inline)
+ allow(Bundler.settings).to receive(:[]).with(:forget_cli_options)
+ allow(Bundler.settings).to receive(:[]).with("build.dummy").and_return("--with-dummy-config=dummy --with-another-dummy-config")
+ expect(spec_source).to receive(:install).with(spec, :force => false, :ensure_builtin_gems_cached => false, :build_args => ["--with-dummy-config=dummy", "--with-another-dummy-config"])
+ subject.install_from_spec
+ end
+ end
end
diff --git a/spec/bundler/bundler/mirror_spec.rb b/spec/bundler/bundler/mirror_spec.rb
index acd0895f2f..fb476b8465 100644
--- a/spec/bundler/bundler/mirror_spec.rb
+++ b/spec/bundler/bundler/mirror_spec.rb
@@ -298,8 +298,8 @@ RSpec.describe Bundler::Settings::TCPSocketProbe do
context "with a listening TCP Server" do
def with_server_and_mirror
- server = TCPServer.new("127.0.0.1", 0)
- mirror = Bundler::Settings::Mirror.new("http://localhost:#{server.addr[1]}", 1)
+ server = TCPServer.new("0.0.0.0", 0)
+ mirror = Bundler::Settings::Mirror.new("http://0.0.0.0:#{server.addr[1]}", 1)
yield server, mirror
server.close unless server.closed?
end
diff --git a/spec/bundler/bundler/plugin/index_spec.rb b/spec/bundler/bundler/plugin/index_spec.rb
index ca3476ea2a..e18e960fb8 100644
--- a/spec/bundler/bundler/plugin/index_spec.rb
+++ b/spec/bundler/bundler/plugin/index_spec.rb
@@ -86,6 +86,17 @@ RSpec.describe Bundler::Plugin::Index do
expect(new_index.hook_plugins("after-bar")).to eq([plugin_name])
end
+ it "only registers a gem once for an event" do
+ path = lib_path(plugin_name)
+ index.register_plugin(plugin_name,
+ path.to_s,
+ [path.join("lib").to_s],
+ commands,
+ sources,
+ hooks + hooks)
+ expect(index.hook_plugins("after-bar")).to eq([plugin_name])
+ end
+
context "that are not registered", :focused do
let(:file) { double("index-file") }
diff --git a/spec/bundler/bundler/plugin/installer_spec.rb b/spec/bundler/bundler/plugin/installer_spec.rb
index f8bf8450c9..71fef76042 100644
--- a/spec/bundler/bundler/plugin/installer_spec.rb
+++ b/spec/bundler/bundler/plugin/installer_spec.rb
@@ -3,10 +3,6 @@
RSpec.describe Bundler::Plugin::Installer do
subject(:installer) { Bundler::Plugin::Installer.new }
- before do
- # allow(Bundler::SharedHelpers).to receive(:find_gemfile).and_return(Pathname.new("/Gemfile"))
- end
-
describe "cli install" do
it "uses Gem.sources when non of the source is provided" do
sources = double(:sources)
@@ -29,6 +25,14 @@ RSpec.describe Bundler::Plugin::Installer do
to eq("new-plugin" => spec)
end
+ it "returns the installed spec after installing local git plugins" do
+ allow(installer).to receive(:install_local_git).
+ and_return("new-plugin" => spec)
+
+ expect(installer.install(["new-plugin"], :local_git => "/phony/path/repo")).
+ to eq("new-plugin" => spec)
+ end
+
it "returns the installed spec after installing rubygems plugins" do
allow(installer).to receive(:install_rubygems).
and_return("new-plugin" => spec)
@@ -69,6 +73,29 @@ RSpec.describe Bundler::Plugin::Installer do
end
end
+ context "local git plugins" do
+ before do
+ build_git "ga-plugin", :path => lib_path("ga-plugin") do |s|
+ s.write "plugins.rb"
+ end
+ end
+
+ let(:result) do
+ installer.install(["ga-plugin"], :local_git => lib_path("ga-plugin").to_s)
+ end
+
+ it "returns the installed spec after installing" do
+ spec = result["ga-plugin"]
+ expect(spec.full_name).to eq "ga-plugin-1.0"
+ end
+
+ it "has expected full gem path" do
+ rev = revision_for(lib_path("ga-plugin"))
+ expect(result["ga-plugin"].full_gem_path).
+ to eq(Bundler::Plugin.root.join("bundler", "gems", "ga-plugin-#{rev[0..11]}").to_s)
+ end
+ end
+
context "rubygems plugins" do
let(:result) do
installer.install(["re-plugin"], :source => "file://#{gem_repo2}")
diff --git a/spec/bundler/bundler/plugin_spec.rb b/spec/bundler/bundler/plugin_spec.rb
index 9266fad1eb..eaa0b80905 100644
--- a/spec/bundler/bundler/plugin_spec.rb
+++ b/spec/bundler/bundler/plugin_spec.rb
@@ -32,6 +32,29 @@ RSpec.describe Bundler::Plugin do
allow(index).to receive(:register_plugin)
end
+ describe "list command" do
+ context "when no plugins are installed" do
+ before { allow(index).to receive(:installed_plugins) { [] } }
+ it "outputs no plugins installed" do
+ expect(Bundler.ui).to receive(:info).with("No plugins installed")
+ subject.list
+ end
+ end
+
+ context "with installed plugins" do
+ before do
+ allow(index).to receive(:installed_plugins) { %w[plug1 plug2] }
+ allow(index).to receive(:plugin_commands).with("plug1") { %w[c11 c12] }
+ allow(index).to receive(:plugin_commands).with("plug2") { %w[c21 c22] }
+ end
+ it "list plugins followed by commands" do
+ expected_output = "plug1\n-----\n c11\n c12\n\nplug2\n-----\n c21\n c22\n\n"
+ expect(Bundler.ui).to receive(:info).with(expected_output)
+ subject.list
+ end
+ end
+ end
+
describe "install command" do
let(:opts) { { "version" => "~> 1.0", "source" => "foo" } }
diff --git a/spec/bundler/bundler/rubygems_integration_spec.rb b/spec/bundler/bundler/rubygems_integration_spec.rb
index b1b15d9e5d..26cbaa630b 100644
--- a/spec/bundler/bundler/rubygems_integration_spec.rb
+++ b/spec/bundler/bundler/rubygems_integration_spec.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
RSpec.describe Bundler::RubygemsIntegration do
- it "uses the same chdir lock as rubygems", :rubygems => "2.1" do
+ it "uses the same chdir lock as rubygems" do
expect(Bundler.rubygems.ext_lock).to eq(Gem::Ext::Builder::CHDIR_MONITOR)
end
@@ -15,30 +15,18 @@ RSpec.describe Bundler::RubygemsIntegration do
end
subject { Bundler.rubygems.validate(spec) }
- it "skips overly-strict gemspec validation", :rubygems => "< 1.7" do
- expect(spec).to_not receive(:validate)
- subject
- end
-
- it "validates with packaging mode disabled", :rubygems => "1.7" do
+ it "validates with packaging mode disabled" do
expect(spec).to receive(:validate).with(false)
subject
end
- it "should set a summary to avoid an overly-strict error", :rubygems => "~> 1.7.0" do
- spec.summary = nil
- expect { subject }.not_to raise_error
- expect(spec.summary).to eq("")
- end
-
context "with an invalid spec" do
before do
expect(spec).to receive(:validate).with(false).
and_raise(Gem::InvalidSpecificationException.new("TODO is not an author"))
end
- it "should raise a Gem::InvalidSpecificationException and produce a helpful warning message",
- :rubygems => "1.7" do
+ it "should raise a Gem::InvalidSpecificationException and produce a helpful warning message" do
expect { subject }.to raise_error(Gem::InvalidSpecificationException,
"The gemspec at #{__FILE__} is not valid. "\
"Please fix this gemspec.\nThe validation error was 'TODO is not an author'\n")
@@ -53,7 +41,7 @@ RSpec.describe Bundler::RubygemsIntegration do
end
end
- describe "#download_gem", :rubygems => ">= 2.0" do
+ describe "#download_gem" do
let(:bundler_retry) { double(Bundler::Retry) }
let(:retry) { double("Bundler::Retry") }
let(:uri) { URI.parse("https://foo.bar") }
@@ -78,7 +66,7 @@ RSpec.describe Bundler::RubygemsIntegration do
end
end
- describe "#fetch_all_remote_specs", :rubygems => ">= 2.0" do
+ describe "#fetch_all_remote_specs" do
let(:uri) { URI("https://example.com") }
let(:fetcher) { double("gem_remote_fetcher") }
let(:specs_response) { Marshal.dump(["specs"]) }
diff --git a/spec/bundler/bundler/settings_spec.rb b/spec/bundler/bundler/settings_spec.rb
index 1a31493e20..339428eb48 100644
--- a/spec/bundler/bundler/settings_spec.rb
+++ b/spec/bundler/bundler/settings_spec.rb
@@ -130,13 +130,15 @@ that would suck --ehhh=oh geez it looks like i might have broken bundler somehow
describe "#temporary" do
it "reset after used" do
- Bundler.settings.set_local :no_install, true
+ Bundler.settings.set_command_option :no_install, true
Bundler.settings.temporary(:no_install => false) do
expect(Bundler.settings[:no_install]).to eq false
end
expect(Bundler.settings[:no_install]).to eq true
+
+ Bundler.settings.set_command_option :no_install, nil
end
it "returns the return value of the block" do
diff --git a/spec/bundler/bundler/shared_helpers_spec.rb b/spec/bundler/bundler/shared_helpers_spec.rb
index fcac37b398..f42d9ed485 100644
--- a/spec/bundler/bundler/shared_helpers_spec.rb
+++ b/spec/bundler/bundler/shared_helpers_spec.rb
@@ -14,7 +14,7 @@ RSpec.describe Bundler::SharedHelpers do
before { ENV["BUNDLE_GEMFILE"] = "/path/Gemfile" }
context "Gemfile is present" do
- let(:expected_gemfile_path) { Pathname.new("/path/Gemfile") }
+ let(:expected_gemfile_path) { Pathname.new("/path/Gemfile").expand_path }
it "returns the Gemfile path" do
expect(subject.default_gemfile).to eq(expected_gemfile_path)
@@ -288,7 +288,7 @@ RSpec.describe Bundler::SharedHelpers do
)
end
- context "with a jruby path_separator regex", :ruby => "1.9" do
+ context "with a jruby path_separator regex" do
# In versions of jruby that supported ruby 1.8, the path separator was the standard File::PATH_SEPARATOR
let(:regex) { Regexp.new("(?<!jar:file|jar|file|classpath|uri:classloader|uri|http|https):") }
it "does not exit if bundle path is the standard uri path" do
@@ -389,7 +389,7 @@ RSpec.describe Bundler::SharedHelpers do
context "bundle executable in ENV['BUNDLE_BIN_PATH'] does not exist" do
before { ENV["BUNDLE_BIN_PATH"] = "/does/not/exist" }
- before { Bundler.rubygems.replace_bin_path [], [] }
+ before { Bundler.rubygems.replace_bin_path [] }
it "sets BUNDLE_BIN_PATH to the bundle executable file" do
subject.set_bundle_environment
@@ -455,7 +455,7 @@ RSpec.describe Bundler::SharedHelpers do
end
end
- context "system throws Errno::ENOTSUP", :ruby => "1.9" do
+ context "system throws Errno::ENOTSUP" do
let(:file_op_block) { proc {|_path| raise Errno::ENOTSUP } }
it "raises a OperationNotSupportedError" do
diff --git a/spec/bundler/bundler/source/git/git_proxy_spec.rb b/spec/bundler/bundler/source/git/git_proxy_spec.rb
index 3a29c97461..016105ccde 100644
--- a/spec/bundler/bundler/source/git/git_proxy_spec.rb
+++ b/spec/bundler/bundler/source/git/git_proxy_spec.rb
@@ -10,29 +10,33 @@ RSpec.describe Bundler::Source::Git::GitProxy do
context "with configured credentials" do
it "adds username and password to URI" do
- Bundler.settings.temporary(uri => "u:p")
- expect(subject).to receive(:git_retry).with(match("https://u:p@github.com/bundler/bundler.git"))
- subject.checkout
+ Bundler.settings.temporary(uri => "u:p") do
+ expect(subject).to receive(:git_retry).with(match("https://u:p@github.com/bundler/bundler.git"))
+ subject.checkout
+ end
end
it "adds username and password to URI for host" do
- Bundler.settings.temporary("github.com" => "u:p")
- expect(subject).to receive(:git_retry).with(match("https://u:p@github.com/bundler/bundler.git"))
- subject.checkout
+ Bundler.settings.temporary("github.com" => "u:p") do
+ expect(subject).to receive(:git_retry).with(match("https://u:p@github.com/bundler/bundler.git"))
+ subject.checkout
+ end
end
it "does not add username and password to mismatched URI" do
- Bundler.settings.temporary("https://u:p@github.com/bundler/bundler-mismatch.git" => "u:p")
- expect(subject).to receive(:git_retry).with(match(uri))
- subject.checkout
+ Bundler.settings.temporary("https://u:p@github.com/bundler/bundler-mismatch.git" => "u:p") do
+ expect(subject).to receive(:git_retry).with(match(uri))
+ subject.checkout
+ end
end
it "keeps original userinfo" do
- Bundler.settings.temporary("github.com" => "u:p")
- original = "https://orig:info@github.com/bundler/bundler.git"
- subject = described_class.new(Pathname("path"), original, "HEAD")
- expect(subject).to receive(:git_retry).with(match(original))
- subject.checkout
+ Bundler.settings.temporary("github.com" => "u:p") do
+ original = "https://orig:info@github.com/bundler/bundler.git"
+ subject = described_class.new(Pathname("path"), original, "HEAD")
+ expect(subject).to receive(:git_retry).with(match(original))
+ subject.checkout
+ end
end
end
diff --git a/spec/bundler/bundler/source/rubygems/remote_spec.rb b/spec/bundler/bundler/source/rubygems/remote_spec.rb
index 9a7ab42128..52fb4e7f1c 100644
--- a/spec/bundler/bundler/source/rubygems/remote_spec.rb
+++ b/spec/bundler/bundler/source/rubygems/remote_spec.rb
@@ -22,8 +22,9 @@ RSpec.describe Bundler::Source::Rubygems::Remote do
end
it "applies configured credentials" do
- Bundler.settings.temporary(uri_no_auth.to_s => credentials)
- expect(remote(uri_no_auth).uri).to eq(uri_with_auth)
+ Bundler.settings.temporary(uri_no_auth.to_s => credentials) do
+ expect(remote(uri_no_auth).uri).to eq(uri_with_auth)
+ end
end
end
@@ -33,8 +34,9 @@ RSpec.describe Bundler::Source::Rubygems::Remote do
end
it "does not apply given credentials" do
- Bundler.settings.temporary(uri_no_auth.to_s => credentials)
- expect(remote(uri_no_auth).anonymized_uri).to eq(uri_no_auth)
+ Bundler.settings.temporary(uri_no_auth.to_s => credentials) do
+ expect(remote(uri_no_auth).anonymized_uri).to eq(uri_no_auth)
+ end
end
end
@@ -44,8 +46,9 @@ RSpec.describe Bundler::Source::Rubygems::Remote do
end
it "only applies the given user" do
- Bundler.settings.temporary(uri_no_auth.to_s => credentials)
- expect(remote(uri_no_auth).cache_slug).to eq("gems.example.com.username.443.MD5HEX(gems.example.com.username.443./)")
+ Bundler.settings.temporary(uri_no_auth.to_s => credentials) do
+ expect(remote(uri_no_auth).cache_slug).to eq("gems.example.com.username.443.MD5HEX(gems.example.com.username.443./)")
+ end
end
end
end
@@ -106,7 +109,9 @@ RSpec.describe Bundler::Source::Rubygems::Remote do
let(:mirror_uri_with_auth) { URI("https://username:password@rubygems-mirror.org/") }
let(:mirror_uri_no_auth) { URI("https://rubygems-mirror.org/") }
- before { Bundler.settings.set_local("mirror.https://rubygems.org/", mirror_uri_with_auth.to_s) }
+ before { Bundler.settings.temporary("mirror.https://rubygems.org/" => mirror_uri_with_auth.to_s) }
+
+ after { Bundler.settings.temporary("mirror.https://rubygems.org/" => nil) }
specify "#uri returns the mirror URI with credentials" do
expect(remote(uri).uri).to eq(mirror_uri_with_auth)
@@ -135,6 +140,11 @@ RSpec.describe Bundler::Source::Rubygems::Remote do
Bundler.settings.temporary(mirror_uri_no_auth.to_s => credentials)
end
+ after do
+ Bundler.settings.temporary("mirror.https://rubygems.org/" => nil)
+ Bundler.settings.temporary(mirror_uri_no_auth.to_s => nil)
+ end
+
specify "#uri returns the mirror URI with credentials" do
expect(remote(uri).uri).to eq(mirror_uri_with_auth)
end
diff --git a/spec/bundler/bundler/source_list_spec.rb b/spec/bundler/bundler/source_list_spec.rb
index 541a46c6d0..a78b80ec3b 100644
--- a/spec/bundler/bundler/source_list_spec.rb
+++ b/spec/bundler/bundler/source_list_spec.rb
@@ -75,7 +75,7 @@ RSpec.describe Bundler::SourceList do
let(:msg) do
"The git source `git://existing-git.org/path.git` " \
"uses the `git` protocol, which transmits data without encryption. " \
- "Disable this warning with `bundle config git.allow_insecure true`, " \
+ "Disable this warning with `bundle config set git.allow_insecure true`, " \
"or switch to the `https` protocol to keep your data secure."
end
@@ -393,19 +393,19 @@ RSpec.describe Bundler::SourceList do
it "returns all sources, without combining rubygems sources", :bundler => "3" do
expect(source_list.lock_sources).to eq [
- Bundler::Source::Rubygems.new,
- Bundler::Source::Rubygems.new("remotes" => ["https://duplicate-rubygems.org"]),
- Bundler::Source::Rubygems.new("remotes" => ["https://first-rubygems.org"]),
- Bundler::Source::Rubygems.new("remotes" => ["https://second-rubygems.org"]),
- Bundler::Source::Rubygems.new("remotes" => ["https://third-rubygems.org"]),
Bundler::Source::Git.new("uri" => "git://first-git.org/path.git"),
Bundler::Source::Git.new("uri" => "git://second-git.org/path.git"),
Bundler::Source::Git.new("uri" => "git://third-git.org/path.git"),
+ ASourcePlugin.new("uri" => "https://second-plugin.org/random"),
+ ASourcePlugin.new("uri" => "https://third-bar.org/foo"),
Bundler::Source::Path.new("path" => "/first/path/to/gem"),
Bundler::Source::Path.new("path" => "/second/path/to/gem"),
Bundler::Source::Path.new("path" => "/third/path/to/gem"),
- ASourcePlugin.new("uri" => "https://second-plugin.org/random"),
- ASourcePlugin.new("uri" => "https://third-bar.org/foo"),
+ Bundler::Source::Rubygems.new,
+ Bundler::Source::Rubygems.new("remotes" => ["https://duplicate-rubygems.org"]),
+ Bundler::Source::Rubygems.new("remotes" => ["https://first-rubygems.org"]),
+ Bundler::Source::Rubygems.new("remotes" => ["https://second-rubygems.org"]),
+ Bundler::Source::Rubygems.new("remotes" => ["https://third-rubygems.org"]),
]
end
end
diff --git a/spec/bundler/bundler/ssl_certs/certificate_manager_spec.rb b/spec/bundler/bundler/ssl_certs/certificate_manager_spec.rb
deleted file mode 100644
index 56606a830f..0000000000
--- a/spec/bundler/bundler/ssl_certs/certificate_manager_spec.rb
+++ /dev/null
@@ -1,140 +0,0 @@
-# frozen_string_literal: true
-
-require "bundler/ssl_certs/certificate_manager"
-
-RSpec.describe Bundler::SSLCerts::CertificateManager do
- let(:rubygems_path) { root }
- let(:stub_cert) { File.join(root.to_s, "lib", "rubygems", "ssl_certs", "rubygems.org", "ssl-cert.pem") }
- let(:rubygems_certs_dir) { File.join(root.to_s, "lib", "rubygems", "ssl_certs", "rubygems.org") }
-
- subject { described_class.new(rubygems_path) }
-
- # Pretend bundler root is rubygems root
- before do
- # Backing up rubygems ceriticates
- FileUtils.mv(rubygems_certs_dir, rubygems_certs_dir + ".back") if ruby_core?
-
- FileUtils.mkdir_p(rubygems_certs_dir)
- FileUtils.touch(stub_cert)
- end
-
- after do
- FileUtils.rm_rf(rubygems_certs_dir)
-
- # Restore rubygems certificates
- FileUtils.mv(rubygems_certs_dir + ".back", rubygems_certs_dir) if ruby_core?
- end
-
- describe "#update_from" do
- let(:cert_manager) { double(:cert_manager) }
-
- before { allow(described_class).to receive(:new).with(rubygems_path).and_return(cert_manager) }
-
- it "should update the certs through a new certificate manager" do
- allow(cert_manager).to receive(:update!)
- expect(described_class.update_from!(rubygems_path)).to be_nil
- end
- end
-
- describe "#initialize" do
- it "should set bundler_cert_path as path of the subdir with bundler ssl certs" do
- expect(subject.bundler_cert_path).to eq(File.join(root, "lib/bundler/ssl_certs"))
- end
-
- it "should set bundler_certs as the paths of the bundler ssl certs" do
- expect(subject.bundler_certs).to include(File.join(root, "lib/bundler/ssl_certs/rubygems.global.ssl.fastly.net/DigiCertHighAssuranceEVRootCA.pem"))
- expect(subject.bundler_certs).to include(File.join(root, "lib/bundler/ssl_certs/index.rubygems.org/GlobalSignRootCA.pem"))
- end
-
- context "when rubygems_path is not nil" do
- it "should set rubygems_certs" do
- expect(subject.rubygems_certs).to include(File.join(root, "lib", "rubygems", "ssl_certs", "rubygems.org", "ssl-cert.pem"))
- end
- end
- end
-
- describe "#up_to_date?" do
- context "when bundler certs and rubygems certs are the same" do
- before do
- bundler_certs = Dir[File.join(root.to_s, "lib", "bundler", "ssl_certs", "**", "*.pem")]
- FileUtils.rm(stub_cert)
- FileUtils.cp(bundler_certs, rubygems_certs_dir)
- end
-
- it "should return true" do
- expect(subject).to be_up_to_date
- end
- end
-
- context "when bundler certs and rubygems certs are not the same" do
- it "should return false" do
- expect(subject).to_not be_up_to_date
- end
- end
- end
-
- describe "#update!" do
- context "when certificate manager is not up to date" do
- before do
- allow(subject).to receive(:up_to_date?).and_return(false)
- allow(bundler_fileutils).to receive(:rm)
- allow(bundler_fileutils).to receive(:cp)
- end
-
- it "should remove the current bundler certs" do
- expect(bundler_fileutils).to receive(:rm).with(subject.bundler_certs)
- subject.update!
- end
-
- it "should copy the rubygems certs into bundler certs" do
- expect(bundler_fileutils).to receive(:cp).with(subject.rubygems_certs, subject.bundler_cert_path)
- subject.update!
- end
-
- it "should return nil" do
- expect(subject.update!).to be_nil
- end
- end
-
- context "when certificate manager is up to date" do
- before { allow(subject).to receive(:up_to_date?).and_return(true) }
-
- it "should return nil" do
- expect(subject.update!).to be_nil
- end
- end
- end
-
- describe "#connect_to" do
- let(:host) { "http://www.host.com" }
- let(:http) { Net::HTTP.new(host, 443) }
- let(:cert_store) { OpenSSL::X509::Store.new }
- let(:http_header_response) { double(:http_header_response) }
-
- before do
- allow(Net::HTTP).to receive(:new).with(host, 443).and_return(http)
- allow(OpenSSL::X509::Store).to receive(:new).and_return(cert_store)
- allow(http).to receive(:head).with("/").and_return(http_header_response)
- end
-
- it "should use ssl for the http request" do
- expect(http).to receive(:use_ssl=).with(true)
- subject.connect_to(host)
- end
-
- it "use verify peer mode" do
- expect(http).to receive(:verify_mode=).with(OpenSSL::SSL::VERIFY_PEER)
- subject.connect_to(host)
- end
-
- it "set its cert store as a OpenSSL::X509::Store populated with bundler certs" do
- expect(cert_store).to receive(:add_file).at_least(:once)
- expect(http).to receive(:cert_store=).with(cert_store)
- subject.connect_to(host)
- end
-
- it "return the headers of the request response" do
- expect(subject.connect_to(host)).to eq(http_header_response)
- end
- end
-end
diff --git a/spec/bundler/bundler/stub_specification_spec.rb b/spec/bundler/bundler/stub_specification_spec.rb
index 5521d83769..7495b5d661 100644
--- a/spec/bundler/bundler/stub_specification_spec.rb
+++ b/spec/bundler/bundler/stub_specification_spec.rb
@@ -13,12 +13,10 @@ RSpec.describe Bundler::StubSpecification do
described_class.from_stub(gemspec)
end
- if Bundler.rubygems.provides?(">= 2.1")
- describe "#from_stub" do
- it "returns the same stub if already a Bundler::StubSpecification" do
- stub = described_class.from_stub(with_bundler_stub_spec)
- expect(stub).to be(with_bundler_stub_spec)
- end
+ describe "#from_stub" do
+ it "returns the same stub if already a Bundler::StubSpecification" do
+ stub = described_class.from_stub(with_bundler_stub_spec)
+ expect(stub).to be(with_bundler_stub_spec)
end
end
end
diff --git a/spec/bundler/bundler/ui/shell_spec.rb b/spec/bundler/bundler/ui/shell_spec.rb
index 951a446aff..23a7670dd1 100644
--- a/spec/bundler/bundler/ui/shell_spec.rb
+++ b/spec/bundler/bundler/ui/shell_spec.rb
@@ -21,11 +21,7 @@ RSpec.describe Bundler::UI::Shell do
describe "#warn" do
before { subject.level = "warn" }
- it "prints to stdout", :bundler => "< 2" do
- expect { subject.warn("warning") }.to output("warning\n").to_stdout
- end
-
- it "prints to stderr", :bundler => "2" do
+ it "prints to stderr" do
expect { subject.warn("warning") }.to output("warning\n").to_stderr
end
@@ -46,11 +42,7 @@ RSpec.describe Bundler::UI::Shell do
describe "#error" do
before { subject.level = "error" }
- it "prints to stdout", :bundler => "< 2" do
- expect { subject.error("error!!!") }.to output("error!!!\n").to_stdout
- end
-
- it "prints to stderr", :bundler => "2" do
+ it "prints to stderr" do
expect { subject.error("error!!!") }.to output("error!!!\n").to_stderr
end
diff --git a/spec/bundler/bundler/ui_spec.rb b/spec/bundler/bundler/ui_spec.rb
index 6ef8729277..6df0d2e290 100644
--- a/spec/bundler/bundler/ui_spec.rb
+++ b/spec/bundler/bundler/ui_spec.rb
@@ -2,7 +2,7 @@
RSpec.describe Bundler::UI do
describe Bundler::UI::Silent do
- it "has the same instance methods as Shell", :ruby => ">= 1.9" do
+ it "has the same instance methods as Shell" do
shell = Bundler::UI::Shell
methods = proc do |cls|
cls.instance_methods.map do |i|
@@ -13,7 +13,7 @@ RSpec.describe Bundler::UI do
expect(methods.call(described_class)).to eq(methods.call(shell))
end
- it "has the same instance class as Shell", :ruby => ">= 1.9" do
+ it "has the same instance class as Shell" do
shell = Bundler::UI::Shell
methods = proc do |cls|
cls.methods.map do |i|
diff --git a/spec/bundler/bundler/vendored_persistent_spec.rb b/spec/bundler/bundler/vendored_persistent_spec.rb
index 338431c4a6..c760c067e0 100644
--- a/spec/bundler/bundler/vendored_persistent_spec.rb
+++ b/spec/bundler/bundler/vendored_persistent_spec.rb
@@ -1,6 +1,5 @@
# frozen_string_literal: true
-require "spec_helper"
require "bundler/vendored_persistent"
RSpec.describe Bundler::PersistentHTTP do
@@ -13,7 +12,7 @@ RSpec.describe Bundler::PersistentHTTP do
before do
allow(connection).to receive(:use_ssl?).and_return(!tls_version.nil?)
- allow(socket).to receive(:io).and_return(socket_io)
+ allow(socket).to receive(:io).and_return(socket_io) if socket
connection.instance_variable_set(:@socket, socket)
if tls_version
diff --git a/spec/bundler/bundler/version_ranges_spec.rb b/spec/bundler/bundler/version_ranges_spec.rb
index ccbb9285d5..bca044b0c0 100644
--- a/spec/bundler/bundler/version_ranges_spec.rb
+++ b/spec/bundler/bundler/version_ranges_spec.rb
@@ -25,9 +25,12 @@ RSpec.describe Bundler::VersionRanges do
include_examples "empty?", false, ">= 1.0.0", "< 2.0.0"
include_examples "empty?", false, "~> 1"
include_examples "empty?", false, "~> 2.0", "~> 2.1"
+ include_examples "empty?", true, ">= 4.1.0", "< 5.0", "= 5.2.1"
+ include_examples "empty?", true, "< 5.0", "< 5.3", "< 6.0", "< 6", "= 5.2.0", "> 2", ">= 3.0", ">= 3.1", ">= 3.2", ">= 4.0.0", ">= 4.1.0", ">= 4.2.0", ">= 4.2", ">= 4"
include_examples "empty?", true, "!= 1", "< 2", "> 2"
include_examples "empty?", true, "!= 1", "<= 1", ">= 1"
include_examples "empty?", true, "< 2", "> 2"
+ include_examples "empty?", true, "< 2", "> 2", "= 2"
include_examples "empty?", true, "= 1", "!= 1"
include_examples "empty?", true, "= 1", "= 2"
include_examples "empty?", true, "= 1", "~> 2"
diff --git a/spec/bundler/cache/cache_path_spec.rb b/spec/bundler/cache/cache_path_spec.rb
index 69d3809964..a4572af11e 100644
--- a/spec/bundler/cache/cache_path_spec.rb
+++ b/spec/bundler/cache/cache_path_spec.rb
@@ -17,7 +17,7 @@ RSpec.describe "bundle package" do
context "with config cache_path" do
it "caches gems at given path" do
- bundle "config cache_path vendor/cache-foo"
+ bundle "config set cache_path vendor/cache-foo"
bundle :package
expect(bundled_app("vendor/cache-foo/rack-1.0.0.gem")).to exist
end
diff --git a/spec/bundler/cache/gems_spec.rb b/spec/bundler/cache/gems_spec.rb
index 4a0b953830..4fc43a50a0 100644
--- a/spec/bundler/cache/gems_spec.rb
+++ b/spec/bundler/cache/gems_spec.rb
@@ -74,16 +74,16 @@ RSpec.describe "bundle cache" do
end
context "using system gems" do
- before { bundle! "config path.system true" }
+ before { bundle! "config set path.system true" }
it_behaves_like "when there are only gemsources"
end
context "installing into a local path" do
- before { bundle! "config path ./.bundle" }
+ before { bundle! "config set path ./.bundle" }
it_behaves_like "when there are only gemsources"
end
- describe "when there is a built-in gem", :ruby => "2.0" do
+ describe "when there is a built-in gem" do
before :each do
build_repo2 do
build_gem "builtin_gem", "1.0.2"
@@ -97,7 +97,7 @@ RSpec.describe "bundle cache" do
end
it "uses builtin gems when installing to system gems" do
- bundle! "config path.system true"
+ bundle! "config set path.system true"
install_gemfile %(gem 'builtin_gem', '1.0.2')
expect(the_bundle).to include_gems("builtin_gem 1.0.2")
end
@@ -129,7 +129,7 @@ RSpec.describe "bundle cache" do
end
it "errors if the builtin gem isn't available to cache" do
- bundle! "config path.system true"
+ bundle! "config set path.system true"
install_gemfile <<-G
gem 'builtin_gem', '1.0.2'
@@ -137,7 +137,7 @@ RSpec.describe "bundle cache" do
bundle :cache
expect(exitstatus).to_not eq(0) if exitstatus
- expect(out).to include("builtin_gem-1.0.2 is built in to Ruby, and can't be cached")
+ expect(err).to include("builtin_gem-1.0.2 is built in to Ruby, and can't be cached")
end
end
@@ -196,7 +196,7 @@ RSpec.describe "bundle cache" do
it "adds and removes when gems are updated" do
update_repo2
- bundle "update", :all => bundle_update_requires_all?
+ bundle "update", :all => true
expect(cached_gem("rack-1.2")).to exist
expect(cached_gem("rack-1.0.0")).not_to exist
end
diff --git a/spec/bundler/cache/git_spec.rb b/spec/bundler/cache/git_spec.rb
index 33387dbbb2..55a24ff118 100644
--- a/spec/bundler/cache/git_spec.rb
+++ b/spec/bundler/cache/git_spec.rb
@@ -81,7 +81,7 @@ end
ref = git.ref_for("master", 11)
expect(ref).not_to eq(old_ref)
- bundle! "update", :all => bundle_update_requires_all?
+ bundle! "update", :all => true
bundle! "#{cmd}", forgotten_command_line_options([:all, :cache_all] => true)
expect(bundled_app("vendor/cache/foo-1.0-#{ref}")).to exist
@@ -127,7 +127,7 @@ end
gem "foo", :git => '#{lib_path("foo-invalid")}', :branch => :master
G
- bundle %(config local.foo #{lib_path("foo-1.0")})
+ bundle %(config set local.foo #{lib_path("foo-1.0")})
bundle "install"
bundle "#{cmd}", forgotten_command_line_options([:all, :cache_all] => true)
@@ -168,7 +168,7 @@ end
expect(the_bundle).to include_gems "has_submodule 1.0"
end
- it "displays warning message when detecting git repo in Gemfile", :bundler => "< 2" do
+ it "displays warning message when detecting git repo in Gemfile", :bundler => "< 3" do
build_git "foo"
install_gemfile <<-G
@@ -177,7 +177,7 @@ end
bundle "#{cmd}"
- expect(out).to include("Your Gemfile contains path and git dependencies.")
+ expect(err).to include("Your Gemfile contains path and git dependencies.")
end
it "does not display warning message if cache_all is set in bundle config" do
@@ -190,7 +190,7 @@ end
bundle cmd, forgotten_command_line_options([:all, :cache_all] => true)
bundle cmd
- expect(out).not_to include("Your Gemfile contains path and git dependencies.")
+ expect(err).not_to include("Your Gemfile contains path and git dependencies.")
end
it "caches pre-evaluated gemspecs" do
diff --git a/spec/bundler/cache/path_spec.rb b/spec/bundler/cache/path_spec.rb
index 12be2dbcf8..0d7b154a37 100644
--- a/spec/bundler/cache/path_spec.rb
+++ b/spec/bundler/cache/path_spec.rb
@@ -94,7 +94,7 @@
G
bundle cmd
- expect(out).to match(/please pass the \-\-all flag/)
+ expect(err).to match(/please pass the \-\-all flag/)
expect(bundled_app("vendor/cache/foo-1.0")).not_to exist
end
diff --git a/spec/bundler/cache/platform_spec.rb b/spec/bundler/cache/platform_spec.rb
index c0622a3c94..b3c4643ef5 100644
--- a/spec/bundler/cache/platform_spec.rb
+++ b/spec/bundler/cache/platform_spec.rb
@@ -41,7 +41,7 @@ RSpec.describe "bundle cache with multiple platforms" do
end
it "ensures that a successful bundle update does not delete gems for other platforms" do
- bundle! "update", :all => bundle_update_requires_all?
+ bundle! "update", :all => true
expect(bundled_app("vendor/cache/rack-1.0.0.gem")).to exist
expect(bundled_app("vendor/cache/activesupport-2.3.5.gem")).to exist
diff --git a/spec/bundler/commands/add_spec.rb b/spec/bundler/commands/add_spec.rb
index 9f11adbcf8..dac1d0f6b9 100644
--- a/spec/bundler/commands/add_spec.rb
+++ b/spec/bundler/commands/add_spec.rb
@@ -106,23 +106,23 @@ RSpec.describe "bundle add" do
it "shows error message when version is not formatted correctly" do
bundle "add 'foo' -v='~>1 . 0'"
- expect(out).to match("Invalid gem requirement pattern '~>1 . 0'")
+ expect(err).to match("Invalid gem requirement pattern '~>1 . 0'")
end
it "shows error message when gem cannot be found" do
bundle "add 'werk_it'"
- expect(out).to match("Could not find gem 'werk_it' in")
+ expect(err).to match("Could not find gem 'werk_it' in")
bundle "add 'werk_it' -s='file://#{gem_repo2}'"
- expect(out).to match("Could not find gem 'werk_it' in rubygems repository")
+ expect(err).to match("Could not find gem 'werk_it' in rubygems repository")
end
it "shows error message when source cannot be reached" do
bundle "add 'baz' --source='http://badhostasdf'"
- expect(out).to include("Could not reach host badhostasdf. Check your network connection and try again.")
+ expect(err).to include("Could not reach host badhostasdf. Check your network connection and try again.")
bundle "add 'baz' --source='file://does/not/exist'"
- expect(out).to include("Could not fetch specs from file://does/not/exist/")
+ expect(err).to include("Could not fetch specs from file://does/not/exist/")
end
describe "with --optimistic" do
@@ -153,7 +153,7 @@ RSpec.describe "bundle add" do
it "throws error" do
bundle "add 'foo' --strict --optimistic"
- expect(out).to include("You can not specify `--strict` and `--optimistic` at the same time")
+ expect(err).to include("You can not specify `--strict` and `--optimistic` at the same time")
end
end
@@ -168,8 +168,8 @@ RSpec.describe "bundle add" do
it "throws error if any of the specified gems are present in the gemfile with different version" do
bundle "add weakling bar"
- expect(out).to include("You cannot specify the same gem twice with different version requirements")
- expect(out).to include("You specified: weakling (~> 0.0.1) and weakling (>= 0).")
+ expect(err).to include("You cannot specify the same gem twice with different version requirements")
+ expect(err).to include("You specified: weakling (~> 0.0.1) and weakling (>= 0).")
end
end
@@ -182,8 +182,8 @@ RSpec.describe "bundle add" do
bundle "add 'rack' --version=1.1"
- expect(out).to include("You cannot specify the same gem twice with different version requirements")
- expect(out).to include("If you want to update the gem version, run `bundle update rack`. You may also need to change the version requirement specified in the Gemfile if it's too restrictive")
+ expect(err).to include("You cannot specify the same gem twice with different version requirements")
+ expect(err).to include("If you want to update the gem version, run `bundle update rack`. You may also need to change the version requirement specified in the Gemfile if it's too restrictive")
end
it "shows error when added without version requirements" do
@@ -194,9 +194,9 @@ RSpec.describe "bundle add" do
bundle "add 'rack'"
- expect(out).to include("Gem already added.")
- expect(out).to include("You cannot specify the same gem twice with different version requirements")
- expect(out).not_to include("If you want to update the gem version, run `bundle update rack`. You may also need to change the version requirement specified in the Gemfile if it's too restrictive")
+ expect(err).to include("Gem already added.")
+ expect(err).to include("You cannot specify the same gem twice with different version requirements")
+ expect(err).not_to include("If you want to update the gem version, run `bundle update rack`. You may also need to change the version requirement specified in the Gemfile if it's too restrictive")
end
end
@@ -209,9 +209,9 @@ RSpec.describe "bundle add" do
bundle "add 'rack' --version=1.1"
- expect(out).to include("You cannot specify the same gem twice with different version requirements")
- expect(out).to include("If you want to update the gem version, run `bundle update rack`.")
- expect(out).not_to include("You may also need to change the version requirement specified in the Gemfile if it's too restrictive")
+ expect(err).to include("You cannot specify the same gem twice with different version requirements")
+ expect(err).to include("If you want to update the gem version, run `bundle update rack`.")
+ expect(err).not_to include("You may also need to change the version requirement specified in the Gemfile if it's too restrictive")
end
end
end
diff --git a/spec/bundler/commands/binstubs_spec.rb b/spec/bundler/commands/binstubs_spec.rb
index 7f2e81c099..3f62f17b45 100644
--- a/spec/bundler/commands/binstubs_spec.rb
+++ b/spec/bundler/commands/binstubs_spec.rb
@@ -59,7 +59,7 @@ RSpec.describe "bundle binstubs <gem>" do
bundle "binstubs"
expect(exitstatus).to eq(1) if exitstatus
- expect(out).to include("`bundle binstubs` needs at least one gem to run.")
+ expect(err).to include("`bundle binstubs` needs at least one gem to run.")
end
it "displays an error when used with --all and gems" do
@@ -124,54 +124,16 @@ RSpec.describe "bundle binstubs <gem>" do
bundle! "binstubs bundler rack prints_loaded_gems"
end
- # When environment has a same version of bundler as default gems.
- # `system_gems "bundler-x.y.z"` will detect system binstub.
- # We need to avoid it by virtual version of bundler.
- let(:system_bundler_version) { Gem::Version.new(Bundler::VERSION).bump.to_s }
+ let(:system_bundler_version) { Bundler::VERSION }
- context "when system bundler was used" do
- # Support master branch of bundler
- if ENV["BUNDLER_SPEC_SUB_VERSION"]
- let(:system_bundler_version) { Bundler::VERSION }
- end
-
- before do
- gemfile <<-G
- source "file:///Users/colby/Projects/bundler/tmp/gems/remote2"
- gem "rack"
- gem "prints_loaded_gems"
- G
-
- lockfile <<-G
- GEM
- remote: file:///Users/colby/Projects/bundler/tmp/gems/remote2/
- specs:
- prints_loaded_gems (1.0)
- rack (1.2)
-
- PLATFORMS
- ruby
-
- DEPENDENCIES
- prints_loaded_gems
- rack
-
- BUNDLED WITH
- #{system_bundler_version}
- G
- end
-
- it "runs bundler" do
- sys_exec! "#{bundled_app("bin/bundle")} install"
- expect(out).to eq %(system bundler #{system_bundler_version}\n["install"])
- end
+ it "runs bundler" do
+ sys_exec! "#{bundled_app("bin/bundle")} install"
+ expect(out).to eq %(system bundler #{system_bundler_version}\n["install"])
end
context "when BUNDLER_VERSION is set" do
- let(:system_bundler_version) { Bundler::VERSION }
-
it "runs the correct version of bundler" do
- sys_exec "BUNDLER_VERSION='999.999.999' #{bundled_app("bin/bundle")} install"
+ sys_exec "#{bundled_app("bin/bundle")} install", "BUNDLER_VERSION" => "999.999.999"
expect(exitstatus).to eq(42) if exitstatus
expect(last_command.stderr).to include("Activating bundler (999.999.999) failed:").
and include("To install the version of bundler this project requires, run `gem install bundler -v '999.999.999'`")
@@ -179,8 +141,6 @@ RSpec.describe "bundle binstubs <gem>" do
end
context "when a lockfile exists with a locked bundler version" do
- let(:system_bundler_version) { Bundler::VERSION }
-
it "runs the correct version of bundler when the version is newer" do
lockfile lockfile.gsub(system_bundler_version, "999.999.999")
sys_exec "#{bundled_app("bin/bundle")} install"
@@ -236,13 +196,7 @@ RSpec.describe "bundle binstubs <gem>" do
let(:system_bundler_version) { :bundler }
it "loads all gems" do
sys_exec! bundled_app("bin/print_loaded_gems").to_s
- # RG < 2.0.14 didn't have a `Gem::Specification#default_gem?`
- # This is dirty detection for old RG versions.
- if File.dirname(Bundler.load.specs["bundler"][0].loaded_from) =~ %r{specifications/default}
- expect(out).to eq %(["prints_loaded_gems-1.0", "rack-1.2"])
- else
- expect(out).to eq %(["bundler-#{Bundler::VERSION}", "prints_loaded_gems-1.0", "rack-1.2"])
- end
+ expect(out).to eq %(["bundler-#{Bundler::VERSION}", "prints_loaded_gems-1.0", "rack-1.2"])
end
context "when requesting a different bundler version" do
@@ -324,7 +278,7 @@ RSpec.describe "bundle binstubs <gem>" do
bundle "binstubs doesnt_exist"
expect(exitstatus).to eq(7) if exitstatus
- expect(out).to include("Could not find gem 'doesnt_exist'.")
+ expect(err).to include("Could not find gem 'doesnt_exist'.")
end
end
@@ -396,8 +350,8 @@ RSpec.describe "bundle binstubs <gem>" do
expect(bundled_app("bin/rackup")).to exist
expect(File.read(bundled_app("bin/rackup"))).to eq("OMG")
- expect(out).to include("Skipped rackup")
- expect(out).to include("overwrite skipped stubs, use --force")
+ expect(err).to include("Skipped rackup")
+ expect(err).to include("overwrite skipped stubs, use --force")
end
context "when using --force" do
@@ -428,8 +382,8 @@ RSpec.describe "bundle binstubs <gem>" do
G
bundle "binstubs rack-obama"
- expect(out).to include("rack-obama has no executables")
- expect(out).to include("rack has: rackup")
+ expect(err).to include("rack-obama has no executables")
+ expect(err).to include("rack has: rackup")
end
it "works if child gems don't have bins" do
@@ -439,7 +393,7 @@ RSpec.describe "bundle binstubs <gem>" do
G
bundle "binstubs actionpack"
- expect(out).to include("no executables for the gem actionpack")
+ expect(err).to include("no executables for the gem actionpack")
end
it "works if the gem has development dependencies" do
@@ -449,7 +403,7 @@ RSpec.describe "bundle binstubs <gem>" do
G
bundle "binstubs with_development_dependency"
- expect(out).to include("no executables for the gem with_development_dependency")
+ expect(err).to include("no executables for the gem with_development_dependency")
end
end
@@ -460,7 +414,7 @@ RSpec.describe "bundle binstubs <gem>" do
gem "rack"
G
- bundle "config auto_install 1"
+ bundle "config set auto_install 1"
bundle "binstubs rack"
expect(out).to include("Installing rack 1.0.0")
expect(the_bundle).to include_gems "rack 1.0.0"
@@ -472,7 +426,7 @@ RSpec.describe "bundle binstubs <gem>" do
gem "rack"
G
- bundle "config auto_install 1"
+ bundle "config set auto_install 1"
bundle "binstubs rack", :env => { "BUNDLE_INSTALL" => 1 }
expect(out).not_to include("Installing rack 1.0.0")
end
diff --git a/spec/bundler/commands/check_spec.rb b/spec/bundler/commands/check_spec.rb
index 890f4b1356..7114610644 100644
--- a/spec/bundler/commands/check_spec.rb
+++ b/spec/bundler/commands/check_spec.rb
@@ -58,7 +58,7 @@ RSpec.describe "bundle check" do
G
bundle :check
- expect(out).to include("Bundler can't satisfy your Gemfile's dependencies.")
+ expect(err).to include("Bundler can't satisfy your Gemfile's dependencies.")
end
it "prints a generic error if a Gemfile.lock does not exist and a toplevel dependency does not exist" do
@@ -69,7 +69,7 @@ RSpec.describe "bundle check" do
bundle :check
expect(exitstatus).to be > 0 if exitstatus
- expect(out).to include("Bundler can't satisfy your Gemfile's dependencies.")
+ expect(err).to include("Bundler can't satisfy your Gemfile's dependencies.")
end
it "prints a generic message if you changed your lockfile" do
@@ -89,7 +89,7 @@ RSpec.describe "bundle check" do
G
bundle :check
- expect(out).to include("Bundler can't satisfy your Gemfile's dependencies.")
+ expect(err).to include("Bundler can't satisfy your Gemfile's dependencies.")
end
it "remembers --without option from install", :bundler => "< 3" do
@@ -106,7 +106,7 @@ RSpec.describe "bundle check" do
end
it "uses the without setting" do
- bundle! "config without foo"
+ bundle! "config set without foo"
install_gemfile! <<-G
source "file://#{gem_repo1}"
group :foo do
@@ -132,7 +132,7 @@ RSpec.describe "bundle check" do
G
bundle "check"
- expect(out).to include("* rack (1.0.0)")
+ expect(err).to include("* rack (1.0.0)")
expect(exitstatus).to eq(1) if exitstatus
end
@@ -201,13 +201,13 @@ RSpec.describe "bundle check" do
it "outputs an error when the default Gemfile is not found" do
bundle :check
expect(exitstatus).to eq(10) if exitstatus
- expect(out).to include("Could not locate Gemfile")
+ expect(err).to include("Could not locate Gemfile")
end
it "does not output fatal error message" do
bundle :check
expect(exitstatus).to eq(10) if exitstatus
- expect(out).not_to include("Unfortunately, a fatal error has occurred. ")
+ expect(err).not_to include("Unfortunately, a fatal error has occurred. ")
end
it "should not crash when called multiple times on a new machine" do
@@ -269,7 +269,7 @@ RSpec.describe "bundle check" do
bundle "check --path vendor/bundle"
expect(exitstatus).to eq(1) if exitstatus
- expect(out).to match(/The following gems are missing/)
+ expect(err).to match(/The following gems are missing/)
end
end
@@ -292,8 +292,8 @@ RSpec.describe "bundle check" do
it "shows what is missing with the current Gemfile if it is not satisfied" do
simulate_new_machine
bundle :check
- expect(out).to match(/The following gems are missing/)
- expect(out).to include("* rack (1.0")
+ expect(err).to match(/The following gems are missing/)
+ expect(err).to include("* rack (1.0")
end
end
diff --git a/spec/bundler/commands/clean_spec.rb b/spec/bundler/commands/clean_spec.rb
index e1f007fc35..0053947c85 100644
--- a/spec/bundler/commands/clean_spec.rb
+++ b/spec/bundler/commands/clean_spec.rb
@@ -142,7 +142,7 @@ RSpec.describe "bundle clean" do
bundle :clean
digest = Digest(:SHA1).hexdigest(git_path.to_s)
- cache_path = Bundler.bundler_major_version < 3 ? vendored_gems("cache/bundler/git/foo-1.0-#{digest}") : home(".bundle/cache/git/foo-1.0-#{digest}")
+ cache_path = Bundler::VERSION.start_with?("2.") ? vendored_gems("cache/bundler/git/foo-1.0-#{digest}") : home(".bundle/cache/git/foo-1.0-#{digest}")
expect(cache_path).to exist
end
@@ -201,7 +201,7 @@ RSpec.describe "bundle clean" do
update_git "foo", :path => lib_path("foo-bar")
revision2 = revision_for(lib_path("foo-bar"))
- bundle! "update", :all => bundle_update_requires_all?
+ bundle! "update", :all => true
bundle! :clean
expect(out).to include("Removing foo-bar (#{revision[0..11]})")
@@ -276,7 +276,7 @@ RSpec.describe "bundle clean" do
end
it "displays an error when used without --path" do
- bundle! "config path.system true"
+ bundle! "config set path.system true"
install_gemfile <<-G
source "file://#{gem_repo1}"
@@ -286,7 +286,7 @@ RSpec.describe "bundle clean" do
bundle :clean
expect(exitstatus).to eq(15) if exitstatus
- expect(out).to include("--force")
+ expect(err).to include("--force")
end
# handling bundle clean upgrade path from the pre's
@@ -320,9 +320,7 @@ RSpec.describe "bundle clean" do
end
it "does not call clean automatically when using system gems" do
- bundle! "config path.system true"
-
- bundle! :config
+ bundle! "config set path.system true"
install_gemfile! <<-G
source "file://#{gem_repo1}"
@@ -331,8 +329,6 @@ RSpec.describe "bundle clean" do
gem "rack"
G
- bundle! "info thin"
-
install_gemfile! <<-G
source "file://#{gem_repo1}"
@@ -378,7 +374,7 @@ RSpec.describe "bundle clean" do
build_gem "foo", "1.0.1"
end
- bundle! "update", :all => bundle_update_requires_all?
+ bundle! "update", :all => true
should_have_gems "foo-1.0.1"
should_not_have_gems "foo-1.0"
@@ -441,12 +437,12 @@ RSpec.describe "bundle clean" do
build_gem "foo", "1.0.1"
end
- bundle! :update, :all => bundle_update_requires_all?
+ bundle! :update, :all => true
should_have_gems "foo-1.0", "foo-1.0.1"
end
it "does not clean on bundle update when using --system" do
- bundle! "config path.system true"
+ bundle! "config set path.system true"
build_repo2
@@ -460,7 +456,7 @@ RSpec.describe "bundle clean" do
update_repo2 do
build_gem "foo", "1.0.1"
end
- bundle! :update, :all => bundle_update_requires_all?
+ bundle! :update, :all => true
gem = ruby_core? ? ENV["BUNDLE_GEM"] : "gem"
sys_exec! "#{gem} list"
@@ -468,7 +464,7 @@ RSpec.describe "bundle clean" do
end
it "cleans system gems when --force is used" do
- bundle! "config path.system true"
+ bundle! "config set path.system true"
gemfile <<-G
source "file://#{gem_repo1}"
@@ -519,8 +515,8 @@ RSpec.describe "bundle clean" do
bundle :clean, :force => true
- expect(out).to include(system_gem_path.to_s)
- expect(out).to include("grant write permissions")
+ expect(err).to include(system_gem_path.to_s)
+ expect(err).to include("grant write permissions")
gem = ruby_core? ? ENV["BUNDLE_GEM"] : "gem"
sys_exec "#{gem} list"
@@ -560,7 +556,7 @@ RSpec.describe "bundle clean" do
end
it "when using --force on system gems, it doesn't remove binaries" do
- bundle! "config path.system true"
+ bundle! "config set path.system true"
build_repo2
update_repo2 do
@@ -650,8 +646,6 @@ RSpec.describe "bundle clean" do
bundle :install
- bundle "configuration --delete path"
-
bundle "clean --dry-run"
expect(out).not_to include("Removing foo (1.0)")
@@ -671,7 +665,7 @@ RSpec.describe "bundle clean" do
G
bundle "install", forgotten_command_line_options(:path => "vendor/bundle", :clean => false)
- bundle "config dry_run false"
+ bundle "config set dry_run false"
gemfile <<-G
source "file://#{gem_repo1}"
@@ -709,14 +703,14 @@ RSpec.describe "bundle clean" do
gem "weakling"
G
- bundle! "config auto_install 1"
+ bundle! "config set auto_install 1"
bundle! :clean
expect(out).to include("Installing weakling 0.0.3")
should_have_gems "thin-1.0", "rack-1.0.0", "weakling-0.0.3"
should_not_have_gems "foo-1.0"
end
- it "doesn't remove extensions artifacts from bundled git gems after clean", :ruby_repo, :rubygems => "2.2" do
+ it "doesn't remove extensions artifacts from bundled git gems after clean", :ruby_repo do
build_git "very_simple_git_binary", &:add_c_extension
revision = revision_for(lib_path("very_simple_git_binary-1.0"))
@@ -738,7 +732,7 @@ RSpec.describe "bundle clean" do
expect(vendored_gems("bundler/gems/very_simple_git_binary-1.0-#{revision[0..11]}")).to exist
end
- it "removes extension directories", :ruby_repo, :rubygems => "2.2" do
+ it "removes extension directories", :ruby_repo do
gemfile <<-G
source "file://#{gem_repo1}"
@@ -772,4 +766,43 @@ RSpec.describe "bundle clean" do
expect(very_simple_binary_extensions_dir).not_to exist
expect(simple_binary_extensions_dir).to exist
end
+
+ it "removes git extension directories", :ruby_repo do
+ build_git "very_simple_git_binary", &:add_c_extension
+
+ revision = revision_for(lib_path("very_simple_git_binary-1.0"))
+ short_revision = revision[0..11]
+
+ gemfile <<-G
+ source "file://#{gem_repo1}"
+
+ gem "thin"
+ gem "very_simple_git_binary", :git => "#{lib_path("very_simple_git_binary-1.0")}", :ref => "#{revision}"
+ G
+
+ bundle! "install", forgotten_command_line_options(:path => "vendor/bundle")
+
+ very_simple_binary_extensions_dir =
+ Pathname.glob("#{vendored_gems}/bundler/gems/extensions/*/*/very_simple_git_binary-1.0-#{short_revision}").first
+
+ expect(very_simple_binary_extensions_dir).to exist
+
+ gemfile <<-G
+ gem "very_simple_git_binary", :git => "#{lib_path("very_simple_git_binary-1.0")}", :ref => "#{revision}"
+ G
+
+ bundle! "install"
+ bundle! :clean
+ expect(out).to include("Removing thin (1.0)")
+ expect(very_simple_binary_extensions_dir).to exist
+
+ gemfile <<-G
+ G
+
+ bundle! "install"
+ bundle! :clean
+ expect(out).to eq("Removing very_simple_git_binary-1.0 (#{short_revision})")
+
+ expect(very_simple_binary_extensions_dir).not_to exist
+ end
end
diff --git a/spec/bundler/commands/config_spec.rb b/spec/bundler/commands/config_spec.rb
index 9e49357465..84f882b410 100644
--- a/spec/bundler/commands/config_spec.rb
+++ b/spec/bundler/commands/config_spec.rb
@@ -1,18 +1,11 @@
# frozen_string_literal: true
RSpec.describe ".bundle/config" do
- before :each do
- gemfile <<-G
- source "file://#{gem_repo1}"
- gem "rack", "1.0.0"
- G
- end
-
describe "config" do
- before { bundle "config foo bar" }
+ before { bundle "config set foo bar" }
it "prints a detailed report of local and user configuration" do
- bundle "config"
+ bundle "config list"
expect(out).to include("Settings are listed in order of priority. The top value will be used")
expect(out).to include("foo\nSet for the current user")
@@ -21,28 +14,35 @@ RSpec.describe ".bundle/config" do
context "given --parseable flag" do
it "prints a minimal report of local and user configuration" do
- bundle "config --parseable"
+ bundle "config list --parseable"
expect(out).to include("foo=bar")
end
context "with global config" do
it "prints config assigned to local scope" do
- bundle "config --local foo bar2"
- bundle "config --parseable"
+ bundle "config set --local foo bar2"
+ bundle "config list --parseable"
expect(out).to include("foo=bar2")
end
end
context "with env overwrite" do
it "prints config with env" do
- bundle "config --parseable", :env => { "BUNDLE_FOO" => "bar3" }
+ bundle "config list --parseable", :env => { "BUNDLE_FOO" => "bar3" }
expect(out).to include("foo=bar3")
end
end
end
end
- describe "BUNDLE_APP_CONFIG" do
+ describe "location" do
+ before :each do
+ gemfile <<-G
+ source "file://#{gem_repo1}"
+ gem "rack", "1.0.0"
+ G
+ end
+
it "can be moved with an environment variable" do
ENV["BUNDLE_APP_CONFIG"] = tmp("foo/bar").to_s
bundle "install", forgotten_command_line_options(:path => "vendor/bundle")
@@ -66,24 +66,29 @@ RSpec.describe ".bundle/config" do
end
describe "global" do
- before(:each) { bundle :install }
+ before(:each) do
+ install_gemfile <<-G
+ source "file://#{gem_repo1}"
+ gem "rack", "1.0.0"
+ G
+ end
it "is the default" do
- bundle "config foo global"
+ bundle "config set foo global"
run "puts Bundler.settings[:foo]"
expect(out).to eq("global")
end
it "can also be set explicitly" do
- bundle! "config --global foo global"
+ bundle! "config set --global foo global"
run! "puts Bundler.settings[:foo]"
expect(out).to eq("global")
end
it "has lower precedence than local" do
- bundle "config --local foo local"
+ bundle "config set --local foo local"
- bundle "config --global foo global"
+ bundle "config set --global foo global"
expect(out).to match(/Your application has set foo to "local"/)
run "puts Bundler.settings[:foo]"
@@ -94,7 +99,7 @@ RSpec.describe ".bundle/config" do
begin
ENV["BUNDLE_FOO"] = "env"
- bundle "config --global foo global"
+ bundle "config set --global foo global"
expect(out).to match(/You have a bundler environment variable for foo set to "env"/)
run "puts Bundler.settings[:foo]"
@@ -105,16 +110,16 @@ RSpec.describe ".bundle/config" do
end
it "can be deleted" do
- bundle "config --global foo global"
- bundle "config --delete foo"
+ bundle "config set --global foo global"
+ bundle "config unset foo"
run "puts Bundler.settings[:foo] == nil"
expect(out).to eq("true")
end
it "warns when overriding" do
- bundle "config --global foo previous"
- bundle "config --global foo global"
+ bundle "config set --global foo previous"
+ bundle "config set --global foo global"
expect(out).to match(/You are replacing the current global value of foo/)
run "puts Bundler.settings[:foo]"
@@ -122,8 +127,8 @@ RSpec.describe ".bundle/config" do
end
it "does not warn when using the same value twice" do
- bundle "config --global foo value"
- bundle "config --global foo value"
+ bundle "config set --global foo value"
+ bundle "config set --global foo value"
expect(out).not_to match(/You are replacing the current global value of foo/)
run "puts Bundler.settings[:foo]"
@@ -131,22 +136,22 @@ RSpec.describe ".bundle/config" do
end
it "expands the path at time of setting" do
- bundle "config --global local.foo .."
+ bundle "config set --global local.foo .."
run "puts Bundler.settings['local.foo']"
expect(out).to eq(File.expand_path(Dir.pwd + "/.."))
end
it "saves with parseable option" do
- bundle "config --global --parseable foo value"
+ bundle "config set --global --parseable foo value"
expect(out).to eq("foo=value")
run "puts Bundler.settings['foo']"
expect(out).to eq("value")
end
context "when replacing a current value with the parseable flag" do
- before { bundle "config --global foo value" }
+ before { bundle "config set --global foo value" }
it "prints the current value in a parseable format" do
- bundle "config --global --parseable foo value2"
+ bundle "config set --global --parseable foo value2"
expect(out).to eq "foo=value2"
run "puts Bundler.settings['foo']"
expect(out).to eq("value2")
@@ -155,10 +160,15 @@ RSpec.describe ".bundle/config" do
end
describe "local" do
- before(:each) { bundle :install }
+ before(:each) do
+ install_gemfile <<-G
+ source "file://#{gem_repo1}"
+ gem "rack", "1.0.0"
+ G
+ end
it "can also be set explicitly" do
- bundle "config --local foo local"
+ bundle "config set --local foo local"
run "puts Bundler.settings[:foo]"
expect(out).to eq("local")
end
@@ -166,7 +176,7 @@ RSpec.describe ".bundle/config" do
it "has higher precedence than env" do
begin
ENV["BUNDLE_FOO"] = "env"
- bundle "config --local foo local"
+ bundle "config set --local foo local"
run "puts Bundler.settings[:foo]"
expect(out).to eq("local")
@@ -176,16 +186,16 @@ RSpec.describe ".bundle/config" do
end
it "can be deleted" do
- bundle "config --local foo local"
- bundle "config --delete foo"
+ bundle "config set --local foo local"
+ bundle "config unset foo"
run "puts Bundler.settings[:foo] == nil"
expect(out).to eq("true")
end
it "warns when overriding" do
- bundle "config --local foo previous"
- bundle "config --local foo local"
+ bundle "config set --local foo previous"
+ bundle "config set --local foo local"
expect(out).to match(/You are replacing the current local value of foo/)
run "puts Bundler.settings[:foo]"
@@ -193,14 +203,14 @@ RSpec.describe ".bundle/config" do
end
it "expands the path at time of setting" do
- bundle "config --local local.foo .."
+ bundle "config set --local local.foo .."
run "puts Bundler.settings['local.foo']"
expect(out).to eq(File.expand_path(Dir.pwd + "/.."))
end
it "can be deleted with parseable option" do
- bundle "config --local foo value"
- bundle "config --delete --parseable foo"
+ bundle "config set --local foo value"
+ bundle "config unset --parseable foo"
expect(out).to eq ""
run "puts Bundler.settings['foo'] == nil"
expect(out).to eq("true")
@@ -208,7 +218,12 @@ RSpec.describe ".bundle/config" do
end
describe "env" do
- before(:each) { bundle :install }
+ before(:each) do
+ install_gemfile <<-G
+ source "file://#{gem_repo1}"
+ gem "rack", "1.0.0"
+ G
+ end
it "can set boolean properties via the environment" do
ENV["BUNDLE_FROZEN"] = "true"
@@ -247,39 +262,44 @@ RSpec.describe ".bundle/config" do
describe "parseable option" do
it "prints an empty string" do
- bundle "config foo --parseable"
+ bundle "config get foo --parseable"
expect(out).to eq ""
end
it "only prints the value of the config" do
- bundle "config foo local"
- bundle "config foo --parseable"
+ bundle "config set foo local"
+ bundle "config get foo --parseable"
expect(out).to eq "foo=local"
end
it "can print global config" do
- bundle "config --global bar value"
- bundle "config bar --parseable"
+ bundle "config set --global bar value"
+ bundle "config get bar --parseable"
expect(out).to eq "bar=value"
end
it "prefers local config over global" do
- bundle "config --local bar value2"
- bundle "config --global bar value"
- bundle "config bar --parseable"
+ bundle "config set --local bar value2"
+ bundle "config set --global bar value"
+ bundle "config get bar --parseable"
expect(out).to eq "bar=value2"
end
end
describe "gem mirrors" do
- before(:each) { bundle :install }
+ before(:each) do
+ install_gemfile <<-G
+ source "file://#{gem_repo1}"
+ gem "rack", "1.0.0"
+ G
+ end
it "configures mirrors using keys with `mirror.`" do
- bundle "config --local mirror.http://gems.example.org http://gem-mirror.example.org"
+ bundle "config set --local mirror.http://gems.example.org http://gem-mirror.example.org"
run(<<-E)
Bundler.settings.gem_mirrors.each do |k, v|
puts "\#{k} => \#{v}"
@@ -297,26 +317,26 @@ E
end
it "saves quotes" do
- bundle "config foo something\\'"
+ bundle "config set foo something\\'"
run "puts Bundler.settings[:foo]"
expect(out).to eq("something'")
end
- it "doesn't return quotes around values", :ruby => "1.9" do
- bundle "config foo '1'"
+ it "doesn't return quotes around values" do
+ bundle "config set foo '1'"
run "puts Bundler.settings.send(:global_config_file).read"
expect(out).to include('"1"')
run "puts Bundler.settings[:foo]"
expect(out).to eq("1")
end
- it "doesn't duplicate quotes around values", :if => (RUBY_VERSION >= "2.1") do
+ it "doesn't duplicate quotes around values" do
bundled_app(".bundle").mkpath
File.open(bundled_app(".bundle/config"), "w") do |f|
f.write 'BUNDLE_FOO: "$BUILD_DIR"'
end
- bundle "config bar baz"
+ bundle "config set bar baz"
run "puts Bundler.settings.send(:local_config_file).read"
# Starting in Ruby 2.1, YAML automatically adds double quotes
@@ -325,12 +345,12 @@ E
end
it "doesn't duplicate quotes around long wrapped values" do
- bundle "config foo #{long_string}"
+ bundle "config set foo #{long_string}"
run "puts Bundler.settings[:foo]"
expect(out).to eq(long_string)
- bundle "config bar baz"
+ bundle "config set bar baz"
run "puts Bundler.settings[:foo]"
expect(out).to eq(long_string)
@@ -338,7 +358,12 @@ E
end
describe "very long lines" do
- before(:each) { bundle :install }
+ before(:each) do
+ install_gemfile <<-G
+ source "file://#{gem_repo1}"
+ gem "rack", "1.0.0"
+ G
+ end
let(:long_string) do
"--with-xml2-include=/usr/pkg/include/libxml2 --with-xml2-lib=/usr/pkg/lib " \
@@ -351,17 +376,103 @@ E
end
it "doesn't wrap values" do
- bundle "config foo #{long_string}"
+ bundle "config set foo #{long_string}"
run "puts Bundler.settings[:foo]"
expect(out).to match(long_string)
end
it "can read wrapped unquoted values" do
- bundle "config foo #{long_string_without_special_characters}"
+ bundle "config set foo #{long_string_without_special_characters}"
run "puts Bundler.settings[:foo]"
expect(out).to match(long_string_without_special_characters)
end
end
+
+ describe "subcommands" do
+ it "list" do
+ bundle! "config list"
+ expect(last_command.stdout).to eq "Settings are listed in order of priority. The top value will be used.\nspec_run\nSet via BUNDLE_SPEC_RUN: \"true\""
+
+ bundle! "config list", :parseable => true
+ expect(last_command.stdout).to eq "spec_run=true"
+ end
+
+ it "get" do
+ ENV["BUNDLE_BAR"] = "bar_val"
+
+ bundle! "config get foo"
+ expect(last_command.stdout).to eq "Settings for `foo` in order of priority. The top value will be used\nYou have not configured a value for `foo`"
+
+ ENV["BUNDLE_FOO"] = "foo_val"
+
+ bundle! "config get foo --parseable"
+ expect(last_command.stdout).to eq "foo=foo_val"
+
+ bundle! "config get foo"
+ expect(last_command.stdout).to eq "Settings for `foo` in order of priority. The top value will be used\nSet via BUNDLE_FOO: \"foo_val\""
+ end
+
+ it "set" do
+ bundle! "config set foo 1"
+ expect(last_command.stdout).to eq ""
+
+ bundle! "config set --local foo 2"
+ expect(last_command.stdout).to eq ""
+
+ bundle! "config set --global foo 3"
+ expect(last_command.stdout).to eq "Your application has set foo to \"2\". This will override the global value you are currently setting"
+
+ bundle! "config set --parseable --local foo 4"
+ expect(last_command.stdout).to eq "foo=4"
+
+ bundle! "config set --local foo 4.1"
+ expect(last_command.stdout).to eq "You are replacing the current local value of foo, which is currently \"4\""
+
+ bundle "config set --global --local foo 5"
+ expect(last_command).to be_failure
+ expect(last_command.bundler_err).to eq "The options global and local were specified. Please only use one of the switches at a time."
+ end
+
+ it "unset" do
+ bundle! "config unset foo"
+ expect(last_command.stdout).to eq ""
+
+ bundle! "config set foo 1"
+ bundle! "config unset foo --parseable"
+ expect(last_command.stdout).to eq ""
+
+ bundle! "config set --local foo 1"
+ bundle! "config set --global foo 2"
+
+ bundle! "config unset foo"
+ expect(last_command.stdout).to eq ""
+ expect(bundle!("config get foo")).to eq "Settings for `foo` in order of priority. The top value will be used\nYou have not configured a value for `foo`"
+
+ bundle! "config set --local foo 1"
+ bundle! "config set --global foo 2"
+
+ bundle! "config unset foo --local"
+ expect(last_command.stdout).to eq ""
+ expect(bundle!("config get foo")).to eq "Settings for `foo` in order of priority. The top value will be used\nSet for the current user (#{home(".bundle/config")}): \"2\""
+ bundle! "config unset foo --global"
+ expect(last_command.stdout).to eq ""
+ expect(bundle!("config get foo")).to eq "Settings for `foo` in order of priority. The top value will be used\nYou have not configured a value for `foo`"
+
+ bundle! "config set --local foo 1"
+ bundle! "config set --global foo 2"
+
+ bundle! "config unset foo --global"
+ expect(last_command.stdout).to eq ""
+ expect(bundle!("config get foo")).to eq "Settings for `foo` in order of priority. The top value will be used\nSet for your local app (#{bundled_app(".bundle/config")}): \"1\""
+ bundle! "config unset foo --local"
+ expect(last_command.stdout).to eq ""
+ expect(bundle!("config get foo")).to eq "Settings for `foo` in order of priority. The top value will be used\nYou have not configured a value for `foo`"
+
+ bundle "config unset foo --local --global"
+ expect(last_command).to be_failure
+ expect(last_command.bundler_err).to eq "The options global and local were specified. Please only use one of the switches at a time."
+ end
+ end
end
RSpec.describe "setting gemfile via config" do
@@ -374,10 +485,10 @@ RSpec.describe "setting gemfile via config" do
G
end
- bundle "config --local gemfile #{bundled_app("NotGemfile")}"
+ bundle "config set --local gemfile #{bundled_app("NotGemfile")}"
expect(File.exist?(".bundle/config")).to eq(true)
- bundle "config"
+ bundle "config list"
expect(out).to include("NotGemfile")
end
end
diff --git a/spec/bundler/commands/console_spec.rb b/spec/bundler/commands/console_spec.rb
index 05b0a6c1e4..cba618db80 100644
--- a/spec/bundler/commands/console_spec.rb
+++ b/spec/bundler/commands/console_spec.rb
@@ -31,7 +31,7 @@ RSpec.describe "bundle console", :bundler => "< 3" do
source "file://#{gem_repo1}"
gem "pry"
G
- bundle "config console pry"
+ bundle "config set console pry"
bundle "console" do |input, _, _|
input.puts("__method__")
@@ -41,7 +41,7 @@ RSpec.describe "bundle console", :bundler => "< 3" do
end
it "falls back to IRB if the other REPL isn't available" do
- bundle "config console pry"
+ bundle "config set console pry"
# make sure pry isn't there
bundle "console" do |input, _, _|
@@ -94,7 +94,7 @@ RSpec.describe "bundle console", :bundler => "< 3" do
gem "foo"
G
- bundle "config auto_install 1"
+ bundle "config set auto_install 1"
bundle :console do |input, _, _|
input.puts("puts 'hello'")
input.puts("exit")
diff --git a/spec/bundler/commands/exec_spec.rb b/spec/bundler/commands/exec_spec.rb
index 2e3cb6621e..a95383ee97 100644
--- a/spec/bundler/commands/exec_spec.rb
+++ b/spec/bundler/commands/exec_spec.rb
@@ -38,7 +38,7 @@ RSpec.describe "bundle exec" do
gem "rack"
G
- bundle "exec 'cd #{tmp("gems")} && rackup'", :env => { :RUBYOPT => "-r#{spec_dir.join("support/hax")}" }
+ bundle "exec 'cd #{tmp("gems")} && rackup'"
expect(out).to include("1.0.0")
end
@@ -51,7 +51,7 @@ RSpec.describe "bundle exec" do
it "works when exec'ing to ruby" do
install_gemfile 'gem "rack"'
- bundle "exec ruby -e 'puts %{hi}'", :env => { :RUBYOPT => "-r#{spec_dir.join("support/hax")}" }
+ bundle "exec ruby -e 'puts %{hi}'"
expect(out).to eq("hi")
end
@@ -79,30 +79,23 @@ RSpec.describe "bundle exec" do
require 'tempfile'
io = Tempfile.new("io-test-fd")
args = %W[#{Gem.ruby} -I#{lib} #{bindir.join("bundle")} exec --keep-file-descriptors #{Gem.ruby} #{command.path} \#{io.to_i}]
- args << { io.to_i => io } if RUBY_VERSION >= "2.0"
+ args << { io.to_i => io }
exec(*args)
end
G
install_gemfile ""
- with_env_vars "RUBYOPT" => "-r#{spec_dir.join("support/hax")}" do
- sys_exec "#{Gem.ruby} #{command.path}"
- end
-
- if Bundler.current_ruby.ruby_2?
- expect(out).to eq("")
- else
- expect(out).to eq("Ruby version #{RUBY_VERSION} defaults to keeping non-standard file descriptors on Kernel#exec.")
- end
+ sys_exec "#{Gem.ruby} #{command.path}"
- expect(err).to lack_errors
+ expect(out).to eq("")
+ expect(last_command.stderr).to be_empty
end
it "accepts --keep-file-descriptors" do
install_gemfile ""
bundle "exec --keep-file-descriptors echo foobar"
- expect(err).to lack_errors
+ expect(last_command.stderr).to be_empty
end
it "can run a command named --verbose" do
@@ -147,6 +140,112 @@ RSpec.describe "bundle exec" do
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 "warns about executable conflicts" do
+ build_repo2 do
+ build_gem "rack_two", "1.0.0" do |s|
+ s.executables = "rackup"
+ end
+ end
+
+ bundle "config set path.system true"
+
+ install_gemfile <<-G
+ source "file://#{gem_repo1}"
+ gem "rack", "0.9.1"
+ G
+
+ Dir.chdir bundled_app2 do
+ install_gemfile bundled_app2("Gemfile"), <<-G
+ source "file://#{gem_repo2}"
+ gem "rack_two", "1.0.0"
+ G
+ end
+
+ bundle! "exec rackup"
+
+ expect(last_command.stderr).to eq(
+ "Bundler is using a binstub that was created for a different gem (rack).\n" \
+ "You should run `bundle binstub rack_two` to work around a system/bundle conflict."
+ )
+ end
+
it "handles gems installed with --without" do
install_gemfile <<-G, forgotten_command_line_options(:without => "middleware")
source "file://#{gem_repo1}"
@@ -201,8 +300,8 @@ RSpec.describe "bundle exec" do
bundle "exec foobarbaz"
expect(exitstatus).to eq(127) if exitstatus
- expect(out).to include("bundler: command not found: foobarbaz")
- expect(out).to include("Install missing gem executables with `bundle install`")
+ expect(err).to include("bundler: command not found: foobarbaz")
+ expect(err).to include("Install missing gem executables with `bundle install`")
end
it "errors nicely when the argument is not executable" do
@@ -213,7 +312,7 @@ RSpec.describe "bundle exec" do
bundle "exec touch foo"
bundle "exec ./foo"
expect(exitstatus).to eq(126) if exitstatus
- expect(out).to include("bundler: not executable: ./foo")
+ expect(err).to include("bundler: not executable: ./foo")
end
it "errors nicely when no arguments are passed" do
@@ -223,36 +322,22 @@ RSpec.describe "bundle exec" do
bundle "exec"
expect(exitstatus).to eq(128) if exitstatus
- expect(out).to include("bundler: exec needs a command to run")
+ expect(err).to include("bundler: exec needs a command to run")
end
- it "raises a helpful error when exec'ing to something outside of the bundle", :ruby_repo, :rubygems => ">= 2.5.2" do
- bundle! "config clean false" # want to keep the rackup binstub
+ it "raises a helpful error when exec'ing to something outside of the bundle", :ruby_repo do
+ bundle! "config set clean false" # want to keep the rackup binstub
install_gemfile! <<-G
source "file://#{gem_repo1}"
gem "with_license"
G
[true, false].each do |l|
- bundle! "config disable_exec_load #{l}"
+ bundle! "config set disable_exec_load #{l}"
bundle "exec rackup"
expect(last_command.stderr).to include "can't find executable rackup for gem rack. rack is not currently included in the bundle, perhaps you meant to add it to your Gemfile?"
end
end
- # Different error message on old RG versions (before activate_bin_path) because they
- # called `Kernel#gem` directly
- it "raises a helpful error when exec'ing to something outside of the bundle", :rubygems => "< 2.5.2" do
- install_gemfile! <<-G
- source "file://#{gem_repo1}"
- gem "with_license"
- G
- [true, false].each do |l|
- bundle! "config disable_exec_load #{l}"
- bundle "exec rackup", :env => { :RUBYOPT => "-r#{spec_dir.join("support/hax")}" }
- expect(last_command.stderr).to include "rack is not part of the bundle. Add it to your Gemfile."
- end
- end
-
describe "with help flags" do
each_prefix = proc do |string, &blk|
1.upto(string.length) {|l| blk.call(string[0, l]) }
@@ -350,14 +435,14 @@ RSpec.describe "bundle exec" do
end
it "works when unlocked" do
- bundle "exec 'cd #{tmp("gems")} && rackup'", :env => { :RUBYOPT => "-r#{spec_dir.join("support/hax")}" }
+ bundle "exec 'cd #{tmp("gems")} && rackup'"
expect(out).to eq("1.0.0")
expect(out).to include("1.0.0")
end
it "works when locked" do
expect(the_bundle).to be_locked
- bundle "exec 'cd #{tmp("gems")} && rackup'", :env => { :RUBYOPT => "-r#{spec_dir.join("support/hax")}" }
+ bundle "exec 'cd #{tmp("gems")} && rackup'"
expect(out).to include("1.0.0")
end
end
@@ -440,13 +525,13 @@ RSpec.describe "bundle exec" do
gem "foo"
G
- bundle "config auto_install 1"
+ bundle "config set auto_install 1"
bundle "exec rackup"
expect(out).to include("Installing foo 1.0")
end
describe "with gems bundled via :path with invalid gemspecs", :ruby_repo do
- it "outputs the gemspec validation errors", :rubygems => ">= 1.7.2" do
+ it "outputs the gemspec validation errors" do
build_lib "foo"
gemspec = lib_path("foo-1.0").join("foo.gemspec").to_s
@@ -467,8 +552,8 @@ RSpec.describe "bundle exec" do
bundle "exec irb"
- expect(err).to match("The gemspec at #{lib_path("foo-1.0").join("foo.gemspec")} is not valid")
- expect(err).to match('"TODO" is not a summary')
+ expect(last_command.stderr).to match("The gemspec at #{lib_path("foo-1.0").join("foo.gemspec")} is not valid")
+ expect(last_command.stderr).to match('"TODO" is not a summary')
end
end
@@ -483,7 +568,7 @@ RSpec.describe "bundle exec" do
Bundler.rubygems.extend(Monkey)
G
bundle "install --deployment"
- bundle "exec ruby -e '`#{bindir.join("bundler")} -v`; puts $?.success?'", :env => { :RUBYOPT => "-r#{spec_dir.join("support/hax")}" }
+ bundle "exec ruby -e '`#{bindir.join("bundler")} -v`; puts $?.success?'"
expect(out).to match("true")
end
end
@@ -516,14 +601,14 @@ RSpec.describe "bundle exec" do
let(:rack) { "RACK: 1.0.0" }
let(:process) do
title = "PROCESS: #{path}"
- title += " arg1 arg2" if RUBY_VERSION >= "2.1"
+ title += " arg1 arg2"
title
end
let(:exit_code) { 0 }
let(:expected) { [exec, args, rack, process].join("\n") }
let(:expected_err) { "" }
- subject { bundle "exec #{path} arg1 arg2", :env => { :RUBYOPT => "-r#{spec_dir.join("support/hax")}" } }
+ subject { bundle "exec #{path} arg1 arg2" }
shared_examples_for "it runs" do
it "like a normally executed executable" do
@@ -553,15 +638,10 @@ RSpec.describe "bundle exec" do
let(:executable) do
ex = super()
ex << "\n"
- if LessThanProc.with(RUBY_VERSION).call("1.9")
- # Ruby < 1.9 needs a flush for a exit by signal, later
- # rubies do not
- ex << "STDOUT.flush\n"
- end
ex << "raise SignalException, 'SIGTERM'\n"
ex
end
- let(:expected_err) { ENV["TRAVIS"] ? "Terminated" : "" }
+ let(:expected_err) { "" }
let(:exit_code) do
# signal mask 128 + plus signal 15 -> TERM
# this is specified by C99
@@ -612,7 +692,8 @@ RSpec.describe "bundle exec" do
end
let(:exit_code) { Bundler::GemNotFound.new.status_code }
- let(:expected) { <<-EOS.strip }
+ let(:expected) { "" }
+ let(:expected_err) { <<-EOS.strip }
\e[31mCould not find gem 'rack (= 2)' in any of the gem sources listed in your Gemfile.\e[0m
\e[33mRun `bundle install` to install missing gems.\e[0m
EOS
@@ -629,7 +710,8 @@ RSpec.describe "bundle exec" do
end
let(:exit_code) { Bundler::GemNotFound.new.status_code }
- let(:expected) { <<-EOS.strip }
+ let(:expected) { "" }
+ let(:expected_err) { <<-EOS.strip }
\e[31mCould not find gem 'rack (= 2)' in locally installed gems.
The source contains 'rack' at: 1.0.0\e[0m
\e[33mRun `bundle install` to install missing gems.\e[0m
@@ -650,7 +732,7 @@ The source contains 'rack' at: 1.0.0\e[0m
let(:process) { "PROCESS: ruby #{path} arg1 arg2" }
before do
- bundle "config disable_exec_load true"
+ bundle "config set disable_exec_load true"
end
it_behaves_like "it runs"
@@ -674,21 +756,13 @@ __FILE__: #{path.to_s.inspect}
context "when the path is relative" do
let(:path) { super().relative_path_from(bundled_app) }
- if LessThanProc.with(RUBY_VERSION).call("1.9")
- pending "relative paths have ./ __FILE__"
- else
- it_behaves_like "it runs"
- end
+ it_behaves_like "it runs"
end
context "when the path is relative with a leading ./" do
let(:path) { Pathname.new("./#{super().relative_path_from(Pathname.pwd)}") }
- if LessThanProc.with(RUBY_VERSION).call("< 1.9")
- pending "relative paths with ./ have absolute __FILE__"
- else
- it_behaves_like "it runs"
- end
+ pending "relative paths with ./ have absolute __FILE__"
end
end
@@ -716,7 +790,7 @@ __FILE__: #{path.to_s.inspect}
end
RUBY
- it "receives the signal", :ruby => ">= 1.9.3" do
+ it "receives the signal" do
bundle!("exec #{path}") do |_, o, thr|
o.gets # Consumes 'Started' and ensures that thread has started
Process.kill("INT", thr.pid)
@@ -762,9 +836,7 @@ __FILE__: #{path.to_s.inspect}
bundle :install, :system_bundler => true, :path => "vendor/bundler"
end
- it "overrides disable_shared_gems so bundler can be found" do
- skip "bundler 1.16.x is not support with Ruby 2.6 on Travis CI" if RUBY_VERSION >= "2.6"
-
+ it "overrides disable_shared_gems so bundler can be found", :rubygems => ">= 2.6.2" do
system_gems :bundler
file = bundled_app("file_that_bundle_execs.rb")
create_file(file, <<-RB)
@@ -809,10 +881,7 @@ __FILE__: #{path.to_s.inspect}
expect(bundle!("exec #{file}", :artifice => nil)).to eq(expected)
expect(bundle!("exec bundle exec #{file}", :artifice => nil)).to eq(expected)
expect(bundle!("exec ruby #{file}", :artifice => nil)).to eq(expected)
- # Ignore expectaion for default bundler gem conflict.
- unless ENV["BUNDLER_SPEC_SUB_VERSION"]
- expect(run!(file.read, :artifice => nil)).to eq(expected)
- end
+ expect(run!(file.read, :artifice => nil)).to eq(expected)
end
# sanity check that we get the newer, custom version without bundler
diff --git a/spec/bundler/commands/help_spec.rb b/spec/bundler/commands/help_spec.rb
index 56b1b6f722..f4f90b9347 100644
--- a/spec/bundler/commands/help_spec.rb
+++ b/spec/bundler/commands/help_spec.rb
@@ -1,15 +1,6 @@
# frozen_string_literal: true
RSpec.describe "bundle help" do
- # RubyGems 1.4+ no longer load gem plugins so this test is no longer needed
- it "complains if older versions of bundler are installed", :rubygems => "< 1.4" do
- system_gems "bundler-0.8.1"
-
- bundle "help"
- expect(err).to include("older than 0.9")
- expect(err).to include("running `gem cleanup bundler`.")
- end
-
it "uses mann when available" do
with_fake_man do
bundle "help gemfile"
@@ -81,7 +72,7 @@ RSpec.describe "bundle help" do
with_fake_man do
bundle "instill -h"
end
- expect(out).to include('Could not find command "instill".')
+ expect(err).to include('Could not find command "instill".')
end
it "is called when only using the --help flag" do
diff --git a/spec/bundler/commands/info_spec.rb b/spec/bundler/commands/info_spec.rb
index a9ab8fc210..fc1d97b1da 100644
--- a/spec/bundler/commands/info_spec.rb
+++ b/spec/bundler/commands/info_spec.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
RSpec.describe "bundle info" do
- context "info from specific gem in gemfile" do
+ context "with a standard Gemfile" do
before do
install_gemfile <<-G
source "file://#{gem_repo1}"
@@ -9,23 +9,39 @@ RSpec.describe "bundle info" do
G
end
- it "prints information about the current gem" do
+ it "creates a Gemfile.lock when invoked with a gem name" do
+ FileUtils.rm("Gemfile.lock")
+
+ bundle "info rails"
+
+ expect(bundled_app("Gemfile.lock")).to exist
+ end
+
+ it "prints information if gem exists in bundle" do
bundle "info rails"
expect(out).to include "* rails (2.3.2)
\tSummary: This is just a fake gem for testing
-\tHomepage: http://example.com"
- expect(out).to match(%r{Path\: .*\/rails\-2\.3\.2})
+\tHomepage: http://example.com
+\tPath: #{default_bundle_path("gems", "rails-2.3.2")}"
end
- context "given a gem that is not installed" do
- it "prints missing gem error" do
- bundle "info foo"
- expect(out).to eq "Could not find gem 'foo'."
- end
+ it "prints path if gem exists in bundle" do
+ bundle "info rails --path"
+ expect(out).to eq(default_bundle_path("gems", "rails-2.3.2").to_s)
+ end
+
+ it "prints the path to the running bundler" do
+ bundle "info bundler --path"
+ expect(out).to eq(root.to_s)
+ end
+
+ it "complains if gem not in bundle" do
+ bundle "info missing"
+ expect(err).to eq("Could not find gem 'missing'.")
end
context "given a default gem shippped in ruby", :ruby_repo do
- it "prints information about the default gem", :if => (RUBY_VERSION >= "2.0") do
+ it "prints information about the default gem" do
bundle "info rdoc"
expect(out).to include("* rdoc")
expect(out).to include("Default Gem: yes")
@@ -34,7 +50,7 @@ RSpec.describe "bundle info" do
context "when gem does not have homepage" do
before do
- build_repo1 do
+ build_repo2 do
build_gem "rails", "2.3.2" do |s|
s.executables = "rails"
s.summary = "Just another test gem"
@@ -46,12 +62,84 @@ RSpec.describe "bundle info" do
expect(out).to_not include("Homepage:")
end
end
+ end
+
+ context "with a git repo in the Gemfile" do
+ before :each do
+ @git = build_git "foo", "1.0"
+ end
+
+ it "prints out git info" do
+ install_gemfile <<-G
+ gem "foo", :git => "#{lib_path("foo-1.0")}"
+ G
+ expect(the_bundle).to include_gems "foo 1.0"
+
+ bundle "info foo"
+ expect(out).to include("foo (1.0 #{@git.ref_for("master", 6)}")
+ end
- context "given --path option" do
- it "prints the path to the gem" do
- bundle "info rails"
- expect(out).to match(%r{.*\/rails\-2\.3\.2})
+ it "prints out branch names other than master" do
+ update_git "foo", :branch => "omg" do |s|
+ s.write "lib/foo.rb", "FOO = '1.0.omg'"
end
+ @revision = revision_for(lib_path("foo-1.0"))[0...6]
+
+ install_gemfile <<-G
+ gem "foo", :git => "#{lib_path("foo-1.0")}", :branch => "omg"
+ G
+ expect(the_bundle).to include_gems "foo 1.0.omg"
+
+ bundle "info foo"
+ expect(out).to include("foo (1.0 #{@git.ref_for("omg", 6)}")
+ end
+
+ it "doesn't print the branch when tied to a ref" do
+ sha = revision_for(lib_path("foo-1.0"))
+ install_gemfile <<-G
+ gem "foo", :git => "#{lib_path("foo-1.0")}", :ref => "#{sha}"
+ G
+
+ bundle "info foo"
+ expect(out).to include("foo (1.0 #{sha[0..6]})")
+ end
+
+ it "handles when a version is a '-' prerelease", :rubygems => "2.1" do
+ @git = build_git("foo", "1.0.0-beta.1", :path => lib_path("foo"))
+ install_gemfile <<-G
+ gem "foo", "1.0.0-beta.1", :git => "#{lib_path("foo")}"
+ G
+ expect(the_bundle).to include_gems "foo 1.0.0.pre.beta.1"
+
+ bundle! "info foo"
+ expect(out).to include("foo (1.0.0.pre.beta.1")
+ end
+ end
+
+ context "with a valid regexp for gem name" do
+ it "presents alternatives" do
+ install_gemfile <<-G
+ source "file://#{gem_repo1}"
+ gem "rack"
+ gem "rack-obama"
+ G
+
+ bundle "info rac"
+ expect(out).to eq "1 : rack\n2 : rack-obama\n0 : - exit -\n>"
+ end
+ end
+
+ context "with an invalid regexp for gem name" do
+ it "does not find the gem" do
+ install_gemfile <<-G
+ source "file://#{gem_repo1}"
+ gem "rails"
+ G
+
+ invalid_regexp = "[]"
+
+ bundle "info #{invalid_regexp}"
+ expect(err).to include("Could not find gem '#{invalid_regexp}'.")
end
end
end
diff --git a/spec/bundler/commands/init_spec.rb b/spec/bundler/commands/init_spec.rb
index 8a8f0effa0..64849beeb9 100644
--- a/spec/bundler/commands/init_spec.rb
+++ b/spec/bundler/commands/init_spec.rb
@@ -1,19 +1,13 @@
# frozen_string_literal: true
RSpec.describe "bundle init" do
- it "generates a Gemfile", :bundler => "< 3" do
+ it "generates a Gemfile" do
bundle! :init
expect(out).to include("Writing new Gemfile")
expect(bundled_app("Gemfile")).to be_file
end
- it "generates a gems.rb", :bundler => "3" do
- bundle! :init
- expect(out).to include("Writing new gems.rb")
- expect(bundled_app("gems.rb")).to be_file
- end
-
- context "when a Gemfile already exists", :bundler => "< 3" do
+ context "when a Gemfile already exists" do
before do
create_file "Gemfile", <<-G
gem "rails"
@@ -26,28 +20,11 @@ RSpec.describe "bundle init" do
it "notifies the user that an existing Gemfile already exists" do
bundle :init
- expect(out).to include("Gemfile already exists")
+ expect(err).to include("Gemfile already exists")
end
end
- context "when gems.rb already exists", :bundler => ">= 3" do
- before do
- create_file("gems.rb", <<-G)
- gem "rails"
- G
- end
-
- it "does not change existing Gemfiles" do
- expect { bundle :init }.not_to change { File.read(bundled_app("gems.rb")) }
- end
-
- it "notifies the user that an existing gems.rb already exists" do
- bundle :init
- expect(out).to include("gems.rb already exists")
- end
- end
-
- context "when a Gemfile exists in a parent directory", :bundler => "< 3" do
+ context "when a Gemfile exists in a parent directory" do
let(:subdir) { "child_dir" }
it "lets users generate a Gemfile in a child directory" do
@@ -77,29 +54,12 @@ RSpec.describe "bundle init" do
bundle :init
end
- expect(out).to include("directory is not writable")
+ expect(err).to include("directory is not writable")
expect(Dir[bundled_app("#{subdir}/*")]).to be_empty
end
end
- context "when a gems.rb file exists in a parent directory", :bundler => ">= 3" do
- let(:subdir) { "child_dir" }
-
- it "lets users generate a Gemfile in a child directory" do
- bundle! :init
-
- FileUtils.mkdir bundled_app(subdir)
-
- Dir.chdir bundled_app(subdir) do
- bundle! :init
- end
-
- expect(out).to include("Writing new gems.rb")
- expect(bundled_app("#{subdir}/gems.rb")).to be_file
- end
- end
-
- context "given --gemspec option", :bundler => "< 3" do
+ context "given --gemspec option" do
let(:spec_file) { tmp.join("test.gemspec") }
it "should generate from an existing gemspec" do
@@ -115,11 +75,7 @@ RSpec.describe "bundle init" do
bundle :init, :gemspec => spec_file
- gemfile = if Bundler::VERSION[0, 2].to_i < 3
- bundled_app("Gemfile").read
- else
- bundled_app("gems.rb").read
- end
+ gemfile = bundled_app("Gemfile").read
expect(gemfile).to match(%r{source 'https://rubygems.org'})
expect(gemfile.scan(/gem "rack", "= 1.0.1"/).size).to eq(1)
expect(gemfile.scan(/gem "rspec", "= 1.2"/).size).to eq(1)
@@ -144,9 +100,49 @@ RSpec.describe "bundle init" do
end
context "when init_gems_rb setting is enabled" do
- before { bundle "config init_gems_rb true" }
+ before { bundle "config set init_gems_rb true" }
+
+ it "generates a gems.rb" do
+ bundle! :init
+ expect(out).to include("Writing new gems.rb")
+ expect(bundled_app("gems.rb")).to be_file
+ end
+
+ context "when gems.rb already exists" do
+ before do
+ create_file("gems.rb", <<-G)
+ gem "rails"
+ G
+ end
+
+ it "does not change existing Gemfiles" do
+ expect { bundle :init }.not_to change { File.read(bundled_app("gems.rb")) }
+ end
+
+ it "notifies the user that an existing gems.rb already exists" do
+ bundle :init
+ expect(err).to include("gems.rb already exists")
+ end
+ end
+
+ context "when a gems.rb file exists in a parent directory" do
+ let(:subdir) { "child_dir" }
+
+ it "lets users generate a Gemfile in a child directory" do
+ bundle! :init
+
+ FileUtils.mkdir bundled_app(subdir)
+
+ Dir.chdir bundled_app(subdir) do
+ bundle! :init
+ end
+
+ expect(out).to include("Writing new gems.rb")
+ expect(bundled_app("#{subdir}/gems.rb")).to be_file
+ end
+ end
- context "given --gemspec option", :bundler => "< 3" do
+ context "given --gemspec option" do
let(:spec_file) { tmp.join("test.gemspec") }
before do
diff --git a/spec/bundler/commands/inject_spec.rb b/spec/bundler/commands/inject_spec.rb
index d091e01380..da31849be7 100644
--- a/spec/bundler/commands/inject_spec.rb
+++ b/spec/bundler/commands/inject_spec.rb
@@ -37,14 +37,14 @@ RSpec.describe "bundle inject", :bundler => "< 3" do
context "with injected gems already in the Gemfile" do
it "doesn't add existing gems" do
bundle "inject 'rack' '> 0'"
- expect(out).to match(/cannot specify the same gem twice/i)
+ expect(err).to match(/cannot specify the same gem twice/i)
end
end
context "incorrect arguments" do
it "fails when more than 2 arguments are passed" do
bundle "inject gem_name 1 v"
- expect(out).to eq(<<-E.strip)
+ expect(err).to eq(<<-E.strip)
ERROR: "bundle inject" was called with arguments ["gem_name", "1", "v"]
Usage: "bundle inject GEM VERSION"
E
@@ -80,9 +80,9 @@ Usage: "bundle inject GEM VERSION"
before do
bundle "install"
if Bundler.feature_flag.bundler_3_mode?
- bundle! "config --local deployment true"
+ bundle! "config set --local deployment true"
else
- bundle! "config --local frozen true"
+ bundle! "config set --local frozen true"
end
end
@@ -109,7 +109,7 @@ Usage: "bundle inject GEM VERSION"
gem "rack-obama"
G
bundle "inject 'rack' '> 0'"
- expect(out).to match(/trying to install in deployment mode after changing/)
+ expect(err).to match(/trying to install in deployment mode after changing/)
expect(bundled_app("Gemfile.lock").read).not_to match(/rack-obama/)
end
diff --git a/spec/bundler/commands/install_spec.rb b/spec/bundler/commands/install_spec.rb
index 326f98161e..21157dd309 100644
--- a/spec/bundler/commands/install_spec.rb
+++ b/spec/bundler/commands/install_spec.rb
@@ -8,7 +8,7 @@ RSpec.describe "bundle install with gem sources" do
G
bundle :install
- expect(out).to match(/no dependencies/)
+ expect(err).to match(/no dependencies/)
end
it "does not make a lockfile if the install fails" do
@@ -311,7 +311,7 @@ RSpec.describe "bundle install with gem sources" do
G
bundle :install
- expect(out).to include("Your Gemfile has no gem server sources")
+ expect(err).to include("Your Gemfile has no gem server sources")
end
it "creates a Gemfile.lock on a blank Gemfile" do
@@ -329,9 +329,9 @@ RSpec.describe "bundle install with gem sources" do
gem "rack"
G
- expect(out).to include("Your Gemfile lists the gem rack (>= 0) more than once.")
- expect(out).to include("Remove any duplicate entries and specify the gem only once (per group).")
- expect(out).to include("While it's not a problem now, it could cause errors if you change the version of one of them later.")
+ expect(err).to include("Your Gemfile lists the gem rack (>= 0) more than once.")
+ expect(err).to include("Remove any duplicate entries and specify the gem only once (per group).")
+ expect(err).to include("While it's not a problem now, it could cause errors if you change the version of one of them later.")
end
it "with same versions" do
@@ -341,9 +341,9 @@ RSpec.describe "bundle install with gem sources" do
gem "rack", "1.0"
G
- expect(out).to include("Your Gemfile lists the gem rack (= 1.0) more than once.")
- expect(out).to include("Remove any duplicate entries and specify the gem only once (per group).")
- expect(out).to include("While it's not a problem now, it could cause errors if you change the version of one of them later.")
+ expect(err).to include("Your Gemfile lists the gem rack (= 1.0) more than once.")
+ expect(err).to include("Remove any duplicate entries and specify the gem only once (per group).")
+ expect(err).to include("While it's not a problem now, it could cause errors if you change the version of one of them later.")
end
end
@@ -355,8 +355,8 @@ RSpec.describe "bundle install with gem sources" do
gem "rack", "1.0"
G
- expect(out).to include("You cannot specify the same gem twice with different version requirements")
- expect(out).to include("You specified: rack (>= 0) and rack (= 1.0).")
+ expect(err).to include("You cannot specify the same gem twice with different version requirements")
+ expect(err).to include("You specified: rack (>= 0) and rack (= 1.0).")
end
it "when different versions of both dependencies are specified" do
@@ -366,25 +366,25 @@ RSpec.describe "bundle install with gem sources" do
gem "rack", "1.1"
G
- expect(out).to include("You cannot specify the same gem twice with different version requirements")
- expect(out).to include("You specified: rack (= 1.0) and rack (= 1.1).")
+ expect(err).to include("You cannot specify the same gem twice with different version requirements")
+ expect(err).to include("You specified: rack (= 1.0) and rack (= 1.1).")
end
end
it "gracefully handles error when rubygems server is unavailable" do
install_gemfile <<-G, :artifice => nil
source "file://#{gem_repo1}"
- source "http://localhost:9384" do
+ source "http://0.0.0.0:9384" do
gem 'foo'
end
G
bundle :install, :artifice => nil
- expect(out).to include("Could not fetch specs from http://localhost:9384/")
- expect(out).not_to include("file://")
+ expect(err).to include("Could not fetch specs from http://0.0.0.0:9384/")
+ expect(err).not_to include("file://")
end
- it "fails gracefully when downloading an invalid specification from the full index", :rubygems => "2.5" do
+ it "fails gracefully when downloading an invalid specification from the full index" do
build_repo2 do
build_gem "ajp-rails", "0.0.0", :gemspec => false, :skip_validation => true do |s|
bad_deps = [["ruby-ajp", ">= 0.2.0"], ["rails", ">= 0.14"]]
@@ -442,7 +442,7 @@ RSpec.describe "bundle install with gem sources" do
::RUBY_VERSION = '2.0.1'
ruby '~> 2.2'
G
- expect(out).to include("Your Ruby version is 2.0.1, but your Gemfile specified ~> 2.2")
+ expect(err).to include("Your Ruby version is 2.0.1, but your Gemfile specified ~> 2.2")
end
end
@@ -529,8 +529,8 @@ RSpec.describe "bundle install with gem sources" do
G
bundle :install, :quiet => true
- expect(out).to include("Could not find gem 'rack'")
- expect(out).to_not include("Your Gemfile has no gem server sources")
+ expect(err).to include("Could not find gem 'rack'")
+ expect(err).to_not include("Your Gemfile has no gem server sources")
end
end
@@ -547,8 +547,8 @@ RSpec.describe "bundle install with gem sources" do
FileUtils.chmod(0o500, bundled_app("vendor"))
bundle :install, forgotten_command_line_options(:path => "vendor")
- expect(out).to include(bundled_app("vendor").to_s)
- expect(out).to include("grant write permissions")
+ expect(err).to include(bundled_app("vendor").to_s)
+ expect(err).to include("grant write permissions")
end
end
@@ -577,10 +577,10 @@ RSpec.describe "bundle install with gem sources" do
G
end
- it "should display a helpful messag explaining how to fix it" do
+ it "should display a helpful message explaining how to fix it" do
bundle :install, :env => { "BUNDLE_RUBYGEMS__ORG" => "user:pass{word" }
expect(exitstatus).to eq(17) if exitstatus
- expect(out).to eq("Please CGI escape your usernames and passwords before " \
+ expect(err).to eq("Please CGI escape your usernames and passwords before " \
"setting them for authentication.")
end
end
diff --git a/spec/bundler/commands/licenses_spec.rb b/spec/bundler/commands/licenses_spec.rb
index d61d3492f3..21fd8eaf2f 100644
--- a/spec/bundler/commands/licenses_spec.rb
+++ b/spec/bundler/commands/licenses_spec.rb
@@ -12,14 +12,7 @@ RSpec.describe "bundle licenses" do
it "prints license information for all gems in the bundle" do
bundle "licenses"
- loaded_bundler_spec = Bundler.load.specs["bundler"]
- expected = if !loaded_bundler_spec.empty?
- loaded_bundler_spec[0].license
- else
- "Unknown"
- end
-
- expect(out).to include("bundler: #{expected}")
+ expect(err).to include("bundler: Unknown")
expect(out).to include("with_license: MIT")
end
@@ -31,7 +24,7 @@ RSpec.describe "bundle licenses" do
gem "foo"
G
- bundle "config auto_install 1"
+ bundle "config set auto_install 1"
bundle :licenses
expect(out).to include("Installing foo 1.0")
end
diff --git a/spec/bundler/commands/list_spec.rb b/spec/bundler/commands/list_spec.rb
index ba4bb9b040..346b47517e 100644
--- a/spec/bundler/commands/list_spec.rb
+++ b/spec/bundler/commands/list_spec.rb
@@ -1,20 +1,11 @@
# frozen_string_literal: true
-RSpec.describe "bundle list", :bundler => "3" do
- before do
- install_gemfile <<-G
- source "file://#{gem_repo1}"
-
- gem "rack"
- gem "rspec", :group => [:test]
- G
- end
-
+RSpec.describe "bundle list" do
context "with name-only and paths option" do
it "raises an error" do
bundle "list --name-only --paths"
- expect(out).to eq "The `--name-only` and `--paths` options cannot be used together"
+ expect(err).to eq "The `--name-only` and `--paths` options cannot be used together"
end
end
@@ -22,11 +13,20 @@ RSpec.describe "bundle list", :bundler => "3" do
it "raises an error" do
bundle "list --without-group dev --only-group test"
- expect(out).to eq "The `--only-group` and `--without-group` options cannot be used together"
+ expect(err).to eq "The `--only-group` and `--without-group` options cannot be used together"
end
end
describe "with without-group option" do
+ before do
+ install_gemfile <<-G
+ source "file://#{gem_repo1}"
+
+ gem "rack"
+ gem "rspec", :group => [:test]
+ G
+ end
+
context "when group is present" do
it "prints the gems not in the specified group" do
bundle! "list --without-group test"
@@ -40,12 +40,21 @@ RSpec.describe "bundle list", :bundler => "3" do
it "raises an error" do
bundle "list --without-group random"
- expect(out).to eq "`random` group could not be found."
+ expect(err).to eq "`random` group could not be found."
end
end
end
describe "with only-group option" do
+ before do
+ install_gemfile <<-G
+ source "file://#{gem_repo1}"
+
+ gem "rack"
+ gem "rspec", :group => [:test]
+ G
+ end
+
context "when group is present" do
it "prints the gems in the specified group" do
bundle! "list --only-group default"
@@ -59,12 +68,21 @@ RSpec.describe "bundle list", :bundler => "3" do
it "raises an error" do
bundle "list --only-group random"
- expect(out).to eq "`random` group could not be found."
+ expect(err).to eq "`random` group could not be found."
end
end
end
context "with name-only option" do
+ before do
+ install_gemfile <<-G
+ source "file://#{gem_repo1}"
+
+ gem "rack"
+ gem "rspec", :group => [:test]
+ G
+ end
+
it "prints only the name of the gems in the bundle" do
bundle "list --name-only"
@@ -82,7 +100,6 @@ RSpec.describe "bundle list", :bundler => "3" do
build_git "git_test", "1.0.0", :path => lib_path("git_test")
build_lib("gemspec_test", :path => tmp.join("gemspec_test")) do |s|
- s.write("Gemfile", "source :rubygems\ngemspec")
s.add_dependency "bar", "=1.0.0"
end
@@ -93,8 +110,6 @@ RSpec.describe "bundle list", :bundler => "3" do
gem "git_test", :git => "#{lib_path("git_test")}"
gemspec :path => "#{tmp.join("gemspec_test")}"
G
-
- bundle! "install"
end
it "prints the path of each gem in the bundle" do
@@ -119,13 +134,35 @@ RSpec.describe "bundle list", :bundler => "3" do
end
end
- it "lists gems installed in the bundle" do
- bundle "list"
- expect(out).to include(" * rack (1.0.0)")
+ context "without options" do
+ before do
+ install_gemfile <<-G
+ source "file://#{gem_repo1}"
+
+ gem "rack"
+ gem "rspec", :group => [:test]
+ G
+ end
+
+ it "lists gems installed in the bundle" do
+ bundle "list"
+ expect(out).to include(" * rack (1.0.0)")
+ end
end
- it "aliases the ls command to list" do
- bundle "ls"
- expect(out).to include("Gems included by the bundle")
+ context "when using the ls alias" do
+ before do
+ install_gemfile <<-G
+ source "file://#{gem_repo1}"
+
+ gem "rack"
+ gem "rspec", :group => [:test]
+ G
+ end
+
+ it "runs the list command" do
+ bundle "ls"
+ expect(out).to include("Gems included by the bundle")
+ end
end
end
diff --git a/spec/bundler/commands/lock_spec.rb b/spec/bundler/commands/lock_spec.rb
index 0b77605f01..f876d719cc 100644
--- a/spec/bundler/commands/lock_spec.rb
+++ b/spec/bundler/commands/lock_spec.rb
@@ -38,8 +38,8 @@ RSpec.describe "bundle lock" do
actionpack (= 2.3.2)
activerecord (= 2.3.2)
activeresource (= 2.3.2)
- rake (= 10.0.2)
- rake (10.0.2)
+ rake (= 12.3.2)
+ rake (12.3.2)
with_license (1.0)
PLATFORMS
@@ -86,14 +86,41 @@ RSpec.describe "bundle lock" do
it "does not fetch remote specs when using the --local option" do
bundle "lock --update --local"
- expect(out).to match(/sources listed in your Gemfile|installed locally/)
+ expect(err).to match(/sources listed in your Gemfile|installed locally/)
+ end
+
+ it "works with --gemfile flag" do
+ create_file "CustomGemfile", <<-G
+ source "file://localhost#{repo}"
+ gem "foo"
+ G
+ lockfile = strip_lockfile(normalize_uri_file(<<-L))
+ GEM
+ remote: file://localhost#{repo}/
+ specs:
+ foo (1.0)
+
+ PLATFORMS
+ #{lockfile_platforms}
+
+ DEPENDENCIES
+ foo
+
+ BUNDLED WITH
+ #{Bundler::VERSION}
+ L
+ bundle "lock --gemfile CustomGemfile"
+
+ expect(out).to match(/Writing lockfile to.+CustomGemfile\.lock/)
+ expect(read_lockfile("CustomGemfile.lock")).to eq(lockfile)
+ expect { read_lockfile }.to raise_error(Errno::ENOENT)
end
it "writes to a custom location using --lockfile" do
bundle "lock --lockfile=lock"
expect(out).to match(/Writing lockfile to.+lock/)
- expect(read_lockfile "lock").to eq(@lockfile)
+ expect(read_lockfile("lock")).to eq(@lockfile)
expect { read_lockfile }.to raise_error(Errno::ENOENT)
end
@@ -106,7 +133,7 @@ RSpec.describe "bundle lock" do
end
it "update specific gems using --update" do
- lockfile @lockfile.gsub("2.3.2", "2.3.1").gsub("10.0.2", "10.0.1")
+ lockfile @lockfile.gsub("2.3.2", "2.3.1").gsub("12.3.2", "10.0.1")
bundle "lock --update rails rake"
@@ -117,11 +144,24 @@ RSpec.describe "bundle lock" do
lockfile @lockfile
bundle "lock --update blahblah"
- expect(out).to eq("Could not find gem 'blahblah'.")
+ expect(err).to eq("Could not find gem 'blahblah'.")
expect(read_lockfile).to eq(@lockfile)
end
+ it "can lock without downloading gems" do
+ gemfile <<-G
+ source "file://#{gem_repo1}"
+
+ gem "thin"
+ gem "rack_middleware", :group => "test"
+ G
+ bundle! "config set without test"
+ bundle! "config set path .bundle"
+ bundle! "lock"
+ expect(bundled_app(".bundle")).not_to exist
+ end
+
# see update_spec for more coverage on same options. logic is shared so it's not necessary
# to repeat coverage here.
context "conservative updates" do
@@ -185,7 +225,7 @@ RSpec.describe "bundle lock" do
it "warns when adding an unknown platform" do
bundle "lock --add-platform foobarbaz"
- expect(out).to include("The platform `foobarbaz` is unknown to RubyGems and adding it will likely lead to resolution errors")
+ expect(err).to include("The platform `foobarbaz` is unknown to RubyGems and adding it will likely lead to resolution errors")
end
it "allows removing platforms" do
diff --git a/spec/bundler/commands/newgem_spec.rb b/spec/bundler/commands/newgem_spec.rb
index e6d6e19122..0d1058ad11 100644
--- a/spec/bundler/commands/newgem_spec.rb
+++ b/spec/bundler/commands/newgem_spec.rb
@@ -6,18 +6,8 @@ RSpec.describe "bundle gem" do
global_config "BUNDLE_GEM__MIT" => "false", "BUNDLE_GEM__TEST" => "false", "BUNDLE_GEM__COC" => "false"
end
- def remove_push_guard(gem_name)
- # Remove exception that prevents public pushes on older RubyGems versions
- if Gem::Version.new(Gem::VERSION) < Gem::Version.new("2.0")
- path = "#{gem_name}/#{gem_name}.gemspec"
- content = File.read(path).sub(/raise "RubyGems 2\.0 or newer.*/, "")
- File.open(path, "w") {|f| f.write(content) }
- end
- end
-
- def execute_bundle_gem(gem_name, flag = "", to_remove_push_guard = true)
+ def execute_bundle_gem(gem_name, flag = "")
bundle! "gem #{gem_name} #{flag}"
- remove_push_guard(gem_name) if to_remove_push_guard
# reset gemspec cache for each test because of commit 3d4163a
Bundler.clear_gemspec_cache
end
@@ -96,7 +86,7 @@ RSpec.describe "bundle gem" do
shared_examples_for "--coc flag" do
before do
- execute_bundle_gem(gem_name, "--coc", false)
+ execute_bundle_gem(gem_name, "--coc")
end
it "generates a gem skeleton with MIT license" do
gem_skeleton_assertions(gem_name)
@@ -113,7 +103,7 @@ RSpec.describe "bundle gem" do
shared_examples_for "--no-coc flag" do
before do
- execute_bundle_gem(gem_name, "--no-coc", false)
+ execute_bundle_gem(gem_name, "--no-coc")
end
it "generates a gem skeleton without Code of Conduct" do
gem_skeleton_assertions(gem_name)
@@ -149,7 +139,6 @@ RSpec.describe "bundle gem" do
reset!
in_app_root
bundle "gem #{gem_name}"
- remove_push_guard(gem_name)
end
it "contribute URL set to [USERNAME]" do
@@ -173,7 +162,7 @@ RSpec.describe "bundle gem" do
load_paths = [lib, spec]
load_path_str = "-I#{load_paths.join(File::PATH_SEPARATOR)}"
- sys_exec "PATH=\"\" #{Gem.ruby} #{load_path_str} #{bindir.join("bundle")} gem #{gem_name}"
+ sys_exec "#{Gem.ruby} #{load_path_str} #{bindir.join("bundle")} gem #{gem_name}", "PATH" => ""
end
it "creates the gem without the need for git" do
@@ -202,16 +191,13 @@ RSpec.describe "bundle gem" do
line.gsub(/\=.*$/, "= %q{A short summary of my new gem.}")
when /spec\.description/
line.gsub(/\=.*$/, "= %q{A longer description of my new gem.}")
- # Remove exception that prevents public pushes on older RubyGems versions
- when /raise "RubyGems 2.0 or newer/
- line.gsub(/.*/, "") if Gem::Version.new(Gem::VERSION) < Gem::Version.new("2.0")
else
line
end
end
Dir.chdir(bundled_app("newgem")) do
- gems = ["rake-10.0.2", :bundler]
+ gems = ["rake-12.3.2", :bundler]
# for Ruby core repository, Ruby 2.6+ has bundler as standard library.
gems.delete(:bundler) if ruby_core?
system_gems gems, :path => :bundle_path
@@ -298,13 +284,12 @@ RSpec.describe "bundle gem" do
reset!
in_app_root
bundle "gem #{gem_name}"
- remove_push_guard(gem_name)
end
it_should_behave_like "git config is absent"
end
- it "sets gemspec metadata['allowed_push_host']", :rubygems => "2.0" do
+ it "sets gemspec metadata['allowed_push_host']" do
expect(generated_gem.gemspec.metadata["allowed_push_host"]).
to match(/mygemserver\.com/)
end
@@ -318,7 +303,7 @@ RSpec.describe "bundle gem" do
end
it "runs rake without problems" do
- system_gems ["rake-10.0.2"]
+ system_gems ["rake-12.3.2"]
rakefile = strip_whitespace <<-RAKEFILE
task :default do
@@ -396,8 +381,7 @@ RSpec.describe "bundle gem" do
expect(bundled_app("test_gem/spec/spec_helper.rb")).to exist
end
- it "depends on a specific version of rspec", :rubygems => ">= 1.8.1" do
- remove_push_guard(gem_name)
+ it "depends on a specific version of rspec" do
rspec_dep = generated_gem.gemspec.development_dependencies.find {|d| d.name == "rspec" }
expect(rspec_dep).to be_specific
end
@@ -415,7 +399,7 @@ RSpec.describe "bundle gem" do
before do
reset!
in_app_root
- bundle "config gem.test rspec"
+ bundle "config set gem.test rspec"
bundle "gem #{gem_name}"
end
@@ -430,7 +414,7 @@ RSpec.describe "bundle gem" do
before do
reset!
in_app_root
- bundle "config gem.test rspec"
+ bundle "config set gem.test rspec"
bundle "gem #{gem_name} --test=minitest"
end
@@ -447,8 +431,7 @@ RSpec.describe "bundle gem" do
bundle "gem #{gem_name} --test=minitest"
end
- it "depends on a specific version of minitest", :rubygems => ">= 1.8.1" do
- remove_push_guard(gem_name)
+ it "depends on a specific version of minitest" do
rspec_dep = generated_gem.gemspec.development_dependencies.find {|d| d.name == "minitest" }
expect(rspec_dep).to be_specific
end
@@ -475,7 +458,7 @@ RSpec.describe "bundle gem" do
before do
reset!
in_app_root
- bundle "config gem.test minitest"
+ bundle "config set gem.test minitest"
bundle "gem #{gem_name}"
end
@@ -592,7 +575,6 @@ RSpec.describe "bundle gem" do
reset!
in_app_root
bundle "gem #{gem_name}"
- remove_push_guard(gem_name)
end
it_should_behave_like "git config is absent"
@@ -603,7 +585,7 @@ RSpec.describe "bundle gem" do
end
it "runs rake without problems" do
- system_gems ["rake-10.0.2"]
+ system_gems ["rake-12.3.2"]
rakefile = strip_whitespace <<-RAKEFILE
task :default do
@@ -820,22 +802,22 @@ Usage: "bundle gem NAME [OPTIONS]"
context "with an existing const name" do
subject { "gem" }
- it { expect(out).to include("Invalid gem name #{subject}") }
+ it { expect(err).to include("Invalid gem name #{subject}") }
end
context "with an existing hyphenated const name" do
subject { "gem-specification" }
- it { expect(out).to include("Invalid gem name #{subject}") }
+ it { expect(err).to include("Invalid gem name #{subject}") }
end
context "starting with an existing const name" do
subject { "gem-somenewconstantname" }
- it { expect(out).not_to include("Invalid gem name #{subject}") }
+ it { expect(err).not_to include("Invalid gem name #{subject}") }
end
context "ending with an existing const name" do
subject { "somenewconstantname-gem" }
- it { expect(out).not_to include("Invalid gem name #{subject}") }
+ it { expect(err).not_to include("Invalid gem name #{subject}") }
end
end
@@ -868,7 +850,7 @@ Usage: "bundle gem NAME [OPTIONS]"
it "asks about MIT license" do
global_config "BUNDLE_GEM__TEST" => "false", "BUNDLE_GEM__COC" => "false"
- bundle :config
+ bundle "config list"
bundle "gem foobar" do |input, _, _|
input.puts "yes"
diff --git a/spec/bundler/commands/open_spec.rb b/spec/bundler/commands/open_spec.rb
index 5cab846fb5..659445da33 100644
--- a/spec/bundler/commands/open_spec.rb
+++ b/spec/bundler/commands/open_spec.rb
@@ -30,7 +30,7 @@ RSpec.describe "bundle open" do
it "complains if gem not in bundle" do
bundle "open missing", :env => { "EDITOR" => "echo editor", "VISUAL" => "", "BUNDLER_EDITOR" => "" }
- expect(out).to match(/could not find gem 'missing'/i)
+ expect(err).to match(/could not find gem 'missing'/i)
end
it "does not blow up if the gem to open does not have a Gemfile" do
@@ -48,7 +48,7 @@ RSpec.describe "bundle open" do
it "suggests alternatives for similar-sounding gems" do
bundle "open Rails", :env => { "EDITOR" => "echo editor", "VISUAL" => "", "BUNDLER_EDITOR" => "" }
- expect(out).to match(/did you mean rails\?/i)
+ expect(err).to match(/did you mean rails\?/i)
end
it "opens the gem with short words" do
@@ -80,7 +80,7 @@ RSpec.describe "bundle open" do
gem "foo"
G
- bundle "config auto_install 1"
+ bundle "config set auto_install 1"
bundle "open rails", :env => { "EDITOR" => "echo editor", "VISUAL" => "", "BUNDLER_EDITOR" => "" }
expect(out).to include("Installing foo 1.0")
end
diff --git a/spec/bundler/commands/outdated_spec.rb b/spec/bundler/commands/outdated_spec.rb
index c9d3ac1de4..843bebf6e0 100644
--- a/spec/bundler/commands/outdated_spec.rb
+++ b/spec/bundler/commands/outdated_spec.rb
@@ -135,6 +135,17 @@ RSpec.describe "bundle outdated" do
expect(out).to include("activesupport")
expect(out).to include("duradura")
end
+
+ it "returns a sorted list of outdated gems from one group => 'test'" do
+ test_group_option("test", 2)
+
+ expect(out).not_to include("===== Group default =====")
+ expect(out).not_to include("terranova (")
+
+ expect(out).to include("===== Group development, test =====")
+ expect(out).to include("activesupport")
+ expect(out).to include("duradura")
+ end
end
describe "with --groups option" do
@@ -191,7 +202,7 @@ RSpec.describe "bundle outdated" do
build_gem "activesupport", "2.3.4"
end
- bundle! "config clean false"
+ bundle! "config set clean false"
install_gemfile <<-G
source "file://#{gem_repo2}"
@@ -302,14 +313,15 @@ RSpec.describe "bundle outdated" do
end
end
- describe "with --strict option" do
+ filter_strict_option = Bundler.feature_flag.bundler_2_mode? ? :"filter-strict" : :strict
+ describe "with --#{filter_strict_option} option" do
it "only reports gems that have a newer version that matches the specified dependency version requirements" do
update_repo2 do
build_gem "activesupport", "3.0"
build_gem "weakling", "0.0.5"
end
- bundle "outdated --strict"
+ bundle :outdated, filter_strict_option => true
expect(out).to_not include("activesupport (newest")
expect(out).to include("(newest 0.0.5, installed 0.0.3, requested ~> 0.0.1)")
@@ -321,7 +333,7 @@ RSpec.describe "bundle outdated" do
gem "rack_middleware", "1.0"
G
- bundle "outdated --strict"
+ bundle :outdated, filter_strict_option => true
expect(out).to_not include("rack (1.2")
end
@@ -339,7 +351,7 @@ RSpec.describe "bundle outdated" do
build_gem "weakling", "0.0.5"
end
- bundle "outdated --strict --filter-patch"
+ bundle :outdated, filter_strict_option => true, "filter-patch" => true
expect(out).to_not include("activesupport (newest")
expect(out).to include("(newest 0.0.5, installed 0.0.3")
@@ -357,7 +369,7 @@ RSpec.describe "bundle outdated" do
build_gem "weakling", "0.1.5"
end
- bundle "outdated --strict --filter-minor"
+ bundle :outdated, filter_strict_option => true, "filter-minor" => true
expect(out).to_not include("activesupport (newest")
expect(out).to include("(newest 0.1.5, installed 0.0.3")
@@ -375,7 +387,7 @@ RSpec.describe "bundle outdated" do
build_gem "weakling", "1.1.5"
end
- bundle "outdated --strict --filter-major"
+ bundle :outdated, filter_strict_option => true, "filter-major" => true
expect(out).to_not include("activesupport (newest")
expect(out).to include("(newest 1.1.5, installed 0.0.3")
@@ -386,7 +398,7 @@ RSpec.describe "bundle outdated" do
describe "with invalid gem name" do
it "returns could not find gem name" do
bundle "outdated invalid_gem_name"
- expect(out).to include("Could not find gem 'invalid_gem_name'.")
+ expect(err).to include("Could not find gem 'invalid_gem_name'.")
end
it "returns non-zero exit code" do
@@ -402,7 +414,7 @@ RSpec.describe "bundle outdated" do
gem "foo"
G
- bundle "config auto_install 1"
+ bundle "config set auto_install 1"
bundle :outdated
expect(out).to include("Installing foo 1.0")
end
@@ -422,14 +434,14 @@ RSpec.describe "bundle outdated" do
bundle "outdated"
expect(last_command).to be_failure
- expect(out).to include("You are trying to check outdated gems in deployment mode.")
- expect(out).to include("Run `bundle outdated` elsewhere.")
- expect(out).to include("If this is a development machine, remove the ")
- expect(out).to include("Gemfile freeze\nby running `bundle install --no-deployment`.")
+ expect(err).to include("You are trying to check outdated gems in deployment mode.")
+ expect(err).to include("Run `bundle outdated` elsewhere.")
+ expect(err).to include("If this is a development machine, remove the ")
+ expect(err).to include("Gemfile freeze\nby running `bundle install --no-deployment`.")
end
end
- context "after bundle config deployment true" do
+ context "after bundle config set deployment true" do
before do
install_gemfile <<-G
source "file://#{gem_repo2}"
@@ -437,7 +449,7 @@ RSpec.describe "bundle outdated" do
gem "rack"
gem "foo"
G
- bundle! "config deployment true"
+ bundle! "config set deployment true"
end
it "outputs a helpful message about being in deployment mode" do
@@ -445,10 +457,10 @@ RSpec.describe "bundle outdated" do
bundle "outdated"
expect(last_command).to be_failure
- expect(out).to include("You are trying to check outdated gems in deployment mode.")
- expect(out).to include("Run `bundle outdated` elsewhere.")
- expect(out).to include("If this is a development machine, remove the ")
- expect(out).to include("Gemfile freeze\nby running `bundle config --delete deployment`.")
+ expect(err).to include("You are trying to check outdated gems in deployment mode.")
+ expect(err).to include("Run `bundle outdated` elsewhere.")
+ expect(err).to include("If this is a development machine, remove the ")
+ expect(err).to include("Gemfile freeze\nby running `bundle config unset deployment`.")
end
end
diff --git a/spec/bundler/commands/package_spec.rb b/spec/bundler/commands/package_spec.rb
index a8426e6322..6cd8e3f85a 100644
--- a/spec/bundler/commands/package_spec.rb
+++ b/spec/bundler/commands/package_spec.rb
@@ -179,10 +179,22 @@ RSpec.describe "bundle package" do
expect(the_bundle).to include_gems "rack 1.0.0"
end
+
+ it "does not prevent installing gems with bundle update" do
+ gemfile <<-D
+ source "file://#{gem_repo1}"
+ gem "rack", "1.0.0"
+ D
+
+ bundle! "package --no-install"
+ bundle! "update --all"
+
+ expect(the_bundle).to include_gems "rack 1.0.0"
+ end
end
context "with --all-platforms" do
- it "puts the gems in vendor/cache even for other rubies", :ruby => "2.1" do
+ it "puts the gems in vendor/cache even for other rubies" do
gemfile <<-D
source "file://#{gem_repo1}"
gem 'rack', :platforms => :ruby_19
@@ -205,7 +217,7 @@ RSpec.describe "bundle package" do
subject { bundle :package, forgotten_command_line_options(:frozen => true) }
it "tries to install with frozen" do
- bundle! "config deployment true"
+ bundle! "config set deployment true"
gemfile <<-G
source "file://#{gem_repo1}"
gem "rack"
@@ -213,9 +225,9 @@ RSpec.describe "bundle package" do
G
subject
expect(exitstatus).to eq(16) if exitstatus
- expect(out).to include("deployment mode")
- expect(out).to include("You have added to the Gemfile")
- expect(out).to include("* rack-obama")
+ expect(err).to include("deployment mode")
+ expect(err).to include("You have added to the Gemfile")
+ expect(err).to include("* rack-obama")
bundle "env"
expect(out).to include("frozen").or include("deployment")
end
@@ -266,7 +278,7 @@ RSpec.describe "bundle install with gem sources" do
end
bundle :install
- expect(err).to lack_errors
+ expect(last_command.stderr).to be_empty
expect(the_bundle).to include_gems "rack 1.0"
end
diff --git a/spec/bundler/commands/pristine_spec.rb b/spec/bundler/commands/pristine_spec.rb
index d8761bba26..93eb81f2af 100644
--- a/spec/bundler/commands/pristine_spec.rb
+++ b/spec/bundler/commands/pristine_spec.rb
@@ -42,7 +42,7 @@ RSpec.describe "bundle pristine", :ruby_repo do
expect(changes_txt).to_not be_file
end
- it "does not delete the bundler gem" do
+ it "does not delete the bundler gem", :rubygems => ">= 2.6.2" do
ENV["BUNDLER_SPEC_KEEP_DEFAULT_BUNDLER_GEM"] = "true"
system_gems :bundler
bundle! "install"
@@ -95,7 +95,7 @@ RSpec.describe "bundle pristine", :ruby_repo do
bundle "pristine"
expect(File.read(changed_file)).to include(diff)
- expect(out).to include("Cannot pristine #{spec.name} (#{spec.version}#{spec.git_version}). Gem is sourced from local path.")
+ expect(err).to include("Cannot pristine #{spec.name} (#{spec.version}#{spec.git_version}). Gem is sourced from local path.")
end
it "reinstall gemspec dependency" do
@@ -118,7 +118,7 @@ RSpec.describe "bundle pristine", :ruby_repo do
FileUtils.touch(changes_txt)
expect(changes_txt).to be_file
bundle "pristine"
- expect(out).to include("Cannot pristine #{spec.name} (#{spec.version}#{spec.git_version}). Gem is sourced from local path.")
+ expect(err).to include("Cannot pristine #{spec.name} (#{spec.version}#{spec.git_version}). Gem is sourced from local path.")
expect(changes_txt).to be_file
end
end
@@ -142,8 +142,8 @@ RSpec.describe "bundle pristine", :ruby_repo do
bundle! "pristine foo bar weakling"
- expect(out).to include("Cannot pristine bar (1.0). Gem is sourced from local path.").
- and include("Installing weakling 1.0")
+ expect(err).to include("Cannot pristine bar (1.0). Gem is sourced from local path.")
+ expect(out).to include("Installing weakling 1.0")
expect(weakling_changes_txt).not_to be_file
expect(foo_changes_txt).not_to be_file
@@ -152,7 +152,7 @@ RSpec.describe "bundle pristine", :ruby_repo do
it "raises when one of them is not in the lockfile" do
bundle "pristine abcabcabc"
- expect(out).to include("Could not find gem 'abcabcabc'.")
+ expect(err).to include("Could not find gem 'abcabcabc'.")
end
end
@@ -160,7 +160,7 @@ RSpec.describe "bundle pristine", :ruby_repo do
let(:very_simple_binary) { Bundler.definition.specs["very_simple_binary"].first }
let(:c_ext_dir) { Pathname.new(very_simple_binary.full_gem_path).join("ext") }
let(:build_opt) { "--with-ext-lib=#{c_ext_dir}" }
- before { bundle "config build.very_simple_binary -- #{build_opt}" }
+ before { bundle "config set build.very_simple_binary -- #{build_opt}" }
# This just verifies that the generated Makefile from the c_ext gem makes
# use of the build_args from the bundle config
@@ -177,7 +177,7 @@ RSpec.describe "bundle pristine", :ruby_repo do
let(:git_with_ext) { Bundler.definition.specs["git_with_ext"].first }
let(:c_ext_dir) { Pathname.new(git_with_ext.full_gem_path).join("ext") }
let(:build_opt) { "--with-ext-lib=#{c_ext_dir}" }
- before { bundle "config build.git_with_ext -- #{build_opt}" }
+ before { bundle "config set build.git_with_ext -- #{build_opt}" }
# This just verifies that the generated Makefile from the c_ext gem makes
# use of the build_args from the bundle config
diff --git a/spec/bundler/commands/remove_spec.rb b/spec/bundler/commands/remove_spec.rb
index faeb654b14..7695d2a881 100644
--- a/spec/bundler/commands/remove_spec.rb
+++ b/spec/bundler/commands/remove_spec.rb
@@ -9,7 +9,7 @@ RSpec.describe "bundle remove" do
bundle "remove"
- expect(out).to include("Please specify gems to remove.")
+ expect(err).to include("Please specify gems to remove.")
end
end
@@ -54,7 +54,7 @@ RSpec.describe "bundle remove" do
bundle "remove rack"
- expect(out).to include("`rack` is not specified in #{bundled_app("Gemfile")} so it could not be removed.")
+ expect(err).to include("`rack` is not specified in #{bundled_app("Gemfile")} so it could not be removed.")
end
end
end
@@ -91,7 +91,7 @@ RSpec.describe "bundle remove" do
bundle "remove rails rack minitest"
- expect(out).to include("`rack` is not specified in #{bundled_app("Gemfile")} so it could not be removed.")
+ expect(err).to include("`rack` is not specified in #{bundled_app("Gemfile")} so it could not be removed.")
gemfile_should_be <<-G
source "file://#{gem_repo1}"
@@ -140,6 +140,30 @@ RSpec.describe "bundle remove" do
end
end
+ context "when gem to be removed is outside block" do
+ it "does not modify group" do
+ gemfile <<-G
+ source "file://#{gem_repo1}"
+
+ gem "rack"
+ group :test do
+ gem "coffee-script-source"
+ end
+ G
+
+ bundle! "remove rack"
+
+ expect(out).to include("rack was removed.")
+ gemfile_should_be <<-G
+ source "file://#{gem_repo1}"
+
+ group :test do
+ gem "coffee-script-source"
+ end
+ G
+ end
+ end
+
context "when an empty block is also present" do
it "removes all empty blocks" do
gemfile <<-G
@@ -294,11 +318,7 @@ RSpec.describe "bundle remove" do
bundle "remove rails"
- if Gem::VERSION >= "1.6.0"
- expect(out).to include("Gems could not be removed. rack (>= 0) would also have been removed.")
- else
- expect(out).to include("Gems could not be removed. rack (>= 0, runtime) would also have been removed.")
- end
+ expect(err).to include("Gems could not be removed. rack (>= 0) would also have been removed.")
gemfile_should_be <<-G
source "file://#{gem_repo1}"
gem "rack"; gem "rails"
@@ -416,7 +436,7 @@ RSpec.describe "bundle remove" do
bundle "remove rack"
- expect(out).to include("`rack` is not specified in #{bundled_app("Gemfile")} so it could not be removed.")
+ expect(err).to include("`rack` is not specified in #{bundled_app("Gemfile")} so it could not be removed.")
end
end
@@ -436,7 +456,7 @@ RSpec.describe "bundle remove" do
bundle "remove rack"
expect(out).to include("rack was removed.")
- expect(out).to include("`rack` is not specified in #{bundled_app("Gemfile-other")} so it could not be removed.")
+ expect(err).to include("`rack` is not specified in #{bundled_app("Gemfile-other")} so it could not be removed.")
gemfile_should_be <<-G
source "file://#{gem_repo1}"
@@ -461,11 +481,7 @@ RSpec.describe "bundle remove" do
bundle "remove rack"
expect(out).to include("rack was removed.")
- if Gem::VERSION >= "1.6.0"
- expect(out).to include("Gems could not be removed. rails (>= 0) would also have been removed.")
- else
- expect(out).to include("Gems could not be removed. rails (>= 0, runtime) would also have been removed.")
- end
+ expect(err).to include("Gems could not be removed. rails (>= 0) would also have been removed.")
gemfile_should_be <<-G
source "file://#{gem_repo1}"
@@ -489,11 +505,7 @@ RSpec.describe "bundle remove" do
bundle "remove rack"
- if Gem::VERSION >= "1.6.0"
- expect(out).to include("Gems could not be removed. rails (>= 0) would also have been removed.")
- else
- expect(out).to include("Gems could not be removed. rails (>= 0, runtime) would also have been removed.")
- end
+ expect(err).to include("Gems could not be removed. rails (>= 0) would also have been removed.")
expect(bundled_app("Gemfile-other").read).to include("gem \"rack\"")
gemfile_should_be <<-G
source "file://#{gem_repo1}"
diff --git a/spec/bundler/commands/show_spec.rb b/spec/bundler/commands/show_spec.rb
index a5c6beec1a..8fb6631f82 100644
--- a/spec/bundler/commands/show_spec.rb
+++ b/spec/bundler/commands/show_spec.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-RSpec.describe "bundle show", :bundler => "< 3", :ruby => ">= 2.0" do
+RSpec.describe "bundle show", :bundler => "< 3" do
context "with a standard Gemfile" do
before :each do
install_gemfile <<-G
@@ -30,46 +30,9 @@ RSpec.describe "bundle show", :bundler => "< 3", :ruby => ">= 2.0" do
expect(out).to eq(default_bundle_path("gems", "rails-2.3.2").to_s)
end
- context "when show command deprecation is enabled" do
- before { bundle "config major_deprecations yes" }
-
- it "prints path if gem exists in bundle" do
- bundle "show rails"
- expect(out).to eq(
- "[DEPRECATED FOR 3.0] use `bundle info rails` instead of `bundle show rails`\n" +
- default_bundle_path("gems", "rails-2.3.2").to_s
- )
- end
-
- it "prints the path to the running bundler" do
- bundle "show bundler"
- expect(out).to eq(
- "[DEPRECATED FOR 3.0] use `bundle info bundler` instead of `bundle show bundler`\n" +
- root.to_s
- )
- end
-
- it "prints path if gem exists in bundle (with --paths option)" do
- bundle "show rails --paths"
- expect(out).to eq(
- "[DEPRECATED FOR 3.0] use `bundle info rails --path` instead of `bundle show rails --paths`\n" +
- default_bundle_path("gems", "rails-2.3.2").to_s
- )
- end
-
- it "prints path of all gems in bundle sorted by name" do
- bundle "show --paths"
-
- expect(out).to include(default_bundle_path("gems", "rake-10.0.2").to_s)
- expect(out).to include(default_bundle_path("gems", "rails-2.3.2").to_s)
-
- out_lines = out.split("\n")
- expect(out_lines[0]).to eq("[DEPRECATED FOR 3.0] use `bundle list` instead of `bundle show --paths`")
-
- # Gem names are the last component of their path.
- gem_list = out_lines[1..-1].map {|p| p.split("/").last }
- expect(gem_list).to eq(gem_list.sort)
- end
+ it "prints deprecation" do
+ bundle "show rails"
+ expect(err).to eq("[DEPRECATED] use `bundle info rails` instead of `bundle show rails`")
end
it "prints path if gem exists in bundle (with --paths option)" do
@@ -77,13 +40,18 @@ RSpec.describe "bundle show", :bundler => "< 3", :ruby => ">= 2.0" do
expect(out).to eq(default_bundle_path("gems", "rails-2.3.2").to_s)
end
+ it "prints deprecation when called with a gem and the --paths option" do
+ bundle "show rails --paths"
+ expect(err).to eq("[DEPRECATED] use `bundle info rails --path` instead of `bundle show rails --paths`")
+ end
+
it "warns if path no longer exists on disk" do
FileUtils.rm_rf(default_bundle_path("gems", "rails-2.3.2"))
bundle "show rails"
- expect(out).to match(/has been deleted/i).
- and include(default_bundle_path("gems", "rails-2.3.2").to_s)
+ expect(err).to match(/has been deleted/i)
+ expect(err).to match(default_bundle_path("gems", "rails-2.3.2").to_s)
end
it "prints the path to the running bundler" do
@@ -91,15 +59,19 @@ RSpec.describe "bundle show", :bundler => "< 3", :ruby => ">= 2.0" do
expect(out).to eq(root.to_s)
end
+ it "prints deprecation when called with bundler" do
+ bundle "show bundler"
+ expect(err).to eq("[DEPRECATED] use `bundle info bundler` instead of `bundle show bundler`")
+ end
it "complains if gem not in bundle" do
bundle "show missing"
- expect(out).to match(/could not find gem 'missing'/i)
+ expect(err).to match(/could not find gem 'missing'/i)
end
it "prints path of all gems in bundle sorted by name" do
bundle "show --paths"
- expect(out).to include(default_bundle_path("gems", "rake-10.0.2").to_s)
+ expect(out).to include(default_bundle_path("gems", "rake-12.3.2").to_s)
expect(out).to include(default_bundle_path("gems", "rails-2.3.2").to_s)
# Gem names are the last component of their path.
@@ -107,19 +79,18 @@ RSpec.describe "bundle show", :bundler => "< 3", :ruby => ">= 2.0" do
expect(gem_list).to eq(gem_list.sort)
end
+ it "prints a deprecation when called with the --paths option" do
+ bundle "show --paths"
+
+ expect(err).to eq("[DEPRECATED] use `bundle list` instead of `bundle show --paths`")
+ end
+
it "prints summary of gems" do
bundle "show --verbose"
- loaded_bundler_spec = Bundler.load.specs["bundler"]
- expected = if !loaded_bundler_spec.empty?
- loaded_bundler_spec[0].homepage
- else
- "No website available."
- end
-
expect(out).to include("* actionmailer (2.3.2)")
expect(out).to include("\tSummary: This is just a fake gem for testing")
- expect(out).to include("\tHomepage: #{expected}")
+ expect(out).to include("\tHomepage: No website available.")
expect(out).to include("\tStatus: Up to date")
end
end
@@ -164,7 +135,7 @@ RSpec.describe "bundle show", :bundler => "< 3", :ruby => ">= 2.0" do
expect(out).to include("foo (1.0 #{sha[0..6]})")
end
- it "handles when a version is a '-' prerelease", :rubygems => "2.1" do
+ it "handles when a version is a '-' prerelease" do
@git = build_git("foo", "1.0.0-beta.1", :path => lib_path("foo"))
install_gemfile <<-G
gem "foo", "1.0.0-beta.1", :git => "#{lib_path("foo")}"
@@ -186,7 +157,7 @@ RSpec.describe "bundle show", :bundler => "< 3", :ruby => ">= 2.0" do
it "does not output git errors" do
bundle :show
- expect(err).to lack_errors
+ expect(err_without_deprecations).to be_empty
end
end
@@ -196,11 +167,24 @@ RSpec.describe "bundle show", :bundler => "< 3", :ruby => ">= 2.0" do
gem "foo"
G
- bundle "config auto_install 1"
+ bundle "config set auto_install 1"
bundle :show
expect(out).to include("Installing foo 1.0")
end
+ context "with a valid regexp for gem name" do
+ it "presents alternatives" do
+ install_gemfile <<-G
+ source "file://#{gem_repo1}"
+ gem "rack"
+ gem "rack-obama"
+ G
+
+ bundle "show rac"
+ expect(out).to eq "1 : rack\n2 : rack-obama\n0 : - exit -\n>"
+ end
+ end
+
context "with an invalid regexp for gem name" do
it "does not find the gem" do
install_gemfile <<-G
@@ -211,7 +195,7 @@ RSpec.describe "bundle show", :bundler => "< 3", :ruby => ">= 2.0" do
invalid_regexp = "[]"
bundle "show #{invalid_regexp}"
- expect(out).to include("Could not find gem '#{invalid_regexp}'.")
+ expect(err).to include("Could not find gem '#{invalid_regexp}'.")
end
end
@@ -242,3 +226,7 @@ RSpec.describe "bundle show", :bundler => "< 3", :ruby => ">= 2.0" do
end
end
end
+
+RSpec.describe "bundle show", :bundler => "3" do
+ pending "shows a friendly error about the command removal"
+end
diff --git a/spec/bundler/commands/update_spec.rb b/spec/bundler/commands/update_spec.rb
index 1effba6526..46c208db6c 100644
--- a/spec/bundler/commands/update_spec.rb
+++ b/spec/bundler/commands/update_spec.rb
@@ -8,6 +8,7 @@ RSpec.describe "bundle update" do
source "file://#{gem_repo2}"
gem "activesupport"
gem "rack-obama"
+ gem "platform_specific"
G
end
@@ -64,25 +65,25 @@ RSpec.describe "bundle update" do
gem "rack", "1.0"
G
- bundle! "update --gemfile OmgFile", :all => bundle_update_requires_all?
+ bundle! "update --gemfile OmgFile", :all => true
expect(bundled_app("OmgFile.lock")).to exist
end
end
context "when update_requires_all_flag is set" do
- before { bundle! "config update_requires_all_flag true" }
+ before { bundle! "config set update_requires_all_flag true" }
it "errors when passed nothing" do
install_gemfile! ""
bundle :update
- expect(out).to eq("To update everything, pass the `--all` flag.")
+ expect(err).to eq("To update everything, pass the `--all` flag.")
end
it "errors when passed --all and another option" do
install_gemfile! ""
bundle "update --all foo"
- expect(out).to eq("Cannot specify --all along with specific options.")
+ expect(err).to eq("Cannot specify --all along with specific options.")
end
it "updates everything when passed --all" do
@@ -113,11 +114,11 @@ RSpec.describe "bundle update" do
describe "with an unknown dependency" do
it "should inform the user" do
bundle "update halting-problem-solver"
- expect(out).to include "Could not find gem 'halting-problem-solver'"
+ expect(err).to include "Could not find gem 'halting-problem-solver'"
end
it "should suggest alternatives" do
- bundle "update active-support"
- expect(out).to include "Did you mean activesupport?"
+ bundle "update platformspecific"
+ expect(err).to include "Did you mean platform_specific?"
end
end
@@ -132,7 +133,7 @@ RSpec.describe "bundle update" do
describe "when a possible resolve requires an older version of a locked gem" do
context "and only_update_to_newer_versions is set" do
before do
- bundle! "config only_update_to_newer_versions true"
+ bundle! "config set only_update_to_newer_versions true"
end
it "does not go to an older version" do
@@ -166,7 +167,7 @@ RSpec.describe "bundle update" do
end
end
- bundle! "update", :all => bundle_update_requires_all?
+ bundle! "update", :all => true
expect(the_bundle).to include_gems("slim 3.0.9", "slim-rails 3.1.3", "slim_lint 0.16.1")
end
@@ -281,25 +282,25 @@ RSpec.describe "bundle update" do
describe "in a frozen bundle" do
it "should fail loudly", :bundler => "< 3" do
bundle! "install --deployment"
- bundle "update", :all => bundle_update_requires_all?
+ bundle "update", :all => true
expect(last_command).to be_failure
- expect(out).to match(/You are trying to install in deployment mode after changing.your Gemfile/m)
- expect(out).to match(/freeze \nby running `bundle install --no-deployment`./m)
+ expect(err).to match(/You are trying to install in deployment mode after changing.your Gemfile/m)
+ expect(err).to match(/freeze \nby running `bundle install --no-deployment`./m)
end
it "should suggest different command when frozen is set globally", :bundler => "< 3" do
- bundle! "config --global frozen 1"
- bundle "update", :all => bundle_update_requires_all?
- expect(out).to match(/You are trying to install in deployment mode after changing.your Gemfile/m).
- and match(/freeze \nby running `bundle config --delete frozen`./m)
+ bundle! "config set --global frozen 1"
+ bundle "update", :all => true
+ expect(err).to match(/You are trying to install in deployment mode after changing.your Gemfile/m).
+ and match(/freeze \nby running `bundle config unset frozen`./m)
end
it "should suggest different command when frozen is set globally", :bundler => "3" do
- bundle! "config --global deployment true"
- bundle "update", :all => bundle_update_requires_all?
- expect(out).to match(/You are trying to install in deployment mode after changing.your Gemfile/m).
- and match(/freeze \nby running `bundle config --delete deployment`./m)
+ bundle! "config set --global deployment true"
+ bundle "update", :all => true
+ expect(err).to match(/You are trying to install in deployment mode after changing.your Gemfile/m).
+ and match(/freeze \nby running `bundle config unset deployment`./m)
end
end
@@ -327,7 +328,7 @@ RSpec.describe "bundle update" do
end
context "with unlock_source_unlocks_spec set to false" do
- before { bundle! "config unlock_source_unlocks_spec false" }
+ before { bundle! "config set unlock_source_unlocks_spec false" }
it "should not update gems not included in the source that happen to have the same name" do
install_gemfile <<-G
@@ -541,7 +542,7 @@ RSpec.describe "bundle update without a Gemfile.lock" do
gem "rack", "1.0"
G
- bundle "update", :all => bundle_update_requires_all?
+ bundle "update", :all => true
expect(the_bundle).to include_gems "rack 1.0.0"
end
@@ -562,7 +563,7 @@ RSpec.describe "bundle update when a gem depends on a newer version of bundler"
end
it "should explain that bundler conflicted", :bundler => "< 3" do
- bundle "update", :all => bundle_update_requires_all?
+ bundle "update", :all => true
expect(last_command.stdboth).not_to match(/in snapshot/i)
expect(last_command.bundler_err).to match(/current Bundler version/i).
and match(/perhaps you need to update bundler/i)
@@ -585,19 +586,19 @@ RSpec.describe "bundle update" do
gem "activesupport"
G
- bundle "update", :all => bundle_update_requires_all?
+ bundle "update", :all => true
expect(out).to include("Using activesupport 2.3.5")
update_repo2 do
build_gem "activesupport", "3.0"
end
- bundle "update", :all => bundle_update_requires_all?
+ bundle "update", :all => true
expect(out).to include("Installing activesupport 3.0 (was 2.3.5)")
end
context "with suppress_install_using_messages set" do
- before { bundle! "config suppress_install_using_messages true" }
+ before { bundle! "config set suppress_install_using_messages true" }
it "only prints `Using` for versions that have changed" do
build_repo4 do
@@ -611,7 +612,7 @@ RSpec.describe "bundle update" do
gem "foo"
G
- bundle! "update", :all => bundle_update_requires_all?
+ bundle! "update", :all => true
out.gsub!(/RubyGems [\d\.]+ is not threadsafe.*\n?/, "")
expect(out).to include "Resolving dependencies...\nBundle updated!"
@@ -619,7 +620,7 @@ RSpec.describe "bundle update" do
build_gem "foo", "2.0"
end
- bundle! "update", :all => bundle_update_requires_all?
+ bundle! "update", :all => true
out.sub!("Removing foo (1.0)\n", "")
out.gsub!(/RubyGems [\d\.]+ is not threadsafe.*\n?/, "")
expect(out).to include strip_whitespace(<<-EOS).strip
@@ -638,7 +639,7 @@ RSpec.describe "bundle update" do
G
bundle "update nonexisting"
- expect(out).to include("This Bundle hasn't been installed yet. Run `bundle install` to update and install the bundled gems.")
+ expect(err).to include("This Bundle hasn't been installed yet. Run `bundle install` to update and install the bundled gems.")
expect(exitstatus).to eq(22) if exitstatus
end
end
@@ -718,7 +719,7 @@ RSpec.describe "bundle update --ruby" do
it "shows a helpful error message" do
bundle "update --ruby"
- expect(out).to include("Your Ruby version is 2.2.2, but your Gemfile specified ~> 2.1.0")
+ expect(err).to include("Your Ruby version is 2.2.2, but your Gemfile specified ~> 2.1.0")
end
end
@@ -808,6 +809,15 @@ RSpec.describe "bundle update conservative" do
G
end
+ context "with patch set as default update level in config" do
+ it "should do a patch level update" do
+ bundle! "config set --local prefer_patch true"
+ bundle! "update foo"
+
+ expect(the_bundle).to include_gems "foo 1.4.5", "bar 2.1.1", "qux 1.0.0"
+ end
+ end
+
context "patch preferred" do
it "single gem updates dependent gem to minor" do
bundle! "update --patch foo"
@@ -816,7 +826,7 @@ RSpec.describe "bundle update conservative" do
end
it "update all" do
- bundle! "update --patch", :all => bundle_update_requires_all?
+ bundle! "update --patch", :all => true
expect(the_bundle).to include_gems "foo 1.4.5", "bar 2.1.1", "qux 1.0.1"
end
@@ -838,7 +848,7 @@ RSpec.describe "bundle update conservative" do
end
it "minor preferred" do
- bundle! "update --minor --strict", :all => bundle_update_requires_all?
+ bundle! "update --minor --strict", :all => true
expect(the_bundle).to include_gems "foo 1.5.0", "bar 2.1.1", "qux 1.1.0"
end
@@ -935,7 +945,7 @@ RSpec.describe "bundle update conservative" do
end
it "raises if too many flags are provided" do
- bundle "update --patch --minor", :all => bundle_update_requires_all?
+ bundle "update --patch --minor", :all => true
expect(last_command.bundler_err).to eq "Provide only one of the following options: minor, patch"
end
diff --git a/spec/bundler/commands/viz_spec.rb b/spec/bundler/commands/viz_spec.rb
index 61414956a9..96cc21b5f7 100644
--- a/spec/bundler/commands/viz_spec.rb
+++ b/spec/bundler/commands/viz_spec.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-RSpec.describe "bundle viz", :ruby => "1.9.3", :bundler => "< 3", :if => Bundler.which("dot") do
+RSpec.describe "bundle viz", :bundler => "< 3", :if => Bundler.which("dot") do
let(:ruby_graphviz) do
graphviz_glob = base_system_gems.join("cache/ruby-graphviz*")
Pathname.glob(graphviz_glob).first
diff --git a/spec/bundler/install/allow_offline_install_spec.rb b/spec/bundler/install/allow_offline_install_spec.rb
index d4bb595771..8af88b7efe 100644
--- a/spec/bundler/install/allow_offline_install_spec.rb
+++ b/spec/bundler/install/allow_offline_install_spec.rb
@@ -2,7 +2,7 @@
RSpec.describe "bundle install with :allow_offline_install" do
before do
- bundle "config allow_offline_install true"
+ bundle "config set allow_offline_install true"
end
context "with no cached data locally" do
@@ -19,7 +19,7 @@ RSpec.describe "bundle install with :allow_offline_install" do
source "http://testgemserver.local"
gem "rack-obama"
G
- expect(out).to include("Could not reach host testgemserver.local.")
+ expect(err).to include("Could not reach host testgemserver.local.")
expect(the_bundle).to_not be_locked
end
end
@@ -28,7 +28,7 @@ RSpec.describe "bundle install with :allow_offline_install" do
it "will install from the compact index" do
system_gems ["rack-1.0.0"], :path => :bundle_path
- bundle! "config clean false"
+ bundle! "config set clean false"
install_gemfile! <<-G, :artifice => "compact_index"
source "http://testgemserver.local"
gem "rack-obama"
@@ -77,7 +77,7 @@ RSpec.describe "bundle install with :allow_offline_install" do
G
break_git_remote_ops! { bundle! :update, :all => true }
- expect(out).to include("Using cached git data because of network errors")
+ expect(err).to include("Using cached git data because of network errors")
expect(the_bundle).to be_locked
break_git_remote_ops! do
@@ -85,7 +85,7 @@ RSpec.describe "bundle install with :allow_offline_install" do
gem "a", :git => #{git.path.to_s.dump}, :branch => "new_branch"
G
end
- expect(out).to include("Using cached git data because of network errors")
+ expect(err).to include("Using cached git data because of network errors")
expect(the_bundle).to be_locked
end
end
diff --git a/spec/bundler/install/binstubs_spec.rb b/spec/bundler/install/binstubs_spec.rb
index f04d3fe654..daa20693c7 100644
--- a/spec/bundler/install/binstubs_spec.rb
+++ b/spec/bundler/install/binstubs_spec.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-RSpec.describe "bundle install", :bundler => "< 3" do
+RSpec.describe "bundle install" do
describe "when system_bindir is set" do
# On OS X, Gem.bindir defaults to /usr/bin, so system_bindir is useful if
# you want to avoid sudo installs for system gems with OS X's default ruby
@@ -20,7 +20,7 @@ RSpec.describe "bundle install", :bundler => "< 3" do
end
end
- describe "when multiple gems contain the same exe", :bundler => "< 3" do
+ describe "when multiple gems contain the same exe" do
before do
build_repo2 do
build_gem "fake", "14" do |s|
@@ -28,16 +28,25 @@ RSpec.describe "bundle install", :bundler => "< 3" do
end
end
- install_gemfile <<-G, :binstubs => true
+ install_gemfile <<-G
source "file://#{gem_repo2}"
gem "fake"
gem "rack"
G
end
- it "loads the correct spec's executable" do
- gembin("rackup")
- expect(out).to eq("1.2")
+ it "warns about the situation" do
+ bundle! "exec rackup"
+
+ expect(last_command.stderr).to include(
+ "The `rackup` executable in the `fake` gem is being loaded, but it's also present in other gems (rack).\n" \
+ "If you meant to run the executable for another gem, make sure you use a project specific binstub (`bundle binstub <gem_name>`).\n" \
+ "If you plan to use multiple conflicting executables, generate binstubs for them and disambiguate their names."
+ ).or include(
+ "The `rackup` executable in the `rack` gem is being loaded, but it's also present in other gems (fake).\n" \
+ "If you meant to run the executable for another gem, make sure you use a project specific binstub (`bundle binstub <gem_name>`).\n" \
+ "If you plan to use multiple conflicting executables, generate binstubs for them and disambiguate their names."
+ )
end
end
end
diff --git a/spec/bundler/install/bundler_spec.rb b/spec/bundler/install/bundler_spec.rb
index 42863ed89b..3347988cdd 100644
--- a/spec/bundler/install/bundler_spec.rb
+++ b/spec/bundler/install/bundler_spec.rb
@@ -125,8 +125,8 @@ RSpec.describe "bundle install" do
expect(last_command.bundler_err).to include(nice_error)
end
- it "can install dependencies with newer bundler version with system gems", :ruby => "> 2" do
- bundle! "config path.system true"
+ it "can install dependencies with newer bundler version with system gems" do
+ bundle! "config set path.system true"
install_gemfile! <<-G
source "file://#{gem_repo2}"
gem "rails", "3.0"
@@ -138,9 +138,9 @@ RSpec.describe "bundle install" do
expect(out).to include("The Gemfile's dependencies are satisfied")
end
- it "can install dependencies with newer bundler version with a local path", :ruby => "> 2" do
- bundle! "config path .bundle"
- bundle! "config global_path_appends_ruby_scope true"
+ it "can install dependencies with newer bundler version with a local path" do
+ bundle! "config set path .bundle"
+ bundle! "config set global_path_appends_ruby_scope true"
install_gemfile! <<-G
source "file://#{gem_repo2}"
gem "rails", "3.0"
@@ -153,7 +153,7 @@ RSpec.describe "bundle install" do
end
context "with allow_bundler_dependency_conflicts set" do
- before { bundle! "config allow_bundler_dependency_conflicts true" }
+ before { bundle! "config set allow_bundler_dependency_conflicts true" }
it "are forced to the current bundler version with warnings when no compatible version is found" do
build_repo4 do
@@ -167,7 +167,7 @@ RSpec.describe "bundle install" do
gem "requires_nonexistant_bundler"
G
- expect(out).to include "requires_nonexistant_bundler (1.0) has dependency bundler (= 99.99.99.99), " \
+ expect(err).to include "requires_nonexistant_bundler (1.0) has dependency bundler (= 99.99.99.99), " \
"which is unsatisfied by the current bundler version #{Bundler::VERSION}, so the dependency is being ignored"
expect(the_bundle).to include_gems "bundler #{Bundler::VERSION}", "requires_nonexistant_bundler 1.0"
diff --git a/spec/bundler/install/deploy_spec.rb b/spec/bundler/install/deploy_spec.rb
index ec72ff69fc..918dbabfbe 100644
--- a/spec/bundler/install/deploy_spec.rb
+++ b/spec/bundler/install/deploy_spec.rb
@@ -11,26 +11,26 @@ RSpec.describe "install with --deployment or --frozen" do
context "with CLI flags", :bundler => "< 3" do
it "fails without a lockfile and says that --deployment requires a lock" do
bundle "install --deployment"
- expect(out).to include("The --deployment flag requires a Gemfile.lock")
+ expect(err).to include("The --deployment flag requires a Gemfile.lock")
end
it "fails without a lockfile and says that --frozen requires a lock" do
bundle "install --frozen"
- expect(out).to include("The --frozen flag requires a Gemfile.lock")
+ expect(err).to include("The --frozen flag requires a Gemfile.lock")
end
it "disallows --deployment --system" do
bundle "install --deployment --system"
- expect(out).to include("You have specified both --deployment")
- expect(out).to include("Please choose only one option")
+ expect(err).to include("You have specified both --deployment")
+ expect(err).to include("Please choose only one option")
expect(exitstatus).to eq(15) if exitstatus
end
it "disallows --deployment --path --system" do
bundle "install --deployment --path . --system"
- expect(out).to include("You have specified both --path")
- expect(out).to include("as well as --system")
- expect(out).to include("Please choose only one option")
+ expect(err).to include("You have specified both --path")
+ expect(err).to include("as well as --system")
+ expect(err).to include("Please choose only one option")
expect(exitstatus).to eq(15) if exitstatus
end
@@ -129,11 +129,11 @@ RSpec.describe "install with --deployment or --frozen" do
G
bundle :install, forgotten_command_line_options(:deployment => true)
- expect(out).to include("deployment mode")
- expect(out).to include("You have added to the Gemfile")
- expect(out).to include("* rack-obama")
- expect(out).not_to include("You have deleted from the Gemfile")
- expect(out).not_to include("You have changed in the Gemfile")
+ expect(err).to include("deployment mode")
+ expect(err).to include("You have added to the Gemfile")
+ expect(err).to include("* rack-obama")
+ expect(err).not_to include("You have deleted from the Gemfile")
+ expect(err).not_to include("You have changed in the Gemfile")
end
it "works if a path gem is missing but is in a without group" do
@@ -162,7 +162,7 @@ RSpec.describe "install with --deployment or --frozen" do
FileUtils.rm_r lib_path("path_gem-1.0")
bundle :install, forgotten_command_line_options(:path => ".bundle", :deployment => true)
- expect(out).to include("The path `#{lib_path("path_gem-1.0")}` does not exist.")
+ expect(err).to include("The path `#{lib_path("path_gem-1.0")}` does not exist.")
end
it "can have --frozen set via an environment variable", :bundler => "< 3" do
@@ -174,11 +174,11 @@ RSpec.describe "install with --deployment or --frozen" do
ENV["BUNDLE_FROZEN"] = "1"
bundle "install"
- expect(out).to include("deployment mode")
- expect(out).to include("You have added to the Gemfile")
- expect(out).to include("* rack-obama")
- expect(out).not_to include("You have deleted from the Gemfile")
- expect(out).not_to include("You have changed in the Gemfile")
+ expect(err).to include("deployment mode")
+ expect(err).to include("You have added to the Gemfile")
+ expect(err).to include("* rack-obama")
+ expect(err).not_to include("You have deleted from the Gemfile")
+ expect(err).not_to include("You have changed in the Gemfile")
end
it "can have --deployment set via an environment variable" do
@@ -190,11 +190,11 @@ RSpec.describe "install with --deployment or --frozen" do
ENV["BUNDLE_DEPLOYMENT"] = "true"
bundle "install"
- expect(out).to include("deployment mode")
- expect(out).to include("You have added to the Gemfile")
- expect(out).to include("* rack-obama")
- expect(out).not_to include("You have deleted from the Gemfile")
- expect(out).not_to include("You have changed in the Gemfile")
+ expect(err).to include("deployment mode")
+ expect(err).to include("You have added to the Gemfile")
+ expect(err).to include("* rack-obama")
+ expect(err).not_to include("You have deleted from the Gemfile")
+ expect(err).not_to include("You have changed in the Gemfile")
end
it "can have --frozen set to false via an environment variable" do
@@ -212,21 +212,6 @@ RSpec.describe "install with --deployment or --frozen" do
expect(out).not_to include("* rack-obama")
end
- it "explodes with the --frozen flag if you make a change and don't check in the lockfile", :bundler => "< 2" do
- gemfile <<-G
- source "file://#{gem_repo1}"
- gem "rack"
- gem "rack-obama", "1.1"
- G
-
- bundle :install, forgotten_command_line_options(:frozen => true)
- expect(out).to include("deployment mode")
- expect(out).to include("You have added to the Gemfile")
- expect(out).to include("* rack-obama (= 1.1)")
- expect(out).not_to include("You have deleted from the Gemfile")
- expect(out).not_to include("You have changed in the Gemfile")
- end
-
it "explodes if you remove a gem and don't check in the lockfile" do
gemfile <<-G
source "file://#{gem_repo1}"
@@ -234,10 +219,10 @@ RSpec.describe "install with --deployment or --frozen" do
G
bundle :install, forgotten_command_line_options(:deployment => true)
- expect(out).to include("deployment mode")
- expect(out).to include("You have added to the Gemfile:\n* activesupport\n\n")
- expect(out).to include("You have deleted from the Gemfile:\n* rack")
- expect(out).not_to include("You have changed in the Gemfile")
+ expect(err).to include("deployment mode")
+ expect(err).to include("You have added to the Gemfile:\n* activesupport\n\n")
+ expect(err).to include("You have deleted from the Gemfile:\n* rack")
+ expect(err).not_to include("You have changed in the Gemfile")
end
it "explodes if you add a source" do
@@ -247,9 +232,9 @@ RSpec.describe "install with --deployment or --frozen" do
G
bundle :install, forgotten_command_line_options(:deployment => true)
- expect(out).to include("deployment mode")
- expect(out).to include("You have added to the Gemfile:\n* source: git://hubz.com (at master)")
- expect(out).not_to include("You have changed in the Gemfile")
+ expect(err).to include("deployment mode")
+ expect(err).to include("You have added to the Gemfile:\n* source: git://hubz.com (at master)")
+ expect(err).not_to include("You have changed in the Gemfile")
end
it "explodes if you unpin a source" do
@@ -266,10 +251,10 @@ RSpec.describe "install with --deployment or --frozen" do
G
bundle :install, forgotten_command_line_options(:deployment => true)
- expect(out).to include("deployment mode")
- expect(out).to include("You have deleted from the Gemfile:\n* source: #{lib_path("rack-1.0")} (at master@#{revision_for(lib_path("rack-1.0"))[0..6]}")
- expect(out).not_to include("You have added to the Gemfile")
- expect(out).not_to include("You have changed in the Gemfile")
+ expect(err).to include("deployment mode")
+ expect(err).to include("You have deleted from the Gemfile:\n* source: #{lib_path("rack-1.0")} (at master@#{revision_for(lib_path("rack-1.0"))[0..6]}")
+ expect(err).not_to include("You have added to the Gemfile")
+ expect(err).not_to include("You have changed in the Gemfile")
end
it "explodes if you unpin a source, leaving it pinned somewhere else" do
@@ -289,19 +274,15 @@ RSpec.describe "install with --deployment or --frozen" do
G
bundle :install, forgotten_command_line_options(:deployment => true)
- expect(out).to include("deployment mode")
- expect(out).to include("You have changed in the Gemfile:\n* rack from `no specified source` to `#{lib_path("rack")} (at master@#{revision_for(lib_path("rack"))[0..6]})`")
- expect(out).not_to include("You have added to the Gemfile")
- expect(out).not_to include("You have deleted from the Gemfile")
+ expect(err).to include("deployment mode")
+ expect(err).to include("You have changed in the Gemfile:\n* rack from `no specified source` to `#{lib_path("rack")} (at master@#{revision_for(lib_path("rack"))[0..6]})`")
+ expect(err).not_to include("You have added to the Gemfile")
+ expect(err).not_to include("You have deleted from the Gemfile")
end
context "when replacing a host with the same host with credentials" do
let(:success_message) do
- if Bundler.bundler_major_version < 3
- "Could not reach host localgemserver.test"
- else
- "Bundle complete!"
- end
+ "Bundle complete!"
end
before do
@@ -322,31 +303,33 @@ RSpec.describe "install with --deployment or --frozen" do
DEPENDENCIES
rack
G
+
+ bundle! "config set --local deployment true"
end
it "prevents the replace by default" do
- bundle :install, forgotten_command_line_options(:deployment => true)
+ bundle :install
- expect(out).to match(/The list of sources changed/)
+ expect(err).to match(/The list of sources changed/)
end
context "when allow_deployment_source_credential_changes is true" do
- before { bundle! "config allow_deployment_source_credential_changes true" }
+ before { bundle! "config set allow_deployment_source_credential_changes true" }
it "allows the replace" do
- bundle :install, forgotten_command_line_options(:deployment => true)
+ bundle :install
expect(out).to match(/#{success_message}/)
end
end
context "when allow_deployment_source_credential_changes is false" do
- before { bundle! "config allow_deployment_source_credential_changes false" }
+ before { bundle! "config set allow_deployment_source_credential_changes false" }
it "prevents the replace" do
- bundle :install, forgotten_command_line_options(:deployment => true)
+ bundle :install
- expect(out).to match(/The list of sources changed/)
+ expect(err).to match(/The list of sources changed/)
end
end
@@ -354,7 +337,7 @@ RSpec.describe "install with --deployment or --frozen" do
before { ENV["BUNDLE_ALLOW_DEPLOYMENT_SOURCE_CREDENTIAL_CHANGES"] = "true" }
it "allows the replace" do
- bundle :install, forgotten_command_line_options(:deployment => true)
+ bundle :install
expect(out).to match(/#{success_message}/)
end
@@ -364,9 +347,9 @@ RSpec.describe "install with --deployment or --frozen" do
before { ENV["BUNDLE_ALLOW_DEPLOYMENT_SOURCE_CREDENTIAL_CHANGES"] = "false" }
it "prevents the replace" do
- bundle :install, forgotten_command_line_options(:deployment => true)
+ bundle :install
- expect(out).to match(/The list of sources changed/)
+ expect(err).to match(/The list of sources changed/)
end
end
end
@@ -374,7 +357,7 @@ RSpec.describe "install with --deployment or --frozen" do
it "remembers that the bundle is frozen at runtime" do
bundle! :lock
- bundle! "config deployment true"
+ bundle! "config set --local deployment true"
gemfile <<-G
source "file://#{gem_repo1}"
@@ -383,7 +366,7 @@ RSpec.describe "install with --deployment or --frozen" do
G
expect(the_bundle).not_to include_gems "rack 1.0.0"
- expect(err).to include strip_whitespace(<<-E).strip
+ expect(last_command.stderr).to include strip_whitespace(<<-E).strip
The dependencies in your gemfile changed
You have added to the Gemfile:
@@ -412,7 +395,8 @@ You have deleted from the Gemfile:
expect(out).to include("Updating files in vendor/cache")
simulate_new_machine
- bundle! "install --verbose", forgotten_command_line_options(:deployment => true)
+ bundle! "config set --local deployment true"
+ bundle! "install --verbose"
expect(out).not_to include("You are trying to install in deployment mode after changing your Gemfile")
expect(out).not_to include("You have added to the Gemfile")
expect(out).not_to include("You have deleted from the Gemfile")
diff --git a/spec/bundler/install/failure_spec.rb b/spec/bundler/install/failure_spec.rb
index b4cdf13857..49e2771dca 100644
--- a/spec/bundler/install/failure_spec.rb
+++ b/spec/bundler/install/failure_spec.rb
@@ -121,5 +121,24 @@ In Gemfile:
activesupport
M
end
+
+ context "because the downloaded .gem was invalid" do
+ before do
+ build_repo4 do
+ build_gem "a"
+ end
+
+ gem_repo4("gems", "a-1.0.gem").open("w") {|f| f << "<html></html>" }
+ end
+
+ it "removes the downloaded .gem" do
+ install_gemfile <<-G
+ source "file:#{gem_repo4}"
+ gem "a"
+ G
+
+ expect(default_bundle_path("cache", "a-1.0.gem")).not_to exist
+ end
+ end
end
end
diff --git a/spec/bundler/install/gemfile/gemspec_spec.rb b/spec/bundler/install/gemfile/gemspec_spec.rb
index bbb56da5a4..0bec2e9d96 100644
--- a/spec/bundler/install/gemfile/gemspec_spec.rb
+++ b/spec/bundler/install/gemfile/gemspec_spec.rb
@@ -117,7 +117,7 @@ RSpec.describe "bundle install from an existing gemspec" do
build_lib("foo", :path => tmp.join("foo")) do |s|
s.write("Gemfile", "source 'file://#{gem_repo1}'\ngemspec")
s.add_dependency "actionpack", "=2.3.2"
- s.add_development_dependency "rake", "=10.0.2"
+ s.add_development_dependency "rake", "=12.3.2"
end
Dir.chdir(tmp.join("foo")) do
@@ -239,7 +239,7 @@ RSpec.describe "bundle install from an existing gemspec" do
expect(the_bundle).to include_gems "foo 1.0.0"
end
- it "does not break Gem.finish_resolve with conflicts", :rubygems => ">= 2" do
+ it "does not break Gem.finish_resolve with conflicts" do
build_lib("foo", :path => tmp.join("foo")) do |s|
s.version = "1.0.0"
s.add_dependency "bar", "= 1.0.0"
@@ -263,6 +263,20 @@ RSpec.describe "bundle install from an existing gemspec" do
expect(out).to eq("WIN")
end
+ it "works with only_update_to_newer_versions" do
+ build_lib "omg", "2.0", :path => lib_path("omg")
+
+ install_gemfile <<-G
+ gemspec :path => "#{lib_path("omg")}"
+ G
+
+ build_lib "omg", "1.0", :path => lib_path("omg")
+
+ bundle! :install, :env => { "BUNDLE_BUNDLE_ONLY_UPDATE_TO_NEWER_VERSIONS" => "true" }
+
+ expect(the_bundle).to include_gems "omg 1.0"
+ end
+
context "in deployment mode" do
context "when the lockfile was not updated after a change to the gemspec's dependencies" do
it "reports that installation failed" do
@@ -283,7 +297,7 @@ RSpec.describe "bundle install from an existing gemspec" do
bundle :install, forgotten_command_line_options(:deployment => true)
- expect(out).to include("changed")
+ expect(err).to include("changed")
end
end
end
@@ -433,7 +447,7 @@ RSpec.describe "bundle install from an existing gemspec" do
end
end
- context "on ruby", :bundler => "< 3" do
+ context "on ruby" do
before do
simulate_platform("ruby")
bundle :install
@@ -533,107 +547,6 @@ RSpec.describe "bundle install from an existing gemspec" do
end
end
end
-
- context "on ruby", :bundler => "3" do
- before do
- simulate_platform("ruby")
- bundle :install
- end
-
- context "as a runtime dependency" do
- it "keeps java dependencies in the lockfile" do
- expect(the_bundle).to include_gems "foo 1.0", "platform_specific 1.0 RUBY"
- expect(lockfile).to eq normalize_uri_file(strip_whitespace(<<-L))
- GEM
- remote: file://localhost#{gem_repo2}/
- specs:
- platform_specific (1.0)
- platform_specific (1.0-java)
-
- PATH
- remote: .
- specs:
- foo (1.0)
- platform_specific
-
- PLATFORMS
- java
- ruby
-
- DEPENDENCIES
- foo!
-
- BUNDLED WITH
- #{Bundler::VERSION}
- L
- end
- end
-
- context "as a development dependency" do
- let(:platform_specific_type) { :development }
-
- it "keeps java dependencies in the lockfile" do
- expect(the_bundle).to include_gems "foo 1.0", "platform_specific 1.0 RUBY"
- expect(lockfile).to eq normalize_uri_file(strip_whitespace(<<-L))
- GEM
- remote: file://localhost#{gem_repo2}/
- specs:
- platform_specific (1.0)
- platform_specific (1.0-java)
-
- PATH
- remote: .
- specs:
- foo (1.0)
-
- PLATFORMS
- java
- ruby
-
- DEPENDENCIES
- foo!
- platform_specific
-
- BUNDLED WITH
- #{Bundler::VERSION}
- L
- end
- end
-
- context "with an indirect platform-specific development dependency" do
- let(:platform_specific_type) { :development }
- let(:dependency) { "indirect_platform_specific" }
-
- it "keeps java dependencies in the lockfile" do
- expect(the_bundle).to include_gems "foo 1.0", "indirect_platform_specific 1.0", "platform_specific 1.0 RUBY"
- expect(lockfile).to eq normalize_uri_file(strip_whitespace(<<-L))
- GEM
- remote: file://localhost#{gem_repo2}/
- specs:
- indirect_platform_specific (1.0)
- platform_specific
- platform_specific (1.0)
- platform_specific (1.0-java)
-
- PATH
- remote: .
- specs:
- foo (1.0)
-
- PLATFORMS
- java
- ruby
-
- DEPENDENCIES
- foo!
- indirect_platform_specific
-
- BUNDLED WITH
- #{Bundler::VERSION}
- L
- end
- end
- end
end
end
diff --git a/spec/bundler/install/gemfile/git_spec.rb b/spec/bundler/install/gemfile/git_spec.rb
index fe396c7a0f..f208853041 100644
--- a/spec/bundler/install/gemfile/git_spec.rb
+++ b/spec/bundler/install/gemfile/git_spec.rb
@@ -32,7 +32,7 @@ RSpec.describe "bundle install with git sources" do
it "caches the git repo globally" do
simulate_new_machine
- bundle! "config global_gem_cache true"
+ bundle! "config set global_gem_cache true"
bundle! :install
expect(Dir["#{home}/.bundle/cache/git/foo-1.0-*"]).to have_attributes :size => 1
end
@@ -87,7 +87,7 @@ RSpec.describe "bundle install with git sources" do
gem "foo", "1.1", :git => "#{lib_path("foo-1.0")}"
G
- expect(out).to include("The source contains 'foo' at: 1.0")
+ expect(err).to include("The source contains 'foo' at: 1.0")
end
it "complains with version and platform if pinned specs don't exist in the git repo" do
@@ -103,7 +103,7 @@ RSpec.describe "bundle install with git sources" do
end
G
- expect(out).to include("The source contains 'only_java' at: 1.0 java")
+ expect(err).to include("The source contains 'only_java' at: 1.0 java")
end
it "complains with multiple versions and platforms if pinned specs don't exist in the git repo" do
@@ -124,7 +124,7 @@ RSpec.describe "bundle install with git sources" do
end
G
- expect(out).to include("The source contains 'only_java' at: 1.0 java, 1.1 java")
+ expect(err).to include("The source contains 'only_java' at: 1.0 java, 1.1 java")
end
it "still works after moving the application directory" do
@@ -204,7 +204,7 @@ RSpec.describe "bundle install with git sources" do
gem "foo"
end
G
- expect(err).to lack_errors
+ expect(last_command.stderr).to be_empty
run <<-RUBY
require 'foo'
@@ -221,7 +221,7 @@ RSpec.describe "bundle install with git sources" do
end
Dir.chdir(lib_path("foo-1.0")) do
- `git update-ref -m 'Bundler Spec!' refs/bundler/1 master~1`
+ `git update-ref -m "Bundler Spec!" refs/bundler/1 master~1`
end
# want to ensure we don't fallback to HEAD
@@ -234,7 +234,7 @@ RSpec.describe "bundle install with git sources" do
gem "foo"
end
G
- expect(err).to lack_errors
+ expect(last_command.stderr).to be_empty
run! <<-RUBY
require 'foo'
@@ -257,7 +257,7 @@ RSpec.describe "bundle install with git sources" do
end
Dir.chdir(lib_path("foo-1.0")) do
- `git update-ref -m 'Bundler Spec!' refs/bundler/1 master~1`
+ `git update-ref -m "Bundler Spec!" refs/bundler/1 master~1`
end
# want to ensure we don't fallback to HEAD
@@ -270,7 +270,7 @@ RSpec.describe "bundle install with git sources" do
gem "foo"
end
G
- expect(err).to lack_errors
+ expect(last_command.stderr).to be_empty
run! <<-RUBY
require 'foo'
@@ -282,10 +282,10 @@ RSpec.describe "bundle install with git sources" do
it "does not download random non-head refs" do
Dir.chdir(lib_path("foo-1.0")) do
- sys_exec!("git update-ref -m 'Bundler Spec!' refs/bundler/1 master~1")
+ sys_exec!('git update-ref -m "Bundler Spec!" refs/bundler/1 master~1')
end
- bundle! "config global_gem_cache true"
+ bundle! "config set global_gem_cache true"
install_gemfile! <<-G
git "#{lib_path("foo-1.0")}" do
@@ -294,7 +294,7 @@ RSpec.describe "bundle install with git sources" do
G
# ensure we also git fetch after cloning
- bundle! :update, :all => bundle_update_requires_all?
+ bundle! :update, :all => true
Dir.chdir(Dir[home(".bundle/cache/git/foo-*")].first) do
sys_exec("git ls-remote .")
@@ -406,7 +406,7 @@ RSpec.describe "bundle install with git sources" do
gem "rack", :git => "#{lib_path("rack-0.8")}", :branch => "master"
G
- bundle! %(config local.rack #{lib_path("local-rack")})
+ bundle! %(config set local.rack #{lib_path("local-rack")})
bundle! :install
run "require 'rack'"
@@ -427,7 +427,7 @@ RSpec.describe "bundle install with git sources" do
gem "rack", :git => "#{lib_path("rack-0.8")}", :branch => "master"
G
- bundle %(config local.rack #{lib_path("local-rack")})
+ bundle %(config set local.rack #{lib_path("local-rack")})
run "require 'rack'"
expect(out).to eq("LOCAL")
end
@@ -447,7 +447,7 @@ RSpec.describe "bundle install with git sources" do
gem "rack", :git => "#{lib_path("rack-0.8")}", :branch => "master"
G
- bundle! %(config local.rack #{lib_path("local-rack")})
+ bundle! %(config set local.rack #{lib_path("local-rack")})
bundle! :install
run! "require 'rack'"
expect(out).to eq("LOCAL")
@@ -470,7 +470,7 @@ RSpec.describe "bundle install with git sources" do
s.add_dependency "nokogiri", "1.4.2"
end
- bundle %(config local.rack #{lib_path("local-rack")})
+ bundle %(config set local.rack #{lib_path("local-rack")})
run "require 'rack'"
lockfile1 = File.read(bundled_app("Gemfile.lock"))
@@ -490,14 +490,14 @@ RSpec.describe "bundle install with git sources" do
FileUtils.cp_r("#{lib_path("rack-0.8")}/.", lib_path("local-rack"))
update_git "rack", "0.8", :path => lib_path("local-rack")
- bundle %(config local.rack #{lib_path("local-rack")})
+ bundle %(config set local.rack #{lib_path("local-rack")})
bundle :install
lockfile1 = File.read(bundled_app("Gemfile.lock"))
expect(lockfile1).not_to eq(lockfile0)
end
- it "explodes if given path does not exist on install" do
+ it "explodes and gives correct solution if given path does not exist on install" do
build_git "rack", "0.8"
install_gemfile <<-G
@@ -505,12 +505,20 @@ RSpec.describe "bundle install with git sources" do
gem "rack", :git => "#{lib_path("rack-0.8")}", :branch => "master"
G
- bundle %(config local.rack #{lib_path("local-rack")})
+ bundle %(config set local.rack #{lib_path("local-rack")})
bundle :install
- expect(out).to match(/Cannot use local override for rack-0.8 because #{Regexp.escape(lib_path('local-rack').to_s)} does not exist/)
+ expect(err).to match(/Cannot use local override for rack-0.8 because #{Regexp.escape(lib_path('local-rack').to_s)} does not exist/)
+
+ solution = "config unset local.rack"
+ expect(err).to match(/Run `bundle #{solution}` to remove the local override/)
+
+ bundle solution
+ bundle :install
+
+ expect(last_command.stderr).to be_empty
end
- it "explodes if branch is not given on install" do
+ it "explodes and gives correct solution if branch is not given on install" do
build_git "rack", "0.8"
FileUtils.cp_r("#{lib_path("rack-0.8")}/.", lib_path("local-rack"))
@@ -519,9 +527,17 @@ RSpec.describe "bundle install with git sources" do
gem "rack", :git => "#{lib_path("rack-0.8")}"
G
- bundle %(config local.rack #{lib_path("local-rack")})
+ bundle %(config set local.rack #{lib_path("local-rack")})
+ bundle :install
+ expect(err).to match(/Cannot use local override for rack-0.8 at #{Regexp.escape(lib_path('local-rack').to_s)} because :branch is not specified in Gemfile/)
+
+ solution = "config unset local.rack"
+ expect(err).to match(/Specify a branch or run `bundle #{solution}` to remove the local override/)
+
+ bundle solution
bundle :install
- expect(out).to match(/cannot use local override/i)
+
+ expect(last_command.stderr).to be_empty
end
it "does not explode if disable_local_branch_check is given" do
@@ -533,8 +549,8 @@ RSpec.describe "bundle install with git sources" do
gem "rack", :git => "#{lib_path("rack-0.8")}"
G
- bundle %(config local.rack #{lib_path("local-rack")})
- bundle %(config disable_local_branch_check true)
+ bundle %(config set local.rack #{lib_path("local-rack")})
+ bundle %(config set disable_local_branch_check true)
bundle :install
expect(out).to match(/Bundle complete!/)
end
@@ -553,9 +569,9 @@ RSpec.describe "bundle install with git sources" do
gem "rack", :git => "#{lib_path("rack-0.8")}", :branch => "master"
G
- bundle %(config local.rack #{lib_path("local-rack")})
+ bundle %(config set local.rack #{lib_path("local-rack")})
bundle :install
- expect(out).to match(/is using branch another but Gemfile specifies master/)
+ expect(err).to match(/is using branch another but Gemfile specifies master/)
end
it "explodes on invalid revision on install" do
@@ -570,9 +586,9 @@ RSpec.describe "bundle install with git sources" do
gem "rack", :git => "#{lib_path("rack-0.8")}", :branch => "master"
G
- bundle %(config local.rack #{lib_path("local-rack")})
+ bundle %(config set local.rack #{lib_path("local-rack")})
bundle :install
- expect(out).to match(/The Gemfile lock is pointing to revision \w+/)
+ expect(err).to match(/The Gemfile lock is pointing to revision \w+/)
end
end
@@ -709,7 +725,7 @@ RSpec.describe "bundle install with git sources" do
build_lib "bar", :path => lib_path("foo/bar"), :gemspec => false do |s|
s.write lib_path("foo/bar/lib/version.rb"), %(BAR_VERSION = '1.0')
s.write "bar.gemspec", <<-G
- $:.unshift Dir.pwd # For 1.9
+ $:.unshift Dir.pwd
require 'lib/version'
Gem::Specification.new do |s|
s.name = 'bar'
@@ -769,7 +785,7 @@ RSpec.describe "bundle install with git sources" do
bundle :install
- expect(out).to include("Git error:")
+ expect(err).to include("Git error:")
expect(err).to include("fatal")
expect(err).to include("omgomg")
end
@@ -798,14 +814,14 @@ RSpec.describe "bundle install with git sources" do
s.write "lib/forced.rb", "FORCED = '1.1'"
end
- bundle "update", :all => bundle_update_requires_all?
+ bundle "update", :all => true
expect(the_bundle).to include_gems "forced 1.1"
Dir.chdir(lib_path("forced-1.0")) do
`git reset --hard HEAD^`
end
- bundle "update", :all => bundle_update_requires_all?
+ bundle "update", :all => true
expect(the_bundle).to include_gems "forced 1.0"
end
@@ -824,7 +840,7 @@ RSpec.describe "bundle install with git sources" do
gem "has_submodule"
end
G
- expect(out).to match(/could not find gem 'submodule/i)
+ expect(err).to match(/could not find gem 'submodule/i)
expect(the_bundle).not_to include_gems "has_submodule 1.0"
end
@@ -910,7 +926,7 @@ RSpec.describe "bundle install with git sources" do
G
expect(exitstatus).to_not eq(0) if exitstatus
- expect(out).to include("Bundler could not install a gem because it " \
+ expect(err).to include("Bundler could not install a gem because it " \
"needs to create a directory, but a file exists " \
"- #{default_bundle_path("bundler")}")
end
@@ -922,12 +938,11 @@ RSpec.describe "bundle install with git sources" do
build_git "foo", :path => lib_path("nested")
build_git "bar", :path => lib_path("nested")
- gemfile <<-G
+ install_gemfile <<-G
gem "foo", :git => "#{lib_path("nested")}"
gem "bar", :git => "#{lib_path("nested")}"
G
- bundle "install"
expect(File.read(bundled_app("Gemfile.lock")).scan("GIT").size).to eq(1)
end
@@ -1010,14 +1025,12 @@ RSpec.describe "bundle install with git sources" do
install_gemfile <<-G
gem "foo", :git => "file://#{lib_path("foo-1.0")}", :ref => "#{revision}"
G
- bundle "install"
expect(out).to_not match(/Revision.*does not exist/)
install_gemfile <<-G
gem "foo", :git => "file://#{lib_path("foo-1.0")}", :ref => "deadbeef"
G
- bundle "install"
- expect(out).to include("Revision deadbeef does not exist in the repository")
+ expect(err).to include("Revision deadbeef does not exist in the repository")
end
end
@@ -1054,7 +1067,7 @@ RSpec.describe "bundle install with git sources" do
bundle :install,
:requires => [lib_path("install_hooks.rb")]
- expect(err).to eq_err("Ran pre-install hook: foo-1.0")
+ expect(err_without_deprecations).to eq("Ran pre-install hook: foo-1.0")
end
it "runs post-install hooks" do
@@ -1074,7 +1087,7 @@ RSpec.describe "bundle install with git sources" do
bundle :install,
:requires => [lib_path("install_hooks.rb")]
- expect(err).to eq_err("Ran post-install hook: foo-1.0")
+ expect(err_without_deprecations).to eq("Ran post-install hook: foo-1.0")
end
it "complains if the install hook fails" do
@@ -1094,7 +1107,7 @@ RSpec.describe "bundle install with git sources" do
bundle :install,
:requires => [lib_path("install_hooks.rb")]
- expect(out).to include("failed for foo-1.0")
+ expect(err).to include("failed for foo-1.0")
end
end
@@ -1150,7 +1163,7 @@ RSpec.describe "bundle install with git sources" do
void Init_foo() { rb_define_global_function("foo", &foo, 0); }
C
end
- `git commit -m 'commit for iteration #{i}' ext/foo.c`
+ `git commit -m "commit for iteration #{i}" ext/foo.c`
end
git_commit_sha = git_reader.ref_for("HEAD")
@@ -1193,7 +1206,48 @@ In Gemfile:
expect(out).not_to include("gem install foo")
end
- it "does not reinstall the extension", :ruby_repo, :rubygems => ">= 2.3.0" do
+ it "does not reinstall the extension", :ruby_repo do
+ build_git "foo" do |s|
+ s.add_dependency "rake"
+ s.extensions << "Rakefile"
+ s.write "Rakefile", <<-RUBY
+ task :default do
+ path = File.expand_path("../lib", __FILE__)
+ FileUtils.mkdir_p(path)
+ cur_time = Time.now.to_f.to_s
+ File.open("\#{path}/foo.rb", "w") do |f|
+ f.puts "FOO = \#{cur_time}"
+ end
+ end
+ RUBY
+ end
+
+ install_gemfile <<-G
+ source "file://#{gem_repo1}"
+ gem "foo", :git => "#{lib_path("foo-1.0")}"
+ G
+
+ run! <<-R
+ require 'foo'
+ puts FOO
+ R
+
+ installed_time = out
+ expect(installed_time).to match(/\A\d+\.\d+\z/)
+
+ install_gemfile <<-G
+ source "file://#{gem_repo1}"
+ gem "foo", :git => "#{lib_path("foo-1.0")}"
+ G
+
+ run! <<-R
+ require 'foo'
+ puts FOO
+ R
+ expect(out).to eq(installed_time)
+ end
+
+ it "does not reinstall the extension when changing another gem" do
build_git "foo" do |s|
s.add_dependency "rake"
s.extensions << "Rakefile"
@@ -1211,6 +1265,7 @@ In Gemfile:
install_gemfile <<-G
source "file://#{gem_repo1}"
+ gem "rack", "0.9.1"
gem "foo", :git => "#{lib_path("foo-1.0")}"
G
@@ -1224,6 +1279,7 @@ In Gemfile:
install_gemfile <<-G
source "file://#{gem_repo1}"
+ gem "rack", "1.0.0"
gem "foo", :git => "#{lib_path("foo-1.0")}"
G
@@ -1233,6 +1289,60 @@ In Gemfile:
R
expect(out).to eq(installed_time)
end
+
+ it "does reinstall the extension when changing refs" do
+ build_git "foo" do |s|
+ s.add_dependency "rake"
+ s.extensions << "Rakefile"
+ s.write "Rakefile", <<-RUBY
+ task :default do
+ path = File.expand_path("../lib", __FILE__)
+ FileUtils.mkdir_p(path)
+ cur_time = Time.now.to_f.to_s
+ File.open("\#{path}/foo.rb", "w") do |f|
+ f.puts "FOO = \#{cur_time}"
+ end
+ end
+ RUBY
+ end
+
+ install_gemfile <<-G
+ source "file://#{gem_repo1}"
+ gem "foo", :git => "#{lib_path("foo-1.0")}"
+ G
+
+ run! <<-R
+ require 'foo'
+ puts FOO
+ R
+
+ update_git("foo", :branch => "branch2")
+
+ installed_time = out
+ expect(installed_time).to match(/\A\d+\.\d+\z/)
+
+ install_gemfile <<-G
+ source "file://#{gem_repo1}"
+ gem "foo", :git => "#{lib_path("foo-1.0")}", :branch => "branch2"
+ G
+
+ run! <<-R
+ require 'foo'
+ puts FOO
+ R
+ expect(out).not_to eq(installed_time)
+
+ installed_time = out
+
+ update_git("foo")
+ bundle! "update foo"
+
+ run! <<-R
+ require 'foo'
+ puts FOO
+ R
+ expect(out).not_to eq(installed_time)
+ end
end
it "ignores git environment variables" do
@@ -1268,7 +1378,7 @@ In Gemfile:
G
with_path_as("") do
- bundle "update", :all => bundle_update_requires_all?
+ bundle "update", :all => true
end
expect(last_command.bundler_err).
to include("You need to install git to be able to use gems from git repositories. For help installing git, please refer to GitHub's tutorial at https://help.github.com/articles/set-up-git")
@@ -1292,7 +1402,7 @@ In Gemfile:
describe "when the git source is overridden with a local git repo" do
before do
- bundle! "config --global local.foo #{lib_path("foo")}"
+ bundle! "config set --global local.foo #{lib_path("foo")}"
end
describe "and git output is colorized" do
@@ -1326,7 +1436,6 @@ In Gemfile:
end
G
- bundle :install
expect(last_command.stdboth).to_not include("password1")
expect(last_command.stdout).to include("Fetching https://user1@github.com/company/private-repo")
end
@@ -1342,7 +1451,6 @@ In Gemfile:
end
G
- bundle :install
expect(last_command.stdboth).to_not include("oauth_token")
expect(last_command.stdout).to include("Fetching https://x-oauth-basic@github.com/company/private-repo")
end
diff --git a/spec/bundler/install/gemfile/groups_spec.rb b/spec/bundler/install/gemfile/groups_spec.rb
index 45395e606f..f836499148 100644
--- a/spec/bundler/install/gemfile/groups_spec.rb
+++ b/spec/bundler/install/gemfile/groups_spec.rb
@@ -25,7 +25,7 @@ RSpec.describe "bundle install with groups" do
puts ACTIVESUPPORT
R
- expect(err).to eq_err("ZOMG LOAD ERROR")
+ expect(err_without_deprecations).to eq("ZOMG LOAD ERROR")
end
it "installs gems with inline :groups into those groups" do
@@ -36,7 +36,7 @@ RSpec.describe "bundle install with groups" do
puts THIN
R
- expect(err).to eq_err("ZOMG LOAD ERROR")
+ expect(err_without_deprecations).to eq("ZOMG LOAD ERROR")
end
it "sets up everything if Bundler.setup is used with no groups" do
@@ -57,7 +57,7 @@ RSpec.describe "bundle install with groups" do
puts THIN
RUBY
- expect(err).to eq_err("ZOMG LOAD ERROR")
+ expect(err_without_deprecations).to eq("ZOMG LOAD ERROR")
end
it "sets up old groups when they have previously been removed" do
@@ -207,7 +207,7 @@ RSpec.describe "bundle install with groups" do
it "errors out when passing a group to with and without via CLI flags", :bundler => "< 3" do
bundle :install, forgotten_command_line_options(:with => "emo debugging", :without => "emo")
expect(last_command).to be_failure
- expect(out).to include("The offending groups are: emo")
+ expect(err).to include("The offending groups are: emo")
end
it "allows the BUNDLE_WITH setting to override BUNDLE_WITHOUT" do
diff --git a/spec/bundler/install/gemfile/lockfile_spec.rb b/spec/bundler/install/gemfile/lockfile_spec.rb
index dc1baca6ea..96cd5067be 100644
--- a/spec/bundler/install/gemfile/lockfile_spec.rb
+++ b/spec/bundler/install/gemfile/lockfile_spec.rb
@@ -16,7 +16,7 @@ RSpec.describe "bundle install with a lockfile present" do
context "with plugins disabled" do
before do
- bundle! "config plugins false"
+ bundle! "config set plugins false"
subject
end
diff --git a/spec/bundler/install/gemfile/path_spec.rb b/spec/bundler/install/gemfile/path_spec.rb
index a508c971ad..54a41b576f 100644
--- a/spec/bundler/install/gemfile/path_spec.rb
+++ b/spec/bundler/install/gemfile/path_spec.rb
@@ -66,8 +66,8 @@ RSpec.describe "bundle install with explicit source paths" do
install_gemfile <<-G
gem 'foo', :path => "~#{username}/#{relative_path}"
G
- expect(out).to match("There was an error while trying to use the path `~#{username}/#{relative_path}`.")
- expect(out).to match("user #{username} doesn't exist")
+ expect(err).to match("There was an error while trying to use the path `~#{username}/#{relative_path}`.")
+ expect(err).to match("user #{username} doesn't exist")
end
it "expands paths relative to Bundler.root" do
@@ -132,6 +132,20 @@ RSpec.describe "bundle install with explicit source paths" do
expect(the_bundle).to include_gems "foo 1.0"
end
+ it "works with only_update_to_newer_versions" do
+ build_lib "omg", "2.0", :path => lib_path("omg")
+
+ install_gemfile <<-G
+ gem "omg", :path => "#{lib_path("omg")}"
+ G
+
+ build_lib "omg", "1.0", :path => lib_path("omg")
+
+ bundle! :install, :env => { "BUNDLE_BUNDLE_ONLY_UPDATE_TO_NEWER_VERSIONS" => "true" }
+
+ expect(the_bundle).to include_gems "omg 1.0"
+ end
+
it "prefers gemspecs closer to the path root" do
build_lib "premailer", "1.0.0", :path => lib_path("premailer") do |s|
s.write "gemfiles/ruby187.gemspec", <<-G
@@ -153,7 +167,7 @@ RSpec.describe "bundle install with explicit source paths" do
expect(the_bundle).to include_gems "premailer 1.0.0"
end
- it "warns on invalid specs", :rubygems => "1.7" do
+ it "warns on invalid specs" do
build_lib "foo"
gemspec = lib_path("foo-1.0").join("foo.gemspec").to_s
@@ -169,11 +183,11 @@ RSpec.describe "bundle install with explicit source paths" do
gem "foo", :path => "#{lib_path("foo-1.0")}"
G
- expect(out).to_not include("ERROR REPORT")
- expect(out).to_not include("Your Gemfile has no gem server sources.")
- expect(out).to match(/is not valid. Please fix this gemspec./)
- expect(out).to match(/The validation error was 'missing value for attribute version'/)
- expect(out).to match(/You have one or more invalid gemspecs that need to be fixed/)
+ expect(err).to_not include("ERROR REPORT")
+ expect(err).to_not include("Your Gemfile has no gem server sources.")
+ expect(err).to match(/is not valid. Please fix this gemspec./)
+ expect(err).to match(/The validation error was 'missing value for attribute version'/)
+ expect(err).to match(/You have one or more invalid gemspecs that need to be fixed/)
end
it "supports gemspec syntax" do
@@ -260,7 +274,7 @@ RSpec.describe "bundle install with explicit source paths" do
G
expect(exitstatus).to eq(15) if exitstatus
- expect(out).to match(/There are multiple gemspecs/)
+ expect(err).to match(/There are multiple gemspecs/)
end
it "allows :name to be specified to resolve ambiguity" do
@@ -299,7 +313,7 @@ RSpec.describe "bundle install with explicit source paths" do
install_gemfile <<-G
gem 'foo', '1.0', :path => "#{lib_path("foo-1.0")}"
G
- expect(err).to lack_errors
+ expect(last_command.stderr).to be_empty
end
it "removes the .gem file after installing" do
@@ -561,7 +575,7 @@ RSpec.describe "bundle install with explicit source paths" do
bundle :install,
:requires => [lib_path("install_hooks.rb")]
- expect(err).to eq_err("Ran pre-install hook: foo-1.0")
+ expect(err_without_deprecations).to eq("Ran pre-install hook: foo-1.0")
end
it "runs post-install hooks" do
@@ -581,7 +595,7 @@ RSpec.describe "bundle install with explicit source paths" do
bundle :install,
:requires => [lib_path("install_hooks.rb")]
- expect(err).to eq_err("Ran post-install hook: foo-1.0")
+ expect(err_without_deprecations).to eq("Ran post-install hook: foo-1.0")
end
it "complains if the install hook fails" do
@@ -601,7 +615,7 @@ RSpec.describe "bundle install with explicit source paths" do
bundle :install,
:requires => [lib_path("install_hooks.rb")]
- expect(out).to include("failed for foo-1.0")
+ expect(err).to include("failed for foo-1.0")
end
it "loads plugins from the path gem" do
diff --git a/spec/bundler/install/gemfile/platform_spec.rb b/spec/bundler/install/gemfile/platform_spec.rb
index b5dbc41a33..891f766cc0 100644
--- a/spec/bundler/install/gemfile/platform_spec.rb
+++ b/spec/bundler/install/gemfile/platform_spec.rb
@@ -248,9 +248,9 @@ RSpec.describe "bundle install across platforms" do
gem "facter"
G
- expect(out).to include "Unable to use the platform-specific (universal-darwin) version of facter (2.4.6) " \
+ expect(err).to include "Unable to use the platform-specific (universal-darwin) version of facter (2.4.6) " \
"because it has different dependencies from the ruby version. " \
- "To use the platform-specific version of the gem, run `bundle config specific_platform true` and install again."
+ "To use the platform-specific version of the gem, run `bundle config set specific_platform true` and install again."
expect(the_bundle).to include_gem "facter 2.4.6"
expect(the_bundle).not_to include_gem "CFPropertyList"
@@ -265,8 +265,7 @@ RSpec.describe "bundle install across platforms" do
bundle! :install, forgotten_command_line_options(:path => "vendor/bundle")
- new_version = Gem::ConfigMap[:ruby_version] == "1.8" ? "1.9.1" : "1.8"
- FileUtils.mv(vendored_gems, bundled_app("vendor/bundle", Gem.ruby_engine, new_version))
+ FileUtils.mv(vendored_gems, bundled_app("vendor/bundle", Gem.ruby_engine, "1.8"))
bundle! :install
expect(vendored_gems("gems/rack-1.0.0")).to exist
@@ -385,13 +384,13 @@ RSpec.describe "bundle install with platform conditionals" do
bundle! "install"
- expect(out).to include <<-O.strip
+ expect(err).to include <<-O.strip
The dependency #{Gem::Dependency.new("rack", ">= 0")} will be unused by any of the platforms Bundler is installing for. Bundler is installing for ruby but the dependency is only for x86-mingw32, x86-mswin32, x64-mingw32, java. To add those platforms to the bundle, run `bundle lock --add-platform x86-mingw32 x86-mswin32 x64-mingw32 java`.
O
end
context "when disable_platform_warnings is true" do
- before { bundle! "config disable_platform_warnings true" }
+ before { bundle! "config set disable_platform_warnings true" }
it "does not print the warning when a dependency is unused on any platform" do
simulate_platform "ruby"
diff --git a/spec/bundler/install/gemfile/ruby_spec.rb b/spec/bundler/install/gemfile/ruby_spec.rb
index 24fe021fa3..3373c9bd3e 100644
--- a/spec/bundler/install/gemfile/ruby_spec.rb
+++ b/spec/bundler/install/gemfile/ruby_spec.rb
@@ -103,6 +103,6 @@ RSpec.describe "ruby requirement" do
gem "rack"
G
- expect(out).to include("There was an error parsing") # i.e. DSL error, not error template
+ expect(err).to include("There was an error parsing") # i.e. DSL error, not error template
end
end
diff --git a/spec/bundler/install/gemfile/sources_spec.rb b/spec/bundler/install/gemfile/sources_spec.rb
index efe6ccce7f..8e1205dfa3 100644
--- a/spec/bundler/install/gemfile/sources_spec.rb
+++ b/spec/bundler/install/gemfile/sources_spec.rb
@@ -15,7 +15,7 @@ RSpec.describe "bundle install with gems on multiple sources" do
end
end
- context "with multiple toplevel sources" do
+ context "with multiple toplevel sources", :bundler => "< 3" do
let(:repo3_rack_version) { "1.0.0" }
before do
@@ -25,27 +25,24 @@ RSpec.describe "bundle install with gems on multiple sources" do
gem "rack-obama"
gem "rack"
G
- bundle "config major_deprecations true"
end
- it "warns about ambiguous gems, but installs anyway, prioritizing sources last to first", :bundler => "< 3" do
+ it "warns about ambiguous gems, but installs anyway, prioritizing sources last to first", :bundler => "2" do
bundle :install
- expect(out).to have_major_deprecation a_string_including("Your Gemfile contains multiple primary sources.")
- expect(out).to include("Warning: the gem 'rack' was found in multiple sources.")
- expect(out).to include(normalize_uri_file("Installed from: file://localhost#{gem_repo1}"))
+ expect(err).to include("Warning: the gem 'rack' was found in multiple sources.")
+ expect(err).to include(normalize_uri_file("Installed from: file://localhost#{gem_repo1}"))
expect(the_bundle).to include_gems("rack-obama 1.0.0", "rack 1.0.0", :source => "remote1")
end
- it "errors when disable_multisource is set" do
- bundle "config disable_multisource true"
+ it "fails", :bundler => "3" do
bundle :install
- expect(out).to include("Each source after the first must include a block")
+ expect(err).to include("Each source after the first must include a block")
expect(exitstatus).to eq(4) if exitstatus
end
end
- context "when different versions of the same gem are in multiple sources" do
+ context "when different versions of the same gem are in multiple sources", :bundler => "< 3" do
let(:repo3_rack_version) { "1.2" }
before do
@@ -55,17 +52,20 @@ RSpec.describe "bundle install with gems on multiple sources" do
gem "rack-obama"
gem "rack", "1.0.0" # force it to install the working version in repo1
G
- bundle "config major_deprecations true"
- end
- it "warns about ambiguous gems, but installs anyway", :bundler => "< 3" do
bundle :install
+ end
- expect(out).to have_major_deprecation a_string_including("Your Gemfile contains multiple primary sources.")
- expect(out).to include("Warning: the gem 'rack' was found in multiple sources.")
- expect(out).to include(normalize_uri_file("Installed from: file://localhost#{gem_repo1}"))
+ it "warns about ambiguous gems, but installs anyway", :bundler => "2" do
+ expect(err).to include("Warning: the gem 'rack' was found in multiple sources.")
+ expect(err).to include(normalize_uri_file("Installed from: file://localhost#{gem_repo1}"))
expect(the_bundle).to include_gems("rack-obama 1.0.0", "rack 1.0.0", :source => "remote1")
end
+
+ it "fails", :bundler => "3" do
+ expect(err).to include("Each source after the first must include a block")
+ expect(exitstatus).to eq(4) if exitstatus
+ end
end
end
@@ -187,10 +187,9 @@ RSpec.describe "bundle install with gems on multiple sources" do
end
end
- context "when lockfile_uses_separate_rubygems_sources is set" do
+ context "when disable_multisource is set" do
before do
- bundle! "config lockfile_uses_separate_rubygems_sources true"
- bundle! "config disable_multisource true"
+ bundle! "config set disable_multisource true"
end
it "installs from the same source without any warning" do
@@ -237,7 +236,7 @@ RSpec.describe "bundle install with gems on multiple sources" do
end
end
- context "and in yet another source" do
+ context "and in yet another source", :bundler => "< 3" do
before do
gemfile <<-G
source "file://localhost#{gem_repo1}"
@@ -246,19 +245,23 @@ RSpec.describe "bundle install with gems on multiple sources" do
gem "depends_on_rack"
end
G
- end
- it "installs from the other source and warns about ambiguous gems", :bundler => "< 3" do
- bundle "config major_deprecations true"
bundle :install
- expect(out).to have_major_deprecation a_string_including("Your Gemfile contains multiple primary sources.")
- expect(out).to include("Warning: the gem 'rack' was found in multiple sources.")
- expect(out).to include(normalize_uri_file("Installed from: file://localhost#{gem_repo2}"))
+ end
+
+ it "installs from the other source and warns about ambiguous gems", :bundler => "2" do
+ expect(err).to include("Warning: the gem 'rack' was found in multiple sources.")
+ expect(err).to include(normalize_uri_file("Installed from: file://localhost#{gem_repo2}"))
expect(the_bundle).to include_gems("depends_on_rack 1.0.1", "rack 1.0.0")
end
+
+ it "fails", :bundler => "3" do
+ expect(err).to include("Each source after the first must include a block")
+ expect(exitstatus).to eq(4) if exitstatus
+ end
end
- context "and only the dependency is pinned" do
+ context "and only the dependency is pinned", :bundler => "< 3" do
before do
# need this to be broken to check for correct source ordering
build_repo gem_repo2 do
@@ -276,10 +279,10 @@ RSpec.describe "bundle install with gems on multiple sources" do
G
end
- it "installs the dependency from the pinned source without warning", :bundler => "< 3" do
+ it "installs the dependency from the pinned source without warning", :bundler => "2" do
bundle :install
- expect(out).not_to include("Warning: the gem 'rack' was found in multiple sources.")
+ expect(err).not_to include("Warning: the gem 'rack' was found in multiple sources.")
expect(the_bundle).to include_gems("depends_on_rack 1.0.1", "rack 1.0.0")
# In https://github.com/bundler/bundler/issues/3585 this failed
@@ -287,18 +290,23 @@ RSpec.describe "bundle install with gems on multiple sources" do
system_gems []
bundle :install
- expect(out).not_to include("Warning: the gem 'rack' was found in multiple sources.")
+ expect(err).not_to include("Warning: the gem 'rack' was found in multiple sources.")
expect(the_bundle).to include_gems("depends_on_rack 1.0.1", "rack 1.0.0")
end
+
+ it "fails", :bundler => "3" do
+ bundle :install
+ expect(err).to include("Each source after the first must include a block")
+ expect(exitstatus).to eq(4) if exitstatus
+ end
end
end
end
context "when a top-level gem has an indirect dependency" do
- context "when lockfile_uses_separate_rubygems_sources is set" do
+ context "when disable_multisource is set" do
before do
- bundle! "config lockfile_uses_separate_rubygems_sources true"
- bundle! "config disable_multisource true"
+ bundle! "config set disable_multisource true"
end
before do
@@ -332,7 +340,7 @@ RSpec.describe "bundle install with gems on multiple sources" do
it "installs all gems without warning" do
bundle :install
- expect(out).not_to include("Warning")
+ expect(err).not_to include("Warning")
expect(the_bundle).to include_gems("depends_on_rack 1.0.1", "rack 1.0.0", "unrelated_gem 1.0.0")
end
end
@@ -348,7 +356,7 @@ RSpec.describe "bundle install with gems on multiple sources" do
it "does not find the dependency" do
bundle :install
- expect(out).to include("Could not find gem 'rack', which is required by gem 'depends_on_rack', in any of the relevant sources")
+ expect(err).to include("Could not find gem 'rack', which is required by gem 'depends_on_rack', in any of the relevant sources")
end
end
@@ -367,7 +375,7 @@ RSpec.describe "bundle install with gems on multiple sources" do
it "installs the dependency from the top-level source without warning" do
bundle :install
- expect(out).not_to include("Warning")
+ expect(err).not_to include("Warning")
expect(the_bundle).to include_gems("depends_on_rack 1.0.1", "rack 1.0.0", "unrelated_gem 1.0.0")
end
end
@@ -388,7 +396,7 @@ RSpec.describe "bundle install with gems on multiple sources" do
it "does not install the gem" do
bundle :install
- expect(out).to include("Could not find gem 'not_in_repo1'")
+ expect(err).to include("Could not find gem 'not_in_repo1'")
end
end
@@ -437,7 +445,7 @@ RSpec.describe "bundle install with gems on multiple sources" do
it "does not unlock the non-path gem after install" do
bundle! :install
- bundle! %(exec ruby -e 'puts "OK"'), :env => { :RUBYOPT => "-r#{spec_dir.join("support/hax")}" }
+ bundle! %(exec ruby -e 'puts "OK"')
expect(out).to include("OK")
end
@@ -456,7 +464,7 @@ RSpec.describe "bundle install with gems on multiple sources" do
it "installs the gems without any warning" do
bundle :install
- expect(out).not_to include("Warning")
+ expect(err).not_to include("Warning")
expect(the_bundle).to include_gems("rack 1.0.0")
end
end
@@ -544,7 +552,7 @@ RSpec.describe "bundle install with gems on multiple sources" do
end
it "does not re-resolve" do
- bundle :install, :verbose => true
+ bundle! :install, :verbose => true
expect(out).to include("using resolution from the lockfile")
expect(out).not_to include("re-resolving dependencies")
end
@@ -616,4 +624,63 @@ RSpec.describe "bundle install with gems on multiple sources" do
end
end
end
+
+ describe "source changed to one containing a higher version of a dependency" do
+ before do
+ install_gemfile! <<-G
+ source "file://#{gem_repo1}"
+
+ gem "rack"
+ G
+
+ build_repo2 do
+ build_gem "bar"
+ end
+
+ build_lib("gemspec_test", :path => tmp.join("gemspec_test")) do |s|
+ s.add_dependency "bar", "=1.0.0"
+ end
+
+ install_gemfile <<-G
+ source "file://#{gem_repo2}"
+ gem "rack"
+ gemspec :path => "#{tmp.join("gemspec_test")}"
+ G
+ end
+
+ it "keeps the old version", :bundler => "2" do
+ expect(the_bundle).to include_gems("rack 1.0.0")
+ end
+
+ it "installs the higher version in the new repo", :bundler => "3" do
+ expect(the_bundle).to include_gems("rack 1.2")
+ end
+ end
+
+ context "when a gem is available from multiple ambiguous sources", :bundler => "3" do
+ it "raises, suggesting a source block" do
+ build_repo4 do
+ build_gem "depends_on_rack" do |s|
+ s.add_dependency "rack"
+ end
+ build_gem "rack"
+ end
+
+ install_gemfile <<-G
+ source "file://localhost#{gem_repo4}"
+ source "file://localhost#{gem_repo1}" do
+ gem "thin"
+ end
+ gem "depends_on_rack"
+ G
+ expect(last_command).to be_failure
+ expect(err).to eq normalize_uri_file(strip_whitespace(<<-EOS).strip)
+ The gem 'rack' was found in multiple relevant sources.
+ * rubygems repository file://localhost#{gem_repo1}/ or installed locally
+ * rubygems repository file://localhost#{gem_repo4}/ or installed locally
+ You must add this gem to the source block for the source you wish it to be installed from.
+ EOS
+ expect(the_bundle).not_to be_locked
+ end
+ end
end
diff --git a/spec/bundler/install/gemfile/specific_platform_spec.rb b/spec/bundler/install/gemfile/specific_platform_spec.rb
index 9c725416d5..2c482b7ad4 100644
--- a/spec/bundler/install/gemfile/specific_platform_spec.rb
+++ b/spec/bundler/install/gemfile/specific_platform_spec.rb
@@ -2,7 +2,7 @@
RSpec.describe "bundle install with specific_platform enabled" do
before do
- bundle "config specific_platform true"
+ bundle "config set specific_platform true"
build_repo2 do
build_gem("google-protobuf", "3.0.0.alpha.5.0.5.1")
diff --git a/spec/bundler/install/gemfile_spec.rb b/spec/bundler/install/gemfile_spec.rb
index e74c5ffe59..c26fbd74e7 100644
--- a/spec/bundler/install/gemfile_spec.rb
+++ b/spec/bundler/install/gemfile_spec.rb
@@ -1,4 +1,3 @@
-# encoding: utf-8
# frozen_string_literal: true
RSpec.describe "bundle install" do
@@ -8,7 +7,7 @@ RSpec.describe "bundle install" do
gem 'rails', '~> 4.0.0'
gem 'rails', '~> 4.0.0'
G
- expect(out).to include("more than once")
+ expect(err).to include("more than once")
end
end
@@ -35,7 +34,7 @@ RSpec.describe "bundle install" do
gem 'rack'
G
- bundle "config --local gemfile #{bundled_app("NotGemfile")}"
+ bundle "config set --local gemfile #{bundled_app("NotGemfile")}"
end
it "uses the gemfile to install" do
bundle "install"
@@ -65,23 +64,7 @@ RSpec.describe "bundle install" do
G
bundle :install
- expect(out).to match(/You passed :lib as an option for gem 'rack', but it is invalid/)
- end
- end
-
- context "with prefer_gems_rb set" do
- before { bundle! "config prefer_gems_rb true" }
-
- it "prefers gems.rb to Gemfile" do
- create_file("gems.rb", "gem 'bundler'")
- create_file("Gemfile", "raise 'wrong Gemfile!'")
-
- bundle! :install
-
- expect(bundled_app("gems.rb")).to be_file
- expect(bundled_app("Gemfile.lock")).not_to be_file
-
- expect(the_bundle).to include_gem "bundler #{Bundler::VERSION}"
+ expect(err).to match(/You passed :lib as an option for gem 'rack', but it is invalid/)
end
end
@@ -116,8 +99,6 @@ RSpec.describe "bundle install" do
context "with a Gemfile containing non-US-ASCII characters" do
it "reads the Gemfile with the UTF-8 encoding by default" do
- skip "Ruby 1.8 has no encodings" if RUBY_VERSION < "1.9"
-
install_gemfile <<-G
str = "Il était une fois ..."
puts "The source encoding is: " + str.encoding.name
@@ -129,8 +110,6 @@ RSpec.describe "bundle install" do
end
it "respects the magic encoding comment" do
- skip "Ruby 1.8 has no encodings" if RUBY_VERSION < "1.9"
-
# NOTE: This works thanks to #eval interpreting the magic encoding comment
install_gemfile <<-G
# encoding: iso-8859-1
diff --git a/spec/bundler/install/gems/compact_index_spec.rb b/spec/bundler/install/gems/compact_index_spec.rb
index 2acade1166..b94b68dbd9 100644
--- a/spec/bundler/install/gems/compact_index_spec.rb
+++ b/spec/bundler/install/gems/compact_index_spec.rb
@@ -22,7 +22,7 @@ RSpec.describe "compact index api" do
G
bundle :install, :artifice => "compact_index"
- expect(out).to include("' sinatra' is not a valid gem name because it contains whitespace.")
+ expect(err).to include("' sinatra' is not a valid gem name because it contains whitespace.")
end
it "should handle nested dependencies" do
@@ -226,7 +226,7 @@ The checksum of /versions does not match the checksum provided by the server! So
G
bundle :install, :artifice => "compact_index_redirects"
- expect(out).to match(/Too many redirects/)
+ expect(err).to match(/Too many redirects/)
end
context "when --full-index is specified" do
@@ -247,7 +247,7 @@ The checksum of /versions does not match the checksum provided by the server! So
gem "rack"
G
- bundle! "update --full-index", :artifice => "compact_index", :all => bundle_update_requires_all?
+ bundle! "update --full-index", :artifice => "compact_index", :all => true
expect(out).to include("Fetching source index from #{source_uri}")
expect(the_bundle).to include_gems "rack 1.0.0"
end
@@ -255,7 +255,7 @@ The checksum of /versions does not match the checksum provided by the server! So
it "does not double check for gems that are only installed locally" do
system_gems %w[rack-1.0.0 thin-1.0 net_a-1.0]
- bundle! "config --local path.system true"
+ bundle! "config set --local path.system true"
ENV["BUNDLER_SPEC_ALL_REQUESTS"] = strip_whitespace(<<-EOS).strip
#{source_uri}/versions
#{source_uri}/info/rack
@@ -628,8 +628,8 @@ The checksum of /versions does not match the checksum provided by the server! So
G
bundle! :install, :artifice => "compact_index_basic_authentication"
- expect(out).to include("Warning: the gem 'rack' was found in multiple sources.")
- expect(out).not_to include("#{user}:#{password}")
+ expect(err).to include("Warning: the gem 'rack' was found in multiple sources.")
+ expect(err).not_to include("#{user}:#{password}")
expect(the_bundle).to include_gems "rack 1.0.0"
end
@@ -652,7 +652,7 @@ The checksum of /versions does not match the checksum provided by the server! So
end
it "reads authentication details by host name from bundle config" do
- bundle "config #{source_hostname} #{user}:#{password}"
+ bundle "config set #{source_hostname} #{user}:#{password}"
bundle! :install, :artifice => "compact_index_strict_basic_authentication"
@@ -662,7 +662,7 @@ The checksum of /versions does not match the checksum provided by the server! So
it "reads authentication details by full url from bundle config" do
# The trailing slash is necessary here; Fetcher canonicalizes the URI.
- bundle "config #{source_uri}/ #{user}:#{password}"
+ bundle "config set #{source_uri}/ #{user}:#{password}"
bundle! :install, :artifice => "compact_index_strict_basic_authentication"
@@ -671,7 +671,7 @@ The checksum of /versions does not match the checksum provided by the server! So
end
it "should use the API" do
- bundle "config #{source_hostname} #{user}:#{password}"
+ bundle "config set #{source_hostname} #{user}:#{password}"
bundle! :install, :artifice => "compact_index_strict_basic_authentication"
expect(out).to include("Fetching gem metadata from #{source_uri}")
expect(the_bundle).to include_gems "rack 1.0.0"
@@ -683,7 +683,7 @@ The checksum of /versions does not match the checksum provided by the server! So
gem "rack"
G
- bundle "config #{source_hostname} otheruser:wrong"
+ bundle "config set #{source_hostname} otheruser:wrong"
bundle! :install, :artifice => "compact_index_strict_basic_authentication"
expect(the_bundle).to include_gems "rack 1.0.0"
@@ -691,14 +691,14 @@ The checksum of /versions does not match the checksum provided by the server! So
it "shows instructions if auth is not provided for the source" do
bundle :install, :artifice => "compact_index_strict_basic_authentication"
- expect(out).to include("bundle config #{source_hostname} username:password")
+ expect(err).to include("bundle config set #{source_hostname} username:password")
end
it "fails if authentication has already been provided, but failed" do
- bundle "config #{source_hostname} #{user}:wrong"
+ bundle "config set #{source_hostname} #{user}:wrong"
bundle :install, :artifice => "compact_index_strict_basic_authentication"
- expect(out).to include("Bad username or password")
+ expect(err).to include("Bad username or password")
end
end
@@ -737,7 +737,7 @@ The checksum of /versions does not match the checksum provided by the server! So
G
bundle :install, :env => { "RUBYOPT" => "-I#{bundled_app("broken_ssl")}" }
- expect(out).to include("OpenSSL")
+ expect(err).to include("OpenSSL")
end
end
@@ -757,7 +757,7 @@ The checksum of /versions does not match the checksum provided by the server! So
G
bundle :install
- expect(out).to match(/could not verify the SSL certificate/i)
+ expect(err).to match(/could not verify the SSL certificate/i)
end
end
@@ -858,12 +858,12 @@ The checksum of /versions does not match the checksum provided by the server! So
gem "rack"
G
expect(exitstatus).to eq(15) if exitstatus
- expect(out).to end_with(<<-E.strip)
+ expect(err).to end_with(<<-E.strip)
The request uri `htps://index.rubygems.org/versions` has an invalid scheme (`htps`). Did you mean `http` or `https`?
E
end
- describe "checksum validation", :rubygems => ">= 2.3.0" do
+ describe "checksum validation" do
it "raises when the checksum does not match" do
install_gemfile <<-G, :artifice => "compact_index_wrong_gem_checksum"
source "#{source_uri}"
@@ -871,7 +871,7 @@ The checksum of /versions does not match the checksum provided by the server! So
G
expect(exitstatus).to eq(19) if exitstatus
- expect(out).
+ expect(err).
to include("Bundler cannot continue installing rack (1.0.0).").
and include("The checksum for the downloaded `rack-1.0.0.gem` does not match the checksum given by the server.").
and include("This means the contents of the downloaded gem is different from what was uploaded to the server, and could be a potential security issue.").
@@ -879,7 +879,7 @@ The checksum of /versions does not match the checksum provided by the server! So
and include("1. delete the downloaded gem located at: `#{default_bundle_path}/gems/rack-1.0.0/rack-1.0.0.gem`").
and include("2. run `bundle install`").
and include("If you wish to continue installing the downloaded gem, and are certain it does not pose a security issue despite the mismatching checksum, do the following:").
- and include("1. run `bundle config disable_checksum_validation true` to turn off checksum verification").
+ and include("1. run `bundle config set disable_checksum_validation true` to turn off checksum verification").
and include("2. run `bundle install`").
and match(/\(More info: The expected SHA256 checksum was "#{"ab" * 22}", but the checksum for the downloaded gem was ".+?"\.\)/)
end
@@ -890,11 +890,11 @@ The checksum of /versions does not match the checksum provided by the server! So
gem "rack"
G
expect(exitstatus).to eq(5) if exitstatus
- expect(out).to include("The given checksum for rack-1.0.0 (\"checksum!\") is not a valid SHA256 hexdigest nor base64digest")
+ expect(err).to include("The given checksum for rack-1.0.0 (\"checksum!\") is not a valid SHA256 hexdigest nor base64digest")
end
it "does not raise when disable_checksum_validation is set" do
- bundle! "config disable_checksum_validation true"
+ bundle! "config set disable_checksum_validation true"
install_gemfile! <<-G, :artifice => "compact_index_wrong_gem_checksum"
source "#{source_uri}"
gem "rack"
@@ -915,7 +915,7 @@ The checksum of /versions does not match the checksum provided by the server! So
source "#{source_uri}"
gem "rails"
G
- deps = [Gem::Dependency.new("rake", "= 10.0.2"),
+ deps = [Gem::Dependency.new("rake", "= 12.3.2"),
Gem::Dependency.new("actionpack", "= 2.3.2"),
Gem::Dependency.new("activerecord", "= 2.3.2"),
Gem::Dependency.new("actionmailer", "= 2.3.2"),
diff --git a/spec/bundler/install/gems/dependency_api_spec.rb b/spec/bundler/install/gems/dependency_api_spec.rb
index 3cb98db1eb..0dc1ee87f2 100644
--- a/spec/bundler/install/gems/dependency_api_spec.rb
+++ b/spec/bundler/install/gems/dependency_api_spec.rb
@@ -22,7 +22,7 @@ RSpec.describe "gemcutter's dependency API" do
G
bundle :install, :artifice => "endpoint"
- expect(out).to include("' sinatra' is not a valid gem name because it contains whitespace.")
+ expect(err).to include("' sinatra' is not a valid gem name because it contains whitespace.")
end
it "should handle nested dependencies" do
@@ -216,7 +216,7 @@ RSpec.describe "gemcutter's dependency API" do
G
bundle :install, :artifice => "endpoint_redirect"
- expect(out).to match(/Too many redirects/)
+ expect(err).to match(/Too many redirects/)
end
context "when --full-index is specified" do
@@ -237,7 +237,7 @@ RSpec.describe "gemcutter's dependency API" do
gem "rack"
G
- bundle! "update --full-index", :artifice => "endpoint", :all => bundle_update_requires_all?
+ bundle! "update --full-index", :artifice => "endpoint", :all => true
expect(out).to include("Fetching source index from #{source_uri}")
expect(the_bundle).to include_gems "rack 1.0.0"
end
@@ -602,8 +602,8 @@ RSpec.describe "gemcutter's dependency API" do
G
bundle :install, :artifice => "endpoint_basic_authentication"
- expect(out).to include("Warning: the gem 'rack' was found in multiple sources.")
- expect(out).not_to include("#{user}:#{password}")
+ expect(err).to include("Warning: the gem 'rack' was found in multiple sources.")
+ expect(err).not_to include("#{user}:#{password}")
expect(the_bundle).to include_gems "rack 1.0.0"
end
@@ -626,7 +626,7 @@ RSpec.describe "gemcutter's dependency API" do
end
it "reads authentication details by host name from bundle config" do
- bundle "config #{source_hostname} #{user}:#{password}"
+ bundle "config set #{source_hostname} #{user}:#{password}"
bundle :install, :artifice => "endpoint_strict_basic_authentication"
@@ -636,7 +636,7 @@ RSpec.describe "gemcutter's dependency API" do
it "reads authentication details by full url from bundle config" do
# The trailing slash is necessary here; Fetcher canonicalizes the URI.
- bundle "config #{source_uri}/ #{user}:#{password}"
+ bundle "config set #{source_uri}/ #{user}:#{password}"
bundle :install, :artifice => "endpoint_strict_basic_authentication"
@@ -645,7 +645,7 @@ RSpec.describe "gemcutter's dependency API" do
end
it "should use the API" do
- bundle "config #{source_hostname} #{user}:#{password}"
+ bundle "config set #{source_hostname} #{user}:#{password}"
bundle :install, :artifice => "endpoint_strict_basic_authentication"
expect(out).to include("Fetching gem metadata from #{source_uri}")
expect(the_bundle).to include_gems "rack 1.0.0"
@@ -657,7 +657,7 @@ RSpec.describe "gemcutter's dependency API" do
gem "rack"
G
- bundle "config #{source_hostname} otheruser:wrong"
+ bundle "config set #{source_hostname} otheruser:wrong"
bundle :install, :artifice => "endpoint_strict_basic_authentication"
expect(the_bundle).to include_gems "rack 1.0.0"
@@ -665,14 +665,14 @@ RSpec.describe "gemcutter's dependency API" do
it "shows instructions if auth is not provided for the source" do
bundle :install, :artifice => "endpoint_strict_basic_authentication"
- expect(out).to include("bundle config #{source_hostname} username:password")
+ expect(err).to include("bundle config set #{source_hostname} username:password")
end
it "fails if authentication has already been provided, but failed" do
- bundle "config #{source_hostname} #{user}:wrong"
+ bundle "config set #{source_hostname} #{user}:wrong"
bundle :install, :artifice => "endpoint_strict_basic_authentication"
- expect(out).to include("Bad username or password")
+ expect(err).to include("Bad username or password")
end
end
@@ -711,7 +711,7 @@ RSpec.describe "gemcutter's dependency API" do
G
bundle :install, :env => { "RUBYOPT" => "-I#{bundled_app("broken_ssl")}" }
- expect(out).to include("OpenSSL")
+ expect(err).to include("OpenSSL")
end
end
@@ -731,7 +731,7 @@ RSpec.describe "gemcutter's dependency API" do
G
bundle :install
- expect(out).to match(/could not verify the SSL certificate/i)
+ expect(err).to match(/could not verify the SSL certificate/i)
end
end
diff --git a/spec/bundler/install/gems/flex_spec.rb b/spec/bundler/install/gems/flex_spec.rb
index 736f418ec7..aeb83d6573 100644
--- a/spec/bundler/install/gems/flex_spec.rb
+++ b/spec/bundler/install/gems/flex_spec.rb
@@ -188,7 +188,7 @@ RSpec.describe "bundle flex_install" do
ruby <<-RUBY
require 'bundler/setup'
RUBY
- expect(err).to match(/could not find gem 'rack-obama/i)
+ expect(last_command.stderr).to match(/could not find gem 'rack-obama/i)
end
it "suggests bundle update when the Gemfile requires different versions than the lock" do
@@ -233,9 +233,9 @@ RSpec.describe "bundle flex_install" do
bundle "install"
end.not_to change { File.read(bundled_app("Gemfile.lock")) }
- expect(out).to include("rack = 0.9.1")
- expect(out).to include("locked at 1.0.0")
- expect(out).to include("bundle update rack")
+ expect(err).to include("rack = 0.9.1")
+ expect(err).to include("locked at 1.0.0")
+ expect(err).to include("bundle update rack")
end
it "should work when you update" do
@@ -264,7 +264,7 @@ RSpec.describe "bundle flex_install" do
rack (1.0.0)
PLATFORMS
- ruby
+ #{lockfile_platforms}
DEPENDENCIES
rack
@@ -345,7 +345,7 @@ RSpec.describe "bundle flex_install" do
gem "capybara", "0.3.9"
G
- expect(out).to include("Gemfile.lock")
+ expect(err).to include("Gemfile.lock")
end
end
end
diff --git a/spec/bundler/install/gems/mirror_spec.rb b/spec/bundler/install/gems/mirror_spec.rb
index 4c35b8f206..ffa6116127 100644
--- a/spec/bundler/install/gems/mirror_spec.rb
+++ b/spec/bundler/install/gems/mirror_spec.rb
@@ -8,7 +8,7 @@ RSpec.describe "bundle install with a mirror configured" do
gem "rack"
G
- bundle "config --local mirror.http://gems.example.org http://gem-mirror.example.org"
+ bundle "config set --local mirror.http://gems.example.org http://gem-mirror.example.org"
end
it "installs from the normal location" do
@@ -26,7 +26,7 @@ RSpec.describe "bundle install with a mirror configured" do
gem "rack"
G
- bundle "config --local mirror.file://localhost#{gem_repo2} file://localhost#{gem_repo1}"
+ bundle "config set --local mirror.file://localhost#{gem_repo2} file://localhost#{gem_repo1}"
end
it "installs the gem from the mirror" do
diff --git a/spec/bundler/install/gems/native_extensions_spec.rb b/spec/bundler/install/gems/native_extensions_spec.rb
index ea616f60d3..9176a07084 100644
--- a/spec/bundler/install/gems/native_extensions_spec.rb
+++ b/spec/bundler/install/gems/native_extensions_spec.rb
@@ -37,7 +37,7 @@ RSpec.describe "installing a gem with native extensions", :ruby_repo do
gem "c_extension"
G
- bundle "config build.c_extension --with-c_extension=hello"
+ bundle "config set build.c_extension --with-c_extension=hello"
bundle "install"
expect(out).not_to include("extconf.rb failed")
@@ -76,7 +76,48 @@ RSpec.describe "installing a gem with native extensions", :ruby_repo do
C
end
- bundle! "config build.c_extension --with-c_extension=hello"
+ bundle! "config set build.c_extension --with-c_extension=hello"
+
+ install_gemfile! <<-G
+ gem "c_extension", :git => #{lib_path("c_extension-1.0").to_s.dump}
+ G
+
+ expect(out).not_to include("extconf.rb failed")
+
+ run! "Bundler.require; puts CExtension.new.its_true"
+ expect(out).to eq("true")
+ end
+
+ it "install with multiple build flags" do
+ build_git "c_extension" do |s|
+ s.extensions = ["ext/extconf.rb"]
+ s.write "ext/extconf.rb", <<-E
+ require "mkmf"
+ name = "c_extension_bundle"
+ dir_config(name)
+ raise "OMG" unless with_config("c_extension") == "hello" && with_config("c_extension_bundle-dir") == "hola"
+ create_makefile(name)
+ E
+
+ s.write "ext/c_extension.c", <<-C
+ #include "ruby.h"
+
+ VALUE c_extension_true(VALUE self) {
+ return Qtrue;
+ }
+
+ void Init_c_extension_bundle() {
+ VALUE c_Extension = rb_define_class("CExtension", rb_cObject);
+ rb_define_method(c_Extension, "its_true", c_extension_true, 0);
+ }
+ C
+
+ s.write "lib/c_extension.rb", <<-C
+ require "c_extension_bundle"
+ C
+ end
+
+ bundle! "config set build.c_extension --with-c_extension=hello --with-c_extension_bundle-dir=hola"
install_gemfile! <<-G
gem "c_extension", :git => #{lib_path("c_extension-1.0").to_s.dump}
diff --git a/spec/bundler/install/gems/post_install_spec.rb b/spec/bundler/install/gems/post_install_spec.rb
index c6e348fb65..a6894fbc14 100644
--- a/spec/bundler/install/gems/post_install_spec.rb
+++ b/spec/bundler/install/gems/post_install_spec.rb
@@ -127,7 +127,7 @@ RSpec.describe "bundle install" do
gem "rack"
G
- bundle "config ignore_messages.rack true"
+ bundle "config set ignore_messages.rack true"
bundle :install
expect(out).not_to include("Post-install message")
@@ -141,7 +141,7 @@ RSpec.describe "bundle install" do
gem "rack"
G
- bundle "config ignore_messages true"
+ bundle "config set ignore_messages true"
bundle :install
expect(out).not_to include("Post-install message")
diff --git a/spec/bundler/install/gems/resolving_spec.rb b/spec/bundler/install/gems/resolving_spec.rb
index 01c03ac793..cf3aaa719e 100644
--- a/spec/bundler/install/gems/resolving_spec.rb
+++ b/spec/bundler/install/gems/resolving_spec.rb
@@ -77,7 +77,7 @@ RSpec.describe "bundle install with install-time dependencies" do
bundle :install, :env => { "DEBUG_RESOLVER" => "1" }
- expect(err).to include("Creating possibility state for net_c")
+ expect(last_command.stderr).to include("Creating possibility state for net_c")
end
end
@@ -91,7 +91,7 @@ RSpec.describe "bundle install with install-time dependencies" do
bundle :install, :env => { "DEBUG_RESOLVER_TREE" => "1" }
- expect(err).to include(" net_b").
+ expect(last_command.stderr).to include(" net_b").
and include("Starting resolution").
and include("Finished resolution").
and include("Attempting to activate")
@@ -117,6 +117,26 @@ RSpec.describe "bundle install with install-time dependencies" do
expect(out).to_not include("rack-9001.0.0 requires ruby version > 9000")
expect(the_bundle).to include_gems("rack 1.2")
end
+
+ it "installs the older version under rate limiting conditions" do
+ build_repo4 do
+ build_gem "rack", "9001.0.0" do |s|
+ s.required_ruby_version = "> 9000"
+ end
+ build_gem "rack", "1.2"
+ build_gem "foo1", "1.0"
+ end
+
+ install_gemfile <<-G, :artifice => "compact_index_rate_limited", :env => { "BUNDLER_SPEC_GEM_REPO" => gem_repo4 }
+ ruby "#{RUBY_VERSION}"
+ source "http://localgemserver.test/"
+ gem 'rack'
+ gem 'foo1'
+ G
+
+ expect(out).to_not include("rack-9001.0.0 requires ruby version > 9000")
+ expect(the_bundle).to include_gems("rack 1.2")
+ end
end
context "allows no gems" do
@@ -142,15 +162,14 @@ RSpec.describe "bundle install with install-time dependencies" do
expect(out).to_not include("Gem::InstallError: require_ruby requires Ruby version > 9000")
nice_error = strip_whitespace(<<-E).strip
- Bundler could not find compatible versions for gem "ruby\0":
+ Bundler found conflicting requirements for the Ruby\0 version:
In Gemfile:
- ruby\0 (#{error_message_requirement})
+ Ruby\0 (#{error_message_requirement})
require_ruby was resolved to 1.0, which depends on
- ruby\0 (> 9000)
+ Ruby\0 (> 9000)
- Could not find gem 'ruby\0 (> 9000)', which is required by gem 'require_ruby', in any of the relevant sources:
- the local ruby installation
+ Ruby\0 (> 9000), which is required by gem 'require_ruby', is not available in the local ruby installation
E
expect(last_command.bundler_err).to end_with(nice_error)
end
@@ -188,8 +207,8 @@ RSpec.describe "bundle install with install-time dependencies" do
gem 'require_rubygems'
G
- expect(out).to_not include("Gem::InstallError: require_rubygems requires RubyGems version > 9000")
- expect(out).to include("require_rubygems-1.0 requires rubygems version > 9000, which is incompatible with the current version, #{Gem::VERSION}")
+ expect(err).to_not include("Gem::InstallError: require_rubygems requires RubyGems version > 9000")
+ expect(err).to include("require_rubygems-1.0 requires rubygems version > 9000, which is incompatible with the current version, #{Gem::VERSION}")
end
end
end
diff --git a/spec/bundler/install/gems/standalone_spec.rb b/spec/bundler/install/gems/standalone_spec.rb
index fa7a3bdc27..e2cfe5ec4c 100644
--- a/spec/bundler/install/gems/standalone_spec.rb
+++ b/spec/bundler/install/gems/standalone_spec.rb
@@ -75,7 +75,7 @@ RSpec.shared_examples "bundle install --standalone" do
G
end
- it "generates a bundle/bundler/setup.rb with the proper paths", :rubygems => "2.4" do
+ it "generates a bundle/bundler/setup.rb with the proper paths" do
expected_path = bundled_app("bundle/bundler/setup.rb")
extension_line = File.read(expected_path).each_line.find {|line| line.include? "/extensions/" }.strip
expect(extension_line).to start_with '$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/extensions/'
@@ -108,8 +108,8 @@ RSpec.shared_examples "bundle install --standalone" do
end
it "outputs a helpful error message" do
- expect(out).to include("You have one or more invalid gemspecs that need to be fixed.")
- expect(out).to include("bar 1.0 has an invalid gemspec")
+ expect(err).to include("You have one or more invalid gemspecs that need to be fixed.")
+ expect(err).to include("bar 1.0 has an invalid gemspec")
end
end
diff --git a/spec/bundler/install/gems/sudo_spec.rb b/spec/bundler/install/gems/sudo_spec.rb
index 1781451c98..fb41f63a07 100644
--- a/spec/bundler/install/gems/sudo_spec.rb
+++ b/spec/bundler/install/gems/sudo_spec.rb
@@ -4,7 +4,7 @@ RSpec.describe "when using sudo", :sudo => true do
describe "and BUNDLE_PATH is writable" do
context "but BUNDLE_PATH/build_info is not writable" do
before do
- bundle! "config path.system true"
+ bundle! "config set path.system true"
subdir = system_gem_path("cache")
subdir.mkpath
sudo "chmod u-w #{subdir}"
@@ -25,7 +25,7 @@ RSpec.describe "when using sudo", :sudo => true do
describe "and GEM_HOME is owned by root" do
before :each do
- bundle! "config path.system true"
+ bundle! "config set path.system true"
chown_system_gems_to_root
end
@@ -52,7 +52,7 @@ RSpec.describe "when using sudo", :sudo => true do
end
it "installs when BUNDLE_PATH is owned by root" do
- bundle! "config global_path_appends_ruby_scope false" # consistency in tests between 1.x and 2.x modes
+ bundle! "config set global_path_appends_ruby_scope false" # consistency in tests between 1.x and 2.x modes
bundle_path = tmp("owned_by_root")
FileUtils.mkdir_p bundle_path
@@ -70,7 +70,7 @@ RSpec.describe "when using sudo", :sudo => true do
end
it "installs when BUNDLE_PATH does not exist" do
- bundle! "config global_path_appends_ruby_scope false" # consistency in tests between 1.x and 2.x modes
+ bundle! "config set global_path_appends_ruby_scope false" # consistency in tests between 1.x and 2.x modes
root_path = tmp("owned_by_root")
FileUtils.mkdir_p root_path
@@ -88,7 +88,7 @@ RSpec.describe "when using sudo", :sudo => true do
expect(the_bundle).to include_gems "rack 1.0"
end
- it "installs extensions/ compiled by RubyGems 2.2", :rubygems => "2.2" do
+ it "installs extensions/" do
install_gemfile <<-G
source "file://#{gem_repo1}"
gem "very_simple_binary"
@@ -133,7 +133,7 @@ RSpec.describe "when using sudo", :sudo => true do
describe "and GEM_HOME is not writable" do
it "installs" do
- bundle! "config path.system true"
+ bundle! "config set path.system true"
gem_home = tmp("sudo_gem_home")
sudo "mkdir -p #{gem_home}"
sudo "chmod ugo-w #{gem_home}"
@@ -158,20 +158,20 @@ RSpec.describe "when using sudo", :sudo => true do
it "warns against that" do
bundle :install, :sudo => true
- expect(out).to include(warning)
+ expect(err).to include(warning)
end
context "when ENV['BUNDLE_SILENCE_ROOT_WARNING'] is set" do
it "skips the warning" do
bundle :install, :sudo => :preserve_env, :env => { "BUNDLE_SILENCE_ROOT_WARNING" => true }
- expect(out).to_not include(warning)
+ expect(err).to_not include(warning)
end
end
context "when silence_root_warning = false" do
it "warns against that" do
bundle :install, :sudo => true, :env => { "BUNDLE_SILENCE_ROOT_WARNING" => "false" }
- expect(out).to include(warning)
+ expect(err).to include(warning)
end
end
end
diff --git a/spec/bundler/install/gemspecs_spec.rb b/spec/bundler/install/gemspecs_spec.rb
index 666707b295..c9878ccae8 100644
--- a/spec/bundler/install/gemspecs_spec.rb
+++ b/spec/bundler/install/gemspecs_spec.rb
@@ -1,4 +1,3 @@
-# encoding: utf-8
# frozen_string_literal: true
RSpec.describe "bundle install" do
@@ -15,7 +14,7 @@ RSpec.describe "bundle install" do
gem "yaml_spec"
G
bundle :install
- expect(err).to lack_errors
+ expect(last_command.stderr).to be_empty
end
it "still installs correctly when using path" do
@@ -24,7 +23,7 @@ RSpec.describe "bundle install" do
install_gemfile <<-G
gem 'yaml_spec', :path => "#{lib_path("yaml_spec-1.0")}"
G
- expect(err).to lack_errors
+ expect(last_command.stderr).to be_empty
end
end
@@ -48,11 +47,11 @@ RSpec.describe "bundle install" do
end
it "does not hang when gemspec has incompatible encoding" do
- create_file "foo.gemspec", <<-G
+ create_file("foo.gemspec", <<-G)
Gem::Specification.new do |gem|
gem.name = "pry-byebug"
gem.version = "3.4.2"
- gem.author = "David Rodriguez"
+ gem.author = "David Rodríguez"
gem.summary = "Good stuff"
end
G
@@ -65,8 +64,6 @@ RSpec.describe "bundle install" do
end
it "reads gemspecs respecting their encoding" do
- skip "Unicode is not supported on Ruby 1.x without extra work" if RUBY_VERSION < "2.0"
-
create_file "version.rb", <<-RUBY
module Persistent💎
VERSION = "0.0.1"
@@ -129,8 +126,8 @@ RSpec.describe "bundle install" do
gemspec
G
- expect(out).to include("Ruby patchlevel")
- expect(out).to include("but your Gemfile specified")
+ expect(err).to include("Ruby patchlevel")
+ expect(err).to include("but your Gemfile specified")
expect(exitstatus).to eq(18) if exitstatus
end
@@ -146,8 +143,8 @@ RSpec.describe "bundle install" do
gemspec
G
- expect(out).to include("Ruby version")
- expect(out).to include("but your Gemfile specified")
+ expect(err).to include("Ruby version")
+ expect(err).to include("but your Gemfile specified")
expect(exitstatus).to eq(18) if exitstatus
end
end
diff --git a/spec/bundler/install/git_spec.rb b/spec/bundler/install/git_spec.rb
index 48086a86c7..68b2f47c10 100644
--- a/spec/bundler/install/git_spec.rb
+++ b/spec/bundler/install/git_spec.rb
@@ -31,7 +31,7 @@ RSpec.describe "bundle install" do
update_git "foo", "4.0", :path => lib_path("foo"), :gemspec => true
- bundle! :update, :all => bundle_update_requires_all?
+ bundle! :update, :all => true
expect(out).to include("Using foo 2.0 (was 1.0) from #{lib_path("foo")} (at master~2@#{rev2})")
expect(the_bundle).to include_gems "foo 2.0", :source => "git@#{lib_path("foo")}"
end
diff --git a/spec/bundler/install/global_cache_spec.rb b/spec/bundler/install/global_cache_spec.rb
index e41e7e0157..345ad86db8 100644
--- a/spec/bundler/install/global_cache_spec.rb
+++ b/spec/bundler/install/global_cache_spec.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
RSpec.describe "global gem caching" do
- before { bundle! "config global_gem_cache true" }
+ before { bundle! "config set global_gem_cache true" }
describe "using the cross-application user cache" do
let(:source) { "http://localgemserver.test" }
@@ -112,7 +112,7 @@ RSpec.describe "global gem caching" do
expect(source_global_cache("rack-1.0.0.gem")).to exist
expect(source2_global_cache("rack-0.9.1.gem")).to exist
bundle :install, :artifice => "compact_index_no_gem"
- expect(out).to include("Internal Server Error 500")
+ expect(err).to include("Internal Server Error 500")
# rack 1.0.0 is not installed and rack 0.9.1 is not
expect(the_bundle).not_to include_gems "rack 1.0.0"
expect(the_bundle).not_to include_gems "rack 0.9.1"
@@ -125,7 +125,7 @@ RSpec.describe "global gem caching" do
expect(source_global_cache("rack-1.0.0.gem")).to exist
expect(source2_global_cache("rack-0.9.1.gem")).to exist
bundle :install, :artifice => "compact_index_no_gem"
- expect(out).to include("Internal Server Error 500")
+ expect(err).to include("Internal Server Error 500")
# rack 0.9.1 is not installed and rack 1.0.0 is not
expect(the_bundle).not_to include_gems "rack 0.9.1"
expect(the_bundle).not_to include_gems "rack 1.0.0"
@@ -187,7 +187,7 @@ RSpec.describe "global gem caching" do
end
end
- describe "extension caching", :ruby_repo, :rubygems => "2.2" do
+ describe "extension caching", :ruby_repo do
it "works" do
build_git "very_simple_git_binary", &:add_c_extension
build_lib "very_simple_path_binary", &:add_c_extension
@@ -220,7 +220,7 @@ RSpec.describe "global gem caching" do
gem_binary_cache.join("very_simple_binary_c.rb").open("w") {|f| f << "puts File.basename(__FILE__)" }
git_binary_cache.join("very_simple_git_binary_c.rb").open("w") {|f| f << "puts File.basename(__FILE__)" }
- bundle! "config --local path different_path"
+ bundle! "config set --local path different_path"
bundle! :install
expect(Dir[home(".bundle", "cache", "extensions", "**", "*binary_c*")]).to all(end_with(".rb"))
diff --git a/spec/bundler/install/path_spec.rb b/spec/bundler/install/path_spec.rb
index 94f38c9290..0947ed9539 100644
--- a/spec/bundler/install/path_spec.rb
+++ b/spec/bundler/install/path_spec.rb
@@ -37,7 +37,7 @@ RSpec.describe "bundle install" do
it "disallows --path vendor/bundle --system", :bundler => "< 3" do
bundle "install --path vendor/bundle --system"
- expect(out).to include("Please choose only one option.")
+ expect(err).to include("Please choose only one option.")
expect(exitstatus).to eq(15) if exitstatus
end
@@ -51,7 +51,7 @@ RSpec.describe "bundle install" do
end
context "with path_relative_to_cwd set to true" do
- before { bundle! "config path_relative_to_cwd true" }
+ before { bundle! "config set path_relative_to_cwd true" }
it "installs the bundle relatively to current working directory", :bundler => "< 3" do
Dir.chdir(bundled_app.parent) do
@@ -98,7 +98,7 @@ RSpec.describe "bundle install" do
if type == :env
ENV["BUNDLE_PATH"] = location
elsif type == :global
- bundle! "config path #{location}", "no-color" => nil
+ bundle! "config set path #{location}", "no-color" => nil
end
end
@@ -116,7 +116,7 @@ RSpec.describe "bundle install" do
context "with global_path_appends_ruby_scope set", :bundler => "3" do
it "installs gems to ." do
set_bundle_path(type, ".")
- bundle! "config --global disable_shared_gems true"
+ bundle! "config set --global disable_shared_gems true"
bundle! :install
@@ -150,7 +150,7 @@ RSpec.describe "bundle install" do
context "with global_path_appends_ruby_scope unset", :bundler => "< 3" do
it "installs gems to ." do
set_bundle_path(type, ".")
- bundle! "config --global disable_shared_gems true"
+ bundle! "config set --global disable_shared_gems true"
bundle! :install
@@ -207,7 +207,7 @@ RSpec.describe "bundle install" do
expect(the_bundle).to include_gems "rack 1.0.0"
end
- it "re-installs gems whose extensions have been deleted", :ruby_repo, :rubygems => ">= 2.3" do
+ it "re-installs gems whose extensions have been deleted", :ruby_repo do
build_lib "very_simple_binary", "1.0.0", :to_system => true do |s|
s.write "lib/very_simple_binary.rb", "raise 'FAIL'"
end
@@ -226,7 +226,7 @@ RSpec.describe "bundle install" do
vendored_gems("extensions").rmtree
run "require 'very_simple_binary_c'"
- expect(err).to include("Bundler::GemNotFound")
+ expect(last_command.stderr).to include("Bundler::GemNotFound")
bundle :install, forgotten_command_line_options(:path => "./vendor/bundle")
@@ -250,7 +250,7 @@ RSpec.describe "bundle install" do
G
bundle :install, forgotten_command_line_options(:path => "bundle")
- expect(out).to include("file already exists")
+ expect(err).to include("file already exists")
end
end
end
diff --git a/spec/bundler/install/post_bundle_message_spec.rb b/spec/bundler/install/post_bundle_message_spec.rb
index 394134f523..1efd0b8146 100644
--- a/spec/bundler/install/post_bundle_message_spec.rb
+++ b/spec/bundler/install/post_bundle_message_spec.rb
@@ -107,7 +107,7 @@ RSpec.describe "post bundle message" do
gem "rack"
gem "not-a-gem", :group => :development
G
- expect(out).to include("Could not find gem 'not-a-gem' in any of the gem sources listed in your Gemfile.")
+ expect(err).to include("Could not find gem 'not-a-gem' in any of the gem sources listed in your Gemfile.")
end
it "should report a helpful error message", :bundler => "3" do
@@ -116,7 +116,7 @@ RSpec.describe "post bundle message" do
gem "rack"
gem "not-a-gem", :group => :development
G
- expect(out).to include normalize_uri_file(<<-EOS.strip)
+ expect(err).to include normalize_uri_file(<<-EOS.strip)
Could not find gem 'not-a-gem' in rubygems repository file://localhost#{gem_repo1}/ or installed locally.
The source does not contain any versions of 'not-a-gem'
EOS
@@ -134,7 +134,7 @@ The source does not contain any versions of 'not-a-gem'
gem "rack"
gem "not-a-gem", :group => :development
G
- expect(out).to include("Could not find gem 'not-a-gem' in").
+ expect(err).to include("Could not find gem 'not-a-gem' in").
and include("or in gems cached in vendor/cache.")
end
end
@@ -177,28 +177,28 @@ The source does not contain any versions of 'not-a-gem'
describe "for bundle update" do
it "without any options" do
- bundle! :update, :all => bundle_update_requires_all?
+ bundle! :update, :all => true
expect(out).not_to include("Gems in the groups")
expect(out).to include(bundle_updated_message)
end
it "with --without one group" do
bundle! :install, forgotten_command_line_options(:without => "emo")
- bundle! :update, :all => bundle_update_requires_all?
+ bundle! :update, :all => true
expect(out).to include("Gems in the group emo were not installed")
expect(out).to include(bundle_updated_message)
end
it "with --without two groups" do
bundle! :install, forgotten_command_line_options(:without => "emo test")
- bundle! :update, :all => bundle_update_requires_all?
+ bundle! :update, :all => true
expect(out).to include("Gems in the groups emo and test were not installed")
expect(out).to include(bundle_updated_message)
end
it "with --without more groups" do
bundle! :install, forgotten_command_line_options(:without => "emo obama test")
- bundle! :update, :all => bundle_update_requires_all?
+ bundle! :update, :all => true
expect(out).to include("Gems in the groups emo, obama and test were not installed")
expect(out).to include(bundle_updated_message)
end
diff --git a/spec/bundler/install/process_lock_spec.rb b/spec/bundler/install/process_lock_spec.rb
index be8fd04fdd..df1e9c6350 100644
--- a/spec/bundler/install/process_lock_spec.rb
+++ b/spec/bundler/install/process_lock_spec.rb
@@ -21,7 +21,7 @@ RSpec.describe "process lock spec" do
expect(the_bundle).to include_gems "rack 1.0"
end
- context "when creating a lock raises Errno::ENOTSUP", :ruby => ">= 1.9" do
+ context "when creating a lock raises Errno::ENOTSUP" do
before { allow(File).to receive(:open).and_raise(Errno::ENOTSUP) }
it "skips creating the lock file and yields" do
diff --git a/spec/bundler/install/redownload_spec.rb b/spec/bundler/install/redownload_spec.rb
index f9caeed58a..2a0cdc9473 100644
--- a/spec/bundler/install/redownload_spec.rb
+++ b/spec/bundler/install/redownload_spec.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-RSpec.describe "bundle install", :bundler => "< 3", :ruby => ">= 2.0" do
+RSpec.describe "bundle install" do
before :each do
gemfile <<-G
source "file://#{gem_repo1}"
@@ -8,8 +8,6 @@ RSpec.describe "bundle install", :bundler => "< 3", :ruby => ">= 2.0" do
G
end
- before { bundle "config major_deprecations yes" }
-
shared_examples_for "an option to force redownloading gems" do
it "re-installs installed gems" do
rack_lib = default_bundle_path("gems/rack-1.0.0/lib/rack.rb")
@@ -58,19 +56,19 @@ RSpec.describe "bundle install", :bundler => "< 3", :ruby => ">= 2.0" do
end
end
- describe "with --force" do
+ describe "with --force", :bundler => 2 do
it_behaves_like "an option to force redownloading gems" do
let(:flag) { "force" }
end
it "shows a deprecation when single flag passed" do
bundle! "install --force"
- expect(out).to include "[DEPRECATED FOR 3.0] The `--force` option has been renamed to `--redownload`"
+ expect(err).to include "[DEPRECATED] The `--force` option has been renamed to `--redownload`"
end
it "shows a deprecation when multiple flags passed" do
bundle! "install --no-color --force"
- expect(out).to include "[DEPRECATED FOR 3.0] The `--force` option has been renamed to `--redownload`"
+ expect(err).to include "[DEPRECATED] The `--force` option has been renamed to `--redownload`"
end
end
@@ -81,12 +79,12 @@ RSpec.describe "bundle install", :bundler => "< 3", :ruby => ">= 2.0" do
it "does not show a deprecation when single flag passed" do
bundle! "install --redownload"
- expect(out).not_to include "[DEPRECATED FOR 2.0] The `--force` option has been renamed to `--redownload`"
+ expect(err).not_to include "[DEPRECATED] The `--force` option has been renamed to `--redownload`"
end
it "does not show a deprecation when single multiple flags passed" do
bundle! "install --no-color --redownload"
- expect(out).not_to include "[DEPRECATED FOR 2.0] The `--force` option has been renamed to `--redownload`"
+ expect(err).not_to include "[DEPRECATED] The `--force` option has been renamed to `--redownload`"
end
end
end
diff --git a/spec/bundler/install/security_policy_spec.rb b/spec/bundler/install/security_policy_spec.rb
index 7be09d6bd4..ad76162aac 100644
--- a/spec/bundler/install/security_policy_spec.rb
+++ b/spec/bundler/install/security_policy_spec.rb
@@ -24,18 +24,17 @@ RSpec.describe "policies with unsigned gems" do
it "will fail when given invalid security policy" do
bundle "install --trust-policy=InvalidPolicyName"
- expect(out).to include("RubyGems doesn't know about trust policy")
+ expect(err).to include("RubyGems doesn't know about trust policy")
end
it "will fail with High Security setting due to presence of unsigned gem" do
bundle "install --trust-policy=HighSecurity"
- expect(out).to include("security policy didn't allow")
+ expect(err).to include("security policy didn't allow")
end
- # This spec will fail on RubyGems 2 rc1 due to a bug in policy.rb. the bug is fixed in rc3.
- it "will fail with Medium Security setting due to presence of unsigned gem", :unless => ENV["RGV"] == "v2.0.0.rc.1" do
+ it "will fail with Medium Security setting due to presence of unsigned gem" do
bundle "install --trust-policy=MediumSecurity"
- expect(out).to include("security policy didn't allow")
+ expect(err).to include("security policy didn't allow")
end
it "will succeed with no policy" do
@@ -55,12 +54,12 @@ RSpec.describe "policies with signed gems and no CA" do
it "will fail with High Security setting, gem is self-signed" do
bundle "install --trust-policy=HighSecurity"
- expect(out).to include("security policy didn't allow")
+ expect(err).to include("security policy didn't allow")
end
it "will fail with Medium Security setting, gem is self-signed" do
bundle "install --trust-policy=MediumSecurity"
- expect(out).to include("security policy didn't allow")
+ expect(err).to include("security policy didn't allow")
end
it "will succeed with Low Security setting, low security accepts self signed gem" do
diff --git a/spec/bundler/install/yanked_spec.rb b/spec/bundler/install/yanked_spec.rb
index 7c4b98bfdf..3e6f6a3bcd 100644
--- a/spec/bundler/install/yanked_spec.rb
+++ b/spec/bundler/install/yanked_spec.rb
@@ -27,7 +27,7 @@ RSpec.context "when installing a bundle that includes yanked gems" do
gem "foo", "10.0.0"
G
- expect(out).to include("Your bundle is locked to foo (10.0.0)")
+ expect(err).to include("Your bundle is locked to foo (10.0.0)")
end
it "throws the original error when only the Gemfile specifies a gem version that doesn't exist" do
@@ -36,8 +36,8 @@ RSpec.context "when installing a bundle that includes yanked gems" do
gem "foo", "10.0.0"
G
- expect(out).not_to include("Your bundle is locked to foo (10.0.0)")
- expect(out).to include("Could not find gem 'foo (= 10.0.0)' in")
+ expect(err).not_to include("Your bundle is locked to foo (10.0.0)")
+ expect(err).to include("Could not find gem 'foo (= 10.0.0)' in")
end
end
@@ -63,9 +63,9 @@ RSpec.context "when using gem before installing" do
bundle :list
- expect(out).to include("Could not find rack-0.9.1 in any of the sources")
- expect(out).to_not include("Your bundle is locked to rack (0.9.1), but that version could not be found in any of the sources listed in your Gemfile.")
- expect(out).to_not include("If you haven't changed sources, that means the author of rack (0.9.1) has removed it.")
- expect(out).to_not include("You'll need to update your bundle to a different version of rack (0.9.1) that hasn't been removed in order to install.")
+ expect(err).to include("Could not find rack-0.9.1 in any of the sources")
+ expect(err).to_not include("Your bundle is locked to rack (0.9.1), but that version could not be found in any of the sources listed in your Gemfile.")
+ expect(err).to_not include("If you haven't changed sources, that means the author of rack (0.9.1) has removed it.")
+ expect(err).to_not include("You'll need to update your bundle to a different version of rack (0.9.1) that hasn't been removed in order to install.")
end
end
diff --git a/spec/bundler/lock/lockfile_bundler_1_spec.rb b/spec/bundler/lock/lockfile_bundler_1_spec.rb
deleted file mode 100644
index e89c5078d9..0000000000
--- a/spec/bundler/lock/lockfile_bundler_1_spec.rb
+++ /dev/null
@@ -1,1386 +0,0 @@
-# frozen_string_literal: true
-
-RSpec.describe "the lockfile format", :bundler => "< 3" do
- include Bundler::GemHelpers
-
- before { ENV["BUNDLER_SPEC_IGNORE_COMPATIBILITY_GUARD"] = "TRUE" }
-
- it "generates a simple lockfile for a single source, gem" do
- install_gemfile <<-G
- source "file://localhost#{gem_repo1}"
-
- gem "rack"
- G
-
- lockfile_should_be <<-G
- GEM
- remote: file://localhost#{gem_repo1}/
- specs:
- rack (1.0.0)
-
- PLATFORMS
- #{generic_local_platform}
-
- DEPENDENCIES
- rack
-
- BUNDLED WITH
- #{Bundler::VERSION}
- G
- end
-
- it "updates the lockfile's bundler version if current ver. is newer" do
- lockfile <<-L
- GIT
- remote: git://github.com/nex3/haml.git
- revision: 8a2271f
- specs:
-
- GEM
- remote: file://localhost#{gem_repo1}/
- specs:
- rack (1.0.0)
-
- PLATFORMS
- #{generic_local_platform}
-
- DEPENDENCIES
- omg!
- rack
-
- BUNDLED WITH
- 1.8.2
- L
-
- install_gemfile <<-G
- source "file://localhost#{gem_repo1}"
-
- gem "rack"
- G
-
- lockfile_should_be <<-G
- GEM
- remote: file://localhost#{gem_repo1}/
- specs:
- rack (1.0.0)
-
- PLATFORMS
- #{generic_local_platform}
-
- DEPENDENCIES
- rack
-
- BUNDLED WITH
- #{Bundler::VERSION}
- G
- end
-
- it "does not update the lockfile's bundler version if nothing changed during bundle install", :ruby_repo do
- version = "#{Bundler::VERSION.split(".").first}.0.0.0.a"
-
- lockfile normalize_uri_file(<<-L)
- GEM
- remote: file://localhost#{gem_repo1}/
- specs:
- rack (1.0.0)
-
- PLATFORMS
- #{generic_local_platform}
-
- DEPENDENCIES
- rack
-
- BUNDLED WITH
- #{version}
- L
-
- install_gemfile normalize_uri_file(<<-G)
- source "file://localhost#{gem_repo1}"
-
- gem "rack"
- G
-
- lockfile_should_be normalize_uri_file(<<-G)
- GEM
- remote: file://localhost#{gem_repo1}/
- specs:
- rack (1.0.0)
-
- PLATFORMS
- #{generic_local_platform}
-
- DEPENDENCIES
- rack
-
- BUNDLED WITH
- #{version}
- G
- end
-
- it "updates the lockfile's bundler version if not present" do
- lockfile <<-L
- GEM
- remote: file://localhost#{gem_repo1}/
- specs:
- rack (1.0.0)
-
- PLATFORMS
- #{generic_local_platform}
-
- DEPENDENCIES
- rack
- L
-
- install_gemfile <<-G
- source "file://localhost#{gem_repo1}"
-
- gem "rack", "> 0"
- G
-
- lockfile_should_be <<-G
- GEM
- remote: file://localhost#{gem_repo1}/
- specs:
- rack (1.0.0)
-
- PLATFORMS
- #{generic_local_platform}
-
- DEPENDENCIES
- rack (> 0)
-
- BUNDLED WITH
- #{Bundler::VERSION}
- G
- end
-
- it "outputs a warning if the current is older than lockfile's bundler version" do
- lockfile <<-L
- GEM
- remote: file://localhost#{gem_repo1}/
- specs:
- rack (1.0.0)
-
- PLATFORMS
- #{generic_local_platform}
-
- DEPENDENCIES
- rack
-
- BUNDLED WITH
- 9999999.1.0
- L
-
- simulate_bundler_version "9999999.0.0" do
- install_gemfile <<-G
- source "file://localhost#{gem_repo1}"
-
- gem "rack"
- G
- end
-
- warning_message = "the running version of Bundler (9999999.0.0) is older " \
- "than the version that created the lockfile (9999999.1.0)"
- expect(out.scan(warning_message).size).to eq(1)
-
- lockfile_should_be <<-G
- GEM
- remote: file://localhost#{gem_repo1}/
- specs:
- rack (1.0.0)
-
- PLATFORMS
- #{generic_local_platform}
- #{specific_local_platform}
-
- DEPENDENCIES
- rack
-
- BUNDLED WITH
- 9999999.1.0
- G
- end
-
- it "errors if the current is a major version older than lockfile's bundler version" do
- lockfile <<-L
- GEM
- remote: file://localhost#{gem_repo1}/
- specs:
- rack (1.0.0)
-
- PLATFORMS
- #{generic_local_platform}
-
- DEPENDENCIES
- rack
-
- BUNDLED WITH
- 9999999.0.0
- L
-
- install_gemfile <<-G
- source "file://localhost#{gem_repo1}"
-
- gem "rack"
- G
-
- expect(exitstatus > 0) if exitstatus
- expect(out).to include("You must use Bundler 9999999 or greater with this lockfile.")
- end
-
- it "shows a friendly error when running with a new bundler 2 lockfile" do
- lockfile <<-L
- GEM
- remote: https://rails-assets.org/
- specs:
- rails-assets-bootstrap (3.3.4)
- rails-assets-jquery (>= 1.9.1)
- rails-assets-jquery (2.1.4)
-
- GEM
- remote: https://rubygems.org/
- specs:
- rake (10.4.2)
-
- PLATFORMS
- ruby
-
- DEPENDENCIES
- rails-assets-bootstrap!
- rake
-
- BUNDLED WITH
- 9999999.0.0
- L
-
- install_gemfile <<-G
- source 'https://rubygems.org'
- gem 'rake'
-
- source 'https://rails-assets.org' do
- gem 'rails-assets-bootstrap'
- end
- G
-
- expect(exitstatus > 0) if exitstatus
- expect(out).to include("You must use Bundler 9999999 or greater with this lockfile.")
- end
-
- it "warns when updating bundler major version" do
- lockfile <<-L
- GEM
- remote: file://localhost#{gem_repo1}/
- specs:
- rack (1.0.0)
-
- PLATFORMS
- #{generic_local_platform}
-
- DEPENDENCIES
- rack
-
- BUNDLED WITH
- 1.10.0
- L
-
- simulate_bundler_version "9999999.0.0" do
- install_gemfile <<-G
- source "file://localhost#{gem_repo1}"
-
- gem "rack"
- G
- end
-
- expect(out).to include("Warning: the lockfile is being updated to Bundler " \
- "9999999, after which you will be unable to return to Bundler 1.")
-
- lockfile_should_be <<-G
- GEM
- remote: file://localhost#{gem_repo1}/
- specs:
- rack (1.0.0)
-
- PLATFORMS
- #{generic_local_platform}
- #{specific_local_platform}
-
- DEPENDENCIES
- rack
-
- BUNDLED WITH
- 9999999.0.0
- G
- end
-
- it "generates a simple lockfile for a single source, gem with dependencies" do
- install_gemfile <<-G
- source "file://localhost#{gem_repo1}"
-
- gem "rack-obama"
- G
-
- lockfile_should_be <<-G
- GEM
- remote: file://localhost#{gem_repo1}/
- specs:
- rack (1.0.0)
- rack-obama (1.0)
- rack
-
- PLATFORMS
- #{generic_local_platform}
-
- DEPENDENCIES
- rack-obama
-
- BUNDLED WITH
- #{Bundler::VERSION}
- G
- end
-
- it "generates a simple lockfile for a single source, gem with a version requirement" do
- install_gemfile <<-G
- source "file://localhost#{gem_repo1}"
-
- gem "rack-obama", ">= 1.0"
- G
-
- lockfile_should_be <<-G
- GEM
- remote: file://localhost#{gem_repo1}/
- specs:
- rack (1.0.0)
- rack-obama (1.0)
- rack
-
- PLATFORMS
- #{generic_local_platform}
-
- DEPENDENCIES
- rack-obama (>= 1.0)
-
- BUNDLED WITH
- #{Bundler::VERSION}
- G
- end
-
- it "generates a lockfile wihout credentials for a configured source" do
- bundle "config http://localgemserver.test/ user:pass"
-
- install_gemfile(<<-G, :artifice => "endpoint_strict_basic_authentication", :quiet => true)
- source "http://localgemserver.test/"
- source "http://user:pass@othergemserver.test/"
-
- gem "rack-obama", ">= 1.0"
- G
-
- lockfile_should_be <<-G
- GEM
- remote: http://localgemserver.test/
- remote: http://user:pass@othergemserver.test/
- specs:
- rack (1.0.0)
- rack-obama (1.0)
- rack
-
- PLATFORMS
- #{generic_local_platform}
-
- DEPENDENCIES
- rack-obama (>= 1.0)
-
- BUNDLED WITH
- #{Bundler::VERSION}
- G
- end
-
- it "generates lockfiles with multiple requirements" do
- install_gemfile <<-G
- source "file://localhost#{gem_repo1}"
- gem "net-sftp"
- G
-
- lockfile_should_be <<-G
- GEM
- remote: file://localhost#{gem_repo1}/
- specs:
- net-sftp (1.1.1)
- net-ssh (>= 1.0.0, < 1.99.0)
- net-ssh (1.0)
-
- PLATFORMS
- ruby
-
- DEPENDENCIES
- net-sftp
-
- BUNDLED WITH
- #{Bundler::VERSION}
- G
-
- expect(the_bundle).to include_gems "net-sftp 1.1.1", "net-ssh 1.0.0"
- end
-
- it "generates a simple lockfile for a single pinned source, gem with a version requirement" do
- git = build_git "foo"
-
- install_gemfile <<-G
- gem "foo", :git => "#{lib_path("foo-1.0")}"
- G
-
- lockfile_should_be <<-G
- GIT
- remote: #{lib_path("foo-1.0")}
- revision: #{git.ref_for("master")}
- specs:
- foo (1.0)
-
- GEM
- specs:
-
- PLATFORMS
- #{generic_local_platform}
-
- DEPENDENCIES
- foo!
-
- BUNDLED WITH
- #{Bundler::VERSION}
- G
- end
-
- it "does not asplode when a platform specific dependency is present and the Gemfile has not been resolved on that platform" do
- build_lib "omg", :path => lib_path("omg")
-
- gemfile <<-G
- source "file://localhost#{gem_repo1}"
-
- platforms :#{not_local_tag} do
- gem "omg", :path => "#{lib_path("omg")}"
- end
-
- gem "rack"
- G
-
- lockfile <<-L
- GIT
- remote: git://github.com/nex3/haml.git
- revision: 8a2271f
- specs:
-
- GEM
- remote: file://localhost#{gem_repo1}/
- specs:
- rack (1.0.0)
-
- PLATFORMS
- #{not_local}
-
- DEPENDENCIES
- omg!
- rack
-
- BUNDLED WITH
- #{Bundler::VERSION}
- L
-
- bundle "install"
- expect(the_bundle).to include_gems "rack 1.0.0"
- end
-
- it "serializes global git sources" do
- git = build_git "foo"
-
- install_gemfile <<-G
- git "#{lib_path("foo-1.0")}" do
- gem "foo"
- end
- G
-
- lockfile_should_be <<-G
- GIT
- remote: #{lib_path("foo-1.0")}
- revision: #{git.ref_for("master")}
- specs:
- foo (1.0)
-
- GEM
- specs:
-
- PLATFORMS
- #{generic_local_platform}
-
- DEPENDENCIES
- foo!
-
- BUNDLED WITH
- #{Bundler::VERSION}
- G
- end
-
- it "generates a lockfile with a ref for a single pinned source, git gem with a branch requirement" do
- git = build_git "foo"
- update_git "foo", :branch => "omg"
-
- install_gemfile <<-G
- gem "foo", :git => "#{lib_path("foo-1.0")}", :branch => "omg"
- G
-
- lockfile_should_be <<-G
- GIT
- remote: #{lib_path("foo-1.0")}
- revision: #{git.ref_for("omg")}
- branch: omg
- specs:
- foo (1.0)
-
- GEM
- specs:
-
- PLATFORMS
- #{generic_local_platform}
-
- DEPENDENCIES
- foo!
-
- BUNDLED WITH
- #{Bundler::VERSION}
- G
- end
-
- it "generates a lockfile with a ref for a single pinned source, git gem with a tag requirement" do
- git = build_git "foo"
- update_git "foo", :tag => "omg"
-
- install_gemfile <<-G
- gem "foo", :git => "#{lib_path("foo-1.0")}", :tag => "omg"
- G
-
- lockfile_should_be <<-G
- GIT
- remote: #{lib_path("foo-1.0")}
- revision: #{git.ref_for("omg")}
- tag: omg
- specs:
- foo (1.0)
-
- GEM
- specs:
-
- PLATFORMS
- #{generic_local_platform}
-
- DEPENDENCIES
- foo!
-
- BUNDLED WITH
- #{Bundler::VERSION}
- G
- end
-
- it "serializes pinned path sources to the lockfile" do
- build_lib "foo"
-
- install_gemfile <<-G
- gem "foo", :path => "#{lib_path("foo-1.0")}"
- G
-
- lockfile_should_be <<-G
- PATH
- remote: #{lib_path("foo-1.0")}
- specs:
- foo (1.0)
-
- GEM
- specs:
-
- PLATFORMS
- #{generic_local_platform}
-
- DEPENDENCIES
- foo!
-
- BUNDLED WITH
- #{Bundler::VERSION}
- G
- end
-
- it "serializes pinned path sources to the lockfile even when packaging" do
- build_lib "foo"
-
- install_gemfile! <<-G
- gem "foo", :path => "#{lib_path("foo-1.0")}"
- G
-
- bundle! :package, forgotten_command_line_options([:all, :cache_all] => true)
- bundle! :install, :local => true
-
- lockfile_should_be <<-G
- PATH
- remote: #{lib_path("foo-1.0")}
- specs:
- foo (1.0)
-
- GEM
- specs:
-
- PLATFORMS
- #{generic_local_platform}
-
- DEPENDENCIES
- foo!
-
- BUNDLED WITH
- #{Bundler::VERSION}
- G
- end
-
- it "sorts serialized sources by type" do
- build_lib "foo"
- bar = build_git "bar"
-
- install_gemfile <<-G
- source "file://localhost#{gem_repo1}"
-
- gem "rack"
- gem "foo", :path => "#{lib_path("foo-1.0")}"
- gem "bar", :git => "#{lib_path("bar-1.0")}"
- G
-
- lockfile_should_be <<-G
- GIT
- remote: #{lib_path("bar-1.0")}
- revision: #{bar.ref_for("master")}
- specs:
- bar (1.0)
-
- PATH
- remote: #{lib_path("foo-1.0")}
- specs:
- foo (1.0)
-
- GEM
- remote: file://localhost#{gem_repo1}/
- specs:
- rack (1.0.0)
-
- PLATFORMS
- #{generic_local_platform}
-
- DEPENDENCIES
- bar!
- foo!
- rack
-
- BUNDLED WITH
- #{Bundler::VERSION}
- G
- end
-
- it "lists gems alphabetically" do
- install_gemfile <<-G
- source "file://localhost#{gem_repo1}"
-
- gem "thin"
- gem "actionpack"
- gem "rack-obama"
- G
-
- lockfile_should_be <<-G
- GEM
- remote: file://localhost#{gem_repo1}/
- specs:
- actionpack (2.3.2)
- activesupport (= 2.3.2)
- activesupport (2.3.2)
- rack (1.0.0)
- rack-obama (1.0)
- rack
- thin (1.0)
- rack
-
- PLATFORMS
- #{generic_local_platform}
-
- DEPENDENCIES
- actionpack
- rack-obama
- thin
-
- BUNDLED WITH
- #{Bundler::VERSION}
- G
- end
-
- it "orders dependencies' dependencies in alphabetical order" do
- install_gemfile <<-G
- source "file://localhost#{gem_repo1}"
-
- gem "rails"
- G
-
- lockfile_should_be <<-G
- GEM
- remote: file://localhost#{gem_repo1}/
- specs:
- actionmailer (2.3.2)
- activesupport (= 2.3.2)
- actionpack (2.3.2)
- activesupport (= 2.3.2)
- activerecord (2.3.2)
- activesupport (= 2.3.2)
- activeresource (2.3.2)
- activesupport (= 2.3.2)
- activesupport (2.3.2)
- rails (2.3.2)
- actionmailer (= 2.3.2)
- actionpack (= 2.3.2)
- activerecord (= 2.3.2)
- activeresource (= 2.3.2)
- rake (= 10.0.2)
- rake (10.0.2)
-
- PLATFORMS
- #{generic_local_platform}
-
- DEPENDENCIES
- rails
-
- BUNDLED WITH
- #{Bundler::VERSION}
- G
- end
-
- it "orders dependencies by version" do
- install_gemfile <<-G
- source "file://localhost#{gem_repo1}"
- gem 'double_deps'
- G
-
- lockfile_should_be <<-G
- GEM
- remote: file://localhost#{gem_repo1}/
- specs:
- double_deps (1.0)
- net-ssh
- net-ssh (>= 1.0.0)
- net-ssh (1.0)
-
- PLATFORMS
- #{generic_local_platform}
-
- DEPENDENCIES
- double_deps
-
- BUNDLED WITH
- #{Bundler::VERSION}
- G
- end
-
- it "does not add the :require option to the lockfile" do
- install_gemfile <<-G
- source "file://localhost#{gem_repo1}"
-
- gem "rack-obama", ">= 1.0", :require => "rack/obama"
- G
-
- lockfile_should_be <<-G
- GEM
- remote: file://localhost#{gem_repo1}/
- specs:
- rack (1.0.0)
- rack-obama (1.0)
- rack
-
- PLATFORMS
- #{generic_local_platform}
-
- DEPENDENCIES
- rack-obama (>= 1.0)
-
- BUNDLED WITH
- #{Bundler::VERSION}
- G
- end
-
- it "does not add the :group option to the lockfile" do
- install_gemfile <<-G
- source "file://localhost#{gem_repo1}"
-
- gem "rack-obama", ">= 1.0", :group => :test
- G
-
- lockfile_should_be <<-G
- GEM
- remote: file://localhost#{gem_repo1}/
- specs:
- rack (1.0.0)
- rack-obama (1.0)
- rack
-
- PLATFORMS
- #{generic_local_platform}
-
- DEPENDENCIES
- rack-obama (>= 1.0)
-
- BUNDLED WITH
- #{Bundler::VERSION}
- G
- end
-
- it "stores relative paths when the path is provided in a relative fashion and in Gemfile dir" do
- build_lib "foo", :path => bundled_app("foo")
-
- install_gemfile <<-G
- path "foo"
- gem "foo"
- G
-
- lockfile_should_be <<-G
- PATH
- remote: foo
- specs:
- foo (1.0)
-
- GEM
- specs:
-
- PLATFORMS
- #{generic_local_platform}
-
- DEPENDENCIES
- foo
-
- BUNDLED WITH
- #{Bundler::VERSION}
- G
- end
-
- it "stores relative paths when the path is provided in a relative fashion and is above Gemfile dir" do
- build_lib "foo", :path => bundled_app(File.join("..", "foo"))
-
- install_gemfile <<-G
- path "../foo"
- gem "foo"
- G
-
- lockfile_should_be <<-G
- PATH
- remote: ../foo
- specs:
- foo (1.0)
-
- GEM
- specs:
-
- PLATFORMS
- #{generic_local_platform}
-
- DEPENDENCIES
- foo
-
- BUNDLED WITH
- #{Bundler::VERSION}
- G
- end
-
- it "stores relative paths when the path is provided in an absolute fashion but is relative" do
- build_lib "foo", :path => bundled_app("foo")
-
- install_gemfile <<-G
- path File.expand_path("../foo", __FILE__)
- gem "foo"
- G
-
- lockfile_should_be <<-G
- PATH
- remote: foo
- specs:
- foo (1.0)
-
- GEM
- specs:
-
- PLATFORMS
- #{generic_local_platform}
-
- DEPENDENCIES
- foo
-
- BUNDLED WITH
- #{Bundler::VERSION}
- G
- end
-
- it "stores relative paths when the path is provided for gemspec" do
- build_lib("foo", :path => tmp.join("foo"))
-
- install_gemfile <<-G
- gemspec :path => "../foo"
- G
-
- lockfile_should_be <<-G
- PATH
- remote: ../foo
- specs:
- foo (1.0)
-
- GEM
- specs:
-
- PLATFORMS
- #{generic_local_platform}
-
- DEPENDENCIES
- foo!
-
- BUNDLED WITH
- #{Bundler::VERSION}
- G
- end
-
- it "keeps existing platforms in the lockfile" do
- lockfile <<-G
- GEM
- remote: file://localhost#{gem_repo1}/
- specs:
- rack (1.0.0)
-
- PLATFORMS
- java
-
- DEPENDENCIES
- rack
-
- BUNDLED WITH
- #{Bundler::VERSION}
- G
-
- install_gemfile <<-G
- source "file://localhost#{gem_repo1}"
-
- gem "rack"
- G
-
- platforms = ["java", generic_local_platform.to_s].sort
-
- lockfile_should_be <<-G
- GEM
- remote: file://localhost#{gem_repo1}/
- specs:
- rack (1.0.0)
-
- PLATFORMS
- #{platforms[0]}
- #{platforms[1]}
-
- DEPENDENCIES
- rack
-
- BUNDLED WITH
- #{Bundler::VERSION}
- G
- end
-
- it "persists the spec's platform to the lockfile" do
- build_gem "platform_specific", "1.0.0", :to_system => true do |s|
- s.platform = Gem::Platform.new("universal-java-16")
- end
-
- simulate_platform "universal-java-16"
-
- install_gemfile <<-G
- source "file://localhost#{gem_repo1}"
- gem "platform_specific"
- G
-
- lockfile_should_be <<-G
- GEM
- remote: file://localhost#{gem_repo1}/
- specs:
- platform_specific (1.0-java)
-
- PLATFORMS
- java
-
- DEPENDENCIES
- platform_specific
-
- BUNDLED WITH
- #{Bundler::VERSION}
- G
- end
-
- it "does not add duplicate gems" do
- install_gemfile <<-G
- source "file://localhost#{gem_repo1}"
- gem "rack"
- G
-
- install_gemfile <<-G
- source "file://localhost#{gem_repo1}"
- gem "rack"
- gem "activesupport"
- G
-
- lockfile_should_be <<-G
- GEM
- remote: file://localhost#{gem_repo1}/
- specs:
- activesupport (2.3.5)
- rack (1.0.0)
-
- PLATFORMS
- ruby
-
- DEPENDENCIES
- activesupport
- rack
-
- BUNDLED WITH
- #{Bundler::VERSION}
- G
- end
-
- it "does not add duplicate dependencies" do
- install_gemfile <<-G
- source "file://localhost#{gem_repo1}"
- gem "rack"
- gem "rack"
- G
-
- lockfile_should_be <<-G
- GEM
- remote: file://localhost#{gem_repo1}/
- specs:
- rack (1.0.0)
-
- PLATFORMS
- ruby
-
- DEPENDENCIES
- rack
-
- BUNDLED WITH
- #{Bundler::VERSION}
- G
- end
-
- it "does not add duplicate dependencies with versions" do
- install_gemfile <<-G
- source "file://localhost#{gem_repo1}"
- gem "rack", "1.0"
- gem "rack", "1.0"
- G
-
- lockfile_should_be <<-G
- GEM
- remote: file://localhost#{gem_repo1}/
- specs:
- rack (1.0.0)
-
- PLATFORMS
- ruby
-
- DEPENDENCIES
- rack (= 1.0)
-
- BUNDLED WITH
- #{Bundler::VERSION}
- G
- end
-
- it "does not add duplicate dependencies in different groups" do
- install_gemfile <<-G
- source "file://localhost#{gem_repo1}"
- gem "rack", "1.0", :group => :one
- gem "rack", "1.0", :group => :two
- G
-
- lockfile_should_be <<-G
- GEM
- remote: file://localhost#{gem_repo1}/
- specs:
- rack (1.0.0)
-
- PLATFORMS
- ruby
-
- DEPENDENCIES
- rack (= 1.0)
-
- BUNDLED WITH
- #{Bundler::VERSION}
- G
- end
-
- it "raises if two different versions are used" do
- install_gemfile <<-G
- source "file://localhost#{gem_repo1}"
- gem "rack", "1.0"
- gem "rack", "1.1"
- G
-
- expect(bundled_app("Gemfile.lock")).not_to exist
- expect(out).to include "rack (= 1.0) and rack (= 1.1)"
- end
-
- it "raises if two different sources are used" do
- install_gemfile <<-G
- source "file://localhost#{gem_repo1}"
- gem "rack"
- gem "rack", :git => "git://hubz.com"
- G
-
- expect(bundled_app("Gemfile.lock")).not_to exist
- expect(out).to include "rack (>= 0) should come from an unspecified source and git://hubz.com (at master)"
- end
-
- it "works correctly with multiple version dependencies" do
- install_gemfile <<-G
- source "file://localhost#{gem_repo1}"
- gem "rack", "> 0.9", "< 1.0"
- G
-
- lockfile_should_be <<-G
- GEM
- remote: file://localhost#{gem_repo1}/
- specs:
- rack (0.9.1)
-
- PLATFORMS
- ruby
-
- DEPENDENCIES
- rack (> 0.9, < 1.0)
-
- BUNDLED WITH
- #{Bundler::VERSION}
- G
- end
-
- it "captures the Ruby version in the lockfile" do
- install_gemfile <<-G
- source "file://localhost#{gem_repo1}"
- ruby '#{RUBY_VERSION}'
- gem "rack", "> 0.9", "< 1.0"
- G
-
- lockfile_should_be <<-G
- GEM
- remote: file://localhost#{gem_repo1}/
- specs:
- rack (0.9.1)
-
- PLATFORMS
- ruby
-
- DEPENDENCIES
- rack (> 0.9, < 1.0)
-
- RUBY VERSION
- ruby #{RUBY_VERSION}p#{RUBY_PATCHLEVEL}
-
- BUNDLED WITH
- #{Bundler::VERSION}
- G
- end
-
- # Some versions of the Bundler 1.1 RC series introduced corrupted
- # lockfiles. There were two major problems:
- #
- # * multiple copies of the same GIT section appeared in the lockfile
- # * when this happened, those sections got multiple copies of gems
- # in those sections.
- it "fixes corrupted lockfiles" do
- build_git "omg", :path => lib_path("omg")
- revision = revision_for(lib_path("omg"))
-
- gemfile <<-G
- source "file://localhost#{gem_repo1}"
- gem "omg", :git => "#{lib_path("omg")}", :branch => 'master'
- G
-
- bundle "install --path vendor"
- expect(the_bundle).to include_gems "omg 1.0"
-
- # Create a Gemfile.lock that has duplicate GIT sections
- lockfile <<-L
- GIT
- remote: #{lib_path("omg")}
- revision: #{revision}
- branch: master
- specs:
- omg (1.0)
-
- GIT
- remote: #{lib_path("omg")}
- revision: #{revision}
- branch: master
- specs:
- omg (1.0)
-
- GEM
- remote: file://localhost#{gem_repo1}/
- specs:
-
- PLATFORMS
- #{local}
-
- DEPENDENCIES
- omg!
-
- BUNDLED WITH
- #{Bundler::VERSION}
- L
-
- FileUtils.rm_rf(bundled_app("vendor"))
- bundle "install"
- expect(the_bundle).to include_gems "omg 1.0"
-
- # Confirm that duplicate specs do not appear
- lockfile_should_be(<<-L)
- GIT
- remote: #{lib_path("omg")}
- revision: #{revision}
- branch: master
- specs:
- omg (1.0)
-
- GEM
- remote: file://localhost#{gem_repo1}/
- specs:
-
- PLATFORMS
- #{local}
-
- DEPENDENCIES
- omg!
-
- BUNDLED WITH
- #{Bundler::VERSION}
- L
- end
-
- it "raises a helpful error message when the lockfile is missing deps" do
- lockfile <<-L
- GEM
- remote: file://localhost#{gem_repo1}/
- specs:
- rack_middleware (1.0)
-
- PLATFORMS
- #{local}
-
- DEPENDENCIES
- rack_middleware
- L
-
- install_gemfile <<-G
- source "file:#{gem_repo1}"
- gem "rack_middleware"
- G
-
- expect(out).to include("Downloading rack_middleware-1.0 revealed dependencies not in the API or the lockfile (#{Gem::Dependency.new("rack", "= 0.9.1")}).").
- and include("Either installing with `--full-index` or running `bundle update rack_middleware` should fix the problem.")
- end
-
- describe "a line ending" do
- def set_lockfile_mtime_to_known_value
- time = Time.local(2000, 1, 1, 0, 0, 0)
- File.utime(time, time, bundled_app("Gemfile.lock"))
- end
- before(:each) do
- build_repo2
-
- install_gemfile <<-G
- source "file://localhost#{gem_repo2}"
- gem "rack"
- G
- set_lockfile_mtime_to_known_value
- end
-
- it "generates Gemfile.lock with \\n line endings" do
- expect(File.read(bundled_app("Gemfile.lock"))).not_to match("\r\n")
- expect(the_bundle).to include_gems "rack 1.0"
- end
-
- context "during updates" do
- it "preserves Gemfile.lock \\n line endings" do
- update_repo2
-
- expect { bundle "update", :all => true }.to change { File.mtime(bundled_app("Gemfile.lock")) }
- expect(File.read(bundled_app("Gemfile.lock"))).not_to match("\r\n")
- expect(the_bundle).to include_gems "rack 1.2"
- end
-
- it "preserves Gemfile.lock \\n\\r line endings" do
- update_repo2
- win_lock = File.read(bundled_app("Gemfile.lock")).gsub(/\n/, "\r\n")
- File.open(bundled_app("Gemfile.lock"), "wb") {|f| f.puts(win_lock) }
- set_lockfile_mtime_to_known_value
-
- expect { bundle "update", :all => true }.to change { File.mtime(bundled_app("Gemfile.lock")) }
- expect(File.read(bundled_app("Gemfile.lock"))).to match("\r\n")
- expect(the_bundle).to include_gems "rack 1.2"
- end
- end
-
- context "when nothing changes" do
- it "preserves Gemfile.lock \\n line endings" do
- expect do
- ruby <<-RUBY
- require 'rubygems'
- require 'bundler'
- Bundler.setup
- RUBY
- end.not_to change { File.mtime(bundled_app("Gemfile.lock")) }
- end
-
- it "preserves Gemfile.lock \\n\\r line endings" do
- win_lock = File.read(bundled_app("Gemfile.lock")).gsub(/\n/, "\r\n")
- File.open(bundled_app("Gemfile.lock"), "wb") {|f| f.puts(win_lock) }
- set_lockfile_mtime_to_known_value
-
- expect do
- ruby <<-RUBY
- require 'rubygems'
- require 'bundler'
- Bundler.setup
- RUBY
- end.not_to change { File.mtime(bundled_app("Gemfile.lock")) }
- end
- end
- end
-
- it "refuses to install if Gemfile.lock contains conflict markers" do
- lockfile <<-L
- GEM
- remote: file://localhost#{gem_repo1}/
- specs:
- <<<<<<<
- rack (1.0.0)
- =======
- rack (1.0.1)
- >>>>>>>
-
- PLATFORMS
- ruby
-
- DEPENDENCIES
- rack
-
- BUNDLED WITH
- #{Bundler::VERSION}
- L
-
- install_gemfile(<<-G)
- source "file://localhost#{gem_repo1}"
- gem "rack"
- G
-
- expect(last_command.bundler_err).to match(/your Gemfile.lock contains merge conflicts/i)
- expect(last_command.bundler_err).to match(/git checkout HEAD -- Gemfile.lock/i)
- end
-end
diff --git a/spec/bundler/lock/lockfile_spec.rb b/spec/bundler/lock/lockfile_spec.rb
index 9e2fb3b2dd..5ee44bf779 100644
--- a/spec/bundler/lock/lockfile_spec.rb
+++ b/spec/bundler/lock/lockfile_spec.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-RSpec.describe "the lockfile format", :bundler => "3" do
+RSpec.describe "the lockfile format" do
include Bundler::GemHelpers
before { ENV["BUNDLER_SPEC_IGNORE_COMPATIBILITY_GUARD"] = "TRUE" }
@@ -76,7 +76,7 @@ RSpec.describe "the lockfile format", :bundler => "3" do
end
it "does not update the lockfile's bundler version if nothing changed during bundle install" do
- version = "#{Bundler::VERSION.split(".").first}.0.0.0.a"
+ version = "#{Bundler::VERSION.split(".").first}.0.0.a"
lockfile <<-L
GEM
@@ -180,8 +180,10 @@ RSpec.describe "the lockfile format", :bundler => "3" do
end
warning_message = "the running version of Bundler (9999999.0.0) is older " \
- "than the version that created the lockfile (9999999.1.0)"
- expect(last_command.bundler_err).to include warning_message
+ "than the version that created the lockfile (9999999.1.0). " \
+ "We suggest you to upgrade to the version that created the " \
+ "lockfile by running `gem install bundler:9999999.1.0`."
+ expect(last_command.stderr).to include warning_message
lockfile_should_be <<-G
GEM
@@ -190,7 +192,8 @@ RSpec.describe "the lockfile format", :bundler => "3" do
rack (1.0.0)
PLATFORMS
- #{lockfile_platforms}
+ #{generic_local_platform}
+ #{specific_local_platform}
DEPENDENCIES
rack
@@ -200,7 +203,7 @@ RSpec.describe "the lockfile format", :bundler => "3" do
G
end
- it "errors if the current is a major version older than lockfile's bundler version" do
+ it "errors if the current is a major version older than lockfile's bundler version", :bundler => "3" do
lockfile <<-L
GEM
remote: file://localhost#{gem_repo1}/
@@ -262,10 +265,10 @@ RSpec.describe "the lockfile format", :bundler => "3" do
G
expect(last_command).to be_failure
- expect(out).to include("You must use Bundler 9999999 or greater with this lockfile.")
+ expect(err).to include("You must use Bundler 9999999 or greater with this lockfile.")
end
- it "warns when updating bundler major version" do
+ it "warns when updating bundler major version", :bundler => "< 3" do
lockfile <<-L
GEM
remote: file://localhost#{gem_repo1}/
@@ -290,8 +293,10 @@ RSpec.describe "the lockfile format", :bundler => "3" do
G
end
- expect(out).to include("Warning: the lockfile is being updated to Bundler " \
- "9999999, after which you will be unable to return to Bundler 1.")
+ expect(last_command.stderr).to include(
+ "Warning: the lockfile is being updated to Bundler " \
+ "9999999, after which you will be unable to return to Bundler 1."
+ )
lockfile_should_be <<-G
GEM
@@ -300,7 +305,8 @@ RSpec.describe "the lockfile format", :bundler => "3" do
rack (1.0.0)
PLATFORMS
- #{lockfile_platforms}
+ #{generic_local_platform}
+ #{specific_local_platform}
DEPENDENCIES
rack
@@ -310,6 +316,53 @@ RSpec.describe "the lockfile format", :bundler => "3" do
G
end
+ it "warns when updating bundler major version", :bundler => "3" do
+ lockfile <<-L
+ GEM
+ remote: file://localhost#{gem_repo1}/
+ specs:
+ rack (1.0.0)
+
+ PLATFORMS
+ #{lockfile_platforms}
+
+ DEPENDENCIES
+ rack
+
+ BUNDLED WITH
+ 1.10.0
+ L
+
+ simulate_bundler_version "9999999.0.0" do
+ install_gemfile <<-G
+ source "file://localhost#{gem_repo1}/"
+
+ gem "rack"
+ G
+
+ expect(last_command.stderr).to include(
+ "Warning: the lockfile is being updated to Bundler " \
+ "9999999, after which you will be unable to return to Bundler 1."
+ )
+
+ lockfile_should_be <<-G
+ GEM
+ remote: file://localhost#{gem_repo1}/
+ specs:
+ rack (1.0.0)
+
+ PLATFORMS
+ #{lockfile_platforms}
+
+ DEPENDENCIES
+ rack
+
+ BUNDLED WITH
+ 9999999.0.0
+ G
+ end
+ end
+
it "generates a simple lockfile for a single source, gem with dependencies" do
install_gemfile <<-G
source "file://localhost#{gem_repo1}/"
@@ -362,8 +415,41 @@ RSpec.describe "the lockfile format", :bundler => "3" do
G
end
- it "generates a lockfile without credentials for a configured source" do
- bundle "config http://localgemserver.test/ user:pass"
+ it "generates a lockfile without credentials for a configured source", :bundler => "< 3" do
+ bundle "config set http://localgemserver.test/ user:pass"
+
+ install_gemfile(<<-G, :artifice => "endpoint_strict_basic_authentication", :quiet => true)
+ source "http://localgemserver.test/" do
+
+ end
+
+ source "http://user:pass@othergemserver.test/" do
+ gem "rack-obama", ">= 1.0"
+ end
+ G
+
+ lockfile_should_be <<-G
+ GEM
+ remote: http://localgemserver.test/
+ remote: http://user:pass@othergemserver.test/
+ specs:
+ rack (1.0.0)
+ rack-obama (1.0)
+ rack
+
+ PLATFORMS
+ #{lockfile_platforms}
+
+ DEPENDENCIES
+ rack-obama (>= 1.0)!
+
+ BUNDLED WITH
+ #{Bundler::VERSION}
+ G
+ end
+
+ it "generates a lockfile without credentials for a configured source", :bundler => "3" do
+ bundle "config set http://localgemserver.test/ user:pass"
install_gemfile(<<-G, :artifice => "endpoint_strict_basic_authentication", :quiet => true)
source "http://localgemserver.test/" do
@@ -464,15 +550,15 @@ RSpec.describe "the lockfile format", :bundler => "3" do
G
lockfile_should_be <<-G
- GEM
- specs:
-
GIT
remote: #{lib_path("foo-1.0")}
revision: #{git.ref_for("master")}
specs:
foo (1.0)
+ GEM
+ specs:
+
PLATFORMS
#{lockfile_platforms}
@@ -533,15 +619,15 @@ RSpec.describe "the lockfile format", :bundler => "3" do
G
lockfile_should_be <<-G
- GEM
- specs:
-
GIT
remote: #{lib_path("foo-1.0")}
revision: #{git.ref_for("master")}
specs:
foo (1.0)
+ GEM
+ specs:
+
PLATFORMS
#{lockfile_platforms}
@@ -562,9 +648,6 @@ RSpec.describe "the lockfile format", :bundler => "3" do
G
lockfile_should_be <<-G
- GEM
- specs:
-
GIT
remote: #{lib_path("foo-1.0")}
revision: #{git.ref_for("omg")}
@@ -572,6 +655,9 @@ RSpec.describe "the lockfile format", :bundler => "3" do
specs:
foo (1.0)
+ GEM
+ specs:
+
PLATFORMS
#{lockfile_platforms}
@@ -592,9 +678,6 @@ RSpec.describe "the lockfile format", :bundler => "3" do
G
lockfile_should_be <<-G
- GEM
- specs:
-
GIT
remote: #{lib_path("foo-1.0")}
revision: #{git.ref_for("omg")}
@@ -602,6 +685,9 @@ RSpec.describe "the lockfile format", :bundler => "3" do
specs:
foo (1.0)
+ GEM
+ specs:
+
PLATFORMS
#{lockfile_platforms}
@@ -621,14 +707,14 @@ RSpec.describe "the lockfile format", :bundler => "3" do
G
lockfile_should_be <<-G
- GEM
- specs:
-
PATH
remote: #{lib_path("foo-1.0")}
specs:
foo (1.0)
+ GEM
+ specs:
+
PLATFORMS
#{lockfile_platforms}
@@ -651,14 +737,14 @@ RSpec.describe "the lockfile format", :bundler => "3" do
bundle! :install, :local => true
lockfile_should_be <<-G
- GEM
- specs:
-
PATH
remote: #{lib_path("foo-1.0")}
specs:
foo (1.0)
+ GEM
+ specs:
+
PLATFORMS
#{lockfile_platforms}
@@ -683,11 +769,6 @@ RSpec.describe "the lockfile format", :bundler => "3" do
G
lockfile_should_be <<-G
- GEM
- remote: file://localhost#{gem_repo1}/
- specs:
- rack (1.0.0)
-
GIT
remote: #{lib_path("bar-1.0")}
revision: #{bar.ref_for("master")}
@@ -699,6 +780,11 @@ RSpec.describe "the lockfile format", :bundler => "3" do
specs:
foo (1.0)
+ GEM
+ remote: file://localhost#{gem_repo1}/
+ specs:
+ rack (1.0.0)
+
PLATFORMS
#{lockfile_platforms}
@@ -772,8 +858,8 @@ RSpec.describe "the lockfile format", :bundler => "3" do
actionpack (= 2.3.2)
activerecord (= 2.3.2)
activeresource (= 2.3.2)
- rake (= 10.0.2)
- rake (10.0.2)
+ rake (= 12.3.2)
+ rake (12.3.2)
PLATFORMS
#{lockfile_platforms}
@@ -874,14 +960,14 @@ RSpec.describe "the lockfile format", :bundler => "3" do
G
lockfile_should_be <<-G
- GEM
- specs:
-
PATH
remote: foo
specs:
foo (1.0)
+ GEM
+ specs:
+
PLATFORMS
#{lockfile_platforms}
@@ -903,14 +989,14 @@ RSpec.describe "the lockfile format", :bundler => "3" do
G
lockfile_should_be <<-G
- GEM
- specs:
-
PATH
remote: ../foo
specs:
foo (1.0)
+ GEM
+ specs:
+
PLATFORMS
#{lockfile_platforms}
@@ -932,14 +1018,14 @@ RSpec.describe "the lockfile format", :bundler => "3" do
G
lockfile_should_be <<-G
- GEM
- specs:
-
PATH
remote: foo
specs:
foo (1.0)
+ GEM
+ specs:
+
PLATFORMS
#{lockfile_platforms}
@@ -959,14 +1045,14 @@ RSpec.describe "the lockfile format", :bundler => "3" do
G
lockfile_should_be <<-G
- GEM
- specs:
-
PATH
remote: ../foo
specs:
foo (1.0)
+ GEM
+ specs:
+
PLATFORMS
#{lockfile_platforms}
@@ -978,7 +1064,48 @@ RSpec.describe "the lockfile format", :bundler => "3" do
G
end
- it "keeps existing platforms in the lockfile" do
+ it "keeps existing platforms in the lockfile", :bundler => "< 3" do
+ lockfile <<-G
+ GEM
+ remote: file://localhost#{gem_repo1}/
+ specs:
+ rack (1.0.0)
+
+ PLATFORMS
+ java
+
+ DEPENDENCIES
+ rack
+
+ BUNDLED WITH
+ #{Bundler::VERSION}
+ G
+
+ install_gemfile <<-G
+ source "file://localhost#{gem_repo1}/"
+
+ gem "rack"
+ G
+
+ lockfile_should_be <<-G
+ GEM
+ remote: file://localhost#{gem_repo1}/
+ specs:
+ rack (1.0.0)
+
+ PLATFORMS
+ java
+ #{generic_local_platform}
+
+ DEPENDENCIES
+ rack
+
+ BUNDLED WITH
+ #{Bundler::VERSION}
+ G
+ end
+
+ it "keeps existing platforms in the lockfile", :bundler => "3" do
lockfile <<-G
GEM
remote: file://localhost#{gem_repo1}/
@@ -1008,7 +1135,9 @@ RSpec.describe "the lockfile format", :bundler => "3" do
rack (1.0.0)
PLATFORMS
- #{lockfile_platforms "java", generic_local_platform, specific_local_platform}
+ java
+ #{generic_local_platform}
+ #{specific_local_platform}
DEPENDENCIES
rack
@@ -1018,7 +1147,38 @@ RSpec.describe "the lockfile format", :bundler => "3" do
G
end
- it "persists the spec's platform to the lockfile" do
+ it "persists the spec's platform to the lockfile", :bundler => "< 3" do
+ build_repo2 do
+ build_gem "platform_specific", "1.0" do |s|
+ s.platform = Gem::Platform.new("universal-java-16")
+ end
+ end
+
+ simulate_platform "universal-java-16"
+
+ install_gemfile! <<-G
+ source "file://localhost#{gem_repo2}"
+ gem "platform_specific"
+ G
+
+ lockfile_should_be <<-G
+ GEM
+ remote: file://localhost#{gem_repo2}/
+ specs:
+ platform_specific (1.0-java)
+
+ PLATFORMS
+ java
+
+ DEPENDENCIES
+ platform_specific
+
+ BUNDLED WITH
+ #{Bundler::VERSION}
+ G
+ end
+
+ it "persists the spec's platform and specific platform to the lockfile", :bundler => "3" do
build_repo2 do
build_gem "platform_specific", "1.0" do |s|
s.platform = Gem::Platform.new("universal-java-16")
@@ -1162,7 +1322,7 @@ RSpec.describe "the lockfile format", :bundler => "3" do
G
expect(bundled_app("Gemfile.lock")).not_to exist
- expect(out).to include "rack (= 1.0) and rack (= 1.1)"
+ expect(err).to include "rack (= 1.0) and rack (= 1.1)"
end
it "raises if two different sources are used" do
@@ -1173,7 +1333,7 @@ RSpec.describe "the lockfile format", :bundler => "3" do
G
expect(bundled_app("Gemfile.lock")).not_to exist
- expect(out).to include "rack (>= 0) should come from an unspecified source and git://hubz.com (at master)"
+ expect(err).to include "rack (>= 0) should come from an unspecified source and git://hubz.com (at master)"
end
it "works correctly with multiple version dependencies" do
@@ -1246,10 +1406,6 @@ RSpec.describe "the lockfile format", :bundler => "3" do
# Create a Gemfile.lock that has duplicate GIT sections
lockfile <<-L
- GEM
- remote: file://localhost#{gem_repo1}/
- specs:
-
GIT
remote: #{lib_path("omg")}
revision: #{revision}
@@ -1264,6 +1420,10 @@ RSpec.describe "the lockfile format", :bundler => "3" do
specs:
omg (1.0)
+ GEM
+ remote: file://localhost#{gem_repo1}/
+ specs:
+
PLATFORMS
#{lockfile_platforms}
@@ -1280,10 +1440,6 @@ RSpec.describe "the lockfile format", :bundler => "3" do
# Confirm that duplicate specs do not appear
lockfile_should_be(<<-L)
- GEM
- remote: file://localhost#{gem_repo1}/
- specs:
-
GIT
remote: #{lib_path("omg")}
revision: #{revision}
@@ -1291,6 +1447,10 @@ RSpec.describe "the lockfile format", :bundler => "3" do
specs:
omg (1.0)
+ GEM
+ remote: file://localhost#{gem_repo1}/
+ specs:
+
PLATFORMS
#{lockfile_platforms}
@@ -1321,7 +1481,7 @@ RSpec.describe "the lockfile format", :bundler => "3" do
gem "rack_middleware"
G
- expect(out).to include("Downloading rack_middleware-1.0 revealed dependencies not in the API or the lockfile (#{Gem::Dependency.new("rack", "= 0.9.1")}).").
+ expect(err).to include("Downloading rack_middleware-1.0 revealed dependencies not in the API or the lockfile (#{Gem::Dependency.new("rack", "= 0.9.1")}).").
and include("Either installing with `--full-index` or running `bundle update rack_middleware` should fix the problem.")
end
diff --git a/spec/bundler/other/bundle_ruby_spec.rb b/spec/bundler/other/bundle_ruby_spec.rb
deleted file mode 100644
index fbca31d0a0..0000000000
--- a/spec/bundler/other/bundle_ruby_spec.rb
+++ /dev/null
@@ -1,155 +0,0 @@
-# frozen_string_literal: true
-
-RSpec.describe "bundle_ruby", :bundler => "< 3" do
- context "without patchlevel" do
- it "returns the ruby version" do
- gemfile <<-G
- source "file://#{gem_repo1}"
- ruby "1.9.3", :engine => 'ruby', :engine_version => '1.9.3'
-
- gem "foo"
- G
-
- bundle_ruby
-
- expect(out).to include("ruby 1.9.3")
- end
-
- it "engine defaults to MRI" do
- gemfile <<-G
- source "file://#{gem_repo1}"
- ruby "1.9.3"
-
- gem "foo"
- G
-
- bundle_ruby
-
- expect(out).to include("ruby 1.9.3")
- end
-
- it "handles jruby" do
- gemfile <<-G
- source "file://#{gem_repo1}"
- ruby "1.8.7", :engine => 'jruby', :engine_version => '1.6.5'
-
- gem "foo"
- G
-
- bundle_ruby
-
- expect(out).to include("ruby 1.8.7 (jruby 1.6.5)")
- end
-
- it "handles rbx" do
- gemfile <<-G
- source "file://#{gem_repo1}"
- ruby "1.8.7", :engine => 'rbx', :engine_version => '1.2.4'
-
- gem "foo"
- G
-
- bundle_ruby
-
- expect(out).to include("ruby 1.8.7 (rbx 1.2.4)")
- end
-
- it "handles truffleruby", :rubygems => ">= 2.1.0" do
- gemfile <<-G
- source "file://#{gem_repo1}"
- ruby "2.5.1", :engine => 'truffleruby', :engine_version => '1.0.0-rc6'
-
- gem "foo"
- G
-
- bundle_ruby
-
- expect(out).to include("ruby 2.5.1 (truffleruby 1.0.0-rc6)")
- end
-
- it "raises an error if engine is used but engine version is not" do
- gemfile <<-G
- source "file://#{gem_repo1}"
- ruby "1.8.7", :engine => 'rbx'
-
- gem "foo"
- G
-
- bundle_ruby
- expect(exitstatus).not_to eq(0) if exitstatus
-
- bundle_ruby
- expect(out).to include("Please define :engine_version")
- end
-
- it "raises an error if engine_version is used but engine is not" do
- gemfile <<-G
- source "file://#{gem_repo1}"
- ruby "1.8.7", :engine_version => '1.2.4'
-
- gem "foo"
- G
-
- bundle_ruby
- expect(exitstatus).not_to eq(0) if exitstatus
-
- bundle_ruby
- expect(out).to include("Please define :engine")
- end
-
- it "raises an error if engine version doesn't match ruby version for MRI" do
- gemfile <<-G
- source "file://#{gem_repo1}"
- ruby "1.8.7", :engine => 'ruby', :engine_version => '1.2.4'
-
- gem "foo"
- G
-
- bundle_ruby
- expect(exitstatus).not_to eq(0) if exitstatus
-
- bundle_ruby
- expect(out).to include("ruby_version must match the :engine_version for MRI")
- end
-
- it "should print if no ruby version is specified" do
- gemfile <<-G
- source "file://#{gem_repo1}"
-
- gem "foo"
- G
-
- bundle_ruby
-
- expect(out).to include("No ruby version specified")
- end
- end
-
- context "when using patchlevel" do
- it "returns the ruby version" do
- gemfile <<-G
- source "file://#{gem_repo1}"
- ruby "1.9.3", :patchlevel => '429', :engine => 'ruby', :engine_version => '1.9.3'
-
- gem "foo"
- G
-
- bundle_ruby
-
- expect(out).to include("ruby 1.9.3p429")
- end
-
- it "handles an engine" do
- gemfile <<-G
- source "file://#{gem_repo1}"
- ruby "1.9.3", :patchlevel => '392', :engine => 'jruby', :engine_version => '1.7.4'
-
- gem "foo"
- G
-
- bundle_ruby
-
- expect(out).to include("ruby 1.9.3p392 (jruby 1.7.4)")
- end
- end
-end
diff --git a/spec/bundler/other/cli_dispatch_spec.rb b/spec/bundler/other/cli_dispatch_spec.rb
index d17819b394..67127fc6e0 100644
--- a/spec/bundler/other/cli_dispatch_spec.rb
+++ b/spec/bundler/other/cli_dispatch_spec.rb
@@ -19,7 +19,7 @@ RSpec.describe "bundle command names" do
end
context "when cache_command_is_package is set" do
- before { bundle! "config cache_command_is_package true" }
+ before { bundle! "config set cache_command_is_package true" }
it "dispatches `bundle cache` to the package command" do
bundle "cache --verbose"
diff --git a/spec/bundler/other/compatibility_guard_spec.rb b/spec/bundler/other/compatibility_guard_spec.rb
index ac05ebd918..c72842eab5 100644
--- a/spec/bundler/other/compatibility_guard_spec.rb
+++ b/spec/bundler/other/compatibility_guard_spec.rb
@@ -12,14 +12,5 @@ RSpec.describe "bundler compatibility guard" do
expect(err).to eq("Bundler 2 requires Ruby 2.3 or later. Either install bundler 1 or update to a supported Ruby version.")
end
end
-
- context "when running on RubyGems < 2.5", :ruby => ">= 2.5" do
- before { simulate_rubygems_version "1.3.6" }
-
- it "raises a friendly error" do
- bundle :version
- expect(err).to eq("Bundler 2 requires RubyGems 2.5 or later. Either install bundler 1 or update to a supported RubyGems version.")
- end
- end
end
end
diff --git a/spec/bundler/other/ext_spec.rb b/spec/bundler/other/ext_spec.rb
index 3f6f8b4928..bc8c781c5d 100644
--- a/spec/bundler/other/ext_spec.rb
+++ b/spec/bundler/other/ext_spec.rb
@@ -54,13 +54,8 @@ RSpec.describe "Gem::SourceIndex#refresh!" do
G
end
- it "does not explode when called", :rubygems => "1.7" do
+ it "does not explode when called" do
run "Gem.source_index.refresh!"
run "Gem::SourceIndex.new([]).refresh!"
end
-
- it "does not explode when called", :rubygems => "< 1.7" do
- run "Gem.source_index.refresh!"
- run "Gem::SourceIndex.from_gems_in([]).refresh!"
- end
end
diff --git a/spec/bundler/other/major_deprecation_spec.rb b/spec/bundler/other/major_deprecation_spec.rb
index 50800dbb0c..83944e4075 100644
--- a/spec/bundler/other/major_deprecation_spec.rb
+++ b/spec/bundler/other/major_deprecation_spec.rb
@@ -1,126 +1,235 @@
# frozen_string_literal: true
-RSpec.describe "major deprecations", :bundler => "< 3" do
- let(:warnings) { last_command.bundler_err } # change to err in 2.0
- let(:warnings_without_version_messages) { warnings.gsub(/#{Spec::Matchers::MAJOR_DEPRECATION}Bundler will only support ruby(gems)? >= .*/, "") }
+RSpec.describe "major deprecations" do
+ let(:warnings) { err }
- context "in a .99 version" do
+ describe "Bundler" do
before do
- simulate_bundler_version "1.99.1"
- bundle "config --delete major_deprecations"
+ install_gemfile! <<-G
+ source "file:#{gem_repo1}"
+ gem "rack"
+ G
end
- it "prints major deprecations without being configured" do
- ruby <<-R
- require "bundler"
- Bundler::SharedHelpers.major_deprecation(Bundler::VERSION)
- R
+ describe ".clean_env" do
+ before do
+ source = "Bundler.clean_env"
+ bundle "exec ruby -e #{source.dump}"
+ end
+
+ it "is deprecated in favor of .unbundled_env", :bundler => "2" do
+ expect(deprecations).to include \
+ "`Bundler.clean_env` has been deprecated in favor of `Bundler.unbundled_env`. " \
+ "If you instead want the environment before bundler was originally loaded, use `Bundler.original_env`"
+ end
- expect(warnings).to have_major_deprecation("1.99.1")
+ pending "is removed and shows a helpful error message about it", :bundler => "3"
end
- end
- before do
- bundle "config major_deprecations true"
+ describe ".with_clean_env" do
+ before do
+ source = "Bundler.with_clean_env {}"
+ bundle "exec ruby -e #{source.dump}"
+ end
- create_file "gems.rb", <<-G
- source "file:#{gem_repo1}"
- ruby #{RUBY_VERSION.dump}
- gem "rack"
- G
- bundle! "install"
- end
+ it "is deprecated in favor of .unbundled_env", :bundler => "2" do
+ expect(deprecations).to include(
+ "`Bundler.with_clean_env` has been deprecated in favor of `Bundler.with_unbundled_env`. " \
+ "If you instead want the environment before bundler was originally loaded, use `Bundler.with_original_env`"
+ )
+ end
- describe "bundle_ruby" do
- it "prints a deprecation" do
- bundle_ruby
- warnings.gsub! "\nruby #{RUBY_VERSION}", ""
- expect(warnings).to have_major_deprecation "the bundle_ruby executable has been removed in favor of `bundle platform --ruby`"
+ pending "is removed and shows a helpful error message about it", :bundler => "3"
end
- end
- describe "Bundler" do
- describe ".clean_env" do
- it "is deprecated in favor of .original_env" do
- source = "Bundler.clean_env"
+ describe ".clean_system" do
+ before do
+ source = "Bundler.clean_system('ls')"
bundle "exec ruby -e #{source.dump}"
- expect(warnings).to have_major_deprecation "`Bundler.clean_env` has weird edge cases, use `.original_env` instead"
end
+
+ it "is deprecated in favor of .unbundled_system", :bundler => "2" do
+ expect(deprecations).to include(
+ "`Bundler.clean_system` has been deprecated in favor of `Bundler.unbundled_system`. " \
+ "If you instead want to run the command in the environment before bundler was originally loaded, use `Bundler.original_system`"
+ )
+ end
+
+ pending "is removed and shows a helpful error message about it", :bundler => "3"
+ end
+
+ describe ".clean_exec" do
+ before do
+ source = "Bundler.clean_exec('ls')"
+ bundle "exec ruby -e #{source.dump}"
+ end
+
+ it "is deprecated in favor of .unbundled_exec", :bundler => "2" do
+ expect(deprecations).to include(
+ "`Bundler.clean_exec` has been deprecated in favor of `Bundler.unbundled_exec`. " \
+ "If you instead want to exec to a command in the environment before bundler was originally loaded, use `Bundler.original_exec`"
+ )
+ end
+
+ pending "is removed and shows a helpful error message about it", :bundler => "3"
end
describe ".environment" do
- it "is deprecated in favor of .load" do
+ before do
source = "Bundler.environment"
bundle "exec ruby -e #{source.dump}"
- expect(warnings).to have_major_deprecation "Bundler.environment has been removed in favor of Bundler.load"
end
+
+ it "is deprecated in favor of .load", :bundler => "2" do
+ expect(deprecations).to include "Bundler.environment has been removed in favor of Bundler.load"
+ end
+
+ pending "is removed and shows a helpful error message about it", :bundler => "3"
end
+ end
- shared_examples_for "environmental deprecations" do |trigger|
- describe "ruby version", :ruby => "< 2.0" do
- it "requires a newer ruby version" do
- instance_eval(&trigger)
- expect(warnings).to have_major_deprecation "Bundler will only support ruby >= 2.0, you are running #{RUBY_VERSION}"
- end
+ describe "bundle update --quiet" do
+ it "does not print any deprecations" do
+ bundle :update, :quiet => true
+ expect(deprecations).to be_empty
+ end
+ end
+
+ describe "bundle config" do
+ describe "old list interface" do
+ before do
+ bundle! "config"
end
- describe "rubygems version", :rubygems => "< 2.0" do
- it "requires a newer rubygems version" do
- instance_eval(&trigger)
- expect(warnings).to have_major_deprecation "Bundler will only support rubygems >= 2.0, you are running #{Gem::VERSION}"
- end
+ it "warns", :bundler => "2" do
+ expect(deprecations).to include("Using the `config` command without a subcommand [list, get, set, unset] is deprecated and will be removed in the future. Use `bundle config list` instead.")
end
+
+ pending "fails with a helpful error", :bundler => "3"
end
- describe "-rbundler/setup" do
- it_behaves_like "environmental deprecations", proc { ruby "require 'bundler/setup'" }
+ describe "old get interface" do
+ before do
+ bundle! "config waka"
+ end
+
+ it "warns", :bundler => "2" do
+ expect(deprecations).to include("Using the `config` command without a subcommand [list, get, set, unset] is deprecated and will be removed in the future. Use `bundle config get waka` instead.")
+ end
+
+ pending "fails with a helpful error", :bundler => "3"
end
- describe "Bundler.setup" do
- it_behaves_like "environmental deprecations", proc { ruby "require 'bundler'; Bundler.setup" }
+ describe "old set interface" do
+ before do
+ bundle! "config waka wakapun"
+ end
+
+ it "warns", :bundler => "2" do
+ expect(deprecations).to include("Using the `config` command without a subcommand [list, get, set, unset] is deprecated and will be removed in the future. Use `bundle config set waka wakapun` instead.")
+ end
+
+ pending "fails with a helpful error", :bundler => "3"
end
- describe "bundle check" do
- it_behaves_like "environmental deprecations", proc { bundle :check }
+ describe "old set interface with --local" do
+ before do
+ bundle! "config --local waka wakapun"
+ end
+
+ it "warns", :bundler => "2" do
+ expect(deprecations).to include("Using the `config` command without a subcommand [list, get, set, unset] is deprecated and will be removed in the future. Use `bundle config set --local waka wakapun` instead.")
+ end
+
+ pending "fails with a helpful error", :bundler => "3"
end
- describe "bundle update --quiet" do
- it "does not print any deprecations" do
- bundle :update, :quiet => true
- expect(warnings_without_version_messages).not_to have_major_deprecation
+ describe "old set interface with --global" do
+ before do
+ bundle! "config --global waka wakapun"
end
+
+ it "warns", :bundler => "2" do
+ expect(deprecations).to include("Using the `config` command without a subcommand [list, get, set, unset] is deprecated and will be removed in the future. Use `bundle config set --global waka wakapun` instead.")
+ end
+
+ pending "fails with a helpful error", :bundler => "3"
end
- describe "bundle update" do
+ describe "old unset interface" do
before do
- create_file("gems.rb", "")
- bundle! "install"
+ bundle! "config --delete waka"
end
- it "warns when no options are given" do
- bundle! "update"
- expect(warnings).to have_major_deprecation a_string_including("Pass --all to `bundle update` to update everything")
+ it "warns", :bundler => "2" do
+ expect(deprecations).to include("Using the `config` command without a subcommand [list, get, set, unset] is deprecated and will be removed in the future. Use `bundle config unset waka` instead.")
end
- it "does not warn when --all is passed" do
- bundle! "update --all"
- expect(warnings_without_version_messages).not_to have_major_deprecation
+ pending "fails with a helpful error", :bundler => "3"
+ end
+
+ describe "old unset interface with --local" do
+ before do
+ bundle! "config --delete --local waka"
+ end
+
+ it "warns", :bundler => "2" do
+ expect(deprecations).to include("Using the `config` command without a subcommand [list, get, set, unset] is deprecated and will be removed in the future. Use `bundle config unset --local waka` instead.")
end
+
+ pending "fails with a helpful error", :bundler => "3"
end
- describe "bundle install --binstubs" do
- it "should output a deprecation warning" do
- gemfile <<-G
- gem 'rack'
- G
+ describe "old unset interface with --global" do
+ before do
+ bundle! "config --delete --global waka"
+ end
- bundle :install, :binstubs => true
- expect(warnings).to have_major_deprecation a_string_including("The --binstubs option will be removed")
+ it "warns", :bundler => "2" do
+ expect(deprecations).to include("Using the `config` command without a subcommand [list, get, set, unset] is deprecated and will be removed in the future. Use `bundle config unset --global waka` instead.")
end
+
+ pending "fails with a helpful error", :bundler => "3"
+ end
+ end
+
+ describe "bundle update" do
+ before do
+ install_gemfile <<-G
+ source "file:#{gem_repo1}"
+ gem "rack"
+ G
+ end
+
+ it "warns when no options are given", :bundler => "2" do
+ bundle! "update"
+ expect(deprecations).to include("Pass --all to `bundle update` to update everything")
+ end
+
+ pending "fails with a helpful error when no options are given", :bundler => "3"
+
+ it "does not warn when --all is passed" do
+ bundle! "update --all"
+ expect(deprecations).to be_empty
+ end
+ end
+
+ describe "bundle install --binstubs" do
+ before do
+ install_gemfile <<-G, :binstubs => true
+ source "file:#{gem_repo1}"
+ gem "rack"
+ G
+ end
+
+ it "should output a deprecation warning", :bundler => "2" do
+ expect(deprecations).to include("The --binstubs option will be removed in favor of `bundle binstubs`")
end
+
+ pending "fails with a helpful error", :bundler => "3"
end
- context "when bundle is run" do
+ context "bundle install with both gems.rb and Gemfile present" do
it "should not warn about gems.rb" do
create_file "gems.rb", <<-G
source "file://#{gem_repo1}"
@@ -128,36 +237,92 @@ RSpec.describe "major deprecations", :bundler => "< 3" do
G
bundle :install
- expect(warnings_without_version_messages).not_to have_major_deprecation
+ expect(deprecations).to be_empty
end
- it "should print a Gemfile deprecation warning" do
+ it "should print a proper warning, and use gems.rb" do
create_file "gems.rb"
install_gemfile! <<-G
source "file://#{gem_repo1}"
gem "rack"
G
- expect(the_bundle).to include_gem "rack 1.0"
- expect(warnings).to have_major_deprecation a_string_including("gems.rb and gems.locked will be preferred to Gemfile and Gemfile.lock.")
+ expect(warnings).to include(
+ "Multiple gemfiles (gems.rb and Gemfile) detected. Make sure you remove Gemfile and Gemfile.lock since bundler is ignoring them in favor of gems.rb and gems.rb.locked."
+ )
+
+ expect(the_bundle).not_to include_gem "rack 1.0"
end
+ end
- context "with flags" do
- it "should print a deprecation warning about autoremembering flags" do
- install_gemfile <<-G, :path => "vendor/bundle"
- source "file://#{gem_repo1}"
- gem "rack"
- G
+ context "bundle install with flags" do
+ before do
+ bundle "config set --local path vendor/bundle"
- expect(warnings).to have_major_deprecation a_string_including(
- "flags passed to commands will no longer be automatically remembered."
- )
+ install_gemfile <<-G
+ source "file://#{gem_repo1}"
+ gem "rack"
+ G
+ end
+
+ {
+ :clean => true,
+ :deployment => true,
+ :frozen => true,
+ :"no-cache" => true,
+ :"no-prune" => true,
+ :path => "vendor/bundle",
+ :shebang => "ruby27",
+ :system => true,
+ :without => "development",
+ :with => "development",
+ }.each do |name, value|
+ flag_name = "--#{name}"
+
+ context "with the #{flag_name} flag" do
+ before do
+ bundle "install" # to create a lockfile, which deployment or frozen need
+ bundle "install #{flag_name} #{value}"
+ end
+
+ it "should print a deprecation warning", :bundler => "2" do
+ expect(deprecations).to include(
+ "The `#{flag_name}` flag is deprecated because it relies on " \
+ "being remembered accross bundler invokations, which bundler " \
+ "will no longer do in future versions. Instead please use " \
+ "`bundle config #{name} '#{value}'`, and stop using this flag"
+ )
+ end
+
+ pending "should fail with a helpful error", :bundler => "3"
end
end
end
+ context "bundle install with multiple sources" do
+ before do
+ install_gemfile <<-G
+ source "file://localhost#{gem_repo3}"
+ source "file://localhost#{gem_repo1}"
+ G
+ end
+
+ it "shows a deprecation", :bundler => "2" do
+ expect(deprecations).to include(
+ "Your Gemfile contains multiple primary sources. " \
+ "Using `source` more than once without a block is a security risk, and " \
+ "may result in installing unexpected gems. To resolve this warning, use " \
+ "a block to indicate which gems should come from the secondary source. " \
+ "To upgrade this warning to an error, run `bundle config set " \
+ "disable_multisource true`."
+ )
+ end
+
+ pending "should fail with a helpful error", :bundler => "3"
+ end
+
context "when Bundler.setup is run in a ruby script" do
- it "should print a single deprecation warning" do
+ before do
create_file "gems.rb"
install_gemfile! <<-G
source "file://#{gem_repo1}"
@@ -173,52 +338,57 @@ RSpec.describe "major deprecations", :bundler => "< 3" do
Bundler.setup
Bundler.setup
RUBY
+ end
- expect(warnings_without_version_messages).to have_major_deprecation("gems.rb and gems.locked will be preferred to Gemfile and Gemfile.lock.")
+ it "should print a single deprecation warning" do
+ expect(warnings).to include(
+ "Multiple gemfiles (gems.rb and Gemfile) detected. Make sure you remove Gemfile and Gemfile.lock since bundler is ignoring them in favor of gems.rb and gems.rb.locked."
+ )
end
end
context "when `bundler/deployment` is required in a ruby script" do
- it "should print a capistrano deprecation warning" do
+ before do
ruby(<<-RUBY)
require 'bundler/deployment'
RUBY
+ end
- expect(warnings).to have_major_deprecation("Bundler no longer integrates " \
+ it "should print a capistrano deprecation warning", :bundler => "2" do
+ expect(deprecations).to include("Bundler no longer integrates " \
"with Capistrano, but Capistrano provides " \
"its own integration with Bundler via the " \
"capistrano-bundler gem. Use it instead.")
end
+
+ pending "should fail with a helpful error", :bundler => "3"
end
describe Bundler::Dsl do
+ let(:msg) do
+ <<-EOS
+The :github git source is deprecated, and will be removed in the future. Change any "reponame" :github sources to "username/reponame". Add this code to the top of your Gemfile to ensure it continues to work:
+
+ git_source(:github) {|repo_name| "https://github.com/\#{repo_name}.git" }
+
+ EOS
+ end
+
before do
@rubygems = double("rubygems")
allow(Bundler::Source::Rubygems).to receive(:new) { @rubygems }
end
context "with github gems" do
- it "warns about the https change" do
- msg = <<-EOS
-The :github git source is deprecated, and will be removed in Bundler 3.0. Change any "reponame" :github sources to "username/reponame". Add this code to the top of your Gemfile to ensure it continues to work:
-
- git_source(:github) {|repo_name| "https://github.com/\#{repo_name}.git" }
-
- EOS
+ it "warns about the https change if people are opting out" do
+ Bundler.settings.temporary "github.https" => false
expect(Bundler::SharedHelpers).to receive(:major_deprecation).with(3, msg)
+ expect(Bundler::SharedHelpers).to receive(:major_deprecation).with(2, "Setting `github.https` to false is deprecated and won't be supported in the future.")
subject.gem("sparks", :github => "indirect/sparks")
end
- it "upgrades to https on request" do
- Bundler.settings.temporary "github.https" => true
- msg = <<-EOS
-The :github git source is deprecated, and will be removed in Bundler 3.0. Change any "reponame" :github sources to "username/reponame". Add this code to the top of your Gemfile to ensure it continues to work:
-
- git_source(:github) {|repo_name| "https://github.com/\#{repo_name}.git" }
-
- EOS
+ it "upgrades to https by default", :bundler => "2" do
expect(Bundler::SharedHelpers).to receive(:major_deprecation).with(3, msg)
- expect(Bundler::SharedHelpers).to receive(:major_deprecation).with(3, "The `github.https` setting will be removed")
subject.gem("sparks", :github => "indirect/sparks")
github_uri = "https://github.com/indirect/sparks.git"
expect(subject.dependencies.first.source.uri).to eq(github_uri)
@@ -229,7 +399,7 @@ The :github git source is deprecated, and will be removed in Bundler 3.0. Change
it "warns about removal" do
allow(Bundler.ui).to receive(:deprecate)
msg = <<-EOS
-The :bitbucket git source is deprecated, and will be removed in Bundler 3.0. Add this code to the top of your Gemfile to ensure it continues to work:
+The :bitbucket git source is deprecated, and will be removed in the future. Add this code to the top of your Gemfile to ensure it continues to work:
git_source(:bitbucket) do |repo_name|
user_name, repo_name = repo_name.split("/")
@@ -246,10 +416,12 @@ The :bitbucket git source is deprecated, and will be removed in Bundler 3.0. Add
context "with gist gems" do
it "warns about removal" do
allow(Bundler.ui).to receive(:deprecate)
- msg = "The :gist git source is deprecated, and will be removed " \
- "in Bundler 3.0. Add this code to the top of your Gemfile to ensure it " \
- "continues to work:\n\n git_source(:gist) {|repo_name| " \
- "\"https://gist.github.com/\#{repo_name}.git\" }\n\n"
+ msg = <<-EOS
+The :gist git source is deprecated, and will be removed in the future. Add this code to the top of your Gemfile to ensure it continues to work:
+
+ git_source(:gist) {|repo_name| "https://gist.github.com/\#{repo_name}.git" }
+
+ EOS
expect(Bundler::SharedHelpers).to receive(:major_deprecation).with(3, msg)
subject.gem("not-really-a-gem", :gist => "1234")
end
@@ -257,26 +429,91 @@ The :bitbucket git source is deprecated, and will be removed in Bundler 3.0. Add
end
context "bundle show" do
- it "prints a deprecation warning" do
+ before do
install_gemfile! <<-G
source "file://#{gem_repo1}"
gem "rack"
G
+ end
- bundle! :show
+ context "without flags" do
+ before do
+ bundle! :show
+ end
- warnings.gsub!(/gems included.*?\[DEPRECATED/im, "[DEPRECATED")
+ it "prints a deprecation warning recommending `bundle list`", :bundler => "2" do
+ expect(deprecations).to include("use `bundle list` instead of `bundle show`")
+ end
- expect(warnings).to have_major_deprecation a_string_including("use `bundle list` instead of `bundle show`")
+ pending "fails with a helpful message", :bundler => "3"
end
+
+ context "with --outdated flag" do
+ before do
+ bundle! "show --outdated"
+ end
+
+ it "prints a deprecation warning informing about its removal", :bundler => "2" do
+ expect(deprecations).to include("the `--outdated` flag to `bundle show` was undocumented and will be removed without replacement")
+ end
+
+ pending "fails with a helpful message", :bundler => "3"
+ end
+
+ context "with --verbose flag" do
+ before do
+ bundle! "show --verbose"
+ end
+
+ it "prints a deprecation warning informing about its removal", :bundler => "2" do
+ expect(deprecations).to include("the `--verbose` flag to `bundle show` was undocumented and will be removed without replacement")
+ end
+
+ pending "fails with a helpful message", :bundler => "3"
+ end
+
+ context "with a gem argument" do
+ before do
+ bundle! "show rack"
+ end
+
+ it "prints a deprecation warning recommending `bundle info`", :bundler => "2" do
+ expect(deprecations).to include("use `bundle info rack` instead of `bundle show rack`")
+ end
+ end
+
+ pending "fails with a helpful message", :bundler => "3"
end
context "bundle console" do
- it "prints a deprecation warning" do
+ before do
bundle "console"
+ end
- expect(warnings).to have_major_deprecation \
- a_string_including("bundle console will be replaced by `bin/console` generated by `bundle gem <name>`")
+ it "prints a deprecation warning", :bundler => "2" do
+ expect(deprecations).to include \
+ "bundle console will be replaced by `bin/console` generated by `bundle gem <name>`"
end
+
+ pending "fails with a helpful message", :bundler => "3"
+ end
+
+ context "bundle viz" do
+ let(:ruby_graphviz) do
+ graphviz_glob = base_system_gems.join("cache/ruby-graphviz*")
+ Pathname.glob(graphviz_glob).first
+ end
+
+ before do
+ system_gems ruby_graphviz
+ create_file "gems.rb"
+ bundle "viz"
+ end
+
+ it "prints a deprecation warning", :bundler => "2" do
+ expect(deprecations).to include "The `viz` command has been moved to the `bundle-viz` gem, see https://github.com/bundler/bundler-viz"
+ end
+
+ pending "fails with a helpful message", :bundler => "3"
end
end
diff --git a/spec/bundler/other/platform_spec.rb b/spec/bundler/other/platform_spec.rb
index 6c59fd893c..9c62904286 100644
--- a/spec/bundler/other/platform_spec.rb
+++ b/spec/bundler/other/platform_spec.rb
@@ -149,7 +149,7 @@ G
expect(out).to eq("ruby 1.8.7 (rbx 1.2.4)")
end
- it "handles truffleruby", :rubygems => ">= 2.1.0" do
+ it "handles truffleruby" do
gemfile <<-G
source "file://#{gem_repo1}"
ruby "2.5.1", :engine => 'truffleruby', :engine_version => '1.0.0-rc6'
@@ -268,27 +268,27 @@ G
def should_be_ruby_version_incorrect
expect(exitstatus).to eq(18) if exitstatus
- expect(out).to be_include("Your Ruby version is #{RUBY_VERSION}, but your Gemfile specified #{not_local_ruby_version}")
+ expect(err).to be_include("Your Ruby version is #{RUBY_VERSION}, but your Gemfile specified #{not_local_ruby_version}")
end
def should_be_engine_incorrect
expect(exitstatus).to eq(18) if exitstatus
- expect(out).to be_include("Your Ruby engine is #{local_ruby_engine}, but your Gemfile specified #{not_local_tag}")
+ expect(err).to be_include("Your Ruby engine is #{local_ruby_engine}, but your Gemfile specified #{not_local_tag}")
end
def should_be_engine_version_incorrect
expect(exitstatus).to eq(18) if exitstatus
- expect(out).to be_include("Your #{local_ruby_engine} version is #{local_engine_version}, but your Gemfile specified #{local_ruby_engine} #{not_local_engine_version}")
+ expect(err).to be_include("Your #{local_ruby_engine} version is #{local_engine_version}, but your Gemfile specified #{local_ruby_engine} #{not_local_engine_version}")
end
def should_be_patchlevel_incorrect
expect(exitstatus).to eq(18) if exitstatus
- expect(out).to be_include("Your Ruby patchlevel is #{RUBY_PATCHLEVEL}, but your Gemfile specified #{not_local_patchlevel}")
+ expect(err).to be_include("Your Ruby patchlevel is #{RUBY_PATCHLEVEL}, but your Gemfile specified #{not_local_patchlevel}")
end
def should_be_patchlevel_fixnum
expect(exitstatus).to eq(18) if exitstatus
- expect(out).to be_include("The Ruby patchlevel in your Gemfile must be a string")
+ expect(err).to be_include("The Ruby patchlevel in your Gemfile must be a string")
end
context "bundle install" do
@@ -511,7 +511,7 @@ G
build_gem "activesupport", "3.0"
end
- bundle "update", :all => bundle_update_requires_all?
+ bundle "update", :all => true
expect(the_bundle).to include_gems "rack 1.2", "rack-obama 1.0", "activesupport 3.0"
end
@@ -528,7 +528,7 @@ G
build_gem "activesupport", "3.0"
end
- bundle "update", :all => bundle_update_requires_all?
+ bundle "update", :all => true
expect(the_bundle).to include_gems "rack 1.2", "rack-obama 1.0", "activesupport 3.0"
end
end
@@ -545,7 +545,7 @@ G
build_gem "activesupport", "3.0"
end
- bundle :update, :all => bundle_update_requires_all?
+ bundle :update, :all => true
should_be_ruby_version_incorrect
end
@@ -561,7 +561,7 @@ G
build_gem "activesupport", "3.0"
end
- bundle :update, :all => bundle_update_requires_all?
+ bundle :update, :all => true
should_be_engine_incorrect
end
@@ -578,7 +578,7 @@ G
build_gem "activesupport", "3.0"
end
- bundle :update, :all => bundle_update_requires_all?
+ bundle :update, :all => true
should_be_engine_version_incorrect
end
end
@@ -594,7 +594,7 @@ G
build_gem "activesupport", "3.0"
end
- bundle :update, :all => bundle_update_requires_all?
+ bundle :update, :all => true
should_be_patchlevel_incorrect
end
end
@@ -863,7 +863,7 @@ G
G
bundle "exec rackup"
- expect(out).to eq("0.9.1")
+ expect(out).to include("0.9.1")
end
it "activates the correct gem when ruby version matches any engine" do
@@ -876,7 +876,7 @@ G
G
bundle "exec rackup"
- expect(out).to eq("0.9.1")
+ expect(out).to include("0.9.1")
end
end
diff --git a/spec/bundler/other/ssl_cert_spec.rb b/spec/bundler/other/ssl_cert_spec.rb
deleted file mode 100644
index 6d957276fc..0000000000
--- a/spec/bundler/other/ssl_cert_spec.rb
+++ /dev/null
@@ -1,18 +0,0 @@
-# frozen_string_literal: true
-
-require "bundler/ssl_certs/certificate_manager"
-
-RSpec.describe "SSL Certificates", :rubygems_master do
- hosts = %w[
- rubygems.org
- index.rubygems.org
- rubygems.global.ssl.fastly.net
- staging.rubygems.org
- ]
-
- hosts.each do |host|
- it "can securely connect to #{host}", :realworld do
- Bundler::SSLCerts::CertificateManager.new.connect_to(host)
- end
- end
-end
diff --git a/spec/bundler/plugins/command_spec.rb b/spec/bundler/plugins/command_spec.rb
index 999d8b722b..53d34f7acc 100644
--- a/spec/bundler/plugins/command_spec.rb
+++ b/spec/bundler/plugins/command_spec.rb
@@ -73,8 +73,8 @@ RSpec.describe "command plugins" do
expect(out).not_to include("Installed plugin copycat")
- expect(out).to include("Failed to install plugin")
+ expect(err).to include("Failed to install plugin")
- expect(out).to include("Command(s) `mahcommand` declared by copycat are already registered.")
+ expect(err).to include("Command(s) `mahcommand` declared by copycat are already registered.")
end
end
diff --git a/spec/bundler/plugins/install_spec.rb b/spec/bundler/plugins/install_spec.rb
index 9304d78062..afc6087c1b 100644
--- a/spec/bundler/plugins/install_spec.rb
+++ b/spec/bundler/plugins/install_spec.rb
@@ -11,7 +11,7 @@ RSpec.describe "bundler plugin install" do
it "shows proper message when gem in not found in the source" do
bundle "plugin install no-foo --source file://#{gem_repo1}"
- expect(out).to include("Could not find")
+ expect(err).to include("Could not find")
plugin_should_not_be_installed("no-foo")
end
@@ -22,6 +22,18 @@ RSpec.describe "bundler plugin install" do
plugin_should_be_installed("foo")
end
+ context "plugin is already installed" do
+ before do
+ bundle "plugin install foo --source file://#{gem_repo2}"
+ end
+
+ it "doesn't install plugin again" do
+ bundle "plugin install foo --source file://#{gem_repo2}"
+ expect(out).not_to include("Installing plugin foo")
+ expect(out).not_to include("Installed plugin foo")
+ end
+ end
+
it "installs multiple plugins" do
bundle "plugin install foo kung-foo --source file://#{gem_repo2}"
@@ -86,7 +98,7 @@ RSpec.describe "bundler plugin install" do
bundle "plugin install charlie --source file://#{gem_repo2}"
- expect(out).to include("plugins.rb was not found")
+ expect(err).to include("plugins.rb was not found")
expect(global_plugin_gem("charlie-1.0")).not_to be_directory
@@ -122,6 +134,24 @@ RSpec.describe "bundler plugin install" do
expect(out).to include("Installed plugin foo")
plugin_should_be_installed("foo")
end
+
+ it "installs form a local git source" do
+ build_git "foo" do |s|
+ s.write "plugins.rb"
+ end
+
+ bundle "plugin install foo --local_git #{lib_path("foo-1.0")}"
+
+ expect(out).to include("Installed plugin foo")
+ plugin_should_be_installed("foo")
+ end
+
+ it "raises an error when both git and local git sources are specified" do
+ bundle "plugin install foo --local_git /phony/path/project --git git@gitphony.com:/repo/project"
+
+ expect(exitstatus).not_to eq(0) if exitstatus
+ expect(err).to eq("Remote and local plugin git sources can't be both specified")
+ end
end
context "Gemfile eval" do
@@ -147,7 +177,7 @@ RSpec.describe "bundler plugin install" do
build_plugin "foo", "1.1.0"
end
- install_gemfile <<-G
+ gemfile <<-G
source 'file://#{gem_repo2}'
plugin 'foo', "1.0"
G
@@ -173,6 +203,28 @@ RSpec.describe "bundler plugin install" do
expect(out).to include("Installed plugin ga-plugin")
plugin_should_be_installed("ga-plugin")
end
+
+ context "in deployment mode" do
+ it "installs plugins" do
+ install_gemfile! <<-G
+ source 'file://#{gem_repo2}'
+ gem 'rack', "1.0.0"
+ G
+
+ install_gemfile! <<-G, forgotten_command_line_options(:deployment => true)
+ source 'file://#{gem_repo2}'
+ plugin 'foo'
+ gem 'rack', "1.0.0"
+ G
+
+ expect(out).to include("Installed plugin foo")
+
+ expect(out).to include("Bundle complete!")
+
+ expect(the_bundle).to include_gems("rack 1.0.0")
+ plugin_should_be_installed("foo")
+ end
+ end
end
context "inline gemfiles" do
diff --git a/spec/bundler/plugins/list_spec.rb b/spec/bundler/plugins/list_spec.rb
new file mode 100644
index 0000000000..7dc9d10c4b
--- /dev/null
+++ b/spec/bundler/plugins/list_spec.rb
@@ -0,0 +1,60 @@
+# frozen_string_literal: true
+
+RSpec.describe "bundler plugin list" do
+ before do
+ build_repo2 do
+ build_plugin "foo" do |s|
+ s.write "plugins.rb", <<-RUBY
+ class Foo < Bundler::Plugin::API
+ command "shout"
+
+ def exec(command, args)
+ puts "Foo shout"
+ end
+ end
+ RUBY
+ end
+ build_plugin "bar" do |s|
+ s.write "plugins.rb", <<-RUBY
+ class Bar < Bundler::Plugin::API
+ command "scream"
+
+ def exec(command, args)
+ puts "Bar scream"
+ end
+ end
+ RUBY
+ end
+ end
+ end
+
+ context "no plugins installed" do
+ it "shows proper no plugins installed message" do
+ bundle "plugin list"
+
+ expect(out).to include("No plugins installed")
+ end
+ end
+
+ context "single plugin installed" do
+ it "shows plugin name with commands list" do
+ bundle "plugin install foo --source file://#{gem_repo2}"
+ plugin_should_be_installed("foo")
+ bundle "plugin list"
+
+ expected_output = "foo\n-----\n shout"
+ expect(out).to include(expected_output)
+ end
+ end
+
+ context "multiple plugins installed" do
+ it "shows plugin names with commands list" do
+ bundle "plugin install foo bar --source file://#{gem_repo2}"
+ plugin_should_be_installed("foo", "bar")
+ bundle "plugin list"
+
+ expected_output = "foo\n-----\n shout\n\nbar\n-----\n scream"
+ expect(out).to include(expected_output)
+ end
+ end
+end
diff --git a/spec/bundler/plugins/source/example_spec.rb b/spec/bundler/plugins/source/example_spec.rb
index d9a3cd2b92..bc076c06bf 100644
--- a/spec/bundler/plugins/source/example_spec.rb
+++ b/spec/bundler/plugins/source/example_spec.rb
@@ -96,16 +96,16 @@ RSpec.describe "real source plugins" do
bundle "install"
lockfile_should_be <<-G
- GEM
- remote: file://localhost#{gem_repo2}/
- specs:
-
PLUGIN SOURCE
remote: #{lib_path("a-path-gem-1.0")}
type: mpath
specs:
a-path-gem (1.0)
+ GEM
+ remote: file://localhost#{gem_repo2}/
+ specs:
+
PLATFORMS
#{lockfile_platforms}
@@ -391,10 +391,6 @@ RSpec.describe "real source plugins" do
bundle "install"
lockfile_should_be <<-G
- GEM
- remote: file://localhost#{gem_repo2}/
- specs:
-
PLUGIN SOURCE
remote: file://#{lib_path("ma-gitp-gem-1.0")}
type: gitp
@@ -402,6 +398,10 @@ RSpec.describe "real source plugins" do
specs:
ma-gitp-gem (1.0)
+ GEM
+ remote: file://localhost#{gem_repo2}/
+ specs:
+
PLATFORMS
#{lockfile_platforms}
diff --git a/spec/bundler/quality_es_spec.rb b/spec/bundler/quality_es_spec.rb
new file mode 100644
index 0000000000..8fc653c45a
--- /dev/null
+++ b/spec/bundler/quality_es_spec.rb
@@ -0,0 +1,70 @@
+# frozen_string_literal: true
+
+if defined?(Encoding) && Encoding.default_external.name != "UTF-8"
+ # An approximation of ruby -E UTF-8, since it works on 1.8.7
+ Encoding.default_external = Encoding.find("UTF-8")
+end
+
+RSpec.describe "La biblioteca si misma" do
+ def check_for_expendable_words(filename)
+ failing_line_message = []
+ useless_words = %w[
+ básicamente
+ claramente
+ sólo
+ solamente
+ obvio
+ obviamente
+ fácil
+ fácilmente
+ sencillamente
+ simplemente
+ ]
+ pattern = /\b#{Regexp.union(useless_words)}\b/i
+
+ File.readlines(filename).each_with_index do |line, number|
+ next unless word_found = pattern.match(line)
+ failing_line_message << "#{filename}:#{number.succ} contiene '#{word_found}'. Esta palabra tiene un significado subjetivo y es mejor obviarla en textos técnicos."
+ end
+
+ failing_line_message unless failing_line_message.empty?
+ end
+
+ def check_for_specific_pronouns(filename)
+ failing_line_message = []
+ specific_pronouns = /\b(él|ella|ellos|ellas)\b/i
+
+ File.readlines(filename).each_with_index do |line, number|
+ next unless word_found = specific_pronouns.match(line)
+ failing_line_message << "#{filename}:#{number.succ} contiene '#{word_found}'. Use pronombres más genéricos en la documentación."
+ end
+
+ failing_line_message unless failing_line_message.empty?
+ end
+
+ it "mantiene la calidad de lenguaje de la documentación" do
+ included = /ronn/
+ error_messages = []
+ Dir.chdir(root) do
+ `git ls-files -z -- man`.split("\x0").each do |filename|
+ next unless filename =~ included
+ error_messages << check_for_expendable_words(filename)
+ error_messages << check_for_specific_pronouns(filename)
+ end
+ end
+ expect(error_messages.compact).to be_well_formed
+ end
+
+ it "mantiene la calidad de lenguaje de oraciones usadas en el código fuente" do
+ error_messages = []
+ exempt = /vendor/
+ Dir.chdir(root) do
+ `git ls-files -z -- lib`.split("\x0").each do |filename|
+ next if filename =~ exempt
+ error_messages << check_for_expendable_words(filename)
+ error_messages << check_for_specific_pronouns(filename)
+ end
+ end
+ expect(error_messages.compact).to be_well_formed
+ end
+end
diff --git a/spec/bundler/quality_spec.rb b/spec/bundler/quality_spec.rb
index b24b42c542..f9c815aee1 100644
--- a/spec/bundler/quality_spec.rb
+++ b/spec/bundler/quality_spec.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
if defined?(Encoding) && Encoding.default_external.name != "UTF-8"
- # Poor man's ruby -E UTF-8, since it works on 1.8.7
+ # An approximation of ruby -E UTF-8, since it works on 1.8.7
Encoding.default_external = Encoding.find("UTF-8")
end
@@ -96,16 +96,8 @@ RSpec.describe "The library itself" do
failing_line_message unless failing_line_message.empty?
end
- RSpec::Matchers.define :be_well_formed do
- match(&:empty?)
-
- failure_message do |actual|
- actual.join("\n")
- end
- end
-
it "has no malformed whitespace" do
- exempt = /\.gitmodules|\.marshal|fixtures|vendor|ssl_certs|LICENSE|vcr_cassettes/
+ exempt = /\.gitmodules|\.marshal|fixtures|vendor|LICENSE|vcr_cassettes/
error_messages = []
Dir.chdir(root) do
lib_files = ruby_core? ? `git ls-files -z -- lib/bundler lib/bundler.rb spec/bundler` : `git ls-files -z -- lib`
@@ -175,16 +167,13 @@ RSpec.describe "The library itself" do
exemptions = %w[
auto_config_jobs
cache_command_is_package
- console_command
deployment_means_frozen
forget_cli_options
gem.coc
gem.mit
+ github.https
inline
- lockfile_upgrade_warning
- lockfile_uses_separate_rubygems_sources
use_gem_version_promoter_for_major_updates
- viz_command
]
all_settings = Hash.new {|h, k| h[k] = [] }
@@ -235,14 +224,10 @@ RSpec.describe "The library itself" do
gem_command! :build, gemspec
end
- if Bundler.rubygems.provides?(">= 2.4")
- # there's no way aroudn this warning
- last_command.stderr.sub!(/^YAML safe loading.*/, "")
+ # there's no way around this warning
+ last_command.stderr.sub!(/^YAML safe loading.*/, "")
- # older rubygems have weird warnings, and we won't actually be using them
- # to build the gem for releases anyways
- expect(last_command.stderr).to be_empty, "bundler should build as a gem without warnings, but\n#{err}"
- end
+ expect(last_command.stderr).to be_empty, "bundler should build as a gem without warnings, but\n#{err}"
ensure
# clean up the .gem generated
FileUtils.rm("bundler-#{Bundler::VERSION}.gem")
@@ -250,6 +235,18 @@ RSpec.describe "The library itself" do
end
end
+ it "ships the correct set of files" do
+ Dir.chdir(root) do
+ git_list = IO.popen("git ls-files -z", &:read).split("\x0").select {|f| f.match(%r{^(lib|exe)/}) }
+ git_list += %w[CHANGELOG.md LICENSE.md README.md bundler.gemspec]
+ git_list += Dir.glob("man/**/*")
+
+ gem_list = Gem::Specification.load(gemspec.to_s).files
+
+ expect(git_list.to_set).to eq(gem_list.to_set)
+ end
+ end
+
it "does not contain any warnings" do
Dir.chdir(root) do
exclusions = %w[
diff --git a/spec/bundler/realworld/dependency_api_spec.rb b/spec/bundler/realworld/dependency_api_spec.rb
index 13527ce5d1..e7d11419cd 100644
--- a/spec/bundler/realworld/dependency_api_spec.rb
+++ b/spec/bundler/realworld/dependency_api_spec.rb
@@ -9,7 +9,7 @@ RSpec.describe "gemcutter's dependency API", :realworld => true do
@server_uri = "http://127.0.0.1:#{port}"
require File.expand_path("../../support/artifice/endpoint_timeout", __FILE__)
- require "thread"
+
@t = Thread.new do
server = Rack::Server.start(:app => EndpointTimeout,
:Host => "0.0.0.0",
@@ -22,7 +22,7 @@ RSpec.describe "gemcutter's dependency API", :realworld => true do
@t.run
wait_for_server("127.0.0.1", port)
- bundle! "config timeout 1"
+ bundle! "config set timeout 1"
end
after do
diff --git a/spec/bundler/realworld/double_check_spec.rb b/spec/bundler/realworld/double_check_spec.rb
index 94ab49ba2a..6fee578a71 100644
--- a/spec/bundler/realworld/double_check_spec.rb
+++ b/spec/bundler/realworld/double_check_spec.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
RSpec.describe "double checking sources", :realworld => true do
- it "finds already-installed gems", :ruby => ">= 2.2" do
+ it "finds already-installed gems" do
create_file("rails.gemspec", <<-RUBY)
Gem::Specification.new do |s|
s.name = "rails"
diff --git a/spec/bundler/realworld/edgecases_spec.rb b/spec/bundler/realworld/edgecases_spec.rb
index 1db5c0f9d6..a3662c91e7 100644
--- a/spec/bundler/realworld/edgecases_spec.rb
+++ b/spec/bundler/realworld/edgecases_spec.rb
@@ -19,63 +19,25 @@ RSpec.describe "real world edgecases", :realworld => true, :sometimes => true do
RUBY
end
- # there is no rbx-relative-require gem that will install on 1.9
- it "ignores extra gems with bad platforms", :ruby => "~> 1.8.7" do
- gemfile <<-G
- source "https://rubygems.org"
- gem "linecache", "0.46"
- G
- bundle :lock
- expect(err).to lack_errors
- expect(exitstatus).to eq(0) if exitstatus
- end
-
- # https://github.com/bundler/bundler/issues/1202
- it "bundle cache works with rubygems 1.3.7 and pre gems",
- :ruby => "~> 1.8.7", :rubygems => "~> 1.3.7" do
- install_gemfile <<-G
- source "https://rubygems.org"
- gem "rack", "1.3.0.beta2"
- gem "will_paginate", "3.0.pre2"
- G
- bundle :cache
- expect(out).not_to include("Removing outdated .gem files from vendor/cache")
- end
-
- # https://github.com/bundler/bundler/issues/1486
- # this is a hash collision that only manifests on 1.8.7
- it "finds the correct child versions", :ruby => "~> 1.8.7" do
- gemfile <<-G
- source "https://rubygems.org"
-
- gem 'i18n', '~> 0.6.0'
- gem 'activesupport', '~> 3.0.5'
- gem 'activerecord', '~> 3.0.5'
- gem 'builder', '~> 2.1.2'
- G
- bundle :lock
- expect(lockfile).to include("activemodel (3.0.5)")
- end
-
- it "resolves dependencies correctly", :ruby => "<= 1.9.3" do
+ it "resolves dependencies correctly" do
gemfile <<-G
source "https://rubygems.org"
- gem 'rails', '~> 3.0'
+ gem 'rails', '~> 5.0'
gem 'capybara', '~> 2.2.0'
gem 'rack-cache', '1.2.0' # last version that works on Ruby 1.9
G
bundle! :lock
- expect(lockfile).to include(rubygems_version("rails", "~> 3.0"))
+ expect(lockfile).to include(rubygems_version("rails", "~> 5.0"))
expect(lockfile).to include("capybara (2.2.1)")
end
- it "installs the latest version of gxapi_rails", :ruby => "<= 1.9.3" do
+ it "installs the latest version of gxapi_rails" do
gemfile <<-G
source "https://rubygems.org"
gem "sass-rails"
- gem "rails", "~> 3"
+ gem "rails", "~> 5"
gem "gxapi_rails", "< 0.1.0" # 0.1.0 was released way after the test was written
gem 'rack-cache', '1.2.0' # last version that works on Ruby 1.9
G
@@ -97,7 +59,7 @@ RSpec.describe "real world edgecases", :realworld => true, :sometimes => true do
expect(lockfile).to include(rubygems_version("activesupport", "~> 3.0"))
end
- it "is able to update a top-level dependency when there is a conflict on a shared transitive child", :ruby => "2.1" do
+ it "is able to update a top-level dependency when there is a conflict on a shared transitive child" do
# from https://github.com/bundler/bundler/issues/5031
gemfile <<-G
@@ -239,9 +201,10 @@ RSpec.describe "real world edgecases", :realworld => true, :sometimes => true do
gem 'rack', '1.0.1'
G
- bundle! :install, forgotten_command_line_options(:path => "vendor/bundle")
+ bundle "config set --local path vendor/bundle"
+ bundle! :install
expect(err).not_to include("Could not find rake")
- expect(err).to lack_errors
+ expect(last_command.stderr).to be_empty
end
it "checks out git repos when the lockfile is corrupted" do
@@ -368,7 +331,7 @@ RSpec.describe "real world edgecases", :realworld => true, :sometimes => true do
L
bundle! :lock
- expect(last_command.stderr).to lack_errors
+ expect(last_command.stderr).to be_empty
end
it "outputs a helpful error message when gems have invalid gemspecs" do
@@ -376,7 +339,7 @@ RSpec.describe "real world edgecases", :realworld => true, :sometimes => true do
source 'https://rubygems.org'
gem "resque-scheduler", "2.2.0"
G
- expect(out).to include("You have one or more invalid gemspecs that need to be fixed.")
- expect(out).to include("resque-scheduler 2.2.0 has an invalid gemspec")
+ expect(err).to include("You have one or more invalid gemspecs that need to be fixed.")
+ expect(err).to include("resque-scheduler 2.2.0 has an invalid gemspec")
end
end
diff --git a/spec/bundler/realworld/gemfile_source_header_spec.rb b/spec/bundler/realworld/gemfile_source_header_spec.rb
index 59c1916874..eaefd0f03e 100644
--- a/spec/bundler/realworld/gemfile_source_header_spec.rb
+++ b/spec/bundler/realworld/gemfile_source_header_spec.rb
@@ -1,14 +1,12 @@
# frozen_string_literal: true
-require "thread"
-
-RSpec.describe "fetching dependencies with a mirrored source", :realworld => true, :rubygems => ">= 2.0" do
+RSpec.describe "fetching dependencies with a mirrored source", :realworld => true do
let(:mirror) { "https://server.example.org" }
let(:original) { "http://127.0.0.1:#{@port}" }
before do
setup_server
- bundle "config --local mirror.#{mirror} #{original}"
+ bundle "config set --local mirror.#{mirror} #{original}"
end
after do
diff --git a/spec/bundler/realworld/mirror_probe_spec.rb b/spec/bundler/realworld/mirror_probe_spec.rb
index ab74886329..c5e95f3059 100644
--- a/spec/bundler/realworld/mirror_probe_spec.rb
+++ b/spec/bundler/realworld/mirror_probe_spec.rb
@@ -1,7 +1,5 @@
# frozen_string_literal: true
-require "thread"
-
RSpec.describe "fetching dependencies with a not available mirror", :realworld => true do
let(:mirror) { @mirror_uri }
let(:original) { @server_uri }
@@ -74,10 +72,10 @@ RSpec.describe "fetching dependencies with a not available mirror", :realworld =
bundle :install, :artifice => nil
expect(out).to include("Fetching source index from #{mirror}")
- expect(out).to include("Retrying fetcher due to error (2/4): Bundler::HTTPError Could not fetch specs from #{mirror}")
- expect(out).to include("Retrying fetcher due to error (3/4): Bundler::HTTPError Could not fetch specs from #{mirror}")
- expect(out).to include("Retrying fetcher due to error (4/4): Bundler::HTTPError Could not fetch specs from #{mirror}")
- expect(out).to include("Could not fetch specs from #{mirror}")
+ expect(err).to include("Retrying fetcher due to error (2/4): Bundler::HTTPError Could not fetch specs from #{mirror}")
+ expect(err).to include("Retrying fetcher due to error (3/4): Bundler::HTTPError Could not fetch specs from #{mirror}")
+ expect(err).to include("Retrying fetcher due to error (4/4): Bundler::HTTPError Could not fetch specs from #{mirror}")
+ expect(err).to include("Could not fetch specs from #{mirror}")
end
it "prints each error and warning on a new line" do
@@ -112,10 +110,10 @@ Could not fetch specs from #{mirror}/
bundle :install, :artifice => nil
expect(out).to include("Fetching source index from #{mirror}")
- expect(out).to include("Retrying fetcher due to error (2/4): Bundler::HTTPError Could not fetch specs from #{mirror}")
- expect(out).to include("Retrying fetcher due to error (3/4): Bundler::HTTPError Could not fetch specs from #{mirror}")
- expect(out).to include("Retrying fetcher due to error (4/4): Bundler::HTTPError Could not fetch specs from #{mirror}")
- expect(out).to include("Could not fetch specs from #{mirror}")
+ expect(err).to include("Retrying fetcher due to error (2/4): Bundler::HTTPError Could not fetch specs from #{mirror}")
+ expect(err).to include("Retrying fetcher due to error (3/4): Bundler::HTTPError Could not fetch specs from #{mirror}")
+ expect(err).to include("Retrying fetcher due to error (4/4): Bundler::HTTPError Could not fetch specs from #{mirror}")
+ expect(err).to include("Could not fetch specs from #{mirror}")
end
end
diff --git a/spec/bundler/realworld/parallel_spec.rb b/spec/bundler/realworld/parallel_spec.rb
index ed4430c68b..7738b46aac 100644
--- a/spec/bundler/realworld/parallel_spec.rb
+++ b/spec/bundler/realworld/parallel_spec.rb
@@ -11,11 +11,7 @@ RSpec.describe "parallel", :realworld => true, :sometimes => true do
bundle :install, :jobs => 4, :env => { "DEBUG" => "1" }
- if Bundler.rubygems.provides?(">= 2.1.0")
- expect(out).to match(/[1-3]: /)
- else
- expect(out).to include("is not threadsafe")
- end
+ expect(out).to match(/[1-3]: /)
bundle "info activesupport --path"
expect(out).to match(/activesupport/)
@@ -38,13 +34,9 @@ RSpec.describe "parallel", :realworld => true, :sometimes => true do
gem 'i18n', '~> 0.6.0' # Because 0.7+ requires Ruby 1.9.3+
G
- bundle :update, :jobs => 4, :env => { "DEBUG" => "1" }, :all => bundle_update_requires_all?
+ bundle :update, :jobs => 4, :env => { "DEBUG" => "1" }, :all => true
- if Bundler.rubygems.provides?(">= 2.1.0")
- expect(out).to match(/[1-3]: /)
- else
- expect(out).to include("is not threadsafe")
- end
+ expect(out).to match(/[1-3]: /)
bundle "info activesupport --path"
expect(out).to match(/activesupport-3\.2\.\d+/)
diff --git a/spec/bundler/resolver/basic_spec.rb b/spec/bundler/resolver/basic_spec.rb
index c023f5d7aa..57897f89b4 100644
--- a/spec/bundler/resolver/basic_spec.rb
+++ b/spec/bundler/resolver/basic_spec.rb
@@ -35,7 +35,7 @@ RSpec.describe "Resolving" do
should_resolve_as %w[berkshelf-2.0.7 chef-10.26 chef_app-1.0.0 json-1.7.7]
end
- it "prefers expicitly requested dependencies when resolving an index which would otherwise be ambiguous" do
+ it "prefers explicitly requested dependencies when resolving an index which would otherwise be ambiguous" do
@index = an_ambiguous_index
dep "a"
dep "b"
@@ -169,10 +169,10 @@ Bundler could not find compatible versions for gem "a":
s.required_ruby_version = "~> 2.0.0"
end
- gem "ruby\0", "1.8.7"
+ gem "Ruby\0", "1.8.7"
end
dep "foo"
- dep "ruby\0", "1.8.7"
+ dep "Ruby\0", "1.8.7"
deps = []
@deps.each do |d|
@@ -226,7 +226,7 @@ Bundler could not find compatible versions for gem "a":
# dependencies and since the dependency of the selected foo gem changes, the latest matching
# dependency of "bar", "~> 2.1" -- bar-2.1.1 -- is selected. This is not a bug and follows
# the long-standing documented Conservative Updating behavior of bundle install.
- # http://bundler.io/v1.12/man/bundle-install.1.html#CONSERVATIVE-UPDATING
+ # https://bundler.io/v1.12/man/bundle-install.1.html#CONSERVATIVE-UPDATING
should_conservative_resolve_and_include :patch, ["foo"], %w[foo-1.4.5 bar-2.1.1]
end
diff --git a/spec/bundler/runtime/executable_spec.rb b/spec/bundler/runtime/executable_spec.rb
index 7ba510a509..b2d5b6c03f 100644
--- a/spec/bundler/runtime/executable_spec.rb
+++ b/spec/bundler/runtime/executable_spec.rb
@@ -129,23 +129,6 @@ RSpec.describe "Running bin/* commands" do
expect(bundled_app("bin/rackup")).to exist
end
- it "rewrites bins on --binstubs (to maintain backwards compatibility)", :bundler => "< 2" do
- gemfile <<-G
- source "file://#{gem_repo1}"
- gem "rack"
- G
-
- bundle! :install, forgotten_command_line_options([:binstubs, :bin] => "bin")
-
- File.open(bundled_app("bin/rackup"), "wb") do |file|
- file.print "OMG"
- end
-
- bundle "install"
-
- expect(bundled_app("bin/rackup").read).to_not eq("OMG")
- end
-
it "rewrites bins on binstubs (to maintain backwards compatibility)" do
install_gemfile! <<-G
source "file://#{gem_repo1}"
diff --git a/spec/bundler/runtime/gem_tasks_spec.rb b/spec/bundler/runtime/gem_tasks_spec.rb
index de72869dc3..3c69f8a800 100644
--- a/spec/bundler/runtime/gem_tasks_spec.rb
+++ b/spec/bundler/runtime/gem_tasks_spec.rb
@@ -22,7 +22,7 @@ RSpec.describe "require 'bundler/gem_tasks'", :ruby_repo do
sys_exec "#{rake} -T"
end
- expect(err).to eq("")
+ expect(last_command.stderr).to eq("")
expected_tasks = [
"rake build",
"rake clean",
diff --git a/spec/bundler/runtime/inline_spec.rb b/spec/bundler/runtime/inline_spec.rb
index 18ca246199..96a3fa09ae 100644
--- a/spec/bundler/runtime/inline_spec.rb
+++ b/spec/bundler/runtime/inline_spec.rb
@@ -67,7 +67,7 @@ RSpec.describe "bundler/inline#gemfile" do
puts "success"
RUBY
- expect(err).to include "Could not find gem 'eleven'"
+ expect(last_command.stderr).to include "Could not find gem 'eleven'"
expect(out).not_to include "success"
script <<-RUBY
@@ -90,7 +90,7 @@ RSpec.describe "bundler/inline#gemfile" do
expect(out).to include("Installing activesupport")
err.gsub! %r{.*lib/sinatra/base\.rb:\d+: warning: constant ::Fixnum is deprecated$}, ""
err.strip!
- expect(err).to lack_errors
+ expect(last_command.stderr).to be_empty
expect(exitstatus).to be_zero if exitstatus
end
@@ -112,6 +112,19 @@ RSpec.describe "bundler/inline#gemfile" do
expect(exitstatus).to be_zero if exitstatus
end
+ it "has an option for quiet installation" do
+ script <<-RUBY, :artifice => "endpoint"
+ require 'bundler'
+
+ gemfile(true, :quiet => true) do
+ source "https://notaserver.com"
+ gem "activesupport", :require => true
+ end
+ RUBY
+
+ expect(out).to be_empty
+ end
+
it "raises an exception if passed unknown arguments" do
script <<-RUBY
gemfile(true, :arglebargle => true) do
@@ -121,7 +134,7 @@ RSpec.describe "bundler/inline#gemfile" do
puts "success"
RUBY
- expect(err).to include "Unknown options: arglebargle"
+ expect(last_command.stderr).to include "Unknown options: arglebargle"
expect(out).not_to include "success"
end
@@ -152,7 +165,7 @@ RSpec.describe "bundler/inline#gemfile" do
RUBY
expect(out).to eq("1.0.0")
- expect(err).to be_empty
+ expect(last_command.stderr).to be_empty
expect(exitstatus).to be_zero if exitstatus
end
@@ -170,7 +183,7 @@ RSpec.describe "bundler/inline#gemfile" do
RUBY
expect(out).to eq("1.0.0\n2.0.0")
- expect(err).to be_empty
+ expect(last_command.stderr).to be_empty
expect(exitstatus).to be_zero if exitstatus
end
@@ -190,7 +203,7 @@ RSpec.describe "bundler/inline#gemfile" do
RUBY
expect(out).to eq("two\nfour")
- expect(err).to be_empty
+ expect(last_command.stderr).to be_empty
expect(exitstatus).to be_zero if exitstatus
end
@@ -227,7 +240,7 @@ RSpec.describe "bundler/inline#gemfile" do
RUBY
end
- expect(err).to be_empty
+ expect(last_command.stderr).to be_empty
expect(exitstatus).to be_zero if exitstatus
end
@@ -245,7 +258,7 @@ RSpec.describe "bundler/inline#gemfile" do
RUBY
end
- expect(err).to be_empty
+ expect(last_command.stderr).to be_empty
expect(exitstatus).to be_zero if exitstatus
end
diff --git a/spec/bundler/runtime/platform_spec.rb b/spec/bundler/runtime/platform_spec.rb
index eecf162427..11fe16f499 100644
--- a/spec/bundler/runtime/platform_spec.rb
+++ b/spec/bundler/runtime/platform_spec.rb
@@ -93,7 +93,7 @@ RSpec.describe "Bundler.setup with multi platform stuff" do
gem "platform_specific"
G
- bundle! "config force_ruby_platform true"
+ bundle! "config set force_ruby_platform true"
bundle! "install"
@@ -108,7 +108,7 @@ RSpec.describe "Bundler.setup with multi platform stuff" do
gem "platform_specific"
G
- bundle! "config force_ruby_platform true"
+ bundle! "config set force_ruby_platform true"
bundle! "install"
diff --git a/spec/bundler/runtime/require_spec.rb b/spec/bundler/runtime/require_spec.rb
index 0484e38845..c9cfa199d3 100644
--- a/spec/bundler/runtime/require_spec.rb
+++ b/spec/bundler/runtime/require_spec.rb
@@ -121,7 +121,7 @@ RSpec.describe "Bundler.require" do
Bundler.require
R
- expect(err).to eq_err("ZOMG LOAD ERROR")
+ expect(err_without_deprecations).to eq("ZOMG LOAD ERROR")
end
it "displays a helpful message if the required gem throws an error" do
@@ -136,8 +136,8 @@ RSpec.describe "Bundler.require" do
G
run "Bundler.require"
- expect(err).to match("error while trying to load the gem 'faulty'")
- expect(err).to match("Gem Internal Error Message")
+ expect(last_command.stderr).to match("error while trying to load the gem 'faulty'")
+ expect(last_command.stderr).to match("Gem Internal Error Message")
end
it "doesn't swallow the error when the library has an unrelated error" do
@@ -160,7 +160,7 @@ RSpec.describe "Bundler.require" do
RUBY
run(cmd)
- expect(err).to eq_err("ZOMG LOAD ERROR: cannot load such file -- load-bar")
+ expect(err_without_deprecations).to eq("ZOMG LOAD ERROR: cannot load such file -- load-bar")
end
describe "with namespaced gems" do
@@ -198,7 +198,7 @@ RSpec.describe "Bundler.require" do
RUBY
ruby(cmd)
- expect(err).to lack_errors
+ expect(last_command.stderr).to be_empty
end
it "does not mangle explicitly given requires" do
@@ -211,7 +211,7 @@ RSpec.describe "Bundler.require" do
load_error_run <<-R, "jquery-rails"
Bundler.require
R
- expect(err).to eq_err("ZOMG LOAD ERROR")
+ expect(err_without_deprecations).to eq("ZOMG LOAD ERROR")
end
it "handles the case where regex fails" do
@@ -234,7 +234,7 @@ RSpec.describe "Bundler.require" do
RUBY
run(cmd)
- expect(err).to eq_err("ZOMG LOAD ERROR")
+ expect(err_without_deprecations).to eq("ZOMG LOAD ERROR")
end
it "doesn't swallow the error when the library has an unrelated error" do
@@ -258,19 +258,19 @@ RSpec.describe "Bundler.require" do
RUBY
run(cmd)
- expect(err).to eq_err("ZOMG LOAD ERROR: cannot load such file -- load-bar")
+ expect(err_without_deprecations).to eq("ZOMG LOAD ERROR: cannot load such file -- load-bar")
end
end
describe "using bundle exec" do
it "requires the locked gems" do
- bundle "exec ruby -e 'Bundler.require'", :env => { :RUBYOPT => "-r#{spec_dir.join("support/hax")}" }
+ bundle "exec ruby -e 'Bundler.require'"
expect(out).to eq("two")
- bundle "exec ruby -e 'Bundler.require(:bar)'", :env => { :RUBYOPT => "-r#{spec_dir.join("support/hax")}" }
+ bundle "exec ruby -e 'Bundler.require(:bar)'"
expect(out).to eq("baz\nqux")
- bundle "exec ruby -e 'Bundler.require(:default, :bar)'", :env => { :RUBYOPT => "-r#{spec_dir.join("support/hax")}" }
+ bundle "exec ruby -e 'Bundler.require(:default, :bar)'"
expect(out).to eq("baz\nqux\ntwo")
end
end
@@ -366,12 +366,12 @@ RSpec.describe "Bundler.require" do
load_error_run <<-R, "no_such_file_omg"
Bundler.require
R
- expect(err).to eq_err("ZOMG LOAD ERROR")
+ expect(err_without_deprecations).to eq("ZOMG LOAD ERROR")
end
end
end
- it "does not load rubygems gemspecs that are used", :rubygems => ">= 2.5.2" do
+ it "does not load rubygems gemspecs that are used" do
install_gemfile! <<-G
source "file://#{gem_repo1}"
gem "rack"
@@ -394,7 +394,7 @@ RSpec.describe "Bundler.require" do
expect(out).to eq("WIN")
end
- it "does not load git gemspecs that are used", :rubygems => ">= 2.5.2" do
+ it "does not load git gemspecs that are used" do
build_git "foo"
install_gemfile! <<-G
@@ -432,7 +432,7 @@ RSpec.describe "Bundler.require with platform specific dependencies" do
G
run "Bundler.require"
- expect(err).to lack_errors
+ expect(last_command.stderr).to be_empty
end
it "requires gems pinned to multiple platforms, including the current one" do
@@ -447,6 +447,6 @@ RSpec.describe "Bundler.require with platform specific dependencies" do
run "Bundler.require; puts RACK"
expect(out).to eq("1.0.0")
- expect(err).to lack_errors
+ expect(last_command.stderr).to be_empty
end
end
diff --git a/spec/bundler/runtime/setup_spec.rb b/spec/bundler/runtime/setup_spec.rb
index f2f750a9ca..c81baa34ea 100644
--- a/spec/bundler/runtime/setup_spec.rb
+++ b/spec/bundler/runtime/setup_spec.rb
@@ -1,5 +1,8 @@
# frozen_string_literal: true
+require "tmpdir"
+require "tempfile"
+
RSpec.describe "Bundler.setup" do
describe "with no arguments" do
it "makes all groups available" do
@@ -16,7 +19,7 @@ RSpec.describe "Bundler.setup" do
require 'rack'
puts RACK
RUBY
- expect(err).to lack_errors
+ expect(last_command.stderr).to be_empty
expect(out).to eq("1.0.0")
end
end
@@ -42,7 +45,7 @@ RSpec.describe "Bundler.setup" do
puts "WIN"
end
RUBY
- expect(err).to lack_errors
+ expect(last_command.stderr).to be_empty
expect(out).to eq("WIN")
end
@@ -55,7 +58,7 @@ RSpec.describe "Bundler.setup" do
require 'rack'
puts RACK
RUBY
- expect(err).to lack_errors
+ expect(last_command.stderr).to be_empty
expect(out).to eq("1.0.0")
end
@@ -69,7 +72,7 @@ RSpec.describe "Bundler.setup" do
require 'rack'
puts RACK
RUBY
- expect(err).to lack_errors
+ expect(last_command.stderr).to be_empty
expect(out).to eq("1.0.0")
end
@@ -87,7 +90,7 @@ RSpec.describe "Bundler.setup" do
puts "FAIL"
end
RUBY
- expect(err).to lack_errors
+ expect(last_command.stderr).to be_empty
expect(out).to match("WIN")
end
@@ -101,8 +104,8 @@ RSpec.describe "Bundler.setup" do
puts "FAIL"
RUBY
- expect(err).to match("rack")
- expect(err).to match("LoadError")
+ expect(last_command.stderr).to match("rack")
+ expect(last_command.stderr).to match("LoadError")
expect(out).not_to match("FAIL")
end
end
@@ -125,7 +128,7 @@ RSpec.describe "Bundler.setup" do
gem "rack"
G
- ENV["RUBYOPT"] = "-Idash_i_dir"
+ ENV["RUBYOPT"] = "#{ENV["RUBYOPT"]} -Idash_i_dir"
ENV["RUBYLIB"] = "rubylib_dir"
ruby <<-RUBY
@@ -138,9 +141,8 @@ RSpec.describe "Bundler.setup" do
load_path = out.split("\n")
rack_load_order = load_path.index {|path| path.include?("rack") }
- expect(err).to eq("")
- expect(load_path[1]).to include "dash_i_dir"
- expect(load_path[2]).to include "rubylib_dir"
+ expect(last_command.stderr).to eq("")
+ expect(load_path).to include(a_string_ending_with("dash_i_dir"), "rubylib_dir")
expect(rack_load_order).to be > 0
end
@@ -159,10 +161,6 @@ RSpec.describe "Bundler.setup" do
load_path = clean_load_path(out.split("\n"))
- unless Bundler.load.specs["bundler"].empty?
- load_path.delete_if {|path| path =~ /bundler/ }
- end
-
expect(load_path).to start_with(
"/gems/rails-2.3.2/lib",
"/gems/activeresource-2.3.2/lib",
@@ -170,7 +168,7 @@ RSpec.describe "Bundler.setup" do
"/gems/actionpack-2.3.2/lib",
"/gems/actionmailer-2.3.2/lib",
"/gems/activesupport-2.3.2/lib",
- "/gems/rake-10.0.2/lib"
+ "/gems/rake-12.3.2/lib"
)
end
@@ -366,7 +364,7 @@ RSpec.describe "Bundler.setup" do
end
R
- expect(err).to lack_errors
+ expect(last_command.stderr).to be_empty
end
it "replaces #gem but raises when the version is wrong" do
@@ -392,7 +390,7 @@ RSpec.describe "Bundler.setup" do
end
R
- expect(err).to lack_errors
+ expect(last_command.stderr).to be_empty
end
end
@@ -451,7 +449,7 @@ RSpec.describe "Bundler.setup" do
it "provides a useful exception when the git repo is not checked out yet" do
run "1"
- expect(err).to match(/the git source #{lib_path('rack-1.0.0')} is not yet checked out. Please run `bundle install`/i)
+ expect(last_command.stderr).to match(/the git source #{lib_path('rack-1.0.0')} is not yet checked out. Please run `bundle install`/i)
end
it "does not hit the git binary if the lockfile is available and up to date" do
@@ -532,12 +530,12 @@ RSpec.describe "Bundler.setup" do
gem "rack", :git => "#{lib_path("rack-0.8")}", :branch => "master"
G
- bundle %(config local.rack #{lib_path("local-rack")})
+ bundle %(config set local.rack #{lib_path("local-rack")})
bundle! :install
FileUtils.rm_rf(lib_path("local-rack"))
run "require 'rack'"
- expect(err).to match(/Cannot use local override for rack-0.8 because #{Regexp.escape(lib_path('local-rack').to_s)} does not exist/)
+ expect(last_command.stderr).to match(/Cannot use local override for rack-0.8 because #{Regexp.escape(lib_path('local-rack').to_s)} does not exist/)
end
it "explodes if branch is not given on runtime" do
@@ -550,7 +548,7 @@ RSpec.describe "Bundler.setup" do
gem "rack", :git => "#{lib_path("rack-0.8")}", :branch => "master"
G
- bundle %(config local.rack #{lib_path("local-rack")})
+ bundle %(config set local.rack #{lib_path("local-rack")})
bundle! :install
gemfile <<-G
@@ -559,7 +557,7 @@ RSpec.describe "Bundler.setup" do
G
run "require 'rack'"
- expect(err).to match(/because :branch is not specified in Gemfile/)
+ expect(last_command.stderr).to match(/because :branch is not specified in Gemfile/)
end
it "explodes on different branches on runtime" do
@@ -572,7 +570,7 @@ RSpec.describe "Bundler.setup" do
gem "rack", :git => "#{lib_path("rack-0.8")}", :branch => "master"
G
- bundle %(config local.rack #{lib_path("local-rack")})
+ bundle %(config set local.rack #{lib_path("local-rack")})
bundle! :install
gemfile <<-G
@@ -581,7 +579,7 @@ RSpec.describe "Bundler.setup" do
G
run "require 'rack'"
- expect(err).to match(/is using branch master but Gemfile specifies changed/)
+ expect(last_command.stderr).to match(/is using branch master but Gemfile specifies changed/)
end
it "explodes on refs with different branches on runtime" do
@@ -599,9 +597,9 @@ RSpec.describe "Bundler.setup" do
gem "rack", :git => "#{lib_path("rack-0.8")}", :ref => "master", :branch => "nonexistant"
G
- bundle %(config local.rack #{lib_path("local-rack")})
+ bundle %(config set local.rack #{lib_path("local-rack")})
run "require 'rack'"
- expect(err).to match(/is using branch master but Gemfile specifies nonexistant/)
+ expect(last_command.stderr).to match(/is using branch master but Gemfile specifies nonexistant/)
end
end
@@ -655,62 +653,6 @@ RSpec.describe "Bundler.setup" do
end
end
- # Unfortunately, gem_prelude does not record the information about
- # activated gems, so this test cannot work on 1.9 :(
- if RUBY_VERSION < "1.9"
- describe "preactivated gems" do
- it "raises an exception if a pre activated gem conflicts with the bundle" do
- system_gems "thin-1.0", "rack-1.0.0"
- build_gem "thin", "1.1", :to_system => true do |s|
- s.add_dependency "rack"
- end
-
- gemfile <<-G
- gem "thin", "1.0"
- G
-
- ruby <<-R
- require 'rubygems'
- gem "thin"
- require 'bundler'
- begin
- Bundler.setup
- puts "FAIL"
- rescue Gem::LoadError => e
- puts e.message
- end
- R
-
- expect(out).to eq("You have already activated thin 1.1, but your Gemfile requires thin 1.0. Prepending `bundle exec` to your command may solve this.")
- end
-
- it "version_requirement is now deprecated in rubygems 1.4.0+" do
- system_gems "thin-1.0", "rack-1.0.0"
- build_gem "thin", "1.1", :to_system => true do |s|
- s.add_dependency "rack"
- end
-
- gemfile <<-G
- gem "thin", "1.0"
- G
-
- ruby <<-R
- require 'rubygems'
- gem "thin"
- require 'bundler'
- begin
- Bundler.setup
- puts "FAIL"
- rescue Gem::LoadError => e
- puts e.message
- end
- R
-
- expect(err).to lack_errors
- end
- end
- end
-
# RubyGems returns loaded_from as a string
it "has loaded_from as a string on all specs" do
build_git "foo"
@@ -732,7 +674,7 @@ RSpec.describe "Bundler.setup" do
expect(out).to be_empty
end
- it "does not load all gemspecs", :rubygems => ">= 2.3" do
+ it "does not load all gemspecs" do
install_gemfile! <<-G
source "file://#{gem_repo1}"
gem "rack"
@@ -767,9 +709,9 @@ end
G
ENV["GEM_HOME"] = ""
- bundle %(exec ruby -e "require 'set'"), :env => { :RUBYOPT => "-r#{spec_dir.join("support/hax")}" }
+ bundle %(exec ruby -e "require 'set'")
- expect(err).to lack_errors
+ expect(last_command.stderr).to be_empty
end
describe "$MANPATH" do
@@ -831,7 +773,7 @@ end
it "should clean $LOAD_PATH properly", :ruby_repo do
gem_name = "very_simple_binary"
full_gem_name = gem_name + "-1.0"
- ext_dir = File.join(tmp "extenstions", full_gem_name)
+ ext_dir = File.join(tmp("extensions", full_gem_name))
install_gem full_gem_name
@@ -863,48 +805,41 @@ end
context "with bundler is located in symlinked GEM_HOME" do
let(:gem_home) { Dir.mktmpdir }
- let(:symlinked_gem_home) { Tempfile.new("gem_home") }
+ let(:symlinked_gem_home) { Tempfile.new("gem_home").path }
let(:bundler_dir) { ruby_core? ? File.expand_path("../../../..", __FILE__) : File.expand_path("../../..", __FILE__) }
- let(:bundler_lib) { File.join(bundler_dir, "lib") }
+ let(:full_name) { "bundler-#{Bundler::VERSION}" }
before do
- FileUtils.ln_sf(gem_home, symlinked_gem_home.path)
+ FileUtils.ln_sf(gem_home, symlinked_gem_home)
gems_dir = File.join(gem_home, "gems")
specifications_dir = File.join(gem_home, "specifications")
Dir.mkdir(gems_dir)
Dir.mkdir(specifications_dir)
- FileUtils.ln_s(bundler_dir, File.join(gems_dir, "bundler-#{Bundler::VERSION}"))
+ FileUtils.ln_s(bundler_dir, File.join(gems_dir, full_name))
gemspec_file = ruby_core? ? "#{bundler_dir}/lib/bundler/bundler.gemspec" : "#{bundler_dir}/bundler.gemspec"
- gemspec = File.read(gemspec_file).
+ gemspec = File.binread(gemspec_file).
sub("Bundler::VERSION", %("#{Bundler::VERSION}"))
gemspec = gemspec.lines.reject {|line| line =~ %r{lib/bundler/version} }.join
- File.open(File.join(specifications_dir, "bundler.gemspec"), "wb") do |f|
+ File.open(File.join(specifications_dir, "#{full_name}.gemspec"), "wb") do |f|
f.write(gemspec)
end
end
- # Can't make this pass on 2.6 since the ruby standard library has the same $LOAD_PATH
- # entry as bundler (since it's a default gem)
- it "should successfully require 'bundler/setup'", :ruby_repo, :ruby => "< 2.6" do
+ it "should not remove itself from the LOAD_PATH and require a different copy of 'bundler/setup'", :ruby_repo do
install_gemfile ""
- ENV["GEM_PATH"] = symlinked_gem_home.path
-
- ruby <<-R
- if $LOAD_PATH.include?("#{bundler_lib}")
- # We should use bundler from GEM_PATH for this test, so we should
- # remove path to the bundler source tree
- $LOAD_PATH.delete("#{bundler_lib}")
- else
- raise "We don't have #{bundler_lib} in $LOAD_PATH"
+ ruby <<-R, :env => { "GEM_PATH" => symlinked_gem_home }, :no_lib => true
+ TracePoint.trace(:class) do |tp|
+ puts "OMG" if tp.path.include?("bundler") && !tp.path.start_with?("#{File.expand_path("../..", __dir__)}")
end
- puts (require 'bundler/setup')
+ gem 'bundler', '#{Bundler::VERSION}'
+ require 'bundler/setup'
R
- expect(out).to eql("true")
+ expect(out).to be_empty
end
end
@@ -943,7 +878,7 @@ end
require 'foo'
R
end
- expect(err).to lack_errors
+ expect(last_command.stderr).to be_empty
end
it "should make sure the Bundler.root is really included in the path relative to the Gemfile" do
@@ -968,7 +903,7 @@ end
R
end
- expect(err).to lack_errors
+ expect(last_command.stderr).to be_empty
end
end
@@ -1046,7 +981,7 @@ end
describe "with system gems in the bundle" do
before :each do
- bundle! "config path.system true"
+ bundle! "config set path.system true"
system_gems "rack-1.0.0"
install_gemfile <<-G
@@ -1099,9 +1034,9 @@ end
end.ref_for("HEAD")
bundle :install
- expect(out.lines.map(&:chomp)).to include(
+ expect(err.lines.map(&:chomp)).to include(
a_string_starting_with("[!] There was an error while loading `bar.gemspec`:"),
- RUBY_VERSION >= "1.9" ? a_string_starting_with("Does it try to require a relative path? That's been removed in Ruby 1.9.") : "",
+ a_string_starting_with("Does it try to require a relative path? That's been removed in Ruby 1.9."),
" # from #{default_bundle_path "bundler", "gems", "bar-1.0-#{ref[0, 12]}", "bar.gemspec"}:1",
" > require 'foobarbaz'"
)
@@ -1118,7 +1053,7 @@ end
Bundler.load
RUBY
- expect(err).to lack_errors
+ expect(last_command.stderr).to be_empty
expect(out).to eq("")
end
end
@@ -1129,8 +1064,8 @@ end
gem "bundler", :path => "#{File.expand_path("..", lib)}"
G
- bundle %(exec ruby -e "require 'bundler'; Bundler.setup"), :env => { :RUBYOPT => "-r#{spec_dir.join("support/hax")}" }
- expect(err).to lack_errors
+ bundle %(exec ruby -e "require 'bundler'; Bundler.setup")
+ expect(last_command.stderr).to be_empty
end
end
@@ -1253,7 +1188,7 @@ end
end
describe "with gemified standard libraries" do
- it "does not load Psych", :ruby => "~> 2.2" do
+ it "does not load Psych" do
gemfile ""
ruby <<-RUBY
require 'bundler/setup'
@@ -1279,7 +1214,7 @@ end
describe "default gem activation" do
let(:exemptions) do
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new("2.7") || ENV["RGV"] == "master"
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new("2.7")
[]
else
%w[io-console openssl]
@@ -1310,7 +1245,6 @@ end
end
let(:code) { strip_whitespace(<<-RUBY) }
- require "bundler/setup"
require "pp"
loaded_specs = Gem.loaded_specs.dup
#{exemptions.inspect}.each {|s| loaded_specs.delete(s) }
@@ -1325,22 +1259,18 @@ end
it "activates no gems with -rbundler/setup" do
install_gemfile! ""
- ruby! code, :env => { :RUBYOPT => activation_warning_hack_rubyopt }
+ ruby! code, :env => { :RUBYOPT => activation_warning_hack_rubyopt + " -rbundler/setup" }
expect(last_command.stdout).to eq("{}")
end
it "activates no gems with bundle exec" do
install_gemfile! ""
- # ensure we clean out the default gems, bceause bundler's allowed to be activated
create_file("script.rb", code)
- bundle! "exec ruby ./script.rb", :env => { :RUBYOPT => activation_warning_hack_rubyopt + " -rbundler/setup" }
+ bundle! "exec ruby ./script.rb", :env => { :RUBYOPT => activation_warning_hack_rubyopt }
expect(last_command.stdout).to eq("{}")
end
it "activates no gems with bundle exec that is loaded" do
- # TODO: remove once https://github.com/erikhuda/thor/pull/539 is released
- exemptions << "io-console"
-
install_gemfile! ""
create_file("script.rb", "#!/usr/bin/env ruby\n\n#{code}")
FileUtils.chmod(0o777, bundled_app("script.rb"))
diff --git a/spec/bundler/runtime/with_clean_env_spec.rb b/spec/bundler/runtime/with_clean_env_spec.rb
deleted file mode 100644
index da8e37b45d..0000000000
--- a/spec/bundler/runtime/with_clean_env_spec.rb
+++ /dev/null
@@ -1,151 +0,0 @@
-# frozen_string_literal: true
-
-RSpec.describe "Bundler.with_env helpers" do
- def bundle_exec_ruby!(code, *args)
- opts = args.last.is_a?(Hash) ? args.pop : {}
- env = opts[:env] ||= {}
- env[:RUBYOPT] ||= "-r#{spec_dir.join("support/hax")}"
- args.push opts
- bundle! "exec '#{Gem.ruby}' -e #{code}", *args
- end
-
- describe "Bundler.original_env" do
- before do
- bundle "config path vendor/bundle"
- gemfile ""
- bundle "install"
- end
-
- it "should return the PATH present before bundle was activated" do
- code = "print Bundler.original_env['PATH']"
- path = `getconf PATH`.strip + "#{File::PATH_SEPARATOR}/foo"
- with_path_as(path) do
- bundle_exec_ruby!(code.dump)
- expect(last_command.stdboth).to eq(path)
- end
- end
-
- it "should return the GEM_PATH present before bundle was activated" do
- code = "print Bundler.original_env['GEM_PATH']"
- gem_path = ENV["GEM_PATH"] + ":/foo"
- with_gem_path_as(gem_path) do
- bundle_exec_ruby!(code.dump)
- expect(last_command.stdboth).to eq(gem_path)
- end
- end
-
- it "works with nested bundle exec invocations", :ruby_repo do
- create_file("exe.rb", <<-'RB')
- count = ARGV.first.to_i
- exit if count < 0
- STDERR.puts "#{count} #{ENV["PATH"].end_with?(":/foo")}"
- if count == 2
- ENV["PATH"] = "#{ENV["PATH"]}:/foo"
- end
- exec(Gem.ruby, __FILE__, (count - 1).to_s)
- RB
- path = `getconf PATH`.strip + File::PATH_SEPARATOR + File.dirname(Gem.ruby)
- with_path_as(path) do
- bundle! "exec '#{Gem.ruby}' #{bundled_app("exe.rb")} 2", :env => { :RUBYOPT => "-r#{spec_dir.join("support/hax")}" }
- end
- expect(err).to eq <<-EOS.strip
-2 false
-1 true
-0 true
- EOS
- end
-
- it "removes variables that bundler added", :ruby_repo do
- original = ruby!('puts ENV.to_a.map {|e| e.join("=") }.sort.join("\n")', :env => { :RUBYOPT => "-r#{spec_dir.join("support/hax")}" })
- code = 'puts Bundler.original_env.to_a.map {|e| e.join("=") }.sort.join("\n")'
- bundle! "exec '#{Gem.ruby}' -e #{code.dump}", :env => { :RUBYOPT => "-r#{spec_dir.join("support/hax")}" }
- expect(out).to eq original
- end
- end
-
- describe "Bundler.clean_env", :bundler => "< 3" do
- before do
- bundle "config path vendor/bundle"
- gemfile ""
- bundle "install"
- end
-
- it "should delete BUNDLE_PATH" do
- code = "print Bundler.clean_env.has_key?('BUNDLE_PATH')"
- ENV["BUNDLE_PATH"] = "./foo"
- bundle_exec_ruby! code.dump
- expect(last_command.stdboth).to eq "false"
- end
-
- it "should remove '-rbundler/setup' from RUBYOPT" do
- code = "print Bundler.clean_env['RUBYOPT']"
- ENV["RUBYOPT"] = "-W2 -rbundler/setup"
- bundle_exec_ruby! code.dump
- expect(last_command.stdboth).not_to include("-rbundler/setup")
- end
-
- it "should clean up RUBYLIB", :ruby_repo do
- code = "print Bundler.clean_env['RUBYLIB']"
- ENV["RUBYLIB"] = root.join("lib").to_s + File::PATH_SEPARATOR + "/foo"
- bundle_exec_ruby! code.dump
- expect(last_command.stdboth).to eq("/foo")
- end
-
- it "should restore the original MANPATH" do
- code = "print Bundler.clean_env['MANPATH']"
- ENV["MANPATH"] = "/foo"
- ENV["BUNDLER_ORIG_MANPATH"] = "/foo-original"
- bundle_exec_ruby! code.dump
- expect(last_command.stdboth).to eq("/foo-original")
- end
- end
-
- describe "Bundler.with_original_env" do
- it "should set ENV to original_env in the block" do
- expected = Bundler.original_env
- actual = Bundler.with_original_env { ENV.to_hash }
- expect(actual).to eq(expected)
- end
-
- it "should restore the environment after execution" do
- Bundler.with_original_env do
- ENV["FOO"] = "hello"
- end
-
- expect(ENV).not_to have_key("FOO")
- end
- end
-
- describe "Bundler.with_clean_env", :bundler => "< 3" do
- it "should set ENV to clean_env in the block" do
- expected = Bundler.clean_env
- actual = Bundler.with_clean_env { ENV.to_hash }
- expect(actual).to eq(expected)
- end
-
- it "should restore the environment after execution" do
- Bundler.with_clean_env do
- ENV["FOO"] = "hello"
- end
-
- expect(ENV).not_to have_key("FOO")
- end
- end
-
- describe "Bundler.clean_system", :ruby => ">= 1.9", :bundler => "< 3" do
- it "runs system inside with_clean_env" do
- Bundler.clean_system(%(echo 'if [ "$BUNDLE_PATH" = "" ]; then exit 42; else exit 1; fi' | /bin/sh))
- expect($?.exitstatus).to eq(42)
- end
- end
-
- describe "Bundler.clean_exec", :ruby => ">= 1.9", :bundler => "< 3" do
- it "runs exec inside with_clean_env" do
- pid = Kernel.fork do
- Bundler.clean_exec(%(echo 'if [ "$BUNDLE_PATH" = "" ]; then exit 42; else exit 1; fi' | /bin/sh))
- end
- Process.wait(pid)
- expect($?.exitstatus).to eq(42)
- end
- end
-end
diff --git a/spec/bundler/runtime/with_unbundled_env_spec.rb b/spec/bundler/runtime/with_unbundled_env_spec.rb
new file mode 100644
index 0000000000..b4503cba32
--- /dev/null
+++ b/spec/bundler/runtime/with_unbundled_env_spec.rb
@@ -0,0 +1,241 @@
+# frozen_string_literal: true
+
+RSpec.describe "Bundler.with_env helpers" do
+ def bundle_exec_ruby!(code)
+ build_bundler_context
+ bundle! "exec '#{Gem.ruby}' -e #{code}"
+ end
+
+ def build_bundler_context
+ bundle "config set path vendor/bundle"
+ gemfile ""
+ bundle "install"
+ end
+
+ describe "Bundler.original_env" do
+ it "should return the PATH present before bundle was activated" do
+ code = "print Bundler.original_env['PATH']"
+ path = `getconf PATH`.strip + "#{File::PATH_SEPARATOR}/foo"
+ with_path_as(path) do
+ bundle_exec_ruby!(code.dump)
+ expect(last_command.stdboth).to eq(path)
+ end
+ end
+
+ it "should return the GEM_PATH present before bundle was activated" do
+ code = "print Bundler.original_env['GEM_PATH']"
+ gem_path = ENV["GEM_PATH"] + ":/foo"
+ with_gem_path_as(gem_path) do
+ bundle_exec_ruby!(code.dump)
+ expect(last_command.stdboth).to eq(gem_path)
+ end
+ end
+
+ it "works with nested bundle exec invocations", :ruby_repo do
+ create_file("exe.rb", <<-'RB')
+ count = ARGV.first.to_i
+ exit if count < 0
+ STDERR.puts "#{count} #{ENV["PATH"].end_with?(":/foo")}"
+ if count == 2
+ ENV["PATH"] = "#{ENV["PATH"]}:/foo"
+ end
+ exec(Gem.ruby, __FILE__, (count - 1).to_s)
+ RB
+ path = `getconf PATH`.strip + File::PATH_SEPARATOR + File.dirname(Gem.ruby)
+ with_path_as(path) do
+ build_bundler_context
+ bundle! "exec '#{Gem.ruby}' #{bundled_app("exe.rb")} 2"
+ end
+ expect(last_command.stderr).to eq <<-EOS.strip
+2 false
+1 true
+0 true
+ EOS
+ end
+
+ it "removes variables that bundler added", :ruby_repo do
+ original = ruby!('puts ENV.to_a.map {|e| e.join("=") }.sort.join("\n")')
+ code = 'puts Bundler.original_env.to_a.map {|e| e.join("=") }.sort.join("\n")'
+ bundle_exec_ruby! code.dump
+ expect(out).to eq original
+ end
+ end
+
+ shared_examples_for "an unbundling helper" do
+ it "should delete BUNDLE_PATH" do
+ code = "print #{modified_env}.has_key?('BUNDLE_PATH')"
+ ENV["BUNDLE_PATH"] = "./foo"
+ bundle_exec_ruby! code.dump
+ expect(last_command.stdboth).to include "false"
+ end
+
+ it "should remove '-rbundler/setup' from RUBYOPT" do
+ code = "print #{modified_env}['RUBYOPT']"
+ ENV["RUBYOPT"] = "-W2 -rbundler/setup #{ENV["RUBYOPT"]}"
+ bundle_exec_ruby! code.dump
+ expect(last_command.stdboth).not_to include("-rbundler/setup")
+ end
+
+ it "should clean up RUBYLIB", :ruby_repo do
+ code = "print #{modified_env}['RUBYLIB']"
+ ENV["RUBYLIB"] = root.join("lib").to_s + File::PATH_SEPARATOR + "/foo"
+ bundle_exec_ruby! code.dump
+ expect(last_command.stdboth).to include("/foo")
+ end
+
+ it "should restore the original MANPATH" do
+ code = "print #{modified_env}['MANPATH']"
+ ENV["MANPATH"] = "/foo"
+ ENV["BUNDLER_ORIG_MANPATH"] = "/foo-original"
+ bundle_exec_ruby! code.dump
+ expect(last_command.stdboth).to include("/foo-original")
+ end
+ end
+
+ describe "Bundler.unbundled_env" do
+ let(:modified_env) { "Bundler.unbundled_env" }
+
+ it_behaves_like "an unbundling helper"
+ end
+
+ describe "Bundler.clean_env", :bundler => 2 do
+ let(:modified_env) { "Bundler.clean_env" }
+
+ it_behaves_like "an unbundling helper"
+ end
+
+ describe "Bundler.with_original_env" do
+ it "should set ENV to original_env in the block" do
+ expected = Bundler.original_env
+ actual = Bundler.with_original_env { ENV.to_hash }
+ expect(actual).to eq(expected)
+ end
+
+ it "should restore the environment after execution" do
+ Bundler.with_original_env do
+ ENV["FOO"] = "hello"
+ end
+
+ expect(ENV).not_to have_key("FOO")
+ end
+ end
+
+ describe "Bundler.with_clean_env", :bundler => 2 do
+ it "should set ENV to unbundled_env in the block" do
+ expected = Bundler.unbundled_env
+ actual = Bundler.with_clean_env { ENV.to_hash }
+ expect(actual).to eq(expected)
+ end
+
+ it "should restore the environment after execution" do
+ Bundler.with_clean_env do
+ ENV["FOO"] = "hello"
+ end
+
+ expect(ENV).not_to have_key("FOO")
+ end
+ end
+
+ describe "Bundler.with_unbundled_env" do
+ it "should set ENV to unbundled_env in the block" do
+ expected = Bundler.unbundled_env
+ actual = Bundler.with_unbundled_env { ENV.to_hash }
+ expect(actual).to eq(expected)
+ end
+
+ it "should restore the environment after execution" do
+ Bundler.with_unbundled_env do
+ ENV["FOO"] = "hello"
+ end
+
+ expect(ENV).not_to have_key("FOO")
+ end
+ end
+
+ describe "Bundler.original_system" do
+ it "runs system inside with_original_env" do
+ code = 'exit Bundler.original_system(%(test "\$BUNDLE_FOO" = "bar"))'
+ lib = File.expand_path("../../lib", __dir__)
+ system({ "BUNDLE_FOO" => "bar" }, "ruby -I#{lib} -rbundler -e '#{code}'")
+ expect($?.exitstatus).to eq(0)
+ end
+ end
+
+ describe "Bundler.clean_system", :bundler => 2 do
+ it "runs system inside with_clean_env" do
+ code = 'exit Bundler.clean_system(%(test "\$BUNDLE_FOO" = "bar"))'
+ lib = File.expand_path("../../lib", __dir__)
+ system({ "BUNDLE_FOO" => "bar" }, "ruby -I#{lib} -rbundler -e '#{code}'")
+ expect($?.exitstatus).to eq(1)
+ end
+ end
+
+ describe "Bundler.unbundled_system" do
+ it "runs system inside with_unbundled_env" do
+ code = 'exit Bundler.clean_system(%(test "\$BUNDLE_FOO" = "bar"))'
+ lib = File.expand_path("../../lib", __dir__)
+ system({ "BUNDLE_FOO" => "bar" }, "ruby -I#{lib} -rbundler -e '#{code}'")
+ expect($?.exitstatus).to eq(1)
+ end
+ end
+
+ describe "Bundler.original_exec" do
+ let(:code) do
+ <<~RUBY
+ Process.fork do
+ exit Bundler.original_exec(%(test "\$BUNDLE_FOO" = "bar"))
+ end
+
+ _, status = Process.wait2
+
+ exit(status.exitstatus)
+ RUBY
+ end
+
+ it "runs exec inside with_original_env" do
+ lib = File.expand_path("../../lib", __dir__)
+ system({ "BUNDLE_FOO" => "bar" }, "ruby -I#{lib} -rbundler -e '#{code}'")
+ expect($?.exitstatus).to eq(0)
+ end
+ end
+
+ describe "Bundler.clean_exec", :bundler => 2 do
+ let(:code) do
+ <<~RUBY
+ Process.fork do
+ exit Bundler.clean_exec(%(test "\$BUNDLE_FOO" = "bar"))
+ end
+
+ _, status = Process.wait2
+
+ exit(status.exitstatus)
+ RUBY
+ end
+
+ it "runs exec inside with_clean_env" do
+ lib = File.expand_path("../../lib", __dir__)
+ system({ "BUNDLE_FOO" => "bar" }, "ruby -I#{lib} -rbundler -e '#{code}'")
+ expect($?.exitstatus).to eq(1)
+ end
+ end
+
+ describe "Bundler.unbundled_exec" do
+ let(:code) do
+ <<~RUBY
+ Process.fork do
+ exit Bundler.unbundled_exec(%(test "\$BUNDLE_FOO" = "bar"))
+ end
+
+ _, status = Process.wait2
+
+ exit(status.exitstatus)
+ RUBY
+ end
+
+ it "runs exec inside with_clean_env" do
+ lib = File.expand_path("../../lib", __dir__)
+ system({ "BUNDLE_FOO" => "bar" }, "ruby -I#{lib} -rbundler -e '#{code}'")
+ expect($?.exitstatus).to eq(1)
+ end
+ end
+end
diff --git a/spec/bundler/spec_helper.rb b/spec/bundler/spec_helper.rb
index c7614e1c43..81c222ea6f 100644
--- a/spec/bundler/spec_helper.rb
+++ b/spec/bundler/spec_helper.rb
@@ -3,43 +3,11 @@
$:.unshift File.expand_path("..", __FILE__)
$:.unshift File.expand_path("../../lib", __FILE__)
-require "rubygems"
-module Gem
- if defined?(@path_to_default_spec_map)
- @path_to_default_spec_map.delete_if do |_path, spec|
- spec.name == "bundler"
- end
- end
-end
-
-begin
- require File.expand_path("../support/path.rb", __FILE__)
- spec = Gem::Specification.load(Spec::Path.gemspec.to_s)
- rspec = spec.dependencies.find {|d| d.name == "rspec" }
- gem "rspec", rspec.requirement.to_s
- require "rspec"
- require "diff/lcs"
-rescue LoadError
- abort "Run rake spec:deps to install development dependencies"
-end
-
require "bundler/psyched_yaml"
require "bundler/vendored_fileutils"
require "uri"
require "digest"
-# Delete the default copy of Bundler that RVM installs for us when running in CI
-require "fileutils"
-if ENV.select {|k, _v| k =~ /TRAVIS/ }.any? && Gem::Version.new(Gem::VERSION) > Gem::Version.new("2.0")
- Dir.glob(File.join(Gem::Specification.default_specifications_dir, "bundler*.gemspec")).each do |file|
- FileUtils.rm_rf(file)
- end
-
- Dir.glob(File.join(RbConfig::CONFIG["sitelibdir"], "bundler*")).each do |file|
- FileUtils.rm_rf(file)
- end
-end
-
if File.expand_path(__FILE__) =~ %r{([^\w/\.:\-])}
abort "The bundler specs cannot be run from a path that contains special characters (particularly #{$1.inspect})"
end
@@ -53,9 +21,8 @@ end
$debug = false
-Spec::Manpages.setup
+Spec::Manpages.setup unless Gem.win_platform?
Spec::Rubygems.setup
-FileUtils.rm_rf(Spec::Path.gem_repo1)
ENV["RUBYOPT"] = "#{ENV["RUBYOPT"]} -r#{Spec::Path.spec_dir}/support/hax.rb"
ENV["BUNDLE_SPEC_RUN"] = "true"
@@ -104,13 +71,10 @@ RSpec.configure do |config|
config.filter_run_excluding :realworld => true
end
- git_version = Bundler::Source::Git::GitProxy.new(nil, nil, nil).version
-
- config.filter_run_excluding :ruby => LessThanProc.with(RUBY_VERSION)
- config.filter_run_excluding :rubygems => LessThanProc.with(Gem::VERSION)
- config.filter_run_excluding :git => LessThanProc.with(git_version)
+ config.filter_run_excluding :ruby => RequirementChecker.against(RUBY_VERSION)
+ config.filter_run_excluding :rubygems => RequirementChecker.against(Gem::VERSION)
config.filter_run_excluding :rubygems_master => (ENV["RGV"] != "master")
- config.filter_run_excluding :bundler => LessThanProc.with(Bundler::VERSION.split(".")[0, 2].join("."))
+ config.filter_run_excluding :bundler => RequirementChecker.against(Bundler::VERSION.split(".")[0])
config.filter_run_excluding :ruby_repo => !(ENV["BUNDLE_RUBY"] && ENV["BUNDLE_GEM"]).nil?
config.filter_run_when_matching :focus unless ENV["CI"]
@@ -122,6 +86,10 @@ RSpec.configure do |config|
c.syntax = :expect
end
+ config.mock_with :rspec do |mocks|
+ mocks.allow_message_expectations_on_nil = false
+ end
+
config.around :each do |example|
if ENV["BUNDLE_RUBY"]
orig_ruby = Gem.ruby
diff --git a/spec/bundler/support/artifice/compact_index.rb b/spec/bundler/support/artifice/compact_index.rb
index 01e8eb7837..4f01690ae4 100644
--- a/spec/bundler/support/artifice/compact_index.rb
+++ b/spec/bundler/support/artifice/compact_index.rb
@@ -21,7 +21,7 @@ class CompactIndexAPI < Endpoint
headers "Surrogate-Control" => "max-age=2592000, stale-while-revalidate=60"
content_type "text/plain"
requested_range_for(response_body)
- rescue => e
+ rescue StandardError => e
puts e
puts e.backtrace
raise
@@ -57,11 +57,7 @@ class CompactIndexAPI < Endpoint
end
def slice_body(body, range)
- if body.respond_to?(:byteslice)
- body.byteslice(range)
- else # pre-1.9.3
- body.unpack("@#{range.first}a#{range.end + 1}").first
- end
+ body.byteslice(range)
end
def gems(gem_repo = GEM_REPO)
@@ -82,8 +78,8 @@ class CompactIndexAPI < Endpoint
CompactIndex::Dependency.new(d.name, reqs)
end
checksum = begin
- Digest::SHA256.file("#{GEM_REPO}/gems/#{spec.original_name}.gem").base64digest
- rescue
+ Digest(:SHA256).file("#{GEM_REPO}/gems/#{spec.original_name}.gem").base64digest
+ rescue StandardError
nil
end
CompactIndex::GemVersion.new(spec.version.version, spec.platform.to_s, checksum, nil,
diff --git a/spec/bundler/support/artifice/compact_index_api_missing.rb b/spec/bundler/support/artifice/compact_index_api_missing.rb
index d4e68c38e8..94e6b73000 100644
--- a/spec/bundler/support/artifice/compact_index_api_missing.rb
+++ b/spec/bundler/support/artifice/compact_index_api_missing.rb
@@ -6,7 +6,7 @@ Artifice.deactivate
class CompactIndexApiMissing < CompactIndexAPI
get "/fetch/actual/gem/:id" do
- $stderr.puts params[:id]
+ warn params[:id]
if params[:id] == "rack-1.0.gemspec.rz"
halt 404
else
diff --git a/spec/bundler/support/artifice/compact_index_rate_limited.rb b/spec/bundler/support/artifice/compact_index_rate_limited.rb
new file mode 100644
index 0000000000..d8f4fc941c
--- /dev/null
+++ b/spec/bundler/support/artifice/compact_index_rate_limited.rb
@@ -0,0 +1,48 @@
+# frozen_string_literal: true
+
+require File.expand_path("../compact_index", __FILE__)
+
+Artifice.deactivate
+
+class CompactIndexRateLimited < CompactIndexAPI
+ class RequestCounter
+ def self.queue
+ @queue ||= Queue.new
+ end
+
+ def self.size
+ @queue.size
+ end
+
+ def self.enq(name)
+ @queue.enq(name)
+ end
+
+ def self.deq
+ @queue.deq
+ end
+ end
+
+ configure do
+ RequestCounter.queue
+ end
+
+ get "/info/:name" do
+ RequestCounter.enq(params[:name])
+
+ begin
+ if RequestCounter.size == 1
+ etag_response do
+ gem = gems.find {|g| g.name == params[:name] }
+ CompactIndex.info(gem ? gem.versions : [])
+ end
+ else
+ status 429
+ end
+ ensure
+ RequestCounter.deq
+ end
+ end
+end
+
+Artifice.activate_with(CompactIndexRateLimited)
diff --git a/spec/bundler/support/artifice/endpoint.rb b/spec/bundler/support/artifice/endpoint.rb
index 9a0cfae8a2..fcced6ea35 100644
--- a/spec/bundler/support/artifice/endpoint.rb
+++ b/spec/bundler/support/artifice/endpoint.rb
@@ -59,7 +59,7 @@ class Endpoint < Sinatra::Base
:platform => spec.platform.to_s,
:dependencies => spec.dependencies.select {|dep| dep.type == :runtime }.map do |dep|
[dep.name, dep.requirement.requirements.map {|a| a.join(" ") }.join(", ")]
- end
+ end,
}
end.compact
end
diff --git a/spec/bundler/support/artifice/endpoint_api_missing.rb b/spec/bundler/support/artifice/endpoint_api_missing.rb
index 95db8e2a7e..2ada0dc553 100644
--- a/spec/bundler/support/artifice/endpoint_api_missing.rb
+++ b/spec/bundler/support/artifice/endpoint_api_missing.rb
@@ -6,7 +6,7 @@ Artifice.deactivate
class EndpointApiMissing < Endpoint
get "/fetch/actual/gem/:id" do
- $stderr.puts params[:id]
+ warn params[:id]
if params[:id] == "rack-1.0.gemspec.rz"
halt 404
else
diff --git a/spec/bundler/support/artifice/vcr.rb b/spec/bundler/support/artifice/vcr.rb
index edd2f49a91..1e3809ff62 100644
--- a/spec/bundler/support/artifice/vcr.rb
+++ b/spec/bundler/support/artifice/vcr.rb
@@ -1,13 +1,6 @@
# frozen_string_literal: true
require "net/http"
-if RUBY_VERSION < "1.9"
- begin
- require "net/https"
- rescue LoadError
- nil # net/https or openssl
- end
-end # but only for 1.8
CASSETTE_PATH = File.expand_path("../vcr_cassettes", __FILE__)
CASSETTE_NAME = ENV.fetch("BUNDLER_SPEC_VCR_CASSETTE_NAME") { "realworld" }
diff --git a/spec/bundler/support/builders.rb b/spec/bundler/support/builders.rb
index 97134a045a..33a81f6f65 100644
--- a/spec/bundler/support/builders.rb
+++ b/spec/bundler/support/builders.rb
@@ -40,7 +40,7 @@ module Spec
build_gem "rails", "2.3.2" do |s|
s.executables = "rails"
- s.add_dependency "rake", "10.0.2"
+ s.add_dependency "rake", "12.3.2"
s.add_dependency "actionpack", "2.3.2"
s.add_dependency "activerecord", "2.3.2"
s.add_dependency "actionmailer", "2.3.2"
@@ -210,12 +210,7 @@ module Spec
# The yard gem iterates over Gem.source_index looking for plugins
build_gem "yard" do |s|
s.write "lib/yard.rb", <<-Y
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new("1.8.10")
- specs = Gem::Specification
- else
- specs = Gem.source_index.find_name('')
- end
- specs.sort_by(&:name).each do |gem|
+ Gem::Specification.sort_by(&:name).each do |gem|
puts gem.full_name
end
Y
@@ -653,7 +648,8 @@ module Spec
`git add *`
`git config user.email "lol@wut.com"`
`git config user.name "lolwut"`
- `git commit -m 'OMG INITIAL COMMIT'`
+ `git config commit.gpgsign false`
+ `git commit -m "OMG INITIAL COMMIT"`
end
end
end
diff --git a/spec/bundler/support/helpers.rb b/spec/bundler/support/helpers.rb
index 89c67c45b7..09e7419a98 100644
--- a/spec/bundler/support/helpers.rb
+++ b/spec/bundler/support/helpers.rb
@@ -41,19 +41,25 @@ module Spec
end
def out
- last_command.stdboth
+ last_command.stdout
end
def err
- last_command.stderr
+ Bundler.feature_flag.error_on_stderr? ? last_command.stderr : last_command.stdout
end
- def exitstatus
- last_command.exitstatus
+ MAJOR_DEPRECATION = /^\[DEPRECATED\]\s*/.freeze
+
+ def err_without_deprecations
+ last_command.stderr.gsub(/#{MAJOR_DEPRECATION}.+[\n]?/, "")
end
- def bundle_update_requires_all?
- Bundler::VERSION.start_with?("2.") ? nil : true
+ def deprecations
+ err.split("\n").select {|l| l =~ MAJOR_DEPRECATION }.join("\n").split(MAJOR_DEPRECATION)
+ end
+
+ def exitstatus
+ last_command.exitstatus
end
def in_app_root(&blk)
@@ -71,7 +77,7 @@ module Spec
def run(cmd, *args)
opts = args.last.is_a?(Hash) ? args.pop : {}
groups = args.map(&:inspect).join(", ")
- setup = "require 'rubygems' ; require 'bundler' ; Bundler.setup(#{groups})\n"
+ setup = "require 'bundler' ; Bundler.setup(#{groups})\n"
ruby(setup + cmd, opts)
end
bang :run
@@ -131,8 +137,6 @@ module Spec
load_path << spec
load_path_str = "-I#{load_path.join(File::PATH_SEPARATOR)}"
- env = env.map {|k, v| "#{k}='#{v}'" }.join(" ")
-
args = options.map do |k, v|
case v
when nil
@@ -146,13 +150,13 @@ module Spec
end
end.join
- cmd = "#{env} #{sudo} #{Gem.ruby} #{load_path_str} #{requires_str} #{bundle_bin} #{cmd}#{args}"
- sys_exec(cmd) {|i, o, thr| yield i, o, thr if block_given? }
+ cmd = "#{sudo} #{Gem.ruby} #{load_path_str} #{requires_str} #{bundle_bin} #{cmd}#{args}"
+ sys_exec(cmd, env) {|i, o, thr| yield i, o, thr if block_given? }
end
bang :bundle
def forgotten_command_line_options(options)
- remembered = Bundler.bundler_major_version < 3
+ remembered = Bundler::VERSION.split(".", 2).first == "2"
options = options.map do |k, v|
k = Array(k)[remembered ? 0 : -1]
v = '""' if v && v.to_s.empty?
@@ -161,9 +165,9 @@ module Spec
return Hash[options] if remembered
options.each do |k, v|
if v.nil?
- bundle! "config --delete #{k}"
+ bundle! "config unset #{k}"
else
- bundle! "config --local #{k} #{v}"
+ bundle! "config set --local #{k} #{v}"
end
end
{}
@@ -174,11 +178,6 @@ module Spec
bundle(cmd, options)
end
- def bundle_ruby(options = {})
- options["bundle_bin"] = bindir.join("bundle_ruby")
- bundle("", options)
- end
-
def ruby(ruby, options = {})
env = (options.delete(:env) || {}).map {|k, v| "#{k}='#{v}' " }.join
ruby = ruby.gsub(/["`\$]/) {|m| "\\#{m}" }
@@ -221,16 +220,18 @@ module Spec
"#{Gem.ruby} -S #{ENV["GEM_PATH"]}/bin/rake"
end
- def sys_exec(cmd)
+ def sys_exec(cmd, env = {})
command_execution = CommandExecution.new(cmd.to_s, Dir.pwd)
- Open3.popen3(cmd.to_s) do |stdin, stdout, stderr, wait_thr|
+ env = env.map {|k, v| [k.to_s, v.to_s] }.to_h # convert env keys and values to string
+
+ Open3.popen3(env, cmd.to_s) do |stdin, stdout, stderr, wait_thr|
yield stdin, stdout, wait_thr if block_given?
stdin.close
- command_execution.exitstatus = wait_thr && wait_thr.value.exitstatus
command_execution.stdout = Thread.new { stdout.read }.value.strip
command_execution.stderr = Thread.new { stderr.read }.value.strip
+ command_execution.exitstatus = wait_thr && wait_thr.value.exitstatus
end
(@command_executions ||= []) << command_execution
@@ -263,18 +264,22 @@ module Spec
end
def gemfile(*args)
- if args.empty?
+ contents = args.shift
+
+ if contents.nil?
File.open("Gemfile", "r", &:read)
else
- create_file("Gemfile", *args)
+ create_file("Gemfile", contents, *args)
end
end
def lockfile(*args)
- if args.empty?
+ contents = args.shift
+
+ if contents.nil?
File.open("Gemfile.lock", "r", &:read)
else
- create_file("Gemfile.lock", *args)
+ create_file("Gemfile.lock", normalize_uri_file(contents), *args)
end
end
@@ -323,7 +328,7 @@ module Spec
Dir.chdir(root) { gem_command! :build, gemspec.to_s }
end
bundler_path = root + "bundler-#{Bundler::VERSION}.gem"
- elsif g.to_s =~ %r{\A/.*\.gem\z}
+ elsif g.to_s =~ %r{\A(?:[A-Z]:)?/.*\.gem\z}
g
else
"#{gem_repo}/gems/#{g}.gem"
@@ -331,11 +336,8 @@ module Spec
raise "OMG `#{path}` does not exist!" unless File.exist?(path)
- if Gem::VERSION < "2.0.0"
- gem_command! :install, "--no-rdoc --no-ri --ignore-dependencies '#{path}'"
- else
- gem_command! :install, "--no-document --ignore-dependencies '#{path}'"
- end
+ gem_command! :install, "--no-document --ignore-dependencies '#{path}'"
+
bundler_path && bundler_path.rmtree
end
end
@@ -437,7 +439,7 @@ module Spec
ENV["GEM_PATH"] = system_gem_path.to_s
gems.each do |gem|
- gem_command :install, "--no-rdoc --no-ri #{gem}"
+ gem_command! :install, "--no-document #{gem}"
end
return unless block_given?
begin
@@ -577,7 +579,7 @@ module Spec
tries = 0
sleep 0.5
TCPSocket.new(host, port)
- rescue => e
+ rescue StandardError => e
raise(e) if tries > (seconds * 2)
tries += 1
retry
@@ -587,7 +589,7 @@ module Spec
port = 21_453
begin
port += 1 while TCPSocket.new("127.0.0.1", port)
- rescue
+ rescue StandardError
false
end
port
diff --git a/spec/bundler/support/indexes.rb b/spec/bundler/support/indexes.rb
index 69f8d9f679..b76f493d01 100644
--- a/spec/bundler/support/indexes.rb
+++ b/spec/bundler/support/indexes.rb
@@ -77,7 +77,7 @@ module Spec
gem "rack-mount", %w[0.4 0.5 0.5.1 0.5.2 0.6]
# --- Pre-release support
- gem "rubygems\0", ["1.3.2"]
+ gem "RubyGems\0", ["1.3.2"]
# --- Rails
versions "1.2.3 2.2.3 2.3.5 3.0.0.beta 3.0.0.beta1" do |version|
@@ -414,7 +414,7 @@ module Spec
gem("b", %w[0.9.0 1.5.0 2.0.0.pre])
# --- Pre-release support
- gem "rubygems\0", ["1.3.2"]
+ gem "RubyGems\0", ["1.3.2"]
end
end
end
diff --git a/spec/bundler/support/less_than_proc.rb b/spec/bundler/support/less_than_proc.rb
deleted file mode 100644
index ddac5458b7..0000000000
--- a/spec/bundler/support/less_than_proc.rb
+++ /dev/null
@@ -1,20 +0,0 @@
-# frozen_string_literal: true
-
-class LessThanProc < Proc
- attr_accessor :present
-
- def self.with(present)
- provided = Gem::Version.new(present.dup)
- new do |required|
- if required =~ /[=><~]/
- !Gem::Requirement.new(required).satisfied_by?(provided)
- else
- provided < Gem::Version.new(required)
- end
- end.tap {|l| l.present = present }
- end
-
- def inspect
- "\"=< #{present}\""
- end
-end
diff --git a/spec/bundler/support/matchers.rb b/spec/bundler/support/matchers.rb
index 8e17be3a02..f9efe32a38 100644
--- a/spec/bundler/support/matchers.rb
+++ b/spec/bundler/support/matchers.rb
@@ -60,36 +60,6 @@ module Spec
end
end
- MAJOR_DEPRECATION = /^\[DEPRECATED FOR 2\.0\]\s*/
-
- RSpec::Matchers.define :lack_errors do
- diffable
- match do |actual|
- actual.gsub(/#{MAJOR_DEPRECATION}.+[\n]?/, "") == ""
- end
- end
-
- RSpec::Matchers.define :eq_err do |expected|
- diffable
- match do |actual|
- actual.gsub(/#{MAJOR_DEPRECATION}.+[\n]?/, "") == expected
- end
- end
-
- RSpec::Matchers.define :have_major_deprecation do |expected|
- diffable
- match do |actual|
- deprecations = actual.split(MAJOR_DEPRECATION)
-
- return !expected.nil? if deprecations.size <= 1
- return true if expected.nil?
-
- deprecations.any? do |d|
- !d.empty? && values_match?(expected, d.strip)
- end
- end
- end
-
RSpec::Matchers.define :have_dep do |*args|
dep = Bundler::Dependency.new(*args)
@@ -128,6 +98,14 @@ module Spec
end
end
+ RSpec::Matchers.define :be_well_formed do
+ match(&:empty?)
+
+ failure_message do |actual|
+ actual.join("\n")
+ end
+ end
+
define_compound_matcher :read_as, [exist] do |file_contents|
diffable
@@ -152,10 +130,9 @@ module Spec
version_const = name == "bundler" ? "Bundler::VERSION" : Spec::Builders.constantize(name)
begin
run! "require '#{name}.rb'; puts #{version_const}", *groups
- rescue => e
+ rescue StandardError => e
next "#{name} is not installed:\n#{indent(e)}"
end
- last_command.stdout.gsub!(/#{MAJOR_DEPRECATION}.*$/, "")
actual_version, actual_platform = last_command.stdout.strip.split(/\s+/, 2)
unless Gem::Version.new(actual_version) == Gem::Version.new(version)
next "#{name} was expected to be at version #{version} but was #{actual_version}"
@@ -167,10 +144,9 @@ module Spec
begin
source_const = "#{Spec::Builders.constantize(name)}_SOURCE"
run! "require '#{name}/source'; puts #{source_const}", *groups
- rescue
+ rescue StandardError
next "#{name} does not have a source defined:\n#{indent(e)}"
end
- last_command.stdout.gsub!(/#{MAJOR_DEPRECATION}.*$/, "")
unless last_command.stdout.strip == source
next "Expected #{name} (#{version}) to be installed from `#{source}`, was actually from `#{out}`"
end
@@ -193,7 +169,7 @@ module Spec
puts "WIN"
end
R
- rescue => e
+ rescue StandardError => e
next "checking for #{name} failed:\n#{e}"
end
next if last_command.stdout == "WIN"
@@ -218,7 +194,7 @@ module Spec
RSpec::Matchers.alias_matcher :include_gem, :include_gems
def have_lockfile(expected)
- read_as(strip_whitespace(expected))
+ read_as(normalize_uri_file(strip_whitespace(expected)))
end
def plugin_should_be_installed(*names)
@@ -236,7 +212,7 @@ module Spec
end
def lockfile_should_be(expected)
- expect(bundled_app("Gemfile.lock")).to read_as(normalize_uri_file(strip_whitespace(expected)))
+ expect(bundled_app("Gemfile.lock")).to have_lockfile(expected)
end
def gemfile_should_be(expected)
diff --git a/spec/bundler/support/path.rb b/spec/bundler/support/path.rb
index 69efcba051..dc4b3bb6eb 100644
--- a/spec/bundler/support/path.rb
+++ b/spec/bundler/support/path.rb
@@ -99,7 +99,7 @@ module Spec
end
def bundler_path
- Pathname.new(File.expand_path(root.join("lib"), __FILE__))
+ root.join("lib")
end
def global_plugin_gem(*args)
diff --git a/spec/bundler/support/platforms.rb b/spec/bundler/support/platforms.rb
index 950311d20e..0a9e4a8cb6 100644
--- a/spec/bundler/support/platforms.rb
+++ b/spec/bundler/support/platforms.rb
@@ -100,9 +100,8 @@ module Spec
9999
end
- def lockfile_platforms(*platforms)
- platforms = local_platforms if platforms.empty?
- platforms.map(&:to_s).sort.join("\n ")
+ def lockfile_platforms
+ local_platforms.map(&:to_s).sort.join("\n ")
end
def local_platforms
diff --git a/spec/bundler/support/requirement_checker.rb b/spec/bundler/support/requirement_checker.rb
new file mode 100644
index 0000000000..d8f5fd5e5f
--- /dev/null
+++ b/spec/bundler/support/requirement_checker.rb
@@ -0,0 +1,11 @@
+# frozen_string_literal: true
+
+class RequirementChecker < Proc
+ def self.against(present)
+ provided = Gem::Version.new(present)
+
+ new do |required|
+ !Gem::Requirement.new(required).satisfied_by?(provided)
+ end
+ end
+end
diff --git a/spec/bundler/support/rubygems_ext.rb b/spec/bundler/support/rubygems_ext.rb
index 42f887f268..2f3d252865 100644
--- a/spec/bundler/support/rubygems_ext.rb
+++ b/spec/bundler/support/rubygems_ext.rb
@@ -1,31 +1,25 @@
# frozen_string_literal: true
require "rubygems/user_interaction"
-require "support/path" unless defined?(Spec::Path)
+require "support/path"
+require "fileutils"
module Spec
module Rubygems
DEPS = begin
- deps = {
- # rack 2.x requires Ruby version >= 2.2.2.
+ {
# artifice doesn't support rack 2.x now.
- # TODO: revert to `< 2` once https://github.com/rack/rack/issues/1168 is
- # addressed
- "rack" => "1.6.6",
- # rack-test 0.7.0 dropped 1.8.7 support
- # https://github.com/rack-test/rack-test/issues/193#issuecomment-314230318
- "rack-test" => "< 0.7.0",
+ "rack" => "< 2.0",
+ "rack-test" => "~> 1.1",
"artifice" => "~> 0.6.0",
"compact_index" => "~> 0.11.0",
"sinatra" => "~> 1.4.7",
# Rake version has to be consistent for tests to pass
- "rake" => "10.0.2",
- # 3.0.0 breaks 1.9.2 specs
- "builder" => "2.1.2",
+ "rake" => "12.3.2",
+ "builder" => "~> 3.2",
+ # ruby-graphviz is used by the viz tests
+ "ruby-graphviz" => nil,
}
- # ruby-graphviz is used by the viz tests
- deps["ruby-graphviz"] = nil if RUBY_VERSION >= "1.9.3"
- deps
end
def self.setup
@@ -33,17 +27,17 @@ module Spec
ENV["BUNDLE_PATH"] = nil
ENV["GEM_HOME"] = ENV["GEM_PATH"] = Path.base_system_gems.to_s
- ENV["PATH"] = [Path.bindir, "#{Path.system_gem_path}/bin", ENV["PATH"]].join(File::PATH_SEPARATOR)
+ ENV["PATH"] = [Path.bindir, Path.system_gem_path.join("bin"), ENV["PATH"]].join(File::PATH_SEPARATOR)
manifest = DEPS.to_a.sort_by(&:first).map {|k, v| "#{k} => #{v}\n" }
- manifest_path = "#{Path.base_system_gems}/manifest.txt"
+ manifest_path = Path.base_system_gems.join("manifest.txt")
# it's OK if there are extra gems
- if !File.exist?(manifest_path) || !(manifest - File.readlines(manifest_path)).empty?
+ if !manifest_path.file? || !(manifest - manifest_path.readlines).empty?
FileUtils.rm_rf(Path.base_system_gems)
FileUtils.mkdir_p(Path.base_system_gems)
puts "installing gems for the tests to use..."
install_gems(DEPS)
- File.open(manifest_path, "w") {|f| f << manifest.join }
+ manifest_path.open("w") {|f| f << manifest.join }
end
ENV["HOME"] = Path.home.to_s
@@ -54,17 +48,11 @@ module Spec
def self.install_gems(gems)
reqs, no_reqs = gems.partition {|_, req| !req.nil? && !req.split(" ").empty? }
- # TODO: remove when we drop ruby 1.8.7-2.2.2 support
- reqs = reqs.sort_by {|name, _| name == "rack" ? 0 : 1 }.sort_by {|name, _| name =~ /rack/ ? 0 : 1 }
no_reqs.map!(&:first)
reqs.map! {|name, req| "'#{name}:#{req}'" }
deps = reqs.concat(no_reqs).join(" ")
- gem = Spec::Path.ruby_core? ? ENV["BUNDLE_GEM"] : "gem"
- cmd = if Gem::VERSION < "2.0.0"
- "#{gem} install #{deps} --no-rdoc --no-ri --conservative"
- else
- "#{gem} install #{deps} --no-document --conservative"
- end
+ gem = Spec::Path.ruby_core? ? ENV["BUNDLE_GEM"] : "#{Gem.ruby} -S gem"
+ cmd = "#{gem} install #{deps} --no-document --conservative"
puts cmd
system(cmd) || raise("Installing gems #{deps} for the tests to use failed!")
end
diff --git a/spec/bundler/update/gemfile_spec.rb b/spec/bundler/update/gemfile_spec.rb
index f59f3a2d32..6c47c254cd 100644
--- a/spec/bundler/update/gemfile_spec.rb
+++ b/spec/bundler/update/gemfile_spec.rb
@@ -9,7 +9,7 @@ RSpec.describe "bundle update" do
G
bundle! :install, :gemfile => bundled_app("NotGemfile")
- bundle! :update, :gemfile => bundled_app("NotGemfile"), :all => bundle_update_requires_all?
+ bundle! :update, :gemfile => bundled_app("NotGemfile"), :all => true
# Specify BUNDLE_GEMFILE for `the_bundle`
# to retrieve the proper Gemfile
@@ -25,12 +25,12 @@ RSpec.describe "bundle update" do
gem 'rack'
G
- bundle "config --local gemfile #{bundled_app("NotGemfile")}"
+ bundle "config set --local gemfile #{bundled_app("NotGemfile")}"
bundle! :install
end
it "uses the gemfile to update" do
- bundle! "update", :all => bundle_update_requires_all?
+ bundle! "update", :all => true
bundle "list"
expect(out).to include("rack (1.0.0)")
@@ -39,28 +39,11 @@ RSpec.describe "bundle update" do
it "uses the gemfile while in a subdirectory" do
bundled_app("subdir").mkpath
Dir.chdir(bundled_app("subdir")) do
- bundle! "update", :all => bundle_update_requires_all?
+ bundle! "update", :all => true
bundle "list"
expect(out).to include("rack (1.0.0)")
end
end
end
-
- context "with prefer_gems_rb set" do
- before { bundle! "config prefer_gems_rb true" }
-
- it "prefers gems.rb to Gemfile" do
- create_file("gems.rb", "gem 'bundler'")
- create_file("Gemfile", "raise 'wrong Gemfile!'")
-
- bundle! :install
- bundle! :update, :all => bundle_update_requires_all?
-
- expect(bundled_app("gems.rb")).to be_file
- expect(bundled_app("Gemfile.lock")).not_to be_file
-
- expect(the_bundle).to include_gem "bundler #{Bundler::VERSION}"
- end
- end
end
diff --git a/spec/bundler/update/gems/post_install_spec.rb b/spec/bundler/update/gems/post_install_spec.rb
index 2fb3547806..f6b7f39d0b 100644
--- a/spec/bundler/update/gems/post_install_spec.rb
+++ b/spec/bundler/update/gems/post_install_spec.rb
@@ -10,7 +10,7 @@ RSpec.describe "bundle update" do
gem 'thin'
G
- bundle! "config #{config}" if config
+ bundle! "config set #{config}" if config
bundle! :install
end
@@ -52,7 +52,7 @@ RSpec.describe "bundle update" do
gem 'thin'
G
- bundle! :update, :all => bundle_update_requires_all?
+ bundle! :update, :all => true
end
it_behaves_like "a post-install message outputter"
@@ -67,7 +67,7 @@ RSpec.describe "bundle update" do
gem 'thin'
G
- bundle! :update, :all => bundle_update_requires_all?
+ bundle! :update, :all => true
end
it_behaves_like "a post-install message outputter"
diff --git a/spec/bundler/update/git_spec.rb b/spec/bundler/update/git_spec.rb
index d97760e84b..4fe22269e2 100644
--- a/spec/bundler/update/git_spec.rb
+++ b/spec/bundler/update/git_spec.rb
@@ -16,7 +16,7 @@ RSpec.describe "bundle update" do
s.write "lib/foo.rb", "FOO = '1.1'"
end
- bundle "update", :all => bundle_update_requires_all?
+ bundle "update", :all => true
expect(the_bundle).to include_gems "foo 1.1"
end
@@ -88,7 +88,7 @@ RSpec.describe "bundle update" do
gem "foo", "1.0", :git => "#{lib_path("foo_two")}"
G
- expect(err).to lack_errors
+ expect(last_command.stderr).to be_empty
expect(out).to include("Fetching #{lib_path}/foo_two")
expect(out).to include("Bundle complete!")
end
@@ -111,7 +111,7 @@ RSpec.describe "bundle update" do
gem 'foo', :git => "#{@remote.path}", :tag => "fubar"
G
- bundle "update", :all => bundle_update_requires_all?
+ bundle "update", :all => true
expect(exitstatus).to eq(0) if exitstatus
end
@@ -191,7 +191,7 @@ RSpec.describe "bundle update" do
lib_path("foo-1.0").join(".git").rmtree
- bundle :update, :all => bundle_update_requires_all?
+ bundle :update, :all => true
expect(last_command.bundler_err).to include(lib_path("foo-1.0").to_s).
and match(/Git error: command `git fetch.+has failed/)
end
@@ -208,7 +208,7 @@ RSpec.describe "bundle update" do
gem "rack", :git => "#{lib_path("rack-0.8")}", :branch => "master"
G
- bundle %(config local.rack #{lib_path("local-rack")})
+ bundle %(config set local.rack #{lib_path("local-rack")})
bundle "update rack"
expect(out).to include("Bundle updated!")
end
@@ -233,7 +233,7 @@ RSpec.describe "bundle update" do
rails!
G
- bundle "update", :all => bundle_update_requires_all?
+ bundle "update", :all => true
expect(out).to include("Using rails 3.0 (was 2.3.2) from #{lib_path("rails")} (at master@#{revision_for(lib_path("rails"))[0..6]})")
end
end
@@ -299,7 +299,7 @@ RSpec.describe "bundle update" do
G
end
- it "the --source flag updates version of gems that were originally pulled in by the source", :bundler => "> 3" do
+ it "the --source flag updates version of gems that were originally pulled in by the source", :bundler => "< 3" do
spec_lines = lib_path("bar/foo.gemspec").read.split("\n")
spec_lines[5] = "s.version = '2.0'"
@@ -348,17 +348,17 @@ RSpec.describe "bundle update" do
bundle "update --source bar"
lockfile_should_be <<-G
- GEM
- remote: file://localhost#{gem_repo2}/
- specs:
- rack (1.0.0)
-
GIT
remote: #{@git.path}
revision: #{ref}
specs:
foo (2.0)
+ GEM
+ remote: file://localhost#{gem_repo2}/
+ specs:
+ rack (1.0.0)
+
PLATFORMS
#{lockfile_platforms}
diff --git a/spec/bundler/update/redownload_spec.rb b/spec/bundler/update/redownload_spec.rb
index 1bbc3a66fc..39edac0902 100644
--- a/spec/bundler/update/redownload_spec.rb
+++ b/spec/bundler/update/redownload_spec.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-RSpec.describe "bundle update", :bundler => "< 3", :ruby => ">= 2.0" do
+RSpec.describe "bundle update" do
before :each do
install_gemfile <<-G
source "file://#{gem_repo1}"
@@ -8,29 +8,27 @@ RSpec.describe "bundle update", :bundler => "< 3", :ruby => ">= 2.0" do
G
end
- before { bundle "config major_deprecations yes" }
-
describe "with --force" do
- it "shows a deprecation when single flag passed" do
+ it "shows a deprecation when single flag passed", :bundler => 2 do
bundle! "update rack --force"
- expect(out).to include "[DEPRECATED FOR 3.0] The `--force` option has been renamed to `--redownload`"
+ expect(err).to include "[DEPRECATED] The `--force` option has been renamed to `--redownload`"
end
- it "shows a deprecation when multiple flags passed" do
+ it "shows a deprecation when multiple flags passed", :bundler => 2 do
bundle! "update rack --no-color --force"
- expect(out).to include "[DEPRECATED FOR 3.0] The `--force` option has been renamed to `--redownload`"
+ expect(err).to include "[DEPRECATED] The `--force` option has been renamed to `--redownload`"
end
end
describe "with --redownload" do
it "does not show a deprecation when single flag passed" do
bundle! "update rack --redownload"
- expect(out).not_to include "[DEPRECATED FOR 3.0] The `--force` option has been renamed to `--redownload`"
+ expect(err).not_to include "[DEPRECATED] The `--force` option has been renamed to `--redownload`"
end
it "does not show a deprecation when single multiple flags passed" do
bundle! "update rack --no-color --redownload"
- expect(out).not_to include "[DEPRECATED FOR 3.0] The `--force` option has been renamed to `--redownload`"
+ expect(err).not_to include "[DEPRECATED] The `--force` option has been renamed to `--redownload`"
end
end
end