Skip to content

Commit

Permalink
Fix multiline messages missing in output
Browse files Browse the repository at this point in the history
This affected especially error messages containing backtraces.
  • Loading branch information
noniq committed Dec 16, 2017
1 parent 38774ba commit ad7ddcc
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions Support/lib/rspec/mate/runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ def run_rspec(argv)
old_stderr = $stderr
$stderr = stderr

Thread.abort_on_exception = true
Dir.chdir(project_directory) do
cmd = Executable.find("rspec") + argv
Open3.popen3(*cmd) do |i, out, err, _thread|
Expand Down
8 changes: 6 additions & 2 deletions Support/lib/rspec/mate/text_mate_backtrace_printer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,17 @@ def initialize(output)
@messages = []
@messages_before_start = []
end

def escape_js_string(str)
h(str).gsub(/\r?\n/, '<br>')
end

def message(str)
str = str.strip
return if @messages.include?(str) # Avoid duplicate messages (e.g. seed notifications in RSpec 3.2)
@messages << str
if @html_output_started
@output.puts "<script type='text/javascript'>addMessage('#{h str}')</script>"
@output.puts "<script type='text/javascript'>addMessage('#{escape_js_string str}')</script>"
else
@messages_before_start << str
end
Expand All @@ -31,7 +35,7 @@ def print_html_start
@output.puts HTML_HEADER
@output.puts REPORT_HEADER
@messages_before_start.each do |msg|
@output.puts "<script type='text/javascript'>addMessage('#{h msg}')</script>"
@output.puts "<script type='text/javascript'>addMessage('#{escape_js_string msg}')</script>"
end
@html_output_started = true
end
Expand Down

0 comments on commit ad7ddcc

Please sign in to comment.