# frozen_string_literal: false require 'rdoc/test_case' class TestRDocMarkupToAnsi < RDoc::Markup::TextFormatterTestCase add_visitor_tests add_text_tests def setup super @to = RDoc::Markup::ToAnsi.new end def accept_blank_line assert_equal "\e[0m\n", @to.res.join end def accept_block_quote assert_equal "\e[0m> quote\n", @to.res.join end def accept_document assert_equal "\e[0mhello\n", @to.res.join end def accept_heading assert_equal "\e[0mHello\n", @to.res.join end def accept_list_end_bullet assert_empty @to.list_index assert_empty @to.list_type assert_empty @to.list_width end def accept_list_end_label assert_empty @to.list_index assert_empty @to.list_type assert_empty @to.list_width end def accept_list_end_lalpha assert_empty @to.list_index assert_empty @to.list_type assert_empty @to.list_width end def accept_list_end_note assert_empty @to.list_index assert_empty @to.list_type assert_empty @to.list_width end def accept_list_end_number assert_empty @to.list_index assert_empty @to.list_type assert_empty @to.list_width end def accept_list_end_ualpha assert_empty @to.list_index assert_empty @to.list_type assert_empty @to.list_width end def accept_list_item_end_bullet assert_equal 0, @to.indent, 'indent' end def accept_list_item_end_label assert_equal "\e[0mcat:\n", @to.res.join assert_equal 0, @to.indent, 'indent' end def accept_list_item_end_lalpha assert_equal 0, @to.indent, 'indent' assert_equal 'b', @to.list_index.last end def accept_list_item_end_note assert_equal "\e[0mcat:\n", @to.res.join assert_equal 0, @to.indent, 'indent' end def accept_list_item_end_number assert_equal 0, @to.indent, 'indent' assert_equal 2, @to.list_index.last end def accept_list_item_end_ualpha assert_equal 0, @to.indent, 'indent' assert_equal 'B', @to.list_index.last end def accept_list_item_start_bullet assert_equal %W"\e[0m", @to.res assert_equal '* ', @to.prefix end def accept_list_item_start_label assert_equal %W"\e[0m", @to.res assert_equal "cat:\n ", @to.prefix assert_equal 2, @to.indent end def accept_list_item_start_lalpha assert_equal %W"\e[0m", @to.res assert_equal 'a. ', @to.prefix assert_equal 'a', @to.list_index.last assert_equal 3, @to.indent end def accept_list_item_start_note assert_equal %W"\e[0m", @to.res assert_equal "cat:\n ", @to.prefix assert_equal 2, @to.indent end def accept_list_item_start_number assert_equal %W"\e[0m", @to.res assert_equal '1. ', @to.prefix assert_equal 1, @to.list_index.last assert_equal 3, @to.indent end def accept_list_item_start_ualpha assert_equal %W"\e[0m", @to.res assert_equal 'A. ', @to.prefix assert_equal 'A', @to.list_index.last assert_equal 3, @to.indent end def accept_list_start_bullet assert_equal "\e[0m", @to.res.join assert_equal [nil], @to.list_index assert_equal [:BULLET], @to.list_type assert_equal [1], @to.list_width end def accept_list_start_label assert_equal "\e[0m", @to.res.join assert_equal [nil], @to.list_index assert_equal [:LABEL], @to.list_type assert_equal [2], @to.list_width end def accept_list_start_lalpha assert_equal "\e[0m", @to.res.join assert_equal ['a'], @to.list_index assert_equal [:LALPHA], @to.list_type assert_equal [1], @to.list_width end def accept_list_start_note assert_equal "\e[0m", @to.res.join assert_equal [nil], @to.list_index assert_equal [:NOTE], @to.list_type assert_equal [2], @to.list_width end def accept_list_start_number assert_equal "\e[0m", @to.res.join assert_equal [1], @to.list_index assert_equal [:NUMBER], @to.list_type assert_equal [1], @to.list_width end def accept_list_start_ualpha assert_equal "\e[0m", @to.res.join assert_equal ['A'], @to.list_index assert_equal [:UALPHA], @to.list_type assert_equal [1], @to.list_width end def accept_paragraph assert_equal "\e[0mhi\n", @to.res.join end def accept_raw raw = <<-RAW.rstrip \e[0m
Name | Count |
---|---|
a | 1 |
b | 2 |