Class: ODDB::View::TestChapter

Inherits:
Test::Unit::TestCase
  • Object
show all
Defined in:
test/test_view/chapter.rb

Instance Method Summary (collapse)

Instance Method Details

- (Object) setup



16
17
18
19
20
21
22
23
24
# File 'test/test_view/chapter.rb', line 16

def setup 
  @lookandfeel = FlexMock.new 'lookandfeel'
  @lookandfeel.should_receive(:section_style).and_return { 'section_style' }
  session = FlexMock.new 'session'
  session.should_receive(:lookandfeel).and_return { @lookandfeel }
  session.should_receive(:user_input)
  assert(session.respond_to?(:lookandfeel))
  @view = View::Chapter.new(:name, nil, session)
end

- (Object) test_escaped_heading



39
40
41
42
43
44
45
46
# File 'test/test_view/chapter.rb', line 39

def test_escaped_heading
  chapter = Text::Chapter.new
  chapter.heading = "Für Zwerge > 1.5 m"
  @view.value = chapter
  expected = '<H3>Für Zwerge &gt; 1.5 m</H3>'
  result = @view.to_html(CGI.new)
  assert_equal(expected, result)
end

- (Object) test_escaped_paragraphs



25
26
27
28
29
30
31
32
33
34
35
# File 'test/test_view/chapter.rb', line 25

def test_escaped_paragraphs
  txt = "Guten Tag! & wie gehts uns Heute? < oder >?"
  par1 = Text::Paragraph.new
  par2 = Text::Paragraph.new
  par1 << txt
  par2 << txt
  par1.preformatted!
  result = @view.paragraphs(CGI.new, [par1, par2])
  expected = "<PRE style=\"\#{View::Chapter.const_get(:PRE_STYLE)}\">Guten Tag! &amp; wie gehts uns Heute? &lt; oder &gt;?</PRE><SPAN style=\"\#{View::Chapter.const_get(:PAR_STYLE)}\">Guten Tag! &amp; wie gehts uns Heute? &lt; oder &gt;?</SPAN><BR>\n"
  assert_equal(expected.strip, result)
end

- (Object) test_escaped_subheading



47
48
49
50
51
52
53
54
55
# File 'test/test_view/chapter.rb', line 47

def test_escaped_subheading
  chapter = Text::Chapter.new
  section = chapter.next_section
  section.subheading = "Für Zwerge > 1.5 m"
  @view.value = chapter
  expected = "<P style=\"section_style\"><SPAN style=\"font-style: italic\">F\374r Zwerge &gt; 1.5 m</SPAN>&nbsp;</P>\n"
  result = @view.to_html(CGI.new)
  assert_equal(expected.strip, result)
end

- (Object) test_formatted_paragraph



59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'test/test_view/chapter.rb', line 59

def test_formatted_paragraph
  par = Text::Paragraph.new
  par << "Guten "
  par.set_format(:italic)
  par << "Tag"
  par.set_format
  par << "! Guten "
  par.set_format(:bold)
  par << "Abend"
  par.set_format
  par << "! Guten "
  par.set_format(:bold, :italic)
  par << "Morgen!!!"
  par.set_format
  par << " Danke."
  result = @view.paragraphs(CGI.new, [par])
  expected = "<SPAN style=\"\#{View::Chapter.const_get(:PAR_STYLE)}\">Guten<SPAN style=\"font-style:italic;\"> Tag</SPAN>! Guten<SPAN style=\"font-weight:bold;\"> Abend</SPAN>! Guten<SPAN style=\"font-style:italic; font-weight:bold;\"> Morgen!!!</SPAN> Danke.</SPAN><BR>\n"
  assert_equal(expected.strip, result)
end