mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Use ExpectationFailed instead of AssertionFailed
This commit is contained in:
parent
98a29309ff
commit
ce6f77656a
3 changed files with 17 additions and 17 deletions
|
@ -1,15 +0,0 @@
|
|||
require "./source"
|
||||
|
||||
module Spectator
|
||||
# Exception that indicates an assertion failed.
|
||||
# When raised within a test, the test should abort.
|
||||
class AssertionFailed < Exception
|
||||
# Location where the assertion failed and the exception raised.
|
||||
getter source : Source
|
||||
|
||||
# Creates the exception.
|
||||
def initialize(@source : Source, message : String? = nil, cause : Exception? = nil)
|
||||
super(message, cause)
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,6 +1,6 @@
|
|||
require "../assertion_failed"
|
||||
require "../block"
|
||||
require "../expectation"
|
||||
require "../expectation_failed"
|
||||
require "../source"
|
||||
require "../value"
|
||||
|
||||
|
@ -10,7 +10,7 @@ module Spectator::DSL
|
|||
# Immediately fail the current test.
|
||||
# A reason can be specified with *message*.
|
||||
def fail(message = "Example failed", *, _file = __FILE__, _line = __LINE__)
|
||||
raise AssertionFailed.new(Source.new(_file, _line), message)
|
||||
raise ExpectationFailed.new(Source.new(_file, _line), message)
|
||||
end
|
||||
|
||||
# Starts an expectation.
|
||||
|
|
15
src/spectator/expectation_failed.cr
Normal file
15
src/spectator/expectation_failed.cr
Normal file
|
@ -0,0 +1,15 @@
|
|||
require "./expectation"
|
||||
|
||||
module Spectator
|
||||
# Exception that indicates an expectation from a test failed.
|
||||
# When raised within a test, the test should abort.
|
||||
class ExpectationFailed < Exception
|
||||
# Expectation that failed.
|
||||
getter expectation : Expectation
|
||||
|
||||
# Creates the exception.
|
||||
def initialize(@expectation : Expectation, message : String? = nil, cause : Exception? = nil)
|
||||
super(message, cause)
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue