Class: RSpec::Core::Formatters::ExceptionPresenter

Inherits:
Object
  • Object
show all
Defined in:
lib/serverspec.rb

Instance Method Summary collapse

Instance Method Details

#failure_linesObject



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/serverspec.rb', line 40

def failure_lines
  host = ENV['TARGET_HOST'] || Specinfra.configuration.host
  @failure_lines ||=
    begin
      lines = []
      lines << "On host `#{host}'" if host
      error_lines = []
      error_lines = [failure_slash_error_line] if defined?(failure_slash_error_line)
      error_lines = failure_slash_error_lines if defined?(failure_slash_error_lines)
      lines += error_lines unless (description == error_lines.join(''))
      lines << "#{exception_class_name}:" unless exception_class_name =~ /RSpec/
      encoded_string(exception.message.to_s).split("\n").each do |line|
        lines << "  #{line}"
      end
      lines << "  #{example.[:command]}"
      lines << "  #{example.[:stdout]}" if example.[:stdout]
      lines << "  #{example.[:stderr]}" if example.[:stderr]
      lines
    end
end