Add text to output for fail-fast

This commit is contained in:
Michael Miller 2019-03-22 00:14:36 -06:00
parent a31d5c8b5b
commit a804907f75
3 changed files with 23 additions and 1 deletions

View file

@ -122,7 +122,7 @@ In no particular order, features that have been implemented and are planned:
- [ ] Misc. matchers - `exist`, `match`, `satisfy`, `change[.by|.from[.to]|.to|.by_at_least|.by_at_most]`, `have_attributes`
- [ ] Expectation combining - `and`, `or`
- [ ] Runner
- [ ] Fail fast
- [X] Fail fast
- [ ] Test filtering - by name, context, and tags
- [ ] Fail on no tests
- [ ] Randomize test order

View file

@ -0,0 +1,15 @@
module Spectator::Formatting
# Text displayed when fail-fast is enabled and tests were skipped.
private struct RemainingText
# Creates the text object.
def initialize(@count : Int32)
end
# Appends the command to the output.
def to_s(io)
io << "Text execution aborted (fail-fast) - "
io << @count
io << " examples were omitted."
end
end
end

View file

@ -14,6 +14,7 @@ module Spectator::Formatting
@io.puts
failures(report.failures) if report.failed?
stats(report)
remaining(report) if report.remaining?
failure_commands(report.failures) if report.failed?
end
@ -35,6 +36,12 @@ module Spectator::Formatting
@io.puts StatsCounter.new(report).color
end
# Produces the skipped tests text if fail-fast is enabled and tests were omitted.
private def remaining(report)
text = RemainingText.new(report.remaining_count)
@io.puts Color.failure(text)
end
# Produces the failure commands section of the summary.
# This provides a set of commands the user can run
# to test just the examples that failed.