Use ExpectationFailed instead of AssertionFailed

This commit is contained in:
Michael Miller 2021-01-20 21:38:34 -07:00
parent 98a29309ff
commit ce6f77656a
No known key found for this signature in database
GPG key ID: F9A0C5C65B162436
3 changed files with 17 additions and 17 deletions

View file

@ -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

View file

@ -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.

View 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