Class: ODDB::OdbaExporter::TestMCMTable

Inherits:
Test::Unit::TestCase
  • Object
show all
Includes:
FlexMock::TestCase
Defined in:
ext/export/test/test_oddbdat.rb

Instance Method Summary (collapse)

Instance Method Details

- (Object) setup



714
715
716
# File 'ext/export/test/test_oddbdat.rb', line 714

def setup
  @mcmtable = MCMTable.new
end


770
771
772
773
774
775
776
777
778
779
780
781
782
783
# File 'ext/export/test/test_oddbdat.rb', line 770

def test_format_lines__ImageLink
  section = flexmock('section') do |sec|
    sec.should_receive(:subheading).and_return('subhead')
    sec.should_receive(:paragraphs).and_return([ODDB::Text::ImageLink])
  end
  chapter = flexmock('chapter') do |chap|
    chap.should_receive(:heading).and_return('head')
    chap.should_receive(:sections).and_return([section])
  end

  # test
  expected = "<BI>head<E><P><I>subhead<E><IMG src='http://server_name/imagelink.src'/>"
  assert_equal(expected, @mcmtable.format_line(chapter))
end

- (Object) test_format_lines__sections_empty



739
740
741
742
743
744
745
746
# File 'ext/export/test/test_oddbdat.rb', line 739

def test_format_lines__sections_empty
  chapter = flexmock('chapter') do |chap|
    chap.should_receive(:heading).and_return('')
    chap.should_receive(:sections).and_return([])
  end

  assert_equal('', @mcmtable.format_line(chapter))
end

- (Object) test_format_lines__sections_not_empty



747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
# File 'ext/export/test/test_oddbdat.rb', line 747

def test_format_lines__sections_not_empty
  format = flexmock('format') do |form|
    form.should_receive(:italic?).and_return(true)
    form.should_receive(:range).and_return(0..7)
  end
  paragraph = flexmock('paragraph') do |par|
    par.should_receive(:text).and_return('par.text')
    par.should_receive(:formats).and_return([format])
    par.should_receive(:preformatted?).and_return(true)
  end
  section = flexmock('section') do |sec|
    sec.should_receive(:subheading).and_return('subhead')
    sec.should_receive(:paragraphs).and_return([paragraph])
  end
  chapter = flexmock('chapter') do |chap|
    chap.should_receive(:heading).and_return('head')
    chap.should_receive(:sections).and_return([section])
  end

  # test
  expected = "<BI>head<E><P><I>subhead<E><I>par.text<E><P>"
  assert_equal(expected, @mcmtable.format_line(chapter))
end

- (Object) test_lines



717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
# File 'ext/export/test/test_oddbdat.rb', line 717

def test_lines
  # test fi.description empty case
  fi = flexmock('fi') do |f|
    f.should_receive(:descriptions).and_return([])
  end
  assert_equal([], @mcmtable.lines(fi))

  # test not empty case
  flexstub(MCMLine).should_receive(:new).and_return('mcmline')
  chapter = flexmock('chapter') do |chap|
    chap.should_receive(:heading).and_return('')
    chap.should_receive(:sections).and_return([])
  end
  doc = flexmock('doc') do |d|
    d.should_receive(:each_chapter).and_yield(chapter)
  end
  fi = flexmock('fi') do |f|
    f.should_receive(:descriptions).and_return({'lang', doc})
    f.should_receive(:oid).and_return('oid')
  end
  assert_equal(['mcmline'], @mcmtable.lines(fi))
end