Have a Ruby Unit :: Test say test results

I use the built-in "say" OSX command to signal the completion of lengthy tests. It is easy and convenient.

I would like it to talk about the last line of results, which says: "6 tests, 18 statements, 0 errors, 0 errors", but still maintain their current performance. Any ideas how to do this?

I tried:

ruby overlay_test.rb | tail -n 1 | say

But this does not display test results as they arise.

Bonus points for saying only the last two parts of the line β€œ0 errors, 0 errors”.

+3
source share
2 answers

tee / ( say STDOUT):

ruby overlay_test.rb | tail -n 1 | tee >(say)

, sed:

ruby overlay_test.rb | tail -n 1 | sed -e 's/.*assertions, //' | tee >(say)
+4

!

tee - , . :

ruby overlay_test.rb | tee >(tail -n 1 |sed -e 's/.*assertions, //' |  say)

, , .

+2

Source: https://habr.com/ru/post/1726006/


All Articles