From 26187a0f315ab0c696b9d5248e689166350b2e1b Mon Sep 17 00:00:00 2001 From: Michael Miller Date: Wed, 27 Feb 2019 22:20:57 -0700 Subject: [PATCH] Fix oddity with type being unresolvable --- spec/helpers/expectations_helper.cr | 10 ++++++++-- spec/successful_result_spec.cr | 4 ++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/spec/helpers/expectations_helper.cr b/spec/helpers/expectations_helper.cr index 6d0246c..ac04060 100644 --- a/spec/helpers/expectations_helper.cr +++ b/spec/helpers/expectations_helper.cr @@ -35,9 +35,15 @@ def new_unsatisfied_expectation(expected : ExpectedType = 123, actual : ActualTy end end +def create_expectations(success_count = 1, failure_count = 0) + satisfied = Array(Spectator::Expectations::Expectation).new(success_count) { new_satisfied_expectation } + unsatisfied = Array(Spectator::Expectations::Expectation).new(failure_count) { new_unsatisfied_expectation } + (satisfied + unsatisfied).shuffle +end + def generate_expectations(success_count = 1, failure_count = 0) - satisfied = Array.new(success_count) { new_satisfied_expectation } - unsatisfied = Array.new(failure_count) { new_unsatisfied_expectation } + satisfied = Array(Spectator::Expectations::Expectation).new(success_count) { new_satisfied_expectation } + unsatisfied = Array(Spectator::Expectations::Expectation).new(failure_count) { new_unsatisfied_expectation } expectations = (satisfied + unsatisfied).shuffle reporter = Spectator::Expectations::ExpectationReporter.new(false) expectations.each do |expectation| diff --git a/spec/successful_result_spec.cr b/spec/successful_result_spec.cr index 9bc0d38..2f6be49 100644 --- a/spec/successful_result_spec.cr +++ b/spec/successful_result_spec.cr @@ -8,7 +8,7 @@ def new_successful_result( Spectator::SuccessfulResult.new( example || PassingExample.create, elapsed || Time::Span.zero, - expectations || Spectator::Expectations::ExampleExpectations.new(generate_expectations(1, 0)[:expectations]) + expectations || Spectator::Expectations::ExampleExpectations.new([new_satisfied_expectation]) ) end @@ -69,7 +69,7 @@ describe Spectator::SuccessfulResult do describe "#expectations" do it "is the expected value" do - expectations = Spectator::Expectations::ExampleExpectations.new(generate_expectations(5, 0)[:expectations]) + expectations = Spectator::Expectations::ExampleExpectations.new(create_expectations(5, 0)) result = new_successful_result(expectations: expectations) result.expectations.should eq(expectations) end