Class: MarkdownExec::TestMDocCollectDependencies

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

Instance Method Summary collapse

Instance Method Details

#setupObject



539
540
541
# File 'lib/mdoc.rb', line 539

def setup
  @mdoc = MDoc.new
end

#test_collect_dependencies_with_no_sourceObject



543
544
545
# File 'lib/mdoc.rb', line 543

def test_collect_dependencies_with_no_source
  assert_empty @mdoc.collect_dependencies
end

#test_collect_dependencies_with_nonexistent_sourceObject

must raise error



548
549
550
551
552
# File 'lib/mdoc.rb', line 548

def test_collect_dependencies_with_nonexistent_source
  assert_raises(RuntimeError) do
    @mdoc.collect_dependencies(pubname: 'nonexistent')
  end
end

#test_collect_dependencies_with_valid_sourceObject



554
555
556
557
558
559
560
561
562
563
# File 'lib/mdoc.rb', line 554

def test_collect_dependencies_with_valid_source
  @mdoc.stubs(:get_blocks_by_anyname)
       .with('source1').returns([OpenStruct.new(id: 'source1',
                                                reqs: ['source2'])])
  @mdoc.stubs(:get_blocks_by_anyname)
       .with('source2').returns([OpenStruct.new(id: 'source2', reqs: [])])

  expected = { 'source1' => ['source2'], 'source2' => [] }
  assert_equal expected, @mdoc.collect_dependencies(pubname: 'source1')
end