diff options
author | Samuel Giddins <segiddins@segiddins.me> | 2017-08-24 15:24:42 -0400 |
---|---|---|
committer | Samuel Giddins <segiddins@segiddins.me> | 2017-08-28 16:21:50 -0500 |
commit | 6c3f9a25162a7aa4668ee14a8b8a9a6493cb715c (patch) | |
tree | 5830e87818a603066d4b5c6f84f0012ee0a94c3c | |
parent | 0cabdaba5bc7ca7d004235e9265e8011038a103f (diff) | |
download | bundler-6c3f9a25162a7aa4668ee14a8b8a9a6493cb715c.tar.gz |
Pretty-print commad invocations
-rw-r--r-- | spec/support/command_execution.rb | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/spec/support/command_execution.rb b/spec/support/command_execution.rb index 5f80334145..556285ac52 100644 --- a/spec/support/command_execution.rb +++ b/spec/support/command_execution.rb @@ -8,7 +8,18 @@ module Spec include RSpec::Matchers::Composable def to_s - "$ #{command.strip}" + c = Shellwords.shellsplit(command.strip).map {|s| s.include?("\n") ? " \\\n <<EOS\n#{s.gsub(/^/, " ").chomp}\nEOS" : Shellwords.shellescape(s) } + c = c.reduce("") do |acc, elem| + concat = acc + " " + elem + + last_line = concat.match(/.*\z/)[0] + if last_line.size >= 100 + acc + " \\\n " + elem + else + concat + end + end + "$ #{c.strip}" end alias_method :inspect, :to_s |