diff --git a/src/spectator/assertion_failed.cr b/src/spectator/assertion_failed.cr deleted file mode 100644 index 81b28d2..0000000 --- a/src/spectator/assertion_failed.cr +++ /dev/null @@ -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 diff --git a/src/spectator/dsl/expectations.cr b/src/spectator/dsl/expectations.cr index bebbb9f..94a90b7 100644 --- a/src/spectator/dsl/expectations.cr +++ b/src/spectator/dsl/expectations.cr @@ -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. diff --git a/src/spectator/expectation_failed.cr b/src/spectator/expectation_failed.cr new file mode 100644 index 0000000..67c6dea --- /dev/null +++ b/src/spectator/expectation_failed.cr @@ -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