mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Add placeholders for profile functionality
This commit is contained in:
parent
2d88097c04
commit
35b887f8f0
9 changed files with 50 additions and 12 deletions
|
@ -3,7 +3,6 @@
|
|||
class SpyFormatter < Spectator::Formatting::Formatter
|
||||
{% for item in [
|
||||
{"start_suite", "Spectator::TestSuite"},
|
||||
{"end_suite", "Spectator::Report"},
|
||||
{"start_example", "Spectator::Example"},
|
||||
{"end_example", "Spectator::Result"},
|
||||
] %}
|
||||
|
@ -27,6 +26,21 @@ class SpyFormatter < Spectator::Formatting::Formatter
|
|||
|
||||
{% end %}
|
||||
|
||||
# Stores all invocatiosn made to `#end_suite`.
|
||||
# Each element is an invocation and the value is the arguments passed to the method.
|
||||
getter end_suite_calls = [] of NamedTuple(report: Spectator::Report, profile: Bool)
|
||||
|
||||
# Number of times the `#end_suite` method was called.
|
||||
def end_suite_call_count
|
||||
@end_suite_calls.size
|
||||
end
|
||||
|
||||
# Increments `#end_suite_call_count` and stores the arguments.
|
||||
def end_suite(report, profile)
|
||||
@all_calls << :end_suite
|
||||
@end_suite_calls << {report: report, profile: profile}
|
||||
end
|
||||
|
||||
# Stores the methods that were called and in which order.
|
||||
# The symbols will be the method name (i.e. `:start_suite`).
|
||||
getter all_calls = [] of Symbol
|
||||
|
|
|
@ -49,8 +49,8 @@ describe Spectator::Runner do
|
|||
suite = new_test_suite(group)
|
||||
runner = Spectator::Runner.new(suite, spectator_test_config(spy, true))
|
||||
runner.run
|
||||
report = spy.end_suite_calls.first
|
||||
report.remaining_count.should eq(3)
|
||||
args = spy.end_suite_calls.first
|
||||
args[:report].remaining_count.should eq(3)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -164,7 +164,8 @@ describe Spectator::Runner do
|
|||
spy = SpyFormatter.new
|
||||
runner = Spectator::Runner.new(suite, spectator_test_config(spy))
|
||||
runner.run
|
||||
spy.end_example_calls.each_with_index do |result, index|
|
||||
args = spy.end_suite_calls.first
|
||||
args[:report].each_with_index do |result, index|
|
||||
if index.odd?
|
||||
result.should be_a(Spectator::SuccessfulResult)
|
||||
else
|
||||
|
@ -180,7 +181,8 @@ describe Spectator::Runner do
|
|||
runner = Spectator::Runner.new(suite, spectator_test_config(spy))
|
||||
max_time = Time.measure { runner.run }
|
||||
min_time = spy.end_example_calls.each.map(&.as(Spectator::FinishedResult)).sum(&.elapsed)
|
||||
report = spy.end_suite_calls.first
|
||||
args = spy.end_suite_calls.first
|
||||
report = args[:report]
|
||||
report.runtime.should be <= max_time
|
||||
report.runtime.should be >= min_time
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue