specreporter-spec

Version, currently 0.1.02 versions

github.com/docelic/specreporter-spec

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

1 stars
1 dependent
License: Apache-2.0

Nothing has been indexed for 0.1.0 yet. The tag is recorded, its shard.yml has not been read, so the manifest and dependency list below are empty because they are unknown rather than because they are absent.

Installation

# Add this to your shard.yml
dependencies:
  specreporter-spec:
    github: docelic/specreporter-spec
    version: ~> 0.1.0

Then run:

shards install

shard.yml

No shard.yml has been indexed for 0.1.0. You can read it on the repository.

Dependencies

Unknown: the shard.yml for this version has not been read yet.

README

This README is the one indexed from the repository at its latest ref, not from the tag for this version.

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.