diff options
author | Samuel Giddins <segiddins@segiddins.me> | 2016-06-08 01:26:00 -0500 |
---|---|---|
committer | Samuel Giddins <segiddins@segiddins.me> | 2016-06-10 01:42:17 -0500 |
commit | d61ab01f5a5370a6873130c13272c515fa76b6af (patch) | |
tree | 6f8a79d67cb8406db4337544db90f09f6422284a /spec/other | |
parent | cfbe2b4b272242b404a6abb318edde030447707a (diff) | |
download | bundler-d61ab01f5a5370a6873130c13272c515fa76b6af.tar.gz |
Add a spec for trampolining
Diffstat (limited to 'spec/other')
-rw-r--r-- | spec/other/trampoline_spec.rb | 118 |
1 files changed, 118 insertions, 0 deletions
diff --git a/spec/other/trampoline_spec.rb b/spec/other/trampoline_spec.rb new file mode 100644 index 00000000..9a76819f --- /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 |