mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Ability to enumerate each result in report
This commit is contained in:
parent
4d38bf3ab2
commit
4890cafefa
2 changed files with 20 additions and 0 deletions
|
@ -44,6 +44,15 @@ describe Spectator::Report do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe "#each" do
|
||||||
|
it "yields all results" do
|
||||||
|
results = new_results
|
||||||
|
report = Spectator::Report.new(results)
|
||||||
|
# The `#each` method is tested through `Enumerable#to_a`.
|
||||||
|
report.to_a.should eq(results)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
describe "#runtime" do
|
describe "#runtime" do
|
||||||
it "is the expected value" do
|
it "is the expected value" do
|
||||||
span = Time::Span.new(10, 10, 10)
|
span = Time::Span.new(10, 10, 10)
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
|
require "./result"
|
||||||
|
|
||||||
module Spectator
|
module Spectator
|
||||||
# Outcome of all tests in a suite.
|
# Outcome of all tests in a suite.
|
||||||
class Report
|
class Report
|
||||||
|
include Enumerable(Result)
|
||||||
|
|
||||||
# Total length of time it took to execute the test suite.
|
# Total length of time it took to execute the test suite.
|
||||||
# This includes examples, hooks, and framework processes.
|
# This includes examples, hooks, and framework processes.
|
||||||
getter runtime : Time::Span
|
getter runtime : Time::Span
|
||||||
|
@ -51,6 +55,13 @@ module Spectator
|
||||||
initialize(results, runtime)
|
initialize(results, runtime)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Yields each result in turn.
|
||||||
|
def each
|
||||||
|
@results.each do |result|
|
||||||
|
yield result
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
# Number of examples.
|
# Number of examples.
|
||||||
def example_count
|
def example_count
|
||||||
@results.size
|
@results.size
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue