diff options
author | hsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-09-08 08:45:41 +0000 |
---|---|---|
committer | hsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-09-08 08:45:41 +0000 |
commit | 8598f8c2dc78c6d1ae87cb6ae19c34ba2cb29241 (patch) | |
tree | 0bbd28f684e745cb212761b7c74fe08668f85cc8 /spec/bundler/update | |
parent | f2e04b77aa8a363d7e36ce5a9cdb60714a537a3c (diff) | |
download | ruby-8598f8c2dc78c6d1ae87cb6ae19c34ba2cb29241.tar.gz |
Merge bundler to standard libraries.
rubygems 2.7.x depends bundler-1.15.x. This is preparation for
rubygems and bundler migration.
* lib/bundler.rb, lib/bundler/*: files of bundler-1.15.4
* spec/bundler/*: rspec examples of bundler-1.15.4. I applied patches.
* https://github.com/bundler/bundler/pull/6007
* Exclude not working examples on ruby repository.
* Fake ruby interpriter instead of installed ruby.
* Makefile.in: Added test task named `test-bundler`. This task is only
working macOS/linux yet. I'm going to support Windows environment later.
* tool/sync_default_gems.rb: Added sync task for bundler.
[Feature #12733][ruby-core:77172]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59779 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'spec/bundler/update')
-rw-r--r-- | spec/bundler/update/gems/post_install_spec.rb | 77 | ||||
-rw-r--r-- | spec/bundler/update/git_spec.rb | 333 | ||||
-rw-r--r-- | spec/bundler/update/path_spec.rb | 19 |
3 files changed, 429 insertions, 0 deletions
diff --git a/spec/bundler/update/gems/post_install_spec.rb b/spec/bundler/update/gems/post_install_spec.rb new file mode 100644 index 0000000000..5a4fe7f321 --- /dev/null +++ b/spec/bundler/update/gems/post_install_spec.rb @@ -0,0 +1,77 @@ +# frozen_string_literal: true +require "spec_helper" + +RSpec.describe "bundle update" do + let(:config) {} + + before do + gemfile <<-G + source "file://#{gem_repo1}" + gem 'rack', "< 1.0" + gem 'thin' + G + + bundle! "config #{config}" if config + + bundle! :install + end + + shared_examples "a config observer" do + context "when ignore post-install messages for gem is set" do + let(:config) { "ignore_messages.rack true" } + + it "doesn't display gem's post-install message" do + expect(out).not_to include("Rack's post install message") + end + end + + context "when ignore post-install messages for all gems" do + let(:config) { "ignore_messages true" } + + it "doesn't display any post-install messages" do + expect(out).not_to include("Post-install message") + end + end + end + + shared_examples "a post-install message outputter" do + it "should display post-install messages for updated gems" do + expect(out).to include("Post-install message from rack:") + expect(out).to include("Rack's post install message") + end + + it "should not display the post-install message for non-updated gems" do + expect(out).not_to include("Thin's post install message") + end + end + + context "when listed gem is updated" do + before do + gemfile <<-G + source "file://#{gem_repo1}" + gem 'rack' + gem 'thin' + G + + bundle! :update + end + + it_behaves_like "a post-install message outputter" + it_behaves_like "a config observer" + end + + context "when dependency triggers update" do + before do + gemfile <<-G + source "file://#{gem_repo1}" + gem 'rack-obama' + gem 'thin' + G + + bundle! :update + end + + it_behaves_like "a post-install message outputter" + it_behaves_like "a config observer" + end +end diff --git a/spec/bundler/update/git_spec.rb b/spec/bundler/update/git_spec.rb new file mode 100644 index 0000000000..021c8c942b --- /dev/null +++ b/spec/bundler/update/git_spec.rb @@ -0,0 +1,333 @@ +# frozen_string_literal: true +require "spec_helper" + +RSpec.describe "bundle update" do + describe "git sources" do + it "floats on a branch when :branch is used" do + build_git "foo", "1.0" + update_git "foo", :branch => "omg" + + install_gemfile <<-G + git "#{lib_path("foo-1.0")}", :branch => "omg" do + gem 'foo' + end + G + + update_git "foo", :branch => "omg" do |s| + s.write "lib/foo.rb", "FOO = '1.1'" + end + + bundle "update" + + expect(the_bundle).to include_gems "foo 1.1" + end + + it "updates correctly when you have like craziness" do + build_lib "activesupport", "3.0", :path => lib_path("rails/activesupport") + build_git "rails", "3.0", :path => lib_path("rails") do |s| + s.add_dependency "activesupport", "= 3.0" + end + + install_gemfile <<-G + gem "rails", :git => "#{lib_path("rails")}" + G + + bundle "update rails" + expect(out).to include("Using activesupport 3.0 from #{lib_path("rails")} (at master@#{revision_for(lib_path("rails"))[0..6]})") + expect(the_bundle).to include_gems "rails 3.0", "activesupport 3.0" + end + + it "floats on a branch when :branch is used and the source is specified in the update" do + build_git "foo", "1.0", :path => lib_path("foo") + update_git "foo", :branch => "omg", :path => lib_path("foo") + + install_gemfile <<-G + git "#{lib_path("foo")}", :branch => "omg" do + gem 'foo' + end + G + + update_git "foo", :branch => "omg", :path => lib_path("foo") do |s| + s.write "lib/foo.rb", "FOO = '1.1'" + end + + bundle "update --source foo" + + expect(the_bundle).to include_gems "foo 1.1" + end + + it "floats on master when updating all gems that are pinned to the source even if you have child dependencies" do + build_git "foo", :path => lib_path("foo") + build_gem "bar", :to_system => true do |s| + s.add_dependency "foo" + end + + install_gemfile <<-G + gem "foo", :git => "#{lib_path("foo")}" + gem "bar" + G + + update_git "foo", :path => lib_path("foo") do |s| + s.write "lib/foo.rb", "FOO = '1.1'" + end + + bundle "update foo" + + expect(the_bundle).to include_gems "foo 1.1" + end + + it "notices when you change the repo url in the Gemfile" do + build_git "foo", :path => lib_path("foo_one") + build_git "foo", :path => lib_path("foo_two") + + install_gemfile <<-G + gem "foo", "1.0", :git => "#{lib_path("foo_one")}" + G + + FileUtils.rm_rf lib_path("foo_one") + + install_gemfile <<-G + gem "foo", "1.0", :git => "#{lib_path("foo_two")}" + G + + expect(err).to lack_errors + expect(out).to include("Fetching #{lib_path}/foo_two") + expect(out).to include("Bundle complete!") + end + + it "fetches tags from the remote" do + build_git "foo" + @remote = build_git("bar", :bare => true) + update_git "foo", :remote => @remote.path + update_git "foo", :push => "master" + + install_gemfile <<-G + gem 'foo', :git => "#{@remote.path}" + G + + # Create a new tag on the remote that needs fetching + update_git "foo", :tag => "fubar" + update_git "foo", :push => "fubar" + + gemfile <<-G + gem 'foo', :git => "#{@remote.path}", :tag => "fubar" + G + + bundle "update" + expect(exitstatus).to eq(0) if exitstatus + end + + describe "with submodules" do + before :each do + build_gem "submodule", :to_system => true do |s| + s.write "lib/submodule.rb", "puts 'GEM'" + end + + build_git "submodule", "1.0" do |s| + s.write "lib/submodule.rb", "puts 'GIT'" + end + + build_git "has_submodule", "1.0" do |s| + s.add_dependency "submodule" + end + + Dir.chdir(lib_path("has_submodule-1.0")) do + sys_exec "git submodule add #{lib_path("submodule-1.0")} submodule-1.0" + `git commit -m "submodulator"` + end + end + + it "it unlocks the source when submodules are added to a git source" do + install_gemfile <<-G + git "#{lib_path("has_submodule-1.0")}" do + gem "has_submodule" + end + G + + run "require 'submodule'" + expect(out).to eq("GEM") + + install_gemfile <<-G + git "#{lib_path("has_submodule-1.0")}", :submodules => true do + gem "has_submodule" + end + G + + run "require 'submodule'" + expect(out).to eq("GIT") + end + + it "unlocks the source when submodules are removed from git source", :git => ">= 2.9.0" do + install_gemfile <<-G + git "#{lib_path("has_submodule-1.0")}", :submodules => true do + gem "has_submodule" + end + G + + run "require 'submodule'" + expect(out).to eq("GIT") + + install_gemfile <<-G + git "#{lib_path("has_submodule-1.0")}" do + gem "has_submodule" + end + G + + run "require 'submodule'" + expect(out).to eq("GEM") + end + end + + it "errors with a message when the .git repo is gone" do + build_git "foo", "1.0" + + install_gemfile <<-G + gem "foo", :git => "#{lib_path("foo-1.0")}" + G + + lib_path("foo-1.0").join(".git").rmtree + + bundle :update + expect(out).to include(lib_path("foo-1.0").to_s) + end + + it "should not explode on invalid revision on update of gem by name" do + build_git "rack", "0.8" + + build_git "rack", "0.8", :path => lib_path("local-rack") do |s| + s.write "lib/rack.rb", "puts :LOCAL" + end + + install_gemfile <<-G + source "file://#{gem_repo1}" + gem "rack", :git => "#{lib_path("rack-0.8")}", :branch => "master" + G + + bundle %(config local.rack #{lib_path("local-rack")}) + bundle "update rack" + expect(out).to include("Bundle updated!") + end + + it "shows the previous version of the gem" do + build_git "rails", "3.0", :path => lib_path("rails") + + install_gemfile <<-G + gem "rails", :git => "#{lib_path("rails")}" + G + + lockfile <<-G + GIT + remote: #{lib_path("rails")} + specs: + rails (2.3.2) + + PLATFORMS + #{generic_local_platform} + + DEPENDENCIES + rails! + G + + bundle "update" + 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 + + describe "with --source flag" do + before :each do + build_repo2 + @git = build_git "foo", :path => lib_path("foo") do |s| + s.executables = "foobar" + end + + install_gemfile <<-G + source "file://#{gem_repo2}" + git "#{lib_path("foo")}" do + gem 'foo' + end + gem 'rack' + G + end + + it "updates the source" do + update_git "foo", :path => @git.path + + bundle "update --source foo" + + in_app_root do + run <<-RUBY + require 'foo' + puts "WIN" if defined?(FOO_PREV_REF) + RUBY + + expect(out).to eq("WIN") + end + end + + it "unlocks gems that were originally pulled in by the source" do + update_git "foo", "2.0", :path => @git.path + + bundle "update --source foo" + expect(the_bundle).to include_gems "foo 2.0" + end + + it "leaves all other gems frozen" do + update_repo2 + update_git "foo", :path => @git.path + + bundle "update --source foo" + expect(the_bundle).to include_gems "rack 1.0" + end + end + + context "when the gem and the repository have different names" do + before :each do + build_repo2 + @git = build_git "foo", :path => lib_path("bar") + + install_gemfile <<-G + source "file://#{gem_repo2}" + git "#{lib_path("bar")}" do + gem 'foo' + end + gem 'rack' + G + end + + it "the --source flag updates version of gems that were originally pulled in by the source" do + spec_lines = lib_path("bar/foo.gemspec").read.split("\n") + spec_lines[5] = "s.version = '2.0'" + + update_git "foo", "2.0", :path => @git.path do |s| + s.write "foo.gemspec", spec_lines.join("\n") + end + + ref = @git.ref_for "master" + + bundle "update --source bar" + + lockfile_should_be <<-G + GIT + remote: #{@git.path} + revision: #{ref} + specs: + foo (2.0) + + GEM + remote: file:#{gem_repo2}/ + specs: + rack (1.0.0) + + PLATFORMS + ruby + + DEPENDENCIES + foo! + rack + + BUNDLED WITH + #{Bundler::VERSION} + G + end + end +end diff --git a/spec/bundler/update/path_spec.rb b/spec/bundler/update/path_spec.rb new file mode 100644 index 0000000000..5ac4f7b1fe --- /dev/null +++ b/spec/bundler/update/path_spec.rb @@ -0,0 +1,19 @@ +# frozen_string_literal: true +require "spec_helper" + +RSpec.describe "path sources" do + describe "bundle update --source" do + it "shows the previous version of the gem when updated from path source" do + build_lib "activesupport", "2.3.5", :path => lib_path("rails/activesupport") + + install_gemfile <<-G + gem "activesupport", :path => "#{lib_path("rails/activesupport")}" + G + + build_lib "activesupport", "3.0", :path => lib_path("rails/activesupport") + + bundle "update --source activesupport" + expect(out).to include("Using activesupport 3.0 (was 2.3.5) from source at `#{lib_path("rails/activesupport")}`") + end + end +end |