mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Add ability to mark example skipped/pending mid-test
This commit is contained in:
parent
ab6487cbfa
commit
8d73434e0b
3 changed files with 22 additions and 0 deletions
|
@ -1,4 +1,5 @@
|
|||
require "../block"
|
||||
require "../example_pending"
|
||||
require "../expectation"
|
||||
require "../expectation_failed"
|
||||
require "../location"
|
||||
|
@ -13,6 +14,18 @@ module Spectator::DSL
|
|||
raise ExpectationFailed.new(Location.new(_file, _line), message)
|
||||
end
|
||||
|
||||
# Mark the current test as pending and immediately abort.
|
||||
# A reason can be specified with *message*.
|
||||
def pending(message = "No reason given")
|
||||
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")
|
||||
raise ExamplePending.new(message)
|
||||
end
|
||||
|
||||
# Starts an expectation.
|
||||
# This should be followed up with `Assertion::Target#to` or `Assertion::Target#to_not`.
|
||||
# The value passed in will be checked to see if it satisfies the conditions of the specified matcher.
|
||||
|
|
6
src/spectator/example_pending.cr
Normal file
6
src/spectator/example_pending.cr
Normal file
|
@ -0,0 +1,6 @@
|
|||
module Spectator
|
||||
# Exception that indicates an example is pending and should be skipped.
|
||||
# When raised within a test, the test should abort.
|
||||
class ExamplePending < Exception
|
||||
end
|
||||
end
|
|
@ -1,4 +1,5 @@
|
|||
require "./error_result"
|
||||
require "./example_pending"
|
||||
require "./expectation"
|
||||
require "./mocks"
|
||||
require "./pass_result"
|
||||
|
@ -119,6 +120,8 @@ module Spectator
|
|||
PassResult.new(elapsed, @expectations)
|
||||
when ExpectationFailed
|
||||
FailResult.new(elapsed, error, @expectations)
|
||||
when ExamplePending
|
||||
PendingResult.new(elapsed, @expectations)
|
||||
else
|
||||
ErrorResult.new(elapsed, error, @expectations)
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue