summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAsutosh Palai <asupalai@gmail.com>2016-06-07 21:09:37 +0530
committerAsutosh Palai <asupalai@gmail.com>2016-06-07 21:36:08 +0530
commit81ea9335591768560dcc917a1d2e848ff938f11e (patch)
tree94491c1df41d358b548825a273e8810f019fbca3
parent1a9857473bbd7b91a5abd0b2e7da144f375ff761 (diff)
downloadbundler-81ea9335591768560dcc917a1d2e848ff938f11e.tar.gz
Added spec for multiple plugin install
-rw-r--r--lib/bundler/plugin.rb6
-rw-r--r--spec/bundler/plugin/installer_spec.rb19
-rw-r--r--spec/bundler/plugin_spec.rb16
-rw-r--r--spec/plugins/install.rb20
4 files changed, 54 insertions, 7 deletions
diff --git a/lib/bundler/plugin.rb b/lib/bundler/plugin.rb
index b01ba7aad1..00b4d9e941 100644
--- a/lib/bundler/plugin.rb
+++ b/lib/bundler/plugin.rb
@@ -13,9 +13,9 @@ module Bundler
PLUGIN_FILE_NAME = "plugins.rb".freeze
- @commands = {}
+ module_function
- module_function
+ @commands = {}
# Installs a new plugin by the given name
#
@@ -28,7 +28,7 @@ module Bundler
save_plugins paths
rescue PluginError => e
- paths.values.map {|path| Bundler.rm_rf(path)} if paths
+ paths.values.map {|path| Bundler.rm_rf(path) } if paths
Bundler.ui.error "Failed to install plugin #{name}: #{e.message}\n #{e.backtrace.join("\n ")}"
end
diff --git a/spec/bundler/plugin/installer_spec.rb b/spec/bundler/plugin/installer_spec.rb
index 0cda970b4b..936732f01a 100644
--- a/spec/bundler/plugin/installer_spec.rb
+++ b/spec/bundler/plugin/installer_spec.rb
@@ -29,6 +29,13 @@ describe Bundler::Plugin::Installer do
end
describe "with actual installers" do
+ before do
+ build_repo2 do
+ build_plugin "re-plugin"
+ build_plugin "ma-plugin"
+ end
+ end
+
it "returns the installation path after installing git plugins" do
build_git "ga-plugin", :path => lib_path("ga-plugin") do |s|
s.write "plugins.rb"
@@ -42,14 +49,18 @@ describe Bundler::Plugin::Installer do
end
it "returns the installation path after installing rubygems plugins" do
- build_repo2 do
- build_plugin "re-plugin"
- end
-
opts = { :source => "file://#{gem_repo2}" }
expect(installer.install(["re-plugin"], opts)).
to eq("re-plugin" => plugin_gems("re-plugin-1.0").to_s)
end
+
+ it "accepts multiple plugins" do
+ opts = { :source => "file://#{gem_repo2}" }
+
+ expect(installer.install(["re-plugin", "ma-plugin"], opts)).
+ to eq("re-plugin" => plugin_gems("re-plugin-1.0").to_s,
+ "ma-plugin" => plugin_gems("ma-plugin-1.0").to_s)
+ end
end
end
end
diff --git a/spec/bundler/plugin_spec.rb b/spec/bundler/plugin_spec.rb
index 573a5d2271..517f539bd8 100644
--- a/spec/bundler/plugin_spec.rb
+++ b/spec/bundler/plugin_spec.rb
@@ -50,6 +50,22 @@ describe Bundler::Plugin do
with("new-plugin", lib_path("new-plugin").to_s, []).once
subject.install ["new-plugin"], opts
end
+
+ context "multiple plugins" do
+ it do
+ allow(installer).to receive(:install).
+ with(["new-plugin", "another-plugin"], opts) do
+ {
+ "new_plugin" => lib_path("new-plugin"),
+ "another-plugin" => lib_path("another-plugin"),
+ }
+ end.once
+
+ allow(subject).to receive(:validate_plugin!).twice
+ allow(index).to receive(:register_plugin).twice
+ subject.install ["new-plugin", "another-plugin"], opts
+ end
+ end
end
describe "evaluate gemfile for plugins" do
diff --git a/spec/plugins/install.rb b/spec/plugins/install.rb
index 971b11a298..08f055e7ac 100644
--- a/spec/plugins/install.rb
+++ b/spec/plugins/install.rb
@@ -5,6 +5,7 @@ describe "bundler plugin install" do
before do
build_repo2 do
build_plugin "foo"
+ build_plugin "kung-foo"
end
end
@@ -28,6 +29,25 @@ describe "bundler plugin install" do
expect(out).to include("Installed plugin foo")
end
+ it "installs multiple plugins" do
+ bundle "plugin install foo kung-foo --source file://#{gem_repo2}"
+
+ expect(out).to include("Installed plugin foo")
+ expect(out).to include("Installed plugin kung-foo")
+ end
+
+ it "uses the same version for multiple plugins" do
+ update_repo2 do
+ build_plugin "foo", "1.1"
+ build_plugin "kung-foo", "1.1"
+ end
+
+ bundle "plugin install foo kung-foo --version '1.0' --source file://#{gem_repo2}"
+
+ expect(out).to include("Installing foo 1.0")
+ expect(out).to include("Installing kung-foo 1.0")
+ end
+
context "malformatted plugin" do
it "fails when plugins.rb is missing" do
build_repo2 do