Skip to content

SpecReporter spec formatter for Crystal, similar to Ruby minitest-reporters' SpecReporter

License

Notifications You must be signed in to change notification settings

docelic/specreporter-spec

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Introduction

SpecReporter is a spec output formatter for Crystal, similar to Ruby minitest-reporters' SpecReporter.

SpecReporter Demo Video

Description

Specreporter-spec looks and works similar to Ruby's "SpecReporter" module from the minitest-reporters gem.

The changes/improvements compared to the default Crystal formatter include:

  • Nicer and more informative output
  • Info on elapsed time for each test
  • Short and informative backtrace summaries
  • Info on total number of assertions ran
  • Configurable field widths
  • Configurable terminal width
  • Configurable elapsed time precision
  • Ability to enable/disable sections from default formatter

Usage

Add this to your application's shard.yml:

development_dependencies:
  specreporter-spec:
    github: docelic/specreporter-spec

Simply add the following content to your spec/spec_helper.cr:

require "spec"

require "specreporter-spec"
Spec.override_default_formatter(
 Spec::SpecReporterFormatter.new(
  #indent_string: "    ",        # Indent string. Default "  "
  #width: (ENV["COLUMNS"]? || 80).to_i-2, # Terminal width. Default 78
  ## ^-- You may need to run "eval `resize`" in term to get COLUMNS variable
  #elapsed_width: 8,     # Number of decimals for "elapsed" time. Default 3
  #status_width: 10,     # Width of the status field. Default 5
  #trim_exceptions: false,     # Hide callstack from exceptions? Default true
  #skip_errors_report: false,  # Skip default backtraces. Default true
  #skip_slowest_report: false, # Skip default "slowest" report. Default true
  #skip_failed_report: false,  # Skip default failed reports summary. Default true
))

Configure the options to your liking.

And run tests in the usual way (crystal s[pec]).

Enjoy!

TODO

The formatter certainly works, but the implementation must be improved before it could be added to Crystal as built-in formatter.

Code improvements and further feature ideas welcome! Thanks!

Other / Unrelated Formatters

Other / unrelated spec formatters for Crystal in existence:

  • Rainbow - formats the standard formatter dots in rainbow colors.

About

SpecReporter spec formatter for Crystal, similar to Ruby minitest-reporters' SpecReporter

Resources

License

Stars

Watchers

Forks

Packages

No packages published