summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndre Arko <andre@arko.net>2013-07-24 23:15:29 -0700
committerJessica Lynn Suttles <jlsuttles@gmail.com>2013-08-05 14:15:50 -0700
commit0750d45b3933a5d1f28ebf4494c8505739a3a827 (patch)
treecf42596c66c2494271f552609d5f6b06fe5a97bf
parent4a53681628b895c7d0d372269ffd556d78763826 (diff)
downloadbundler-0750d45b3933a5d1f28ebf4494c8505739a3a827.tar.gz
break out cli command specs into a dedicated dir
move the dispatch integration specs into other load friendly_errors so we can unit test it require Thor so we can rescue the errors bump ArgumentError above Exception so it wins
-rw-r--r--lib/bundler/friendly_errors.rb11
-rw-r--r--spec/bundler/friendly_errors_spec.rb21
-rw-r--r--spec/commands/binstubs_spec.rb (renamed from spec/other/binstubs_spec.rb)0
-rw-r--r--spec/commands/check_spec.rb (renamed from spec/other/check_spec.rb)0
-rw-r--r--spec/commands/clean_spec.rb (renamed from spec/other/clean_spec.rb)0
-rw-r--r--spec/commands/config_spec.rb (renamed from spec/other/config_spec.rb)0
-rw-r--r--spec/commands/console_spec.rb (renamed from spec/other/console_spec.rb)0
-rw-r--r--spec/commands/exec_spec.rb (renamed from spec/other/exec_spec.rb)0
-rw-r--r--spec/commands/help_spec.rb (renamed from spec/other/help_spec.rb)0
-rw-r--r--spec/commands/init_spec.rb (renamed from spec/other/init_spec.rb)0
-rw-r--r--spec/commands/licenses_spec.rb (renamed from spec/other/licenses_spec.rb)0
-rw-r--r--spec/commands/newgem_spec.rb (renamed from spec/other/newgem_spec.rb)0
-rw-r--r--spec/commands/open_spec.rb (renamed from spec/other/open_spec.rb)0
-rw-r--r--spec/commands/outdated_spec.rb (renamed from spec/other/outdated_spec.rb)0
-rw-r--r--spec/commands/show_spec.rb (renamed from spec/other/show_spec.rb)0
-rw-r--r--spec/other/cli_dispatch_spec.rb13
16 files changed, 28 insertions, 17 deletions
diff --git a/lib/bundler/friendly_errors.rb b/lib/bundler/friendly_errors.rb
index ee1a9552ae..0cc29e8e36 100644
--- a/lib/bundler/friendly_errors.rb
+++ b/lib/bundler/friendly_errors.rb
@@ -1,3 +1,5 @@
+require "bundler/vendored_thor"
+
module Bundler
def self.with_friendly_errors
yield
@@ -21,6 +23,11 @@ module Bundler
WARN
Bundler.ui.trace e
exit 1
+ rescue ArgumentError => e
+ Bundler.ui.warn "caught argument #{e.message}"
+ raise e unless e.message =~ /Ambiguous task/
+ Bundler.ui.error "\nA more hepful message"
+ exit e.status_code
rescue Interrupt => e
Bundler.ui.error "\nQuitting..."
Bundler.ui.trace e
@@ -33,9 +40,5 @@ module Bundler
troubleshooting documentation at http://bit.ly/bundler-issues. Thanks!
ERR
raise e
- rescue ArgumentError => e
- raise e unless e.message =~ /Ambiguous task/
- Bundler.ui.error "\nA more hepful message"
- exit e.status_code
end
end
diff --git a/spec/bundler/friendly_errors_spec.rb b/spec/bundler/friendly_errors_spec.rb
index bef049b588..02da1d4729 100644
--- a/spec/bundler/friendly_errors_spec.rb
+++ b/spec/bundler/friendly_errors_spec.rb
@@ -1,18 +1,13 @@
require "spec_helper"
+require "bundler"
+require "bundler/friendly_errors"
-describe "friendly errors" do
+describe Bundler, "friendly errors" do
it "rescues ArgumentErrors" do
- expect{ Bundler.with_friendly_errors {
- raise ArgumentError.new("Ambiguous task") } }.not_to raise_error
- end
-
- it "rescues ArgumentErrors" do
- bundle :i
- expect(err).to be_empty
- end
-
- it "prints a friendly error message" do
- bundle :i
- expect(out).to match /A more helpful message/
+ expect {
+ Bundler.with_friendly_errors do
+ raise ArgumentError.new("Ambiguous task")
+ end
+ }.to_not raise_error
end
end
diff --git a/spec/other/binstubs_spec.rb b/spec/commands/binstubs_spec.rb
index 3d3ed0fc58..3d3ed0fc58 100644
--- a/spec/other/binstubs_spec.rb
+++ b/spec/commands/binstubs_spec.rb
diff --git a/spec/other/check_spec.rb b/spec/commands/check_spec.rb
index 248b5c2eed..248b5c2eed 100644
--- a/spec/other/check_spec.rb
+++ b/spec/commands/check_spec.rb
diff --git a/spec/other/clean_spec.rb b/spec/commands/clean_spec.rb
index cee1312a5f..cee1312a5f 100644
--- a/spec/other/clean_spec.rb
+++ b/spec/commands/clean_spec.rb
diff --git a/spec/other/config_spec.rb b/spec/commands/config_spec.rb
index 100889bce7..100889bce7 100644
--- a/spec/other/config_spec.rb
+++ b/spec/commands/config_spec.rb
diff --git a/spec/other/console_spec.rb b/spec/commands/console_spec.rb
index b72883a01c..b72883a01c 100644
--- a/spec/other/console_spec.rb
+++ b/spec/commands/console_spec.rb
diff --git a/spec/other/exec_spec.rb b/spec/commands/exec_spec.rb
index ed03e2b0a9..ed03e2b0a9 100644
--- a/spec/other/exec_spec.rb
+++ b/spec/commands/exec_spec.rb
diff --git a/spec/other/help_spec.rb b/spec/commands/help_spec.rb
index 739f62224e..739f62224e 100644
--- a/spec/other/help_spec.rb
+++ b/spec/commands/help_spec.rb
diff --git a/spec/other/init_spec.rb b/spec/commands/init_spec.rb
index 8bd566dcf5..8bd566dcf5 100644
--- a/spec/other/init_spec.rb
+++ b/spec/commands/init_spec.rb
diff --git a/spec/other/licenses_spec.rb b/spec/commands/licenses_spec.rb
index c8d5ff739e..c8d5ff739e 100644
--- a/spec/other/licenses_spec.rb
+++ b/spec/commands/licenses_spec.rb
diff --git a/spec/other/newgem_spec.rb b/spec/commands/newgem_spec.rb
index 7694e94740..7694e94740 100644
--- a/spec/other/newgem_spec.rb
+++ b/spec/commands/newgem_spec.rb
diff --git a/spec/other/open_spec.rb b/spec/commands/open_spec.rb
index b586376254..b586376254 100644
--- a/spec/other/open_spec.rb
+++ b/spec/commands/open_spec.rb
diff --git a/spec/other/outdated_spec.rb b/spec/commands/outdated_spec.rb
index b498510ff7..b498510ff7 100644
--- a/spec/other/outdated_spec.rb
+++ b/spec/commands/outdated_spec.rb
diff --git a/spec/other/show_spec.rb b/spec/commands/show_spec.rb
index bdd3a1f6a2..bdd3a1f6a2 100644
--- a/spec/other/show_spec.rb
+++ b/spec/commands/show_spec.rb
diff --git a/spec/other/cli_dispatch_spec.rb b/spec/other/cli_dispatch_spec.rb
new file mode 100644
index 0000000000..cd1868aef5
--- /dev/null
+++ b/spec/other/cli_dispatch_spec.rb
@@ -0,0 +1,13 @@
+require 'spec_helper'
+
+describe "bundle command names" do
+ it "work when given fully"
+
+ it "work when not ambiguous"
+
+ it "print a friendly error when ambiguous" do
+ bundle "i"
+ expect(out).to match(/helpful message/)
+ expect(err).to eq("")
+ end
+end