diff options
author | Asutosh Palai <asupalai@gmail.com> | 2016-07-15 21:10:46 +0530 |
---|---|---|
committer | Asutosh Palai <asupalai@gmail.com> | 2016-07-21 09:53:08 +0530 |
commit | 363c16198b05fc829fbe47febc481e0deede4a3c (patch) | |
tree | a8ec0944482e177cd7594109fdd870c183cbf2ba | |
parent | 2b6400a6d8cbccf2e917d993dd50e4cc1269d9ad (diff) | |
download | bundler-363c16198b05fc829fbe47febc481e0deede4a3c.tar.gz |
Added integration specs for app level plugin
-rw-r--r-- | lib/bundler/plugin.rb | 2 | ||||
-rw-r--r-- | spec/bundler/plugin/installer_spec.rb | 6 | ||||
-rw-r--r-- | spec/plugins/install_spec.rb | 68 | ||||
-rw-r--r-- | spec/support/path.rb | 6 |
4 files changed, 73 insertions, 9 deletions
diff --git a/lib/bundler/plugin.rb b/lib/bundler/plugin.rb index 64cdf94a11..cd3843fc0d 100644 --- a/lib/bundler/plugin.rb +++ b/lib/bundler/plugin.rb @@ -146,7 +146,7 @@ module Bundler # Used by specs def reset! - instance_variables.each {|i| remove_instance_variable(i)} + instance_variables.each {|i| remove_instance_variable(i) } @sources = {} @commands = {} diff --git a/spec/bundler/plugin/installer_spec.rb b/spec/bundler/plugin/installer_spec.rb index a914aabbf3..0cdd36ee2a 100644 --- a/spec/bundler/plugin/installer_spec.rb +++ b/spec/bundler/plugin/installer_spec.rb @@ -75,7 +75,7 @@ describe Bundler::Plugin::Installer do it "has expected full_gem)path" do expect(result["re-plugin"].full_gem_path). - to eq(plugin_gems("re-plugin-1.0").to_s) + to eq(global_plugin_gems("re-plugin-1.0").to_s) end end @@ -90,8 +90,8 @@ describe Bundler::Plugin::Installer do end it "has expected full_gem)path" do - expect(result["re-plugin"].full_gem_path).to eq(plugin_gems("re-plugin-1.0").to_s) - expect(result["ma-plugin"].full_gem_path).to eq(plugin_gems("ma-plugin-1.0").to_s) + expect(result["re-plugin"].full_gem_path).to eq(global_plugin_gems("re-plugin-1.0").to_s) + expect(result["ma-plugin"].full_gem_path).to eq(global_plugin_gems("ma-plugin-1.0").to_s) end end end diff --git a/spec/plugins/install_spec.rb b/spec/plugins/install_spec.rb index b700ee0fe3..31271e7233 100644 --- a/spec/plugins/install_spec.rb +++ b/spec/plugins/install_spec.rb @@ -78,7 +78,7 @@ describe "bundler plugin install" do expect(out).to include("plugins.rb was not found") - expect(plugin_gems("charlie-1.0")).not_to be_directory + expect(global_plugin_gems("charlie-1.0")).not_to be_directory plugin_should_not_be_installed("charlie") end @@ -94,7 +94,7 @@ describe "bundler plugin install" do bundle "plugin install chaplin --source file://#{gem_repo2}" - expect(plugin_gems("chaplin-1.0")).not_to be_directory + expect(global_plugin_gems("chaplin-1.0")).not_to be_directory plugin_should_not_be_installed("chaplin") end @@ -179,4 +179,68 @@ describe "bundler plugin install" do expect(local_plugin_gems("foo-1.0", "plugins.rb")).to exist end end + + describe "local plugin", :focused do + it "is installed when inside an app" do + gemfile "" + bundle "plugin install foo --source file://#{gem_repo2}" + + plugin_should_be_installed("foo") + expect(local_plugin_gems("foo-1.0")).to be_directory + end + + context "conflict with global plugin" do + before do + update_repo2 do + build_plugin "fubar" do |s| + s.write "plugins.rb", <<-RUBY + class Fubar < Bundler::Plugin::API + command "shout" + + def exec(command, args) + puts "local_one" + end + end + RUBY + end + end + + # inside the app + gemfile "source 'file://#{gem_repo2}'\nplugin 'fubar'" + bundle "install" + + update_repo2 do + build_plugin "fubar", "1.1" do |s| + s.write "plugins.rb", <<-RUBY + class Fubar < Bundler::Plugin::API + command "shout" + + def exec(command, args) + puts "global_one" + end + end + RUBY + end + end + + # outside the app + Dir.chdir tmp + bundle "plugin install fubar --source file://#{gem_repo2}" + 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" + expect(out).to eq("global_one") + end + end + end end diff --git a/spec/support/path.rb b/spec/support/path.rb index d8b1384ede..bd6cd4e47a 100644 --- a/spec/support/path.rb +++ b/spec/support/path.rb @@ -81,12 +81,12 @@ module Spec Pathname.new(File.expand_path("../../../lib", __FILE__)) end - def local_plugin_root(*args) - bundled_app ".bundle", "plugin", *args + def global_plugin_gems(*args) + home ".bundle", "plugin", "gems", *args end def local_plugin_gems(*args) - local_plugin_root "gems", *args + bundled_app ".bundle", "plugin", "gems", *args end extend self |