mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Consistency with location and location?
This commit is contained in:
parent
e316dd8a11
commit
52a0ae938a
3 changed files with 11 additions and 4 deletions
|
@ -41,12 +41,19 @@ module Spectator
|
|||
# Attempts to retrieve the location where the example failed.
|
||||
# This only works if the location of the failed expectation was reported.
|
||||
# If available, returns a `Location`, otherwise `nil`.
|
||||
def location : Location?
|
||||
def location? : Location?
|
||||
return unless error = @error.as?(ExampleFailed)
|
||||
|
||||
error.location?
|
||||
end
|
||||
|
||||
# Attempts to retrieve the location where the example failed.
|
||||
# This only works if the location of the failed expectation was reported.
|
||||
# If available, returns a `Location`, otherwise raises `NilAssertionError`.
|
||||
def location : Location
|
||||
location? || raise(NilAssertionError.new("Source location of result unavailable"))
|
||||
end
|
||||
|
||||
# One-word description of the result.
|
||||
def to_s(io)
|
||||
io << "fail"
|
||||
|
|
|
@ -71,8 +71,8 @@ module Spectator::Formatting::Components
|
|||
# Produces the location line.
|
||||
# This is where the result was determined.
|
||||
private def location_line(io)
|
||||
location = if (result = @example.result).responds_to?(:location)
|
||||
result.location
|
||||
location = if (result = @example.result).responds_to?(:location?)
|
||||
result.location?
|
||||
end
|
||||
location ||= @example.location?
|
||||
return unless location
|
||||
|
|
|
@ -11,7 +11,7 @@ module Spectator
|
|||
getter reason : String
|
||||
|
||||
# Location the pending result was triggered from.
|
||||
getter location : Location?
|
||||
getter! location : Location
|
||||
|
||||
# Creates the result.
|
||||
# *elapsed* is the length of time it took to run the example.
|
||||
|
|
Loading…
Reference in a new issue