Class: RSpec::Core::Notifications::FailedExampleNotification

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

Instance Method Summary collapse

Instance Method Details

#failure_linesObject


17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/serverspec.rb', line 17

def failure_lines
  host = ENV['TARGET_HOST'] || Specinfra.configuration.host
  @failure_lines ||=
    begin
      lines = []
      lines << "On host `#{host}'" if host
      lines << "Failure/Error: #{read_failed_line.strip}"
      lines << "#{exception_class_name}:" unless exception_class_name =~ /RSpec/
      exception.message.to_s.split("\n").each do |line|
        lines << "  #{line}" if exception.message
      end
      lines << "  #{example.metadata[:command]}"
      lines << "  #{example.metadata[:stdout]}" if example.[:stdout]
      lines << "  #{example.metadata[:stderr]}" if example.[:stderr]
      lines
    end
end