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.
|
# Attempts to retrieve the location where the example failed.
|
||||||
# This only works if the location of the failed expectation was reported.
|
# This only works if the location of the failed expectation was reported.
|
||||||
# If available, returns a `Location`, otherwise `nil`.
|
# If available, returns a `Location`, otherwise `nil`.
|
||||||
def source : Location?
|
def location : Location?
|
||||||
return unless error = @error.as?(ExampleFailed)
|
return unless error = @error.as?(ExampleFailed)
|
||||||
|
|
||||||
error.location?
|
error.location?
|
||||||
|
|
|
@ -15,8 +15,8 @@ module Spectator::Formatting::Components
|
||||||
io.puts
|
io.puts
|
||||||
@failures.each do |failure|
|
@failures.each do |failure|
|
||||||
# Use failed location if it's available.
|
# Use failed location if it's available.
|
||||||
if (result = failure.result).responds_to?(:source)
|
if (result = failure.result).responds_to?(:location)
|
||||||
location = result.source
|
location = result.location
|
||||||
end
|
end
|
||||||
|
|
||||||
io.puts ExampleCommand.new(failure, location).colorize(:red)
|
io.puts ExampleCommand.new(failure, location).colorize(:red)
|
||||||
|
|
|
@ -48,7 +48,7 @@ module Spectator::Formatting::Components
|
||||||
subtitle_line(io)
|
subtitle_line(io)
|
||||||
io.puts
|
io.puts
|
||||||
content(io)
|
content(io)
|
||||||
source_line(io)
|
location_line(io)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -68,16 +68,16 @@ module Spectator::Formatting::Components
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Produces the (example) source line.
|
# Produces the (example) location line.
|
||||||
private def source_line(io)
|
private def location_line(io)
|
||||||
source = if (result = @example.result).responds_to?(:source)
|
location = if (result = @example.result).responds_to?(:location)
|
||||||
result.source
|
result.location
|
||||||
else
|
else
|
||||||
@example.location?
|
@example.location?
|
||||||
end
|
end
|
||||||
return unless source
|
return unless location
|
||||||
|
|
||||||
line(io) { io << Comment.colorize(source) }
|
line(io) { io << Comment.colorize(location) }
|
||||||
end
|
end
|
||||||
|
|
||||||
# Computes the number of spaces the index takes
|
# Computes the number of spaces the index takes
|
||||||
|
|
Loading…
Reference in a new issue