summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Giddins <segiddins@segiddins.me>2016-06-08 01:26:00 -0500
committerSamuel Giddins <segiddins@segiddins.me>2016-06-10 01:42:17 -0500
commitd61ab01f5a5370a6873130c13272c515fa76b6af (patch)
tree6f8a79d67cb8406db4337544db90f09f6422284a
parentcfbe2b4b272242b404a6abb318edde030447707a (diff)
downloadbundler-d61ab01f5a5370a6873130c13272c515fa76b6af.tar.gz
Add a spec for trampolining
-rw-r--r--spec/other/trampoline_spec.rb118
-rw-r--r--spec/support/rubygems_ext.rb3
2 files changed, 120 insertions, 1 deletions
diff --git a/spec/other/trampoline_spec.rb b/spec/other/trampoline_spec.rb
new file mode 100644
index 0000000000..9a76819f8f
--- /dev/null
+++ b/spec/other/trampoline_spec.rb
@@ -0,0 +1,118 @@
+# frozen_string_literal: true
+require "spec_helper"
+
+describe "bundler version trampolining" do
+ before do
+ ENV["BUNDLE_DISABLE_POSTIT"] = nil
+ FileUtils.rm_rf(system_gem_path)
+ FileUtils.cp_r(base_system_gems, system_gem_path)
+ end
+
+ context "version guessing" do
+ shared_examples_for "guesses" do |version|
+ it "guesses the correct bundler version" do
+ bundle! "--version"
+ expect(out).to eq("Bundler version #{version}")
+
+ if bundled_app("Gemfile").file?
+ bundle! "exec ruby -e 'puts Bundler::VERSION'"
+ expect(out).to eq(version)
+ end
+ end
+ end
+
+ context "with a lockfile" do
+ before do
+ install_gemfile ""
+ lockfile lockfile.sub(Bundler::VERSION, "1.12.0")
+ end
+
+ include_examples "guesses", "1.12.0"
+ end
+
+ context "with BUNDLER_VERSION" do
+ before do
+ ENV["BUNDLER_VERSION"] = "1.12.0"
+ end
+
+ context "with a lockfile" do
+ before { install_gemfile "" }
+ include_examples "guesses", "1.12.0"
+ end
+
+ context "without a lockfile" do
+ include_examples "guesses", "1.12.0"
+ end
+ end
+
+ context "with no hints" do
+ include_examples "guesses", Bundler::VERSION
+ end
+
+ context "with a gemfile and no lockfile" do
+ before do
+ gemfile ""
+ end
+
+ include_examples "guesses", Bundler::VERSION
+ end
+ end
+
+ context "installing missing bundler versions", :realworld => true do
+ before do
+ ENV["BUNDLER_VERSION"] = "1.12.3"
+ end
+
+ it "guesses & installs the correct bundler version" do
+ expect(system_gem_path.join("gems", "bundler-1.12.3")).not_to exist
+ bundle! "--version"
+ expect(out).to eq("Bundler version 1.12.3")
+ expect(system_gem_path.join("gems", "bundler-1.12.3")).to exist
+ end
+ end
+
+ context "bundle update --bundler" do
+ before do
+ simulate_bundler_version("1.11.1") do
+ install_gemfile ""
+ end
+ end
+
+ it "updates to the specified version" do
+ # HACK: since no released bundler version actually supports this feature!
+ bundle "update --bundler=1.12.0", :expect_err => true
+ expect(out).to include("Unknown switches '--bundler=1.12.0'")
+ end
+
+ it "updates to the specified (running) version" do
+ # HACK: since no released bundler version actually supports this feature!
+ bundle! "update --bundler=#{Bundler::VERSION}"
+ bundle! "--version"
+ expect(out).to eq("Bundler version #{Bundler::VERSION}")
+ end
+
+ it "updates to the running version" do
+ # HACK: since no released bundler version actually supports this feature!
+ bundle! "update --bundler"
+ bundle! "--version"
+ expect(out).to eq("Bundler version #{Bundler::VERSION}")
+ end
+ end
+
+ context "-rbundler/setup" do
+ before do
+ simulate_bundler_version("1.12.0") do
+ install_gemfile ""
+ end
+ end
+
+ it "uses the locked version" do
+ ruby! <<-R
+ require "bundler/setup"
+ puts Bundler::VERSION
+ R
+ expect(err).to be_empty
+ expect(out).to eq("1.12.0")
+ end
+ end
+end
diff --git a/spec/support/rubygems_ext.rb b/spec/support/rubygems_ext.rb
index 64cc41443d..95f596ea79 100644
--- a/spec/support/rubygems_ext.rb
+++ b/spec/support/rubygems_ext.rb
@@ -11,7 +11,8 @@ module Spec
# 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"
+ "builder" => "2.1.2",
+ "bundler" => "1.12.0",
}
# ruby-graphviz is used by the viz tests
deps["ruby-graphviz"] = nil if RUBY_VERSION >= "1.9.3"