Shorten names of result classes

This commit is contained in:
Michael Miller 2018-09-15 13:25:11 -06:00
parent 6ca4d8d2a6
commit 5819e0201e
13 changed files with 30 additions and 33 deletions

View file

@ -1,7 +1,7 @@
require "./failed_example_result"
require "./failed_result"
module Spectator
class ErroredExampleResult < FailedExampleResult
class ErroredResult < FailedResult
getter error : Exception
def errored? : Bool

View file

@ -6,7 +6,7 @@ module Spectator
def initialize(@group)
end
abstract def run : ExampleResult
abstract def run : Result
abstract def description : String
end
end

View file

@ -1,7 +1,7 @@
require "./example_result"
require "./result"
module Spectator
class FailedExampleResult < ExampleResult
class FailedResult < Result
getter error : Exception
def passed? : Bool

View file

@ -14,15 +14,15 @@ module Spectator
def start_example(example : Example)
end
def end_example(result : ExampleResult)
def end_example(result : Result)
print case result
when SuccessfulExampleResult
when SuccessfulResult
".".colorize.green
when PendingExampleResult
when PendingResult
"P".colorize.yellow
when ErroredExampleResult
when ErroredResult
"E".colorize.magenta
when FailedExampleResult
when FailedResult
"F".colorize.red
end
end

View file

@ -4,7 +4,7 @@ module Spectator
abstract def start_suite
abstract def end_suite(report : Report)
abstract def start_example(example : Example)
abstract def end_example(result : ExampleResult)
abstract def end_example(result : Result)
end
end
end

View file

@ -3,7 +3,7 @@ require "./example"
module Spectator
abstract class PendingExample < Example
def run
PendingExampleResult.new(self)
PendingResult.new(self)
end
end
end

View file

@ -1,7 +1,7 @@
require "./example_result"
require "./result"
module Spectator
class PendingExampleResult < ExampleResult
class PendingResult < Result
def passed?
false
end

View file

@ -2,9 +2,9 @@ module Spectator
class Report
getter runtime : Time::Span
@results : Array(ExampleResult)
@results : Array(Result)
def initialize(results : Enumerable(ExampleResult), @runtime)
def initialize(results : Enumerable(Result), @runtime)
@results = results.to_a
end

View file

@ -1,5 +1,5 @@
module Spectator
abstract class ExampleResult
abstract class Result
getter example : Example
getter elapsed : Time::Span

View file

@ -36,11 +36,11 @@ module Spectator
private def translate_result(result)
case (error = result.error)
when Nil
SuccessfulExampleResult.new(self, result.elapsed)
SuccessfulResult.new(self, result.elapsed)
when ExpectationFailed
FailedExampleResult.new(self, result.elapsed, error)
FailedResult.new(self, result.elapsed, error)
else
ErroredExampleResult.new(self, result.elapsed, error)
ErroredResult.new(self, result.elapsed, error)
end
end

View file

@ -1,6 +1,3 @@
require "./failed_example_result"
require "./successful_example_result"
module Spectator
class Runner
def initialize(@group : ExampleGroup,
@ -8,7 +5,7 @@ module Spectator
end
def run : Nil
results = [] of ExampleResult
results = [] of Result
elapsed = Time.measure do
@formatter.start_suite
results = @group.all_examples.map do |example|

View file

@ -1,9 +0,0 @@
require "./example_result"
module Spectator
class SuccessfulExampleResult < ExampleResult
def passed? : Bool
true
end
end
end

View file

@ -0,0 +1,9 @@
require "./result"
module Spectator
class SuccessfulResult < Result
def passed? : Bool
true
end
end
end