Lazy iterate over failures and errors

Return iterator from #failures and #errors methods in Report.
Update spec to reflect this.
This commit is contained in:
Michael Miller 2019-02-17 20:09:13 -07:00
parent 32a049d973
commit dc7d5fbe25
2 changed files with 6 additions and 6 deletions

View file

@ -75,7 +75,7 @@ describe Spectator::Report do
it "returns the expected results" do
results = Array.new(5) { new_failure_result.as(Spectator::Result) }
report = Spectator::Report.new(results, Time::Span.zero)
report.failures.should eq(results)
report.failures.to_a.should eq(results)
end
it "includes errors" do
@ -87,7 +87,7 @@ describe Spectator::Report do
end
end
report = Spectator::Report.new(results, Time::Span.zero)
report.failures.should eq(results)
report.failures.to_a.should eq(results)
end
end
@ -95,7 +95,7 @@ describe Spectator::Report do
it "returns the expected results" do
results = Array.new(5) { new_failure_result(Spectator::ErroredResult).as(Spectator::Result) }
report = Spectator::Report.new(results, Time::Span.zero)
report.errors.should eq(results)
report.errors.to_a.should eq(results)
end
it "does not include failures" do
@ -108,7 +108,7 @@ describe Spectator::Report do
end
report = Spectator::Report.new(results, Time::Span.zero)
errors_only = results.select(&.is_a?(Spectator::ErroredResult))
report.errors.should eq(errors_only)
report.errors.to_a.should eq(errors_only)
end
end

View file

@ -38,12 +38,12 @@ module Spectator
# Returns a set of results for all failed examples.
def failures
@results.compact_map(&.as?(FailedResult))
@results.each.compact_map(&.as?(FailedResult))
end
# Returns a set of results for all errored examples.
def errors
@results.compact_map(&.as?(ErroredResult))
@results.each.compact_map(&.as?(ErroredResult))
end
# Length of time it took to run just example code.