Class: ODDB::FiPDF::TestFachinfoWrapper

Inherits:
Test::Unit::TestCase
  • Object
show all
Defined in:
ext/fipdf/test/fachinfo_wrapper_test.rb

Defined Under Namespace

Classes: StubChapter, StubChapterWrapper, StubFachinfo, StubFormat

Instance Method Summary collapse

Instance Method Details

#setupObject



42
43
44
45
# File 'ext/fipdf/test/fachinfo_wrapper_test.rb', line 42

def setup
  @fachinfo = StubFachinfo.new
  @wrapper = FachinfoWrapper.new(@fachinfo)
end

#test_each_chapterObject



126
127
128
129
130
131
132
133
# File 'ext/fipdf/test/fachinfo_wrapper_test.rb', line 126

def test_each_chapter
  @fachinfo.chapters = [
    "foo", "bar", "baz"
  ]
  @wrapper.each_chapter { |chapter|
    assert_instance_of(ChapterWrapper, chapter)
  }
end

#test_need_new_page__chapterObject



82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# File 'ext/fipdf/test/fachinfo_wrapper_test.rb', line 82

def test_need_new_page__chapter
  @fachinfo.name = "Ponstan"
  @fachinfo.company_name = "ywesee"
  fmt_dname = StubFormat.new
  fmt_dname.margin = 0
  fmt_dname.height = 10
  fmt_cname = StubFormat.new
  fmt_cname.height = 5
  formats = {
    :drug_name => fmt_dname,
    :company_name => fmt_cname
  }
  @wrapper.wrapper_class = StubChapterWrapper
  height = 16 
  width = "ignored in this test"
  chapter = StubChapter.new
  chapter.need_new_page = true
  @fachinfo.chapters = [chapter]
  @wrapper.wrapper_class = StubChapterWrapper
  result = @wrapper.need_new_page?(height, width, formats)
  assert_equal(true, result)
end

#test_need_new_page__company_nameObject



64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'ext/fipdf/test/fachinfo_wrapper_test.rb', line 64

def test_need_new_page__company_name
  @fachinfo.name = "Ponstan"
  @fachinfo.company_name = "ywesee"
  fmt_dname = StubFormat.new
  fmt_dname.margin = 0
  fmt_dname.height = 10
  fmt_cname = StubFormat.new
  fmt_cname.height = 5
  formats = {
    :drug_name => fmt_dname,
    :company_name => fmt_cname
  }
  @wrapper.wrapper_class = StubChapterWrapper
  height = 14 
  width = "ignored in this test"
  result = @wrapper.need_new_page?(height, width, formats)
  assert_equal(true, result)
end

#test_need_new_page__drug_nameObject



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'ext/fipdf/test/fachinfo_wrapper_test.rb', line 46

def test_need_new_page__drug_name
  @fachinfo.name = "Ponstan"
  @fachinfo.company_name = "ywesee"
  fmt_dname = StubFormat.new
  fmt_dname.height = 10
  fmt_dname.margin = 0
  fmt_cname = StubFormat.new
  fmt_cname.height = 5
  formats = {
    :drug_name => fmt_dname,
    :company_name => fmt_cname
  }
  @wrapper.wrapper_class = StubChapterWrapper
  height = 7
  width = "ignored in this test"
  result = @wrapper.need_new_page?(height, width, formats)
  assert_equal(true, result)
end

#test_need_new_page__noObject



104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
# File 'ext/fipdf/test/fachinfo_wrapper_test.rb', line 104

def test_need_new_page__no
  @fachinfo.name = "Ponstan"
  @fachinfo.company_name = "ywesee"
  fmt_dname = StubFormat.new
  fmt_dname.margin = 0
  fmt_dname.height = 10
  fmt_cname = StubFormat.new
  fmt_cname.height = 5
  formats = {
    :drug_name => fmt_dname,
    :company_name => fmt_cname
  }
  @wrapper.wrapper_class = StubChapterWrapper
  height = 16 
  width = "ignored in this test"
  chapter = StubChapter.new
  chapter.need_new_page = false
  @fachinfo.chapters = [chapter]
  @wrapper.wrapper_class = StubChapterWrapper
  result = @wrapper.need_new_page?(height, width, formats)
  assert_equal(false, result)
end