quickspec_markdown_xcpretty_formatter.rb 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. require 'xcpretty'
  2. class QuickSpecMarkdown < XCPretty::Simple
  3. def format_test_case_name(name)
  4. separator = " ⇒ "
  5. name = name.gsub('Don_t', "Don't")
  6. name = name.gsub(/(\d+)_(\d+)/, '\1.\2')
  7. name = name.gsub('____', separator)
  8. name = name.gsub('__', separator)
  9. name = name.gsub('_', ' ')
  10. name
  11. end
  12. def format_test_run_started(name)
  13. %{
  14. # Started: #{name}
  15. | Test/Suite | |
  16. |:-----|:-----|}
  17. end
  18. def format_test_suite_started(name)
  19. if name != "All tests" # We don't consider "All tests" a suite.
  20. text = <<~EOD
  21. | | |
  22. | **#{name}** | |}
  23. EOD
  24. text.chomp
  25. else
  26. ""
  27. end
  28. end
  29. def format_passing_test(suite, test_case, time)
  30. "| #{format_test_case_name(test_case)} (#{time}) | ✓ |"
  31. end
  32. def format_test_run_finished(name, time)
  33. ""
  34. end
  35. def format_test_summary(executed_message, failures_per_suite)
  36. ""
  37. end
  38. def format_failing_test(suite, test_case, reason, file_path)
  39. %{| #{format_test_case_name(test_case)} | ✗ |
  40. | #{file_path} | |
  41. | Reason: #{reason}| |}
  42. end
  43. private
  44. def format_duration(duration)
  45. "%.2f seconds" % duration
  46. end
  47. end
  48. QuickSpecMarkdown