class Object

Constants

BAZ
BULLET_POINTS_REGEX

Public Instance Methods

dpa(msg, *colors)
Alias for: logd
generate_markdown_and_print(test_case_lines) click to toggle source
# File lib/markdown_generator.rb, line 26
def generate_markdown_and_print(test_case_lines)
  puts
  pa 'generating markdown ...', :gray, :bright
  desc = ''
  steps = ''
  expected_result = ''
  tcs = [ table_headings ]

  test_case_lines.each do |ll|
    if is_step? ll
      txt = ll.gsub('-', '').lstrip
      steps += "#{txt}\n"
    elsif is_expected_result? ll
      txt = ll.gsub('-', '').gsub('>','').lstrip
      expected_result += "* #{txt}\n"
    elsif is_blank_line? ll
      unless desc == ''
        row = "| #{desc} | #{steps.chomp} | #{expected_result.chomp}"
        tcs << MarkdownTestCase.new(row)
        desc = ''
        steps = ''
        expected_result = ''
      end
    else
      desc += ll.lstrip
    end
  end
  unless desc == ''
    row = "| #{desc} | #{steps.chomp} | #{expected_result.chomp}"
    tcs << MarkdownTestCase.new(row)
  end
  puts
  tcs.each do |tc|
    puts tc
  end
  puts
end
is_blank_line?(ll) click to toggle source
# File lib/markdown_generator.rb, line 22
def is_blank_line?(ll)
  ll == ''
end
is_expected_result?(ll) click to toggle source
# File lib/markdown_generator.rb, line 18
def is_expected_result?(ll)
  ll.start_with?('-') && ll.include?('>')
end
is_step?(ll) click to toggle source
# File lib/markdown_generator.rb, line 14
def is_step?(ll)
  ll.start_with?('-') && not(ll.include?('>'))
end
logd(msg, *colors) click to toggle source
# File lib/futo-spec.rb, line 17
def logd(msg, *colors)
  if $debug
    unless colors
      puts msg
    else
      if colors.first == :bb
        pa msg, :yellow, :bright
      else
        pa msg, *colors
      end
    end
  end
end
Also aliased as: dpa
table_headings() click to toggle source
# File lib/markdown_generator.rb, line 10
def table_headings
  '|| test case || steps || expected result' 
end