mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Add FinishedResult intermediary class
This commit is contained in:
parent
9e004324c9
commit
4e0c821b8f
4 changed files with 29 additions and 25 deletions
|
@ -2,24 +2,21 @@ require "./result"
|
||||||
|
|
||||||
module Spectator
|
module Spectator
|
||||||
# Outcome that indicates running an example was a failure.
|
# Outcome that indicates running an example was a failure.
|
||||||
class FailedResult < Result
|
class FailedResult < FinishedResult
|
||||||
# Error that occurred while running the example.
|
# Error that occurred while running the example.
|
||||||
getter error : Exception
|
getter error : Exception
|
||||||
|
|
||||||
# The expectations that were run in the example.
|
# The expectations that were run in the example.
|
||||||
getter expectations : Expectations::ExampleExpectations
|
getter expectations : Expectations::ExampleExpectations
|
||||||
|
|
||||||
# Length of time it took to run the example.
|
|
||||||
getter elapsed : Time::Span
|
|
||||||
|
|
||||||
# Creates a failed result.
|
# Creates a failed result.
|
||||||
# The `example` should refer to the example that was run
|
# The `example` should refer to the example that was run
|
||||||
# and that this result is for.
|
# and that this result is for.
|
||||||
# The `elapsed` argument is the length of time it took to run the example.
|
# The `elapsed` argument is the length of time it took to run the example.
|
||||||
# The `expectations` references the expectations that were checked in the example.
|
# The `expectations` references the expectations that were checked in the example.
|
||||||
# The `error` is the exception that was raised to cause the failure.
|
# The `error` is the exception that was raised to cause the failure.
|
||||||
def initialize(example, @elapsed, @expectations, @error)
|
def initialize(example, elapsed, @expectations, @error)
|
||||||
super(example)
|
super(example, elapsed)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Indicates that an example was run and it was successful.
|
# Indicates that an example was run and it was successful.
|
||||||
|
@ -41,11 +38,5 @@ module Spectator
|
||||||
def errored?
|
def errored?
|
||||||
false
|
false
|
||||||
end
|
end
|
||||||
|
|
||||||
# Indicates that an example was marked as pending.
|
|
||||||
# This will always be false for this type of result.
|
|
||||||
def pending?
|
|
||||||
false
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
21
src/spectator/finished_result.cr
Normal file
21
src/spectator/finished_result.cr
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
module Spectator
|
||||||
|
# Abstract class for all results by examples
|
||||||
|
abstract class FinishedResult < Result
|
||||||
|
# Length of time it took to run the example.
|
||||||
|
getter elapsed : Time::Span
|
||||||
|
|
||||||
|
# Creates a successful result.
|
||||||
|
# The `example` should refer to the example that was run
|
||||||
|
# and that this result is for.
|
||||||
|
# The `elapsed` argument is the length of time it took to run the example.
|
||||||
|
def initialize(example, @elapsed)
|
||||||
|
super(example)
|
||||||
|
end
|
||||||
|
|
||||||
|
# Indicates that an example was marked as pending.
|
||||||
|
# This will always be false for this type of result.
|
||||||
|
def pending?
|
||||||
|
false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -29,6 +29,7 @@ require "./test_results"
|
||||||
require "./runner"
|
require "./runner"
|
||||||
|
|
||||||
require "./result"
|
require "./result"
|
||||||
|
require "./finished_result"
|
||||||
require "./successful_result"
|
require "./successful_result"
|
||||||
require "./pending_result"
|
require "./pending_result"
|
||||||
require "./failed_result"
|
require "./failed_result"
|
||||||
|
|
|
@ -1,21 +1,18 @@
|
||||||
require "./result"
|
require "./finished_result"
|
||||||
|
|
||||||
module Spectator
|
module Spectator
|
||||||
# Outcome that indicates running an example was successful.
|
# Outcome that indicates running an example was successful.
|
||||||
class SuccessfulResult < Result
|
class SuccessfulResult < FinishedResult
|
||||||
# The expectations that were run in the example.
|
# The expectations that were run in the example.
|
||||||
getter expectations : Expectations::ExampleExpectations
|
getter expectations : Expectations::ExampleExpectations
|
||||||
|
|
||||||
# Length of time it took to run the example.
|
|
||||||
getter elapsed : Time::Span
|
|
||||||
|
|
||||||
# Creates a successful result.
|
# Creates a successful result.
|
||||||
# The `example` should refer to the example that was run
|
# The `example` should refer to the example that was run
|
||||||
# and that this result is for.
|
# and that this result is for.
|
||||||
# The `elapsed` argument is the length of time it took to run the example.
|
# The `elapsed` argument is the length of time it took to run the example.
|
||||||
# The `expectations` references the expectations that were checked in the example.
|
# The `expectations` references the expectations that were checked in the example.
|
||||||
def initialize(example, @elapsed, @expectations)
|
def initialize(example, elapsed, @expectations)
|
||||||
super(example)
|
super(example, elapsed)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Indicates that an example was run and it was successful.
|
# Indicates that an example was run and it was successful.
|
||||||
|
@ -37,11 +34,5 @@ module Spectator
|
||||||
def errored?
|
def errored?
|
||||||
false
|
false
|
||||||
end
|
end
|
||||||
|
|
||||||
# Indicates that an example was marked as pending.
|
|
||||||
# This will always be false for this type of result.
|
|
||||||
def pending?
|
|
||||||
false
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue