diff options
author | Homu <homu@barosl.com> | 2016-08-16 08:42:50 +0900 |
---|---|---|
committer | Homu <homu@barosl.com> | 2016-08-16 08:42:50 +0900 |
commit | f81446d095c60a162ec57c18fd62c29e9567a0a2 (patch) | |
tree | 9fc6e04a3405f99b7855f99dece62e4c96791dc6 /spec/plugins/install_spec.rb | |
parent | 7c38144e84b48cc932756932ad4679c4f71400c0 (diff) | |
parent | 888041af40a9e7a9a173439c41f2961de152b39c (diff) | |
download | bundler-f81446d095c60a162ec57c18fd62c29e9567a0a2.tar.gz |
Auto merge of #4788 - asutoshpalai:plugin-project-level, r=segiddins
Project local plugins
If the user is in an app directory the plugin is installed in `.bundle/` inside the app root.
If the user is in not in any app directory the plugin is installed in the `.bundle/` in the user's home.
Diffstat (limited to 'spec/plugins/install_spec.rb')
-rw-r--r-- | spec/plugins/install_spec.rb | 68 |
1 files changed, 66 insertions, 2 deletions
diff --git a/spec/plugins/install_spec.rb b/spec/plugins/install_spec.rb index c667ed0a68..a24f318156 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_gem("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_gem("chaplin-1.0")).not_to be_directory plugin_should_not_be_installed("chaplin") end @@ -176,7 +176,71 @@ describe "bundler plugin install" do RUBY ruby code + expect(local_plugin_gem("foo-1.0", "plugins.rb")).to exist + end + end + + describe "local plugin" 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_gem("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 |