tap-invert

1.0.0 • Public • Published

Tap Invert

This util takes STDOUT generated during a test run and puts it below the corresponding assertion line. This is useful for piping to certain other tap reporters which expect the corresponding extra lines to be below the assertion, ex. tap-html

Example usage:

LOG_LEVEL=debug bundle exec rspec --order rand --format RspecTap::Formatter | tap-invert | tap-html

Example inverted output with Rails logger

$ cat example.tap | tap-invert
1..2
# MyClass
# MyClass.MySpec
ok 1 - MyClass::MySpec do_it does it
D, [2018-01-12T21:18:33.829999 #50430] DEBUG -- :     0 rows, 0 bytes
D, [2018-01-12T21:18:33.830057 #50430] DEBUG -- :
D, [2018-01-12T21:18:33.831636 #50430] DEBUG -- :     0 rows, 0 bytes
D, [2018-01-12T21:18:33.831658 #50430] DEBUG -- :
D, [2018-01-12T21:18:33.832574 #50430] DEBUG -- :     0 rows, 0 bytes
D, [2018-01-12T21:18:33.832594 #50430] DEBUG -- :
D, [2018-01-12T21:18:33.833568 #50430] DEBUG -- :     0 rows, 0 bytes
D, [2018-01-12T21:18:33.833590 #50430] DEBUG -- :
D, [2018-01-12T21:18:33.834634 #50430] DEBUG -- :     0 rows, 0 bytes
D, [2018-01-12T21:18:33.834663 #50430] DEBUG -- :
D, [2018-01-12T21:18:33.840591 #50430] DEBUG -- :     405 rows, 24645 bytes
D, [2018-01-12T21:18:33.840617 #50430] DEBUG -- :
D, [2018-01-12T21:18:33.844848 #50430] DEBUG -- :     1 rows, 11 bytes
D, [2018-01-12T21:18:33.844872 #50430] DEBUG -- :
D, [2018-01-12T21:18:33.852862 #50430] DEBUG -- :     1 rows, 1 bytes
D, [2018-01-12T21:18:33.852918 #50430] DEBUG -- :
D, [2018-01-12T21:18:33.854212 #50430] DEBUG -- :   ActiveRecord::SchemaMigration Load (0.8ms)  SELECT "schema_migrations".* FROM "schema_migrations"
D, [2018-01-12T21:18:33.854826 #50430] DEBUG -- :     40 rows, 560 bytes
D, [2018-01-12T21:18:33.854846 #50430] DEBUG -- :
D, [2018-01-12T21:18:33.856871 #50430] DEBUG -- :     1 rows, 37 bytes
D, [2018-01-12T21:18:33.856894 #50430] DEBUG -- :
Randomized with seed 21869
D, [2018-01-12T21:18:34.407022 #50430] DEBUG -- :    (0.5ms)  BEGIN
D, [2018-01-12T21:18:34.431372 #50430] DEBUG -- :     11 rows, 408 bytes
D, [2018-01-12T21:18:34.431410 #50430] DEBUG -- :
D, [2018-01-12T21:18:34.434122 #50430] DEBUG -- :     1 rows, 1 bytes
D, [2018-01-12T21:18:34.434150 #50430] DEBUG -- :
D, [2018-01-12T21:18:34.436942 #50430] DEBUG -- :     1 rows, 2 bytes
D, [2018-01-12T21:18:34.436967 #50430] DEBUG -- :
D, [2018-01-12T21:18:34.444503 #50430] DEBUG -- :    (0.5ms)  SAVEPOINT active_record_1
D, [2018-01-12T21:18:34.469430 #50430] DEBUG -- :   User Exists (1.0ms)  SELECT  1 AS one FROM "users"  WHERE ("users"."email" = 'email1@mail.com' AND "users"."role_id" = 1) LIMIT 1
D, [2018-01-12T21:18:34.472014 #50430] DEBUG -- :     0 rows, 0 bytes
D, [2018-01-12T21:18:34.472044 #50430] DEBUG -- :
D, [2018-01-12T21:18:34.475157 #50430] DEBUG -- :   SQL (0.9ms)  INSERT INTO "users" ("created_at", "email", "name", "role_id", "token", "updated_at", "user_id") VALUES ($1, $2, $3, $4, $5, $6, $7) RETURNING "id"  [["created_at", "2018-01-13 03:18:34.472160"], ["email", "email1@mail.com"], ["name", "Some Name 1"], ["role_id", 1], ["token", "EN_li2Q"], ["updated_at", "2018-01-13 03:18:34.472160"], ["user_id", 1]]
D, [2018-01-12T21:18:34.477333 #50430] DEBUG -- :     1 rows, 5 bytes
D, [2018-01-12T21:18:34.477364 #50430] DEBUG -- :
D, [2018-01-12T21:18:34.477987 #50430] DEBUG -- :    (0.4ms)  RELEASE SAVEPOINT active_record_1
D, [2018-01-12T21:18:34.568130 #50430] DEBUG -- :    (0.7ms)  ROLLBACK
ok 2 - MyClass::MySpec #do_it does not do it when state is wrong
D, [2018-01-12T21:18:34.569400 #50430] DEBUG -- :    (0.3ms)  BEGIN
D, [2018-01-12T21:18:34.573490 #50430] DEBUG -- :    (0.3ms)  SAVEPOINT active_record_1
D, [2018-01-12T21:18:34.574540 #50430] DEBUG -- :   User Exists (0.4ms)  SELECT  1 AS one FROM "users"  WHERE ("users"."email" = 'email2@mail.com' AND "users"."role_id" = 1) LIMIT 1
D, [2018-01-12T21:18:34.575792 #50430] DEBUG -- :     0 rows, 0 bytes
D, [2018-01-12T21:18:34.575816 #50430] DEBUG -- :
D, [2018-01-12T21:18:34.576876 #50430] DEBUG -- :   SQL (0.4ms)  INSERT INTO "users" ("created_at", "email", "name", "role_id", "token", "updated_at", "user_id") VALUES ($1, $2, $3, $4, $5, $6, $7) RETURNING "id"  [["created_at", "2018-01-13 03:18:34.575887"], ["email", "email2@mail.com"], ["name", "Some Name 2"], ["role_id", 1], ["token", "EDBhJN0"], ["updated_at", "2018-01-13 03:18:34.575887"], ["user_id", 2]]
D, [2018-01-12T21:18:34.578055 #50430] DEBUG -- :     1 rows, 5 bytes
D, [2018-01-12T21:18:34.578078 #50430] DEBUG -- :
D, [2018-01-12T21:18:34.638803 #50430] DEBUG -- :    (0.4ms)  ROLLBACK TO SAVEPOINT active_record_1
D, [2018-01-12T21:18:34.642678 #50430] DEBUG -- :    (0.4ms)  ROLLBACK

Readme

Keywords

none

Package Sidebar

Install

npm i tap-invert

Weekly Downloads

0

Version

1.0.0

License

MIT

Last publish

Collaborators

  • gburgett