mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Consolidate default pending reason
This commit is contained in:
parent
4f2df78c34
commit
14d45756e9
4 changed files with 8 additions and 5 deletions
|
@ -3,6 +3,7 @@ require "../example_pending"
|
|||
require "../expectation"
|
||||
require "../expectation_failed"
|
||||
require "../location"
|
||||
require "../pending_result"
|
||||
require "../value"
|
||||
|
||||
module Spectator::DSL
|
||||
|
@ -16,13 +17,13 @@ module Spectator::DSL
|
|||
|
||||
# Mark the current test as pending and immediately abort.
|
||||
# A reason can be specified with *message*.
|
||||
def pending(message = "No reason given")
|
||||
def pending(message = PendingResult::DEFAULT_REASON)
|
||||
raise ExamplePending.new(message)
|
||||
end
|
||||
|
||||
# Mark the current test as skipped and immediately abort.
|
||||
# A reason can be specified with *message*.
|
||||
def skip(message = "No reason given")
|
||||
def skip(message = PendingResult::DEFAULT_REASON)
|
||||
raise ExamplePending.new(message)
|
||||
end
|
||||
|
||||
|
|
|
@ -89,7 +89,7 @@ module Spectator
|
|||
if pending?
|
||||
Log.debug { "Skipping example #{self} - marked pending" }
|
||||
@finished = true
|
||||
return @result = PendingResult.new(tags[:pending] || "No reason given")
|
||||
return @result = PendingResult.new(tags[:pending] || PendingResult::DEFAULT_REASON)
|
||||
end
|
||||
|
||||
previous_example = @@current
|
||||
|
|
|
@ -121,7 +121,7 @@ module Spectator
|
|||
when ExpectationFailed
|
||||
FailResult.new(elapsed, error, @expectations)
|
||||
when ExamplePending
|
||||
PendingResult.new(error.message || "No reason given", elapsed, @expectations)
|
||||
PendingResult.new(error.message || PendingResult::DEFAULT_REASON, elapsed, @expectations)
|
||||
else
|
||||
ErrorResult.new(elapsed, error, @expectations)
|
||||
end
|
||||
|
|
|
@ -5,13 +5,15 @@ module Spectator
|
|||
# A pending result means the example is not ready to run yet.
|
||||
# This can happen when the functionality to be tested is not implemented yet.
|
||||
class PendingResult < Result
|
||||
DEFAULT_REASON = "No reason given"
|
||||
|
||||
# Reason the example was skipped or marked pending.
|
||||
getter reason : String
|
||||
|
||||
# Creates the result.
|
||||
# *elapsed* is the length of time it took to run the example.
|
||||
# A *reason* for the skip/pending result can be specified.
|
||||
def initialize(@reason = "No reason given", elapsed = Time::Span::ZERO, expectations = [] of Expectation)
|
||||
def initialize(@reason = DEFAULT_REASON, elapsed = Time::Span::ZERO, expectations = [] of Expectation)
|
||||
super(elapsed, expectations)
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue