Extend PendingBlock from ResultBlock and rename to PendingResultBlock

This commit is contained in:
Michael Miller 2021-05-30 10:02:25 -06:00
parent 7215e28d75
commit a4042a9684
No known key found for this signature in database
GPG key ID: FB9F12F7C646A4AD
3 changed files with 25 additions and 29 deletions

View file

@ -1,28 +0,0 @@
require "../../example"
require "./comment"
module Spectator::Formatting::Components
struct PendingBlock
private INDENT = 2
def initialize(@example : Example, @index : Int32)
end
def to_s(io)
2.times { io << ' ' }
io << @index
io << ')'
io << ' '
io.puts @example
indent = INDENT + index_digit_count + 2
indent.times { io << ' ' }
io.puts Comment.colorize("No reason given") # TODO: Get reason from result.
indent.times { io << ' ' }
io.puts Comment.colorize(@example.location) # TODO: Pending result could be triggered from another location.
end
private def index_digit_count
(Math.log(@index.to_f + 1) / Math.log(10)).ceil.to_i
end
end
end

View file

@ -0,0 +1,23 @@
require "../../example"
require "../../pending_result"
require "./result_block"
module Spectator::Formatting::Components
struct PendingResultBlock < ResultBlock
def initialize(index : Int32, example : Example, @result : PendingResult)
super(index, example)
end
private def subtitle
"No reason given" # TODO: Get reason from result.
end
private def subtitle_label
# TODO: Could be pending or skipped.
"Pending: ".colorize(:yellow)
end
private def content(io)
end
end
end

View file

@ -24,7 +24,8 @@ module Spectator::Formatting
io.puts "Pending:"
io.puts
examples.each_with_index(1) do |example, index|
io.puts Components::PendingBlock.new(example, index)
result = example.result.as(PendingResult)
io.puts Components::PendingResultBlock.new(index, example, result)
end
end