From 3382084f03f3958632874e359b9f67b1bea20008 Mon Sep 17 00:00:00 2001 From: Michael Miller Date: Mon, 22 Oct 2018 10:49:42 -0600 Subject: [PATCH] Implement remaining harness specs --- spec/internals/harness_spec.cr | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/spec/internals/harness_spec.cr b/spec/internals/harness_spec.cr index 6900a71..e988777 100644 --- a/spec/internals/harness_spec.cr +++ b/spec/internals/harness_spec.cr @@ -53,7 +53,15 @@ describe Spectator::Internals::Harness do describe "#report_expectation" do context "with a successful result" do it "stores the result" do - + error = nil.as(Exception?) + success = new_successful_result + spy = SpyExample.create do + harness = Spectator::Internals::Harness.current + harness.report_expectation(success) + end + result = Spectator::Internals::Harness.run(spy) + result.should be_a(Spectator::SuccessfulResult) + result.as(Spectator::SuccessfulResult).expectations.should contain(success) end end @@ -71,12 +79,33 @@ describe Spectator::Internals::Harness do Spectator::Internals::Harness.run(spy) error.should be_a(Spectator::ExampleFailed) end + + it "stores the result" do + error = nil.as(Exception?) + failure = new_failure_result + spy = SpyExample.create do + harness = Spectator::Internals::Harness.current + harness.report_expectation(failure) + end + result = Spectator::Internals::Harness.run(spy) + result.should be_a(Spectator::FailedResult) + result.as(Spectator::FailedResult).expectations.should contain(failure) + end end end describe "#expectation_results" do it "contains the reported results" do - + results = [new_successful_result, new_failure_result] + spy = SpyExample.create do + harness = Spectator::Internals::Harness.current + results.each do |result| + harness.report_expectation(result) + end + end + result = Spectator::Internals::Harness.run(spy) + reported_results = result.as(Spectator::FailedResult).expectations.to_a + (results - reported_results).size.should eq(0) end end end