2023-05-12 12:22:15 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module TurboTests
|
2023-05-29 21:52:46 -04:00
|
|
|
class ProgressFormatter < ::TurboTests::BaseFormatter
|
2023-05-12 12:22:15 -04:00
|
|
|
LINE_LENGTH = 80
|
|
|
|
|
|
|
|
RSpec::Core::Formatters.register(
|
|
|
|
self,
|
|
|
|
:example_passed,
|
|
|
|
:example_pending,
|
|
|
|
:example_failed,
|
|
|
|
:start_dump,
|
|
|
|
)
|
|
|
|
|
|
|
|
def initialize(*args)
|
|
|
|
super
|
|
|
|
@examples = 0
|
|
|
|
end
|
|
|
|
|
|
|
|
def example_passed(_notification)
|
|
|
|
output.print RSpec::Core::Formatters::ConsoleCodes.wrap(".", :success)
|
|
|
|
wrap
|
|
|
|
end
|
|
|
|
|
|
|
|
def example_pending(_notification)
|
|
|
|
output.print RSpec::Core::Formatters::ConsoleCodes.wrap("*", :pending)
|
|
|
|
wrap
|
|
|
|
end
|
|
|
|
|
|
|
|
def example_failed(_notification)
|
|
|
|
output.print RSpec::Core::Formatters::ConsoleCodes.wrap("F", :failure)
|
|
|
|
wrap
|
|
|
|
end
|
|
|
|
|
|
|
|
def start_dump(_notification)
|
|
|
|
output.puts
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def wrap
|
|
|
|
@examples += 1
|
|
|
|
|
2023-05-17 05:22:31 -04:00
|
|
|
if ENV["GITHUB_ACTIONS"] && @examples == LINE_LENGTH
|
2023-05-12 12:22:15 -04:00
|
|
|
output.print "\n"
|
|
|
|
@examples = 0
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|