class TableBuilder
converts the examples array to a table string
Public Class Methods
new(examples)
click to toggle source
# File lib/table_builder.rb, line 7 def initialize(examples) @examples = examples end
Public Instance Methods
generate_table()
click to toggle source
# File lib/table_builder.rb, line 11 def generate_table Terminal::Table.new do |t| t.headings = ['Test Case', 'Expected result', 'status'] t.rows = map_examples(@examples) t.style = { border_left: false, border_right: false, border: :markdown } end end
Protected Instance Methods
execution_status(example)
click to toggle source
# File lib/table_builder.rb, line 33 def execution_status(example) puts example.execution_result.status case example.execution_result.status when :passed '✔️ Passed' when :failed '❌ Failed' when :pending '⚠️ Test case pending' else '' end end
map_example(example)
click to toggle source
# File lib/table_builder.rb, line 25 def map_example(example) [ example.metadata[:example_group][:full_description], example.description, execution_status(example) ] end
map_examples(examples)
click to toggle source
# File lib/table_builder.rb, line 21 def map_examples(examples) examples.map { |example| map_example(example) } end