mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Bubble up matcher description
The last run matcher's description is used if one wasn't provided by the user. Only applies to examples that actually run and have expectations.
This commit is contained in:
parent
d64ecc4192
commit
88ed415191
3 changed files with 12 additions and 2 deletions
|
@ -6,6 +6,9 @@ module Spectator
|
||||||
# Concrete types must implement the `#run_impl` method.
|
# Concrete types must implement the `#run_impl` method.
|
||||||
abstract class Example < ExampleComponent
|
abstract class Example < ExampleComponent
|
||||||
@finished = false
|
@finished = false
|
||||||
|
@description : String? = nil
|
||||||
|
|
||||||
|
protected setter description
|
||||||
|
|
||||||
# Indicates whether the example has already been run.
|
# Indicates whether the example has already been run.
|
||||||
def finished? : Bool
|
def finished? : Bool
|
||||||
|
@ -23,11 +26,13 @@ module Spectator
|
||||||
@test_wrapper.source
|
@test_wrapper.source
|
||||||
end
|
end
|
||||||
|
|
||||||
def description : String | Symbol?
|
def description : String | Symbol
|
||||||
@test_wrapper.description
|
@description || @test_wrapper.description
|
||||||
end
|
end
|
||||||
|
|
||||||
def symbolic? : Bool
|
def symbolic? : Bool
|
||||||
|
return false unless @test_wrapper.description?
|
||||||
|
|
||||||
description = @test_wrapper.description
|
description = @test_wrapper.description
|
||||||
description.starts_with?('#') || description.starts_with?('.')
|
description.starts_with?('#') || description.starts_with?('.')
|
||||||
end
|
end
|
||||||
|
|
|
@ -44,6 +44,10 @@ module Spectator::Expectations
|
||||||
values?.not_nil!
|
values?.not_nil!
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def description
|
||||||
|
@match_data.description
|
||||||
|
end
|
||||||
|
|
||||||
# Creates the JSON representation of the expectation.
|
# Creates the JSON representation of the expectation.
|
||||||
def to_json(json : ::JSON::Builder)
|
def to_json(json : ::JSON::Builder)
|
||||||
json.object do
|
json.object do
|
||||||
|
|
|
@ -46,6 +46,7 @@ module Spectator
|
||||||
# Reports the outcome of an expectation.
|
# Reports the outcome of an expectation.
|
||||||
# An exception will be raised when a failing result is given.
|
# An exception will be raised when a failing result is given.
|
||||||
def report_expectation(expectation : Expectations::Expectation) : Nil
|
def report_expectation(expectation : Expectations::Expectation) : Nil
|
||||||
|
@example.description = expectation.description unless @example.test_wrapper.description?
|
||||||
@reporter.report(expectation)
|
@reporter.report(expectation)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue