diff options
author | Hiroshi SHIBATA <hsbt@ruby-lang.org> | 2020-05-08 14:19:04 +0900 |
---|---|---|
committer | Hiroshi SHIBATA <hsbt@ruby-lang.org> | 2020-05-13 07:54:37 +0900 |
commit | 0e60b59d5884edb8f9aea023efd9b24f1ff02049 (patch) | |
tree | e52935ce510440872ca5ce6b0e092cbc94f18bc9 /spec/bundler/plugins | |
parent | 68224651a4d4dc3ce0cea666f5423dd8b6ba6cfc (diff) | |
download | ruby-0e60b59d5884edb8f9aea023efd9b24f1ff02049.tar.gz |
Update the bundler version with master branch
Diffstat (limited to 'spec/bundler/plugins')
-rw-r--r-- | spec/bundler/plugins/install_spec.rb | 14 | ||||
-rw-r--r-- | spec/bundler/plugins/source/example_spec.rb | 11 | ||||
-rw-r--r-- | spec/bundler/plugins/source_spec.rb | 3 | ||||
-rw-r--r-- | spec/bundler/plugins/uninstall_spec.rb | 49 |
4 files changed, 64 insertions, 13 deletions
diff --git a/spec/bundler/plugins/install_spec.rb b/spec/bundler/plugins/install_spec.rb index 669ed09fb5..663363ca21 100644 --- a/spec/bundler/plugins/install_spec.rb +++ b/spec/bundler/plugins/install_spec.rb @@ -155,6 +155,10 @@ RSpec.describe "bundler plugin install" do end context "Gemfile eval" do + before do + allow(Bundler::SharedHelpers).to receive(:find_gemfile).and_return(bundled_app_gemfile) + end + it "installs plugins listed in gemfile" do gemfile <<-G source '#{file_uri_for(gem_repo2)}' @@ -245,6 +249,7 @@ RSpec.describe "bundler plugin install" do describe "local plugin" do it "is installed when inside an app" do + allow(Bundler::SharedHelpers).to receive(:find_gemfile).and_return(bundled_app_gemfile) gemfile "" bundle "plugin install foo --source #{file_uri_for(gem_repo2)}" @@ -287,21 +292,16 @@ RSpec.describe "bundler plugin install" do end # outside the app - Dir.chdir tmp - bundle "plugin install fubar --source #{file_uri_for(gem_repo2)}" + bundle "plugin install fubar --source #{file_uri_for(gem_repo2)}", :dir => tmp end it "inside the app takes precedence over global plugin" do - Dir.chdir bundled_app - bundle "shout" expect(out).to eq("local_one") end it "outside the app global plugin is used" do - Dir.chdir tmp - - bundle "shout" + bundle "shout", :dir => tmp expect(out).to eq("global_one") end end diff --git a/spec/bundler/plugins/source/example_spec.rb b/spec/bundler/plugins/source/example_spec.rb index f2151a5a73..aac506dc9a 100644 --- a/spec/bundler/plugins/source/example_spec.rb +++ b/spec/bundler/plugins/source/example_spec.rb @@ -215,6 +215,8 @@ RSpec.describe "real source plugins" do build_repo2 do build_plugin "bundler-source-gitp" do |s| s.write "plugins.rb", <<-RUBY + require "open3" + class SPlugin < Bundler::Plugin::API source "gitp" @@ -254,9 +256,7 @@ RSpec.describe "real source plugins" do mkdir_p(install_path.dirname) rm_rf(install_path) `git clone --no-checkout --quiet "\#{cache_path}" "\#{install_path}"` - Dir.chdir install_path do - `git reset --hard \#{revision}` - end + Open3.capture2e("git reset --hard \#{revision}", :chdir => install_path) spec_path = install_path.join("\#{spec.full_name}.gemspec") spec_path.open("wb") {|f| f.write spec.to_ruby } @@ -310,9 +310,8 @@ RSpec.describe "real source plugins" do cache_repo end - Dir.chdir cache_path do - `git rev-parse --verify \#{@ref}`.strip - end + output, _status = Open3.capture2e("git rev-parse --verify \#{@ref}", :chdir => cache_path) + output.strip end def base_name diff --git a/spec/bundler/plugins/source_spec.rb b/spec/bundler/plugins/source_spec.rb index c8deee96b1..14643e5c81 100644 --- a/spec/bundler/plugins/source_spec.rb +++ b/spec/bundler/plugins/source_spec.rb @@ -21,6 +21,7 @@ RSpec.describe "bundler source plugin" do end G + allow(Bundler::SharedHelpers).to receive(:find_gemfile).and_return(bundled_app_gemfile) plugin_should_be_installed("bundler-source-psource") end @@ -75,6 +76,7 @@ RSpec.describe "bundler source plugin" do end it "installs the explicit one" do + allow(Bundler::SharedHelpers).to receive(:find_gemfile).and_return(bundled_app_gemfile) plugin_should_be_installed("another-psource") end @@ -100,6 +102,7 @@ RSpec.describe "bundler source plugin" do end it "installs the default one" do + allow(Bundler::SharedHelpers).to receive(:find_gemfile).and_return(bundled_app_gemfile) plugin_should_be_installed("bundler-source-psource") end end diff --git a/spec/bundler/plugins/uninstall_spec.rb b/spec/bundler/plugins/uninstall_spec.rb new file mode 100644 index 0000000000..8180241911 --- /dev/null +++ b/spec/bundler/plugins/uninstall_spec.rb @@ -0,0 +1,49 @@ +# frozen_string_literal: true + +RSpec.describe "bundler plugin uninstall" do + before do + build_repo2 do + build_plugin "foo" + build_plugin "kung-foo" + end + end + + it "shows proper error message when plugins are not specified" do + bundle "plugin uninstall" + expect(err).to include("No plugins to uninstall") + end + + it "uninstalls specified plugins" do + bundle "plugin install foo kung-foo --source #{file_uri_for(gem_repo2)}" + plugin_should_be_installed("foo") + plugin_should_be_installed("kung-foo") + + bundle "plugin uninstall foo" + expect(out).to include("Uninstalled plugin foo") + plugin_should_not_be_installed("foo") + plugin_should_be_installed("kung-foo") + end + + it "shows proper message when plugin is not installed" do + bundle "plugin uninstall foo" + expect(err).to include("Plugin foo is not installed") + plugin_should_not_be_installed("foo") + end + + describe "with --all" do + it "uninstalls all installed plugins" do + bundle "plugin install foo kung-foo --source #{file_uri_for(gem_repo2)}" + plugin_should_be_installed("foo") + plugin_should_be_installed("kung-foo") + + bundle "plugin uninstall --all" + plugin_should_not_be_installed("foo") + plugin_should_not_be_installed("kung-foo") + end + + it "shows proper no plugins installed message when no plugins installed" do + bundle "plugin uninstall --all" + expect(out).to include("No plugins installed") + end + end +end |