Class: MarkdownExec::TestMDoc

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

Instance Method Summary collapse

Instance Method Details

#setupObject



431
432
433
434
435
436
437
438
# File 'lib/mdoc.rb', line 431

def setup
  @table = [
    { oname: 'block1', body: ['code for block1'], reqs: ['block2'] },
    { oname: 'block2', body: ['code for block2'], reqs: nil },
    { oname: 'block3', body: ['code for block3'], reqs: ['block1'] }
  ]
  @doc = MDoc.new(@table)
end

#test_collect_block_dependenciesObject

broken test



455
456
457
458
459
460
461
462
463
# File 'lib/mdoc.rb', line 455

def test_collect_block_dependencies
  result = @doc.collect_block_dependencies(anyname: 'block3')[:blocks]
  expected_result = [@table[0], @table[1], @table[2]]
  assert_equal expected_result, result

  assert_raises(RuntimeError) do
    @doc.collect_block_dependencies(anyname: 'missing_block')
  end
end

#test_get_block_by_nameObject

def test_collect_recursively_required_code

result = @doc.collect_recursively_required_code('block1')[:code]
expected_result = @table[0][:body] + @table[1][:body]
assert_equal expected_result, result

end



446
447
448
449
450
451
452
# File 'lib/mdoc.rb', line 446

def test_get_block_by_name
  result = @doc.get_block_by_anyname('block1')
  assert_equal @table[0], result

  result_missing = @doc.get_block_by_anyname('missing_block')
  assert_equal({}, result_missing)
end

#test_hide_menu_block_on_nameObject



465
466
467
468
469
470
471
# File 'lib/mdoc.rb', line 465

def test_hide_menu_block_on_name
  opts = { hide_blocks_by_name: true,
           block_name_hidden_match: 'block1' }
  block = FCB.new(oname: 'block1')
  result = @doc.hide_menu_block_on_name(opts, block)
  assert result # this should be true based on the given logic
end

#test_recursively_requiredObject

broken test def test_fcbs_per_options

opts = { hide_blocks_by_name: true, block_name_hidden_match: 'block1' }
result = @doc.fcbs_per_options(opts)
assert_equal [@table[1], @table[2]], result

end



480
481
482
483
484
485
486
487
# File 'lib/mdoc.rb', line 480

def test_recursively_required
  result = @doc.recursively_required_hash('block3')
  assert_equal ({ 'block3' => ['block1'], 'block1' => ['block2'], 'block2' => nil }),
               result

  result_no_reqs = @doc.recursively_required_hash(nil)
  assert_equal ({}), result_no_reqs
end