summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAsutosh Palai <asupalai@gmail.com>2016-05-31 12:11:38 +0530
committerAsutosh Palai <asupalai@gmail.com>2016-05-31 12:11:54 +0530
commit2054b7dfa2c4573664ed87cf45a1898905aadec0 (patch)
tree2ea4c3592f3b17b81446101cee33b8fba91b85e3
parentb44cb31c89fe77084923f83bdcc3d88b452f1e6a (diff)
downloadbundler-2054b7dfa2c4573664ed87cf45a1898905aadec0.tar.gz
Added spec for commands plugins
-rw-r--r--spec/plugins/command.rb52
1 files changed, 52 insertions, 0 deletions
diff --git a/spec/plugins/command.rb b/spec/plugins/command.rb
new file mode 100644
index 0000000000..e2fd3ddcb5
--- /dev/null
+++ b/spec/plugins/command.rb
@@ -0,0 +1,52 @@
+# frozen_string_literal: true
+require "spec_helper"
+
+describe "command plugins" do
+ it "executes without arguments" do
+ build_repo2 do
+ build_plugin "command-mah"do |s|
+ s.write "plugin.rb", <<-RUBY
+ module Mah
+ class Plugin < Bundler::Plugin::Api
+ command "mahcommand"
+
+ def exec(command, args)
+ puts "MahHello"
+ end
+ end
+ end
+ RUBY
+ end
+ end
+
+ bundle "plugin install command-mah --source file://#{gem_repo2}"
+ expect(out).to include("Installed plugin command-mah")
+ puts out
+
+ bundle "mahcommand"
+ expect(out).to eq("MahHello")
+ end
+
+ it "accepts the arguments" do
+ build_repo2 do
+ build_plugin "the-echoer"do |s|
+ s.write "plugin.rb", <<-RUBY
+ module Resonance
+ class Echoer < Bundler::Plugin::Api
+ command "echo"
+
+ def exec(command, args)
+ puts "You gave me \#{args.join(", ")}"
+ end
+ end
+ end
+ RUBY
+ end
+ end
+
+ bundle "plugin install the-echoer --source file://#{gem_repo2}"
+
+ bundle "echo tacos tofu lasange", "no-color" => false
+ expect(out).to eq("You gave me tacos, tofu, lasange")
+ end
+end