class DebugExceptionsJson::RSpec::Formatter
Constants
- RSPEC3
For RSpec2 compatibility
Public Instance Methods
dump_failures(notification = nil)
click to toggle source
# File lib/debug_exceptions_json/rspec/formatter.rb, line 14 def dump_failures(notification = nil) if RSPEC3 dump_failures_3(notification) else dump_failures_2 end end
Private Instance Methods
dump_failures_2()
click to toggle source
# File lib/debug_exceptions_json/rspec/formatter.rb, line 50 def dump_failures_2 return if failed_examples.empty? output.puts output.puts "Failures:" failed_examples.each_with_index do |example, index| output.puts pending_fixed?(example) ? dump_pending_fixed(example, index) : dump_failure(example, index) dump_backtrace(example) response = example.metadata[:response] if response && response.server_error? begin e = JSON(response.body)['error'] rescue JSON::ParserError e = {} end if e['exception_class'] && e['message'] && e['backtrace'] output.puts error_to_dump_message(e) end end end end
dump_failures_3(notification)
click to toggle source
# File lib/debug_exceptions_json/rspec/formatter.rb, line 24 def dump_failures_3(notification) return if notification.failure_notifications.empty? colorizer = ::RSpec::Core::Formatters::ConsoleCodes formatted = "\nFailures:\n" notification.failure_notifications.each_with_index do |failure, index| formatted << failure.fully_formatted(index.next, colorizer) response = failure.example.metadata[:response] if response && response.server_error? begin e = JSON(response.body)['error'] rescue JSON::ParserError e = {} end if e && e['exception_class'] && e['message'] && e['backtrace'] formatted << error_to_dump_message(e) end end end output.puts formatted end
error_to_dump_message(error)
click to toggle source
TODO: colorize server error dump?
# File lib/debug_exceptions_json/rspec/formatter.rb, line 77 def error_to_dump_message(error) <<-EOM ServerErrorDump: exception class: #{error['exception_class']} message: #{error['message']} short_backtrace: #{error['backtrace'][0..10].join("\n ")} EOM end