summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndré Arko <mail@arko.net>2015-04-11 22:26:13 -0700
committerAndré Arko <mail@arko.net>2015-04-11 22:26:13 -0700
commit60f2096f33df2a3392d251f55301b0e8566ab0fa (patch)
tree8a79636e14a50024d78a0614e12ca41209c24b08
parenta72df72c7719bcb7677e5cb140cf7cdb11be652d (diff)
parentf810834f0626823232e169056e8615a72ce70dc3 (diff)
downloadbundler-60f2096f33df2a3392d251f55301b0e8566ab0fa.tar.gz
Merge pull request #3562 from TimMoore/shorter-issue-search-urls-in-error-report
Only use first line of error messages in the issue search URL
-rw-r--r--lib/bundler/friendly_errors.rb2
-rw-r--r--spec/bundler/friendly_errors_spec.rb17
2 files changed, 18 insertions, 1 deletions
diff --git a/lib/bundler/friendly_errors.rb b/lib/bundler/friendly_errors.rb
index 1431725d3d..1b5be762bf 100644
--- a/lib/bundler/friendly_errors.rb
+++ b/lib/bundler/friendly_errors.rb
@@ -70,7 +70,7 @@ module Bundler
def self.issues_url(exception)
'https://github.com/bundler/bundler/search?q=' \
- "#{CGI.escape(exception.message)}&type=Issues"
+ "#{CGI.escape(exception.message.lines.first.chomp)}&type=Issues"
end
end
diff --git a/spec/bundler/friendly_errors_spec.rb b/spec/bundler/friendly_errors_spec.rb
index 96c333a739..ee0667cb2f 100644
--- a/spec/bundler/friendly_errors_spec.rb
+++ b/spec/bundler/friendly_errors_spec.rb
@@ -10,4 +10,21 @@ describe Bundler, "friendly errors" do
end
}.to raise_error(SystemExit)
end
+
+ describe "#issues_url" do
+ it "generates a search URL for the exception message" do
+ exception = Exception.new("Exception message")
+
+ expect(Bundler.issues_url(exception)).to eq("https://github.com/bundler/bundler/search?q=Exception+message&type=Issues")
+ end
+
+ it "generates a search URL for only the first line of a multi-line exception message" do
+ exception = Exception.new(<<END)
+First line of the exception message
+Second line of the exception message
+END
+
+ expect(Bundler.issues_url(exception)).to eq("https://github.com/bundler/bundler/search?q=First+line+of+the+exception+message&type=Issues")
+ end
+ end
end