diff options
author | Atsushi Yamamoto <yamaatsushi927@gmail.com> | 2017-10-22 14:14:06 -0700 |
---|---|---|
committer | Atsushi Yamamoto <yamaatsushi927@gmail.com> | 2017-10-22 14:14:06 -0700 |
commit | e1dfa07f7b3c09fe34119bb876dfb22801c69bb3 (patch) | |
tree | 00a15528508d2376f0f899f3d9a09d9444880aa2 | |
parent | a08d08eb9854435ba6d5ef513d95e295ab19e8a6 (diff) | |
download | bundler-e1dfa07f7b3c09fe34119bb876dfb22801c69bb3.tar.gz |
Fix 'plugins list' pull request
-rw-r--r-- | lib/bundler/plugin/index.rb | 2 | ||||
-rw-r--r-- | spec/bundler/plugin_spec.rb | 2 | ||||
-rw-r--r-- | spec/plugins/list_spec.rb | 60 |
3 files changed, 61 insertions, 3 deletions
diff --git a/lib/bundler/plugin/index.rb b/lib/bundler/plugin/index.rb index b9328d3177..f5c2baf431 100644 --- a/lib/bundler/plugin/index.rb +++ b/lib/bundler/plugin/index.rb @@ -100,7 +100,7 @@ module Bundler end def plugin_commands(plugin) - @commands.find_all {|_, n| n == plugins }.map(&:first) + @commands.find_all {|_, n| n == plugin }.map(&:first) end def source?(source) diff --git a/spec/bundler/plugin_spec.rb b/spec/bundler/plugin_spec.rb index 40e71ab578..68a7e32ad1 100644 --- a/spec/bundler/plugin_spec.rb +++ b/spec/bundler/plugin_spec.rb @@ -33,8 +33,6 @@ RSpec.describe Bundler::Plugin do end describe "list command" do - let(:opts) { { "version" => "~> 1.0", "source" => "foo" } } - context "when no plugins are installed" do before { allow(index).to receive(:installed_plugins) { [] } } it "outputs no plugins installed" do diff --git a/spec/plugins/list_spec.rb b/spec/plugins/list_spec.rb new file mode 100644 index 0000000000..7dc9d10c4b --- /dev/null +++ b/spec/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 |