Rename reporters to formatters

This commit is contained in:
Michael Miller 2018-09-15 10:56:58 -06:00
parent 251bf5bb5e
commit cfe1a014dd
5 changed files with 16 additions and 16 deletions

View file

@ -0,0 +1,6 @@
require "./formatters/*"
module Spectator
module Formatters
end
end

View file

@ -1,6 +1,6 @@
module Spectator module Spectator
module Reporters module Formatters
abstract class Reporter abstract class Formatter
abstract def start_suite abstract def start_suite
abstract def end_suite(report : Report) abstract def end_suite(report : Report)
abstract def start_example(example : Example) abstract def start_example(example : Example)

View file

@ -1,9 +1,9 @@
require "./reporter" require "./formatter"
require "colorize" require "colorize"
module Spectator module Spectator
module Reporters module Formatters
class StandardReporter < Reporter class StandardFormatter < Formatter
def start_suite def start_suite
end end

View file

@ -1,6 +0,0 @@
require "./reporters/*"
module Spectator
module Reporters
end
end

View file

@ -4,22 +4,22 @@ require "./successful_example_result"
module Spectator module Spectator
class Runner class Runner
def initialize(@group : ExampleGroup, def initialize(@group : ExampleGroup,
@reporter : Reporters::Reporter = Reporters::StandardReporter.new) @formatter : Formatters::Formatter = Formatters::StandardFormatter.new)
end end
def run : Nil def run : Nil
results = [] of ExampleResult results = [] of ExampleResult
elapsed = Time.measure do elapsed = Time.measure do
@reporter.start_suite @formatter.start_suite
results = @group.all_examples.map do |example| results = @group.all_examples.map do |example|
@reporter.start_example(example) @formatter.start_example(example)
example.run.tap do |result| example.run.tap do |result|
@reporter.end_example(result) @formatter.end_example(result)
end end
end end
end end
report = Report.new(results, elapsed) report = Report.new(results, elapsed)
@reporter.end_suite(report) @formatter.end_suite(report)
end end
end end
end end