mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Use location instead of source
This commit is contained in:
parent
7e2b267e93
commit
81f1966417
3 changed files with 13 additions and 13 deletions
|
@ -41,7 +41,7 @@ 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 source : Location?
|
||||
def location : Location?
|
||||
return unless error = @error.as?(ExampleFailed)
|
||||
|
||||
error.location?
|
||||
|
|
|
@ -15,8 +15,8 @@ module Spectator::Formatting::Components
|
|||
io.puts
|
||||
@failures.each do |failure|
|
||||
# Use failed location if it's available.
|
||||
if (result = failure.result).responds_to?(:source)
|
||||
location = result.source
|
||||
if (result = failure.result).responds_to?(:location)
|
||||
location = result.location
|
||||
end
|
||||
|
||||
io.puts ExampleCommand.new(failure, location).colorize(:red)
|
||||
|
|
|
@ -48,7 +48,7 @@ module Spectator::Formatting::Components
|
|||
subtitle_line(io)
|
||||
io.puts
|
||||
content(io)
|
||||
source_line(io)
|
||||
location_line(io)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -68,16 +68,16 @@ module Spectator::Formatting::Components
|
|||
end
|
||||
end
|
||||
|
||||
# Produces the (example) source line.
|
||||
private def source_line(io)
|
||||
source = if (result = @example.result).responds_to?(:source)
|
||||
result.source
|
||||
else
|
||||
@example.location?
|
||||
end
|
||||
return unless source
|
||||
# Produces the (example) location line.
|
||||
private def location_line(io)
|
||||
location = if (result = @example.result).responds_to?(:location)
|
||||
result.location
|
||||
else
|
||||
@example.location?
|
||||
end
|
||||
return unless location
|
||||
|
||||
line(io) { io << Comment.colorize(source) }
|
||||
line(io) { io << Comment.colorize(location) }
|
||||
end
|
||||
|
||||
# Computes the number of spaces the index takes
|
||||
|
|
Loading…
Reference in a new issue