mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Treat harness more like a facade
This commit is contained in:
parent
f5317ecbd3
commit
d8223297af
3 changed files with 15 additions and 5 deletions
|
@ -23,7 +23,7 @@ module Spectator::Expectations
|
||||||
def to(matcher : Matchers::ValueMatcher(ExpectedType)) : Nil forall ExpectedType
|
def to(matcher : Matchers::ValueMatcher(ExpectedType)) : Nil forall ExpectedType
|
||||||
expectation = ValueExpectation.new(self, matcher)
|
expectation = ValueExpectation.new(self, matcher)
|
||||||
result = expectation.eval
|
result = expectation.eval
|
||||||
Internals::Harness.current.reporter.report(result)
|
Internals::Harness.current.report_expectation(result)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Asserts that the `#actual` value *does not* match some criteria.
|
# Asserts that the `#actual` value *does not* match some criteria.
|
||||||
|
@ -31,7 +31,7 @@ module Spectator::Expectations
|
||||||
def to_not(matcher : Matchers::ValueMatcher(ExpectedType)) : Nil forall ExpectedType
|
def to_not(matcher : Matchers::ValueMatcher(ExpectedType)) : Nil forall ExpectedType
|
||||||
expectation = ValueExpectation.new(self, matcher)
|
expectation = ValueExpectation.new(self, matcher)
|
||||||
result = expectation.eval(true)
|
result = expectation.eval(true)
|
||||||
Internals::Harness.current.reporter.report(result)
|
Internals::Harness.current.report_expectation(result)
|
||||||
end
|
end
|
||||||
|
|
||||||
# ditto
|
# ditto
|
||||||
|
|
|
@ -34,12 +34,22 @@ module Spectator::Internals
|
||||||
# Retrieves the current running example.
|
# Retrieves the current running example.
|
||||||
getter example : Example
|
getter example : Example
|
||||||
|
|
||||||
# Provides access to the expectation reporter.
|
# Reports the outcome of an expectation.
|
||||||
getter reporter = Expectations::ExpectationReporter.new
|
# An exception will be raised when a failing result is given.
|
||||||
|
def report_expectation(result : Expectations::Expectation::Result) : Nil
|
||||||
|
@reporter.report(result)
|
||||||
|
end
|
||||||
|
|
||||||
|
# Generates the reported expectation results from the example.
|
||||||
|
# This should be run after the example has finished.
|
||||||
|
def expectation_results : Expectations::ExpectationResults
|
||||||
|
@reporter.results
|
||||||
|
end
|
||||||
|
|
||||||
# Creates a new harness.
|
# Creates a new harness.
|
||||||
# The example the harness is for should be passed in.
|
# The example the harness is for should be passed in.
|
||||||
private def initialize(@example)
|
private def initialize(@example)
|
||||||
|
@reporter = Expectations::ExpectationReporter.new
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -13,7 +13,7 @@ module Spectator
|
||||||
group.run_after_each_hooks
|
group.run_after_each_hooks
|
||||||
group.run_after_all_hooks
|
group.run_after_all_hooks
|
||||||
end
|
end
|
||||||
expectations = Internals::Harness.current.reporter.results
|
expectations = Internals::Harness.current.expectation_results
|
||||||
translate_result(result, expectations)
|
translate_result(result, expectations)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue