diff options
author | André Arko <mail@arko.net> | 2015-04-11 22:26:13 -0700 |
---|---|---|
committer | André Arko <mail@arko.net> | 2015-04-11 22:26:13 -0700 |
commit | 60f2096f33df2a3392d251f55301b0e8566ab0fa (patch) | |
tree | 8a79636e14a50024d78a0614e12ca41209c24b08 | |
parent | a72df72c7719bcb7677e5cb140cf7cdb11be652d (diff) | |
parent | f810834f0626823232e169056e8615a72ce70dc3 (diff) | |
download | bundler-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.rb | 2 | ||||
-rw-r--r-- | spec/bundler/friendly_errors_spec.rb | 17 |
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 |