diff options
Diffstat (limited to 'spec/bundler/plugins')
-rw-r--r-- | spec/bundler/plugins/command_spec.rb | 4 | ||||
-rw-r--r-- | spec/bundler/plugins/install_spec.rb | 58 | ||||
-rw-r--r-- | spec/bundler/plugins/list_spec.rb | 60 | ||||
-rw-r--r-- | spec/bundler/plugins/source/example_spec.rb | 16 |
4 files changed, 125 insertions, 13 deletions
diff --git a/spec/bundler/plugins/command_spec.rb b/spec/bundler/plugins/command_spec.rb index 999d8b722b..53d34f7acc 100644 --- a/spec/bundler/plugins/command_spec.rb +++ b/spec/bundler/plugins/command_spec.rb @@ -73,8 +73,8 @@ RSpec.describe "command plugins" do expect(out).not_to include("Installed plugin copycat") - expect(out).to include("Failed to install plugin") + expect(err).to include("Failed to install plugin") - expect(out).to include("Command(s) `mahcommand` declared by copycat are already registered.") + expect(err).to include("Command(s) `mahcommand` declared by copycat are already registered.") end end diff --git a/spec/bundler/plugins/install_spec.rb b/spec/bundler/plugins/install_spec.rb index 9304d78062..afc6087c1b 100644 --- a/spec/bundler/plugins/install_spec.rb +++ b/spec/bundler/plugins/install_spec.rb @@ -11,7 +11,7 @@ RSpec.describe "bundler plugin install" do it "shows proper message when gem in not found in the source" do bundle "plugin install no-foo --source file://#{gem_repo1}" - expect(out).to include("Could not find") + expect(err).to include("Could not find") plugin_should_not_be_installed("no-foo") end @@ -22,6 +22,18 @@ RSpec.describe "bundler plugin install" do plugin_should_be_installed("foo") end + context "plugin is already installed" do + before do + bundle "plugin install foo --source file://#{gem_repo2}" + end + + it "doesn't install plugin again" do + bundle "plugin install foo --source file://#{gem_repo2}" + expect(out).not_to include("Installing plugin foo") + expect(out).not_to include("Installed plugin foo") + end + end + it "installs multiple plugins" do bundle "plugin install foo kung-foo --source file://#{gem_repo2}" @@ -86,7 +98,7 @@ RSpec.describe "bundler plugin install" do bundle "plugin install charlie --source file://#{gem_repo2}" - expect(out).to include("plugins.rb was not found") + expect(err).to include("plugins.rb was not found") expect(global_plugin_gem("charlie-1.0")).not_to be_directory @@ -122,6 +134,24 @@ RSpec.describe "bundler plugin install" do expect(out).to include("Installed plugin foo") plugin_should_be_installed("foo") end + + it "installs form a local git source" do + build_git "foo" do |s| + s.write "plugins.rb" + end + + bundle "plugin install foo --local_git #{lib_path("foo-1.0")}" + + expect(out).to include("Installed plugin foo") + plugin_should_be_installed("foo") + end + + it "raises an error when both git and local git sources are specified" do + bundle "plugin install foo --local_git /phony/path/project --git git@gitphony.com:/repo/project" + + expect(exitstatus).not_to eq(0) if exitstatus + expect(err).to eq("Remote and local plugin git sources can't be both specified") + end end context "Gemfile eval" do @@ -147,7 +177,7 @@ RSpec.describe "bundler plugin install" do build_plugin "foo", "1.1.0" end - install_gemfile <<-G + gemfile <<-G source 'file://#{gem_repo2}' plugin 'foo', "1.0" G @@ -173,6 +203,28 @@ RSpec.describe "bundler plugin install" do expect(out).to include("Installed plugin ga-plugin") plugin_should_be_installed("ga-plugin") end + + context "in deployment mode" do + it "installs plugins" do + install_gemfile! <<-G + source 'file://#{gem_repo2}' + gem 'rack', "1.0.0" + G + + install_gemfile! <<-G, forgotten_command_line_options(:deployment => true) + source 'file://#{gem_repo2}' + plugin 'foo' + gem 'rack', "1.0.0" + G + + expect(out).to include("Installed plugin foo") + + expect(out).to include("Bundle complete!") + + expect(the_bundle).to include_gems("rack 1.0.0") + plugin_should_be_installed("foo") + end + end end context "inline gemfiles" do diff --git a/spec/bundler/plugins/list_spec.rb b/spec/bundler/plugins/list_spec.rb new file mode 100644 index 0000000000..7dc9d10c4b --- /dev/null +++ b/spec/bundler/plugins/list_spec.rb @@ -0,0 +1,60 @@ +# frozen_string_literal: true + +RSpec.describe "bundler plugin list" do + before do + build_repo2 do + build_plugin "foo" do |s| + s.write "plugins.rb", <<-RUBY + class Foo < Bundler::Plugin::API + command "shout" + + def exec(command, args) + puts "Foo shout" + end + end + RUBY + end + build_plugin "bar" do |s| + s.write "plugins.rb", <<-RUBY + class Bar < Bundler::Plugin::API + command "scream" + + def exec(command, args) + puts "Bar scream" + end + end + RUBY + end + end + end + + context "no plugins installed" do + it "shows proper no plugins installed message" do + bundle "plugin list" + + expect(out).to include("No plugins installed") + end + end + + context "single plugin installed" do + it "shows plugin name with commands list" do + bundle "plugin install foo --source file://#{gem_repo2}" + plugin_should_be_installed("foo") + bundle "plugin list" + + expected_output = "foo\n-----\n shout" + expect(out).to include(expected_output) + end + end + + context "multiple plugins installed" do + it "shows plugin names with commands list" do + bundle "plugin install foo bar --source file://#{gem_repo2}" + plugin_should_be_installed("foo", "bar") + bundle "plugin list" + + expected_output = "foo\n-----\n shout\n\nbar\n-----\n scream" + expect(out).to include(expected_output) + end + end +end diff --git a/spec/bundler/plugins/source/example_spec.rb b/spec/bundler/plugins/source/example_spec.rb index d9a3cd2b92..bc076c06bf 100644 --- a/spec/bundler/plugins/source/example_spec.rb +++ b/spec/bundler/plugins/source/example_spec.rb @@ -96,16 +96,16 @@ RSpec.describe "real source plugins" do bundle "install" lockfile_should_be <<-G - GEM - remote: file://localhost#{gem_repo2}/ - specs: - PLUGIN SOURCE remote: #{lib_path("a-path-gem-1.0")} type: mpath specs: a-path-gem (1.0) + GEM + remote: file://localhost#{gem_repo2}/ + specs: + PLATFORMS #{lockfile_platforms} @@ -391,10 +391,6 @@ RSpec.describe "real source plugins" do bundle "install" lockfile_should_be <<-G - GEM - remote: file://localhost#{gem_repo2}/ - specs: - PLUGIN SOURCE remote: file://#{lib_path("ma-gitp-gem-1.0")} type: gitp @@ -402,6 +398,10 @@ RSpec.describe "real source plugins" do specs: ma-gitp-gem (1.0) + GEM + remote: file://localhost#{gem_repo2}/ + specs: + PLATFORMS #{lockfile_platforms} |