Class: MarkdownExec::TestMDoc2

Inherits:
Minitest::Test
  • Object
show all
Defined in:
lib/mdoc.rb

Instance Method Summary collapse

Instance Method Details

#setupObject

Mocking the @table object for testing



559
560
561
562
563
564
565
566
567
568
569
570
# File 'lib/mdoc.rb', line 559

def setup
  @table = [
    OpenStruct.new(oname: '{wrap1}'),
    OpenStruct.new(oname: '{wrap2-before}'),
    OpenStruct.new(oname: '{wrap2}'),
    OpenStruct.new(oname: '{wrap2-after}'),
    OpenStruct.new(oname: '{wrap3-before}'),
    OpenStruct.new(oname: '{wrap3}'),
    OpenStruct.new(oname: '{wrap3-after}')
  ]
  @mdoc = MDoc.new(@table)
end

#test_collect_wrapped_blocksObject



572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
# File 'lib/mdoc.rb', line 572

def test_collect_wrapped_blocks
  # Test case 1: blocks with wraps
  OpenStruct.new(oname: 'block1')

  assert_equal(%w[{wrap2-before} {wrap2} b {wrap2-after}],
               @mdoc.collect_wrapped_blocks(
                 [OpenStruct.new(oname: 'b',
                                 wraps: ['{wrap2}'])]
               ).map(&:oname))

  assert_equal(%w[{wrap2-before} {wrap2} {wrap3-before} {wrap3} c {wrap3-after} {wrap2-after}],
               @mdoc.collect_wrapped_blocks(
                 [OpenStruct.new(oname: 'c',
                                 wraps: %w[{wrap2} {wrap3}])]
               ).map(&:oname))

  # Test case 2: blocks with no wraps
  blocks = @mdoc.collect_wrapped_blocks([])
  assert_empty blocks

  # Test case 3: blocks with missing wraps
  assert_equal(
    %w[block4],
    @mdoc.collect_wrapped_blocks([OpenStruct.new(oname: 'block4',
                                                 wraps: ['wrap4'])]).map(&:oname)
  )
end