Minimal handling of expectations and failures

This commit is contained in:
Michael Miller 2018-08-23 12:44:40 -06:00
parent 7ec33943a4
commit 74905b82bd
3 changed files with 14 additions and 0 deletions

View file

@ -5,6 +5,8 @@ module Spectator
def run
@block.call
rescue ex : ExpectationFailedError
puts ex
end
end
end

View file

@ -1,3 +1,5 @@
require "./matchers/matcher"
def expect(actual : T) forall T
Spectator::Expectation.new(actual)
end
@ -8,5 +10,11 @@ module Spectator
protected def initialize(@actual : T)
end
def to(matcher : Matchers::Matcher)
unless matcher.match?(self)
raise ExpectationFailedError.new
end
end
end
end

View file

@ -0,0 +1,4 @@
module Spectator
class ExpectationFailedError < Exception
end
end