thinreports 0.7.7 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (280) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +3 -6
  3. data/.travis.yml +4 -10
  4. data/CHANGELOG.md +220 -0
  5. data/Gemfile +3 -3
  6. data/MIT-LICENSE +1 -1
  7. data/README.md +286 -0
  8. data/Rakefile +38 -8
  9. data/examples/character_spacing/character_spacing.rb +8 -0
  10. data/examples/character_spacing/character_spacing.tlf +1 -0
  11. data/examples/dynamic_image/dynamic_image.rb +31 -0
  12. data/examples/dynamic_image/dynamic_image.tlf +1 -0
  13. data/{test/case → examples}/dynamic_image/img200x100.png +0 -0
  14. data/{test/case → examples}/dynamic_image/img50x50.png +0 -0
  15. data/examples/dynamic_style/dynamic_style.rb +150 -0
  16. data/examples/dynamic_style/dynamic_style.tlf +1 -0
  17. data/examples/dynamic_style/dynamic_style_in_list.tlf +1 -0
  18. data/{test/case → examples}/dynamic_style/image.png +0 -0
  19. data/examples/eudc/eudc.rb +20 -0
  20. data/examples/eudc/eudc.tlf +1 -0
  21. data/{test/case → examples}/eudc/eudc.ttf +0 -0
  22. data/{test/case → examples}/helper.rb +14 -12
  23. data/examples/hidden_shapes/hidden_shapes.rb +9 -0
  24. data/examples/hidden_shapes/hidden_shapes.tlf +1 -0
  25. data/examples/list_events/list_events.rb +59 -0
  26. data/examples/list_events/list_events_0_7_7.tlf +1 -0
  27. data/examples/list_events/list_events_0_8.tlf +1 -0
  28. data/{test/case → examples}/list_manual_generation/list_manual_generation.rb +4 -4
  29. data/examples/list_manual_generation/list_manual_generation.tlf +1 -0
  30. data/{test/case → examples}/list_page_number/list_page_number.rb +3 -3
  31. data/examples/list_page_number/list_page_number.tlf +1 -0
  32. data/examples/page_number/page_number.rb +33 -0
  33. data/examples/page_number/page_number.tlf +1 -0
  34. data/examples/password_setting/password_setting.rb +10 -0
  35. data/examples/password_setting/password_setting.tlf +1 -0
  36. data/examples/report_callbacks/report_callbacks.rb +31 -0
  37. data/examples/report_callbacks/report_callbacks.tlf +1 -0
  38. data/{test/case → examples}/single_line_tblock/single_line_tblock.rb +2 -2
  39. data/examples/single_line_tblock/single_line_tblock.tlf +1 -0
  40. data/examples/tblock_overflow/tblock_overflow.rb +20 -0
  41. data/examples/tblock_overflow/tblock_overflow.tlf +1 -0
  42. data/examples/tblock_styles/font_size.tlf +1 -0
  43. data/examples/tblock_styles/tblock_styles.rb +43 -0
  44. data/examples/tblock_styles/tblock_styles.tlf +1 -0
  45. data/examples/text_align/text_align.rb +8 -0
  46. data/examples/text_align/text_align.tlf +1 -0
  47. data/examples/typeB_page_size/B4_ISO.tlf +1 -0
  48. data/examples/typeB_page_size/B4_JIS.tlf +1 -0
  49. data/{test/case → examples}/typeB_page_size/typeB_page_size.rb +3 -3
  50. data/examples/word_wrap/word_wrap.rb +26 -0
  51. data/examples/word_wrap/word_wrap.tlf +1 -0
  52. data/{resources/fonts → fonts}/IPA_Font_License_Agreement_v1.0.txt +0 -0
  53. data/{resources/fonts → fonts}/ipag.ttf +0 -0
  54. data/{resources/fonts → fonts}/ipagp.ttf +0 -0
  55. data/{resources/fonts → fonts}/ipam.ttf +0 -0
  56. data/{resources/fonts → fonts}/ipamp.ttf +0 -0
  57. data/lib/thinreports.rb +14 -2
  58. data/lib/thinreports/config.rb +30 -10
  59. data/lib/thinreports/core/errors.rb +23 -20
  60. data/lib/thinreports/core/events.rb +18 -19
  61. data/lib/thinreports/core/format/base.rb +20 -20
  62. data/lib/thinreports/core/format/builder.rb +14 -22
  63. data/lib/thinreports/core/shape.rb +9 -13
  64. data/lib/thinreports/core/shape/base.rb +4 -5
  65. data/lib/thinreports/core/shape/base/interface.rb +15 -15
  66. data/lib/thinreports/core/shape/base/internal.rb +15 -20
  67. data/lib/thinreports/core/shape/basic.rb +1 -1
  68. data/lib/thinreports/core/shape/basic/block_format.rb +3 -4
  69. data/lib/thinreports/core/shape/basic/block_interface.rb +9 -4
  70. data/lib/thinreports/core/shape/basic/block_internal.rb +9 -10
  71. data/lib/thinreports/core/shape/basic/format.rb +11 -10
  72. data/lib/thinreports/core/shape/basic/interface.rb +3 -3
  73. data/lib/thinreports/core/shape/basic/internal.rb +4 -5
  74. data/lib/thinreports/core/shape/image_block.rb +1 -1
  75. data/lib/thinreports/core/shape/image_block/format.rb +5 -6
  76. data/lib/thinreports/core/shape/image_block/interface.rb +9 -7
  77. data/lib/thinreports/core/shape/image_block/internal.rb +5 -6
  78. data/lib/thinreports/core/shape/list.rb +1 -1
  79. data/lib/thinreports/core/shape/list/configuration.rb +30 -15
  80. data/lib/thinreports/core/shape/list/events.rb +11 -11
  81. data/lib/thinreports/core/shape/list/format.rb +27 -28
  82. data/lib/thinreports/core/shape/list/manager.rb +128 -95
  83. data/lib/thinreports/core/shape/list/page.rb +54 -50
  84. data/lib/thinreports/core/shape/list/page_state.rb +15 -16
  85. data/lib/thinreports/core/shape/list/section_format.rb +14 -15
  86. data/lib/thinreports/core/shape/list/section_interface.rb +15 -16
  87. data/lib/thinreports/core/shape/list/section_internal.rb +7 -8
  88. data/lib/thinreports/core/shape/list/store.rb +10 -11
  89. data/lib/thinreports/core/shape/manager.rb +1 -1
  90. data/lib/thinreports/core/shape/manager/format.rb +10 -11
  91. data/lib/thinreports/core/shape/manager/internal.rb +21 -20
  92. data/lib/thinreports/core/shape/manager/target.rb +63 -34
  93. data/lib/thinreports/core/shape/page_number.rb +1 -1
  94. data/lib/thinreports/core/shape/page_number/format.rb +3 -3
  95. data/lib/thinreports/core/shape/page_number/interface.rb +2 -2
  96. data/lib/thinreports/core/shape/page_number/internal.rb +3 -3
  97. data/lib/thinreports/core/shape/style.rb +1 -1
  98. data/lib/thinreports/core/shape/style/base.rb +29 -29
  99. data/lib/thinreports/core/shape/style/basic.rb +1 -1
  100. data/lib/thinreports/core/shape/style/graphic.rb +10 -25
  101. data/lib/thinreports/core/shape/style/text.rb +36 -30
  102. data/lib/thinreports/core/shape/text.rb +1 -1
  103. data/lib/thinreports/core/shape/text/format.rb +8 -9
  104. data/lib/thinreports/core/shape/text/interface.rb +2 -2
  105. data/lib/thinreports/core/shape/text/internal.rb +6 -7
  106. data/lib/thinreports/core/shape/text_block.rb +1 -1
  107. data/lib/thinreports/core/shape/text_block/format.rb +17 -18
  108. data/lib/thinreports/core/shape/text_block/formatter.rb +7 -8
  109. data/lib/thinreports/core/shape/text_block/formatter/basic.rb +13 -12
  110. data/lib/thinreports/core/shape/text_block/formatter/datetime.rb +8 -9
  111. data/lib/thinreports/core/shape/text_block/formatter/number.rb +11 -12
  112. data/lib/thinreports/core/shape/text_block/formatter/padding.rb +9 -32
  113. data/lib/thinreports/core/shape/text_block/interface.rb +2 -2
  114. data/lib/thinreports/core/shape/text_block/internal.rb +19 -20
  115. data/lib/thinreports/core/utils.rb +33 -32
  116. data/lib/thinreports/generator.rb +6 -8
  117. data/lib/thinreports/generator/base.rb +15 -24
  118. data/lib/thinreports/generator/configuration.rb +10 -9
  119. data/lib/thinreports/generator/pdf.rb +27 -30
  120. data/lib/thinreports/generator/pdf/configuration.rb +11 -6
  121. data/lib/thinreports/generator/pdf/document.rb +28 -28
  122. data/lib/thinreports/generator/pdf/document/draw_shape.rb +30 -31
  123. data/lib/thinreports/generator/pdf/document/font.rb +53 -44
  124. data/lib/thinreports/generator/pdf/document/graphics.rb +8 -9
  125. data/lib/thinreports/generator/pdf/document/graphics/attributes.rb +25 -25
  126. data/lib/thinreports/generator/pdf/document/graphics/basic.rb +25 -25
  127. data/lib/thinreports/generator/pdf/document/graphics/image.rb +15 -15
  128. data/lib/thinreports/generator/pdf/document/graphics/text.rb +40 -41
  129. data/lib/thinreports/generator/pdf/document/page.rb +20 -21
  130. data/lib/thinreports/generator/pdf/document/parse_color.rb +9 -10
  131. data/lib/thinreports/generator/pdf/document/parse_svg.rb +14 -15
  132. data/lib/thinreports/generator/pdf/drawer/base.rb +13 -14
  133. data/lib/thinreports/generator/pdf/drawer/list.rb +13 -14
  134. data/lib/thinreports/generator/pdf/drawer/list_section.rb +13 -14
  135. data/lib/thinreports/generator/pdf/drawer/page.rb +16 -17
  136. data/lib/thinreports/generator/pdf/prawn_ext.rb +17 -33
  137. data/lib/thinreports/layout.rb +2 -2
  138. data/lib/thinreports/layout/base.rb +22 -36
  139. data/lib/thinreports/layout/configuration.rb +11 -9
  140. data/lib/thinreports/layout/format.rb +26 -27
  141. data/lib/thinreports/layout/version.rb +8 -9
  142. data/lib/thinreports/report.rb +10 -14
  143. data/lib/thinreports/report/base.rb +104 -126
  144. data/lib/thinreports/report/events.rb +5 -5
  145. data/lib/thinreports/report/internal.rb +41 -33
  146. data/lib/thinreports/{core → report}/page.rb +38 -30
  147. data/lib/thinreports/version.rb +2 -3
  148. data/test/data/font.ttf +0 -0
  149. data/test/data/layout_block.tlf +1 -0
  150. data/test/data/layout_list.tlf +1 -0
  151. data/test/data/layout_list_noheader.tlf +1 -0
  152. data/test/data/layout_text1.tlf +1 -0
  153. data/test/data/layout_text2.tlf +1 -0
  154. data/test/test_helper.rb +74 -0
  155. data/test/{unit/tmp → tmp}/.gitkeep +0 -0
  156. data/test/unit/core/format/test_base.rb +14 -14
  157. data/test/unit/core/format/test_builder.rb +19 -23
  158. data/test/unit/core/shape/base/test_internal.rb +34 -37
  159. data/test/unit/core/shape/basic/test_basic_format.rb +4 -4
  160. data/test/unit/core/shape/basic/test_basic_interface.rb +15 -13
  161. data/test/unit/core/shape/basic/test_basic_internal.rb +19 -16
  162. data/test/unit/core/shape/basic/test_format.rb +4 -4
  163. data/test/unit/core/shape/basic/test_interface.rb +36 -46
  164. data/test/unit/core/shape/basic/test_internal.rb +23 -20
  165. data/test/unit/core/shape/image_block/test_format.rb +5 -5
  166. data/test/unit/core/shape/image_block/test_interface.rb +17 -16
  167. data/test/unit/core/shape/image_block/test_internal.rb +19 -16
  168. data/test/unit/core/shape/list/test_configuration.rb +45 -33
  169. data/test/unit/core/shape/list/test_events.rb +7 -7
  170. data/test/unit/core/shape/list/test_format.rb +16 -18
  171. data/test/unit/core/shape/list/test_manager.rb +5 -5
  172. data/test/unit/core/shape/list/test_page.rb +80 -22
  173. data/test/unit/core/shape/list/test_page_state.rb +12 -12
  174. data/test/unit/core/shape/list/test_section_format.rb +16 -17
  175. data/test/unit/core/shape/list/test_section_interface.rb +30 -22
  176. data/test/unit/core/shape/list/test_section_internal.rb +21 -19
  177. data/test/unit/core/shape/list/test_store.rb +7 -7
  178. data/test/unit/core/shape/manager/test_format.rb +11 -15
  179. data/test/unit/core/shape/manager/test_internal.rb +9 -9
  180. data/test/unit/core/shape/manager/test_target.rb +85 -57
  181. data/test/unit/core/shape/page_number/test_format.rb +4 -4
  182. data/test/unit/core/shape/page_number/test_interface.rb +11 -8
  183. data/test/unit/core/shape/page_number/test_internal.rb +5 -5
  184. data/test/unit/core/shape/styles/test_base.rb +9 -9
  185. data/test/unit/core/shape/styles/test_basic.rb +5 -5
  186. data/test/unit/core/shape/styles/test_graphic.rb +19 -33
  187. data/test/unit/core/shape/styles/test_text.rb +18 -7
  188. data/test/unit/core/shape/text/test_format.rb +6 -6
  189. data/test/unit/core/shape/text/test_internal.rb +11 -12
  190. data/test/unit/core/shape/text_block/formatter/test_basic.rb +16 -16
  191. data/test/unit/core/shape/text_block/formatter/test_datetime.rb +4 -4
  192. data/test/unit/core/shape/text_block/formatter/test_number.rb +34 -34
  193. data/test/unit/core/shape/text_block/formatter/test_padding.rb +44 -44
  194. data/test/unit/core/shape/text_block/test_format.rb +8 -8
  195. data/test/unit/core/shape/text_block/test_formatter.rb +17 -17
  196. data/test/unit/core/shape/text_block/test_interface.rb +37 -20
  197. data/test/unit/core/shape/text_block/test_internal.rb +38 -38
  198. data/test/unit/core/test_events.rb +5 -5
  199. data/test/unit/core/test_shape.rb +6 -6
  200. data/test/unit/core/test_utils.rb +68 -0
  201. data/test/unit/generator/pdf/document/graphics/test_attributes.rb +4 -4
  202. data/test/unit/generator/pdf/document/graphics/test_text.rb +60 -53
  203. data/test/unit/generator/pdf/document/test_draw_shape.rb +9 -7
  204. data/test/unit/generator/pdf/document/test_font.rb +79 -58
  205. data/test/unit/generator/pdf/document/test_graphics.rb +18 -19
  206. data/test/unit/generator/pdf/document/test_page.rb +44 -45
  207. data/test/unit/generator/pdf/document/test_parse_color.rb +5 -5
  208. data/test/unit/generator/pdf/test_configuration.rb +16 -9
  209. data/test/unit/generator/pdf/test_document.rb +8 -16
  210. data/test/unit/generator/test_base.rb +31 -42
  211. data/test/unit/generator/test_configuration.rb +6 -6
  212. data/test/unit/generator/test_pdf.rb +17 -14
  213. data/test/unit/layout/test_base.rb +34 -79
  214. data/test/unit/layout/test_configuration.rb +12 -37
  215. data/test/unit/layout/test_format.rb +36 -39
  216. data/test/unit/layout/test_version.rb +4 -4
  217. data/test/unit/report/test_base.rb +134 -213
  218. data/test/unit/report/test_events.rb +4 -4
  219. data/test/unit/report/test_internal.rb +84 -86
  220. data/test/unit/test_config.rb +31 -12
  221. data/test/unit/test_layout.rb +7 -7
  222. data/test/unit/test_report.rb +12 -24
  223. data/thinreports.gemspec +18 -22
  224. metadata +101 -200
  225. data/LICENSE +0 -1
  226. data/README.rdoc +0 -166
  227. data/doc/yardoc_templates/default/layout/html/footer.erb +0 -10
  228. data/lib/thinreports/core.rb +0 -20
  229. data/lib/thinreports/core/ext.rb +0 -5
  230. data/lib/thinreports/core/ext/array.rb +0 -19
  231. data/lib/thinreports/core/ext/hash.rb +0 -19
  232. data/lib/thinreports/core/ext/object.rb +0 -25
  233. data/lib/thinreports/core/format.rb +0 -14
  234. data/lib/thinreports/core/ordered_hash.rb +0 -39
  235. data/lib/thinreports/generator/pdf/drawer.rb +0 -16
  236. data/tasks/doc.rake +0 -12
  237. data/tasks/test.rake +0 -56
  238. data/test/benchmark/basic_estimate.tlf +0 -1
  239. data/test/benchmark/bench_basic_estimate.rb +0 -95
  240. data/test/case/character_spacing/character_spacing.rb +0 -8
  241. data/test/case/character_spacing/character_spacing.tlf +0 -1
  242. data/test/case/dynamic_image/dynamic_image.rb +0 -41
  243. data/test/case/dynamic_image/dynamic_image.tlf +0 -1
  244. data/test/case/dynamic_style/dynamic_style.rb +0 -154
  245. data/test/case/dynamic_style/dynamic_style.tlf +0 -1
  246. data/test/case/dynamic_style/dynamic_style_in_list.tlf +0 -1
  247. data/test/case/eudc/eudc.rb +0 -20
  248. data/test/case/eudc/eudc.tlf +0 -1
  249. data/test/case/hidden_shapes/hidden_shapes.rb +0 -9
  250. data/test/case/hidden_shapes/hidden_shapes.tlf +0 -1
  251. data/test/case/list_events/list_events.rb +0 -32
  252. data/test/case/list_events/list_events.tlf +0 -1
  253. data/test/case/list_manual_generation/list_manual_generation.tlf +0 -1
  254. data/test/case/list_page_number/list_page_number.tlf +0 -1
  255. data/test/case/page_number/page_number.rb +0 -33
  256. data/test/case/page_number/page_number.tlf +0 -1
  257. data/test/case/password_setting/password_setting.rb +0 -10
  258. data/test/case/password_setting/password_setting.tlf +0 -1
  259. data/test/case/single_line_tblock/single_line_tblock.tlf +0 -1
  260. data/test/case/tblock_overflow/tblock_overflow.rb +0 -20
  261. data/test/case/tblock_overflow/tblock_overflow.tlf +0 -1
  262. data/test/case/tblock_styles/tblock_styles.rb +0 -27
  263. data/test/case/tblock_styles/tblock_styles.tlf +0 -1
  264. data/test/case/text_align/text_align.rb +0 -8
  265. data/test/case/text_align/text_align.tlf +0 -1
  266. data/test/case/typeB_page_size/B4_ISO.tlf +0 -1
  267. data/test/case/typeB_page_size/B4_JIS.tlf +0 -1
  268. data/test/case/word_wrap/word_wrap.rb +0 -26
  269. data/test/case/word_wrap/word_wrap.tlf +0 -1
  270. data/test/unit/core/ext/array_spec.rb +0 -29
  271. data/test/unit/core/ext/hash_spec.rb +0 -29
  272. data/test/unit/core/ext/object_spec.rb +0 -30
  273. data/test/unit/core/ordered_hash_spec.rb +0 -51
  274. data/test/unit/core/shape/base/test_interface.rb +0 -52
  275. data/test/unit/core/utils_spec.rb +0 -56
  276. data/test/unit/data/basic_layout1.tlf +0 -1
  277. data/test/unit/data/basic_layout2.tlf +0 -1
  278. data/test/unit/data/basic_list_layout.tlf +0 -1
  279. data/test/unit/data/basic_list_noheader_layout.tlf +0 -1
  280. data/test/unit/helper.rb +0 -87
@@ -1,92 +1,47 @@
1
1
  # coding: utf-8
2
2
 
3
- require 'test/unit/helper'
3
+ require 'test_helper'
4
+
5
+ class Thinreports::Layout::TestBase < Minitest::Test
6
+ include Thinreports::TestHelper
7
+
8
+ Layout = Thinreports::Layout
4
9
 
5
- class ThinReports::Layout::TestBase < MiniTest::Unit::TestCase
6
- include ThinReports::TestHelpers
7
-
8
- # Alias
9
- Layout = ThinReports::Layout::Base
10
-
11
- def test_load_format_raise_error_when_file_not_found
12
- assert_raises ThinReports::Errors::LayoutFileNotFound do
13
- Layout.load_format('dummy.tlf')
14
- end
15
- end
16
-
17
10
  def test_load_format
18
- flexmock(File).should_receive(:exists? => true).once
19
- flexmock(ThinReports::Layout::Format).should_receive(:build).once
20
-
21
- Layout.load_format('sample.tlf')
22
- end
23
-
24
- def test_load_format_when_omit_the_file_extension
25
- specified_name = 'sample'
26
- resolved_name = 'sample.tlf'
27
-
28
- flexmock(File).
29
- should_receive(:exists?).with(resolved_name).and_return(true).once
30
- flexmock(ThinReports::Layout::Format).should_receive(:build).once
31
-
32
- Layout.load_format(specified_name)
33
- end
34
-
35
- def test_Page_when_not_defined_PageHelpers
36
- assert_same Layout.Page, ThinReports::Core::Page
37
- end
38
-
39
- def test_Page_when_defined_PageHelpers
40
- Layout.send(:PageHelpers, &proc{})
41
-
42
- refute_same Layout.Page, ThinReports::Core::Page
43
-
44
- # Teardown
45
- ThinReports::Layout::Base.send(:remove_const, :Page)
46
- end
47
-
48
- def test_PageHelpers
49
- Layout.send(:PageHelpers) do
50
- def foo
51
- 'foo'
52
- end
11
+ assert_instance_of Layout::Format,
12
+ Layout::Base.load_format(data_file('layout_text1.tlf'))
13
+ assert_instance_of Layout::Format,
14
+ Layout::Base.load_format(data_file('layout_text1'))
15
+
16
+ assert_raises Thinreports::Errors::LayoutFileNotFound do
17
+ Layout::Base.load_format 'unknown.tlf'
53
18
  end
54
-
55
- assert_same Layout::Page.superclass, ThinReports::Core::Page
56
- assert Layout::Page.method_defined?(:foo)
57
-
58
- # Teardown
59
- ThinReports::Layout::Base.send(:remove_const, :Page)
60
19
  end
61
-
62
- def test_initialize_with_specified_id
63
- layout = init_layout(:id => :foo)
64
- assert_equal layout.id, :foo
20
+
21
+ def test_new
22
+ layout = create_layout id: 'foo'
23
+
24
+ assert_equal 'foo', layout.id
25
+ assert_equal data_file('layout_text1.tlf'), layout.filename
65
26
  end
66
-
27
+
67
28
  def test_default?
68
- assert_equal init_layout.default?, true
69
- assert_equal init_layout(:id => :foo).default?, false
29
+ assert_equal false, create_layout(id: 'foo').default?
30
+ assert_equal true, create_layout.default?
70
31
  end
71
-
32
+
72
33
  def test_config
73
- layout = init_layout
74
- assert_instance_of ThinReports::Layout::Configuration, layout.config
34
+ assert_instance_of Thinreports::Layout::Configuration,
35
+ create_layout.config
75
36
  end
76
-
77
- def test_init_new_page
78
- parent = flexmock('parent')
79
- layout = init_layout
80
-
81
- # Should call ThinReports::Core::Page#new with parent and layout.
82
- flexmock(ThinReports::Core::Page).
83
- should_receive(:new).with(parent, layout, {}).once
84
-
85
- layout.init_new_page(parent)
37
+
38
+ def test_new_page
39
+ report = new_report 'layout_text1'
40
+ assert_instance_of Thinreports::Report::Page,
41
+ create_layout.new_page(report)
86
42
  end
87
-
88
- def init_layout(options = {})
89
- flexmock(Layout).should_receive(:load_format => flexmock('format'))
90
- Layout.new('dummy.tlf', options)
43
+
44
+ def create_layout(options = {})
45
+ Layout::Base.new data_file('layout_text1.tlf'), options
91
46
  end
92
- end
47
+ end
@@ -1,46 +1,21 @@
1
1
  # coding: utf-8
2
2
 
3
- require 'test/unit/helper'
3
+ require 'test_helper'
4
+
5
+ class Thinreports::Layout::TestConfiguration < Minitest::Test
6
+ include Thinreports::TestHelper
4
7
 
5
- class ThinReports::Layout::TestConfiguration < MiniTest::Unit::TestCase
6
- include ThinReports::TestHelpers
7
-
8
8
  # Alias
9
- Configuration = ThinReports::Layout::Configuration
10
-
9
+ Configuration = Thinreports::Layout::Configuration
10
+
11
11
  def setup
12
- layout = flexmock('layout')
13
- flexmock(layout).should_receive(:format => flexmock('layout_format'))
14
-
12
+ layout = Thinreports::Layout.new data_file('layout_text1.tlf')
15
13
  @config = Configuration.new(layout)
16
14
  end
17
-
18
- def test_undef_items_method
19
- refute_respond_to @config, :items
20
- end
21
-
22
- def test_undef_values_method
23
- refute_respond_to @config, :values
24
- end
25
-
26
- def test_properly_set_init_item_handler
27
- list_format = flexmock('list_format').should_receive(:type => 's-list').once.mock
28
- list_config = flexmock('list_config').should_receive(:new).once.mock
29
-
30
- flexmock(ThinReports::Core::Shape).
31
- should_receive(:Configuration).with('s-list').and_return(list_config).once
32
-
33
- @config.manager.init_item(list_format)
34
- end
35
-
36
- def test_activate
37
- list_config = flexmock('list_config').should_receive(:copy).once.mock
38
- @config.manager.shapes[:foo] = list_config
39
15
 
40
- @config.activate(:foo)
41
- end
42
-
43
- def test_activate_return_nil_when_unknown_shape_id
44
- assert_nil @config.activate(:unknown)
16
+ def test_disable_methods
17
+ assert_raises NoMethodError do
18
+ @config.values
19
+ end
45
20
  end
46
- end
21
+ end
@@ -1,10 +1,10 @@
1
1
  # coding: utf-8
2
2
 
3
- require 'test/unit/helper'
3
+ require 'test_helper'
4
+
5
+ class Thinreports::Layout::TestFormat < Minitest::Test
6
+ include Thinreports::TestHelper
4
7
 
5
- class ThinReports::Layout::TestFormat < MiniTest::Unit::TestCase
6
- include ThinReports::TestHelpers
7
-
8
8
  TEST_SIMPLE_FORMAT = <<-'EOF'
9
9
  {
10
10
  "version":"%s",
@@ -32,92 +32,89 @@ class ThinReports::Layout::TestFormat < MiniTest::Unit::TestCase
32
32
  }
33
33
  }
34
34
  EOF
35
-
35
+
36
36
  # Alias
37
- Shape = ThinReports::Core::Shape
38
- Layout = ThinReports::Layout
39
-
37
+ Shape = Thinreports::Core::Shape
38
+ Layout = Thinreports::Layout
39
+
40
40
  def test_report_title_should_return_the_value_of_config_title_key
41
41
  format = Layout::Format.new('config' => {'title' => 'Title'})
42
42
  assert_equal format.report_title, 'Title'
43
43
  end
44
-
44
+
45
45
  def test_user_paper_type_asker_should_return_true_when_paper_type_is_user
46
46
  format = Layout::Format.new('config' => {'page' => {'paper-type' => 'user'}})
47
47
  assert_equal format.user_paper_type?, true
48
48
  end
49
-
49
+
50
50
  def test_user_paper_type_asker_should_return_false_when_paper_type_is_not_user
51
51
  format = Layout::Format.new('config' => {'page' => {'paper-type' => 'A4'}})
52
52
  assert_equal format.user_paper_type?, false
53
53
  end
54
-
54
+
55
55
  def test_last_version_should_return_the_value_of_version_key
56
56
  format = Layout::Format.new('version' => '1.0')
57
57
  assert_equal format.last_version, '1.0'
58
58
  end
59
-
59
+
60
60
  def test_build_should_properly_build_layout_format
61
- build_format(:force => true)
61
+ build_format(force: true)
62
62
  rescue => e
63
63
  flunk exception_details(e, 'Faile to build.')
64
64
  end
65
-
65
+
66
66
  def test_build_should_properly_set_built_shapes_to_shapes_attributes_of_format
67
67
  assert_equal build_format.shapes.size, 4
68
68
  end
69
-
69
+
70
70
  def test_config_attributes_of_built_format_should_not_have_unnecessary_attributes
71
- format = build_format(:force => true)
71
+ format = build_format(force: true)
72
72
  config = format.instance_variable_get(:@config)
73
-
73
+
74
74
  refute %w( version finger-print state).any? {|a| config.key?(a)},
75
75
  'A config attributes of built format have unnecessary attributes.'
76
76
  end
77
-
77
+
78
78
  def test_identifier_should_return_the_digest_value_of_the_raw_layout_using_sha1
79
79
  format = build_format
80
80
  expect = Digest::SHA1.hexdigest(create_raw_format)
81
-
81
+
82
82
  assert_equal format.identifier, expect.to_sym
83
83
  ensure
84
- clear_building_cache
84
+ clear_cache_for_building
85
85
  end
86
-
86
+
87
87
  def test_build_should_always_return_the_same_result_in_cache_mode
88
88
  result1 = build_format
89
89
  result2 = build_format
90
-
90
+
91
91
  assert_same result1, result2
92
92
  ensure
93
- clear_building_cache
93
+ clear_cache_for_building
94
94
  end
95
-
95
+
96
96
  def test_build_should_raise_when_layout_file_is_incompatible
97
97
  original_rules = Layout::Version::REQUIRED_RULES.dup
98
98
  Layout::Version::REQUIRED_RULES.replace(['>= 0.6.0.pre3', '< 0.8.0'])
99
-
100
- assert_raises ThinReports::Errors::IncompatibleLayoutFormat do
101
- build_format(:version => '0.6.0.pre2')
99
+
100
+ assert_raises Thinreports::Errors::IncompatibleLayoutFormat do
101
+ build_format(version: '0.6.0.pre2')
102
102
  end
103
103
  ensure
104
104
  Layout::Version::REQUIRED_RULES.replace(original_rules)
105
- clear_building_cache
105
+ clear_cache_for_building
106
106
  end
107
-
107
+
108
108
  def create_raw_format(version = nil)
109
- clean_whitespaces(TEST_SIMPLE_FORMAT) % (version || ThinReports::VERSION)
109
+ clean_whitespaces(TEST_SIMPLE_FORMAT) % (version || Thinreports::VERSION)
110
110
  end
111
-
111
+
112
112
  def build_format(options = {})
113
- flexmock(Layout::Format).
114
- should_receive(:read_format_file).
115
- and_return(create_raw_format(options[:version]))
116
-
117
- Layout::Format.build('dummy.tlf', :force => options[:force])
113
+ Layout::Format.stubs(read_format_file: create_raw_format(options[:version]))
114
+ Layout::Format.build('dummy.tlf', force: options[:force])
118
115
  end
119
-
120
- def clear_building_cache
116
+
117
+ def clear_cache_for_building
121
118
  Layout::Format.send(:built_format_registry).clear
122
119
  end
123
- end
120
+ end
@@ -1,12 +1,12 @@
1
1
  # coding: utf-8
2
2
 
3
- require 'test/unit/helper'
3
+ require 'test_helper'
4
4
 
5
- class ThinReports::Layout::TestVersion < MiniTest::Unit::TestCase
6
- include ThinReports::TestHelpers
5
+ class Thinreports::Layout::TestVersion < Minitest::Test
6
+ include Thinreports::TestHelper
7
7
 
8
8
  # Alias
9
- Version = ThinReports::Layout::Version
9
+ Version = Thinreports::Layout::Version
10
10
 
11
11
  def test_comparable_version_should_add_99_when_the_given_version_is_not_PRE
12
12
  assert_equal Version.comparable_version('0.7.0'), '0.7.0.99'
@@ -1,76 +1,91 @@
1
1
  # coding: utf-8
2
2
 
3
- require 'test/unit/helper'
3
+ require 'test_helper'
4
+
5
+ class Thinreports::Report::TestBase < Minitest::Test
6
+ include Thinreports::TestHelper
4
7
 
5
- class ThinReports::Report::TestBase < MiniTest::Unit::TestCase
6
- include ThinReports::TestHelpers
7
-
8
8
  # Alias
9
- Report = ThinReports::Report
10
-
9
+ Report = Thinreports::Report
10
+
11
11
  def setup
12
12
  @report = Report::Base.new
13
13
  end
14
-
14
+
15
+ def test_on_page_create_callback
16
+ report = Report::Base.new layout: data_file('layout_text1.tlf')
17
+
18
+ counter = 0
19
+ callback = -> page {
20
+ assert_instance_of Report::Page, page
21
+ counter += 1
22
+ }
23
+
24
+ report.on_page_create(&callback)
25
+
26
+ 2.times { report.start_new_page }
27
+ assert_equal counter, 2
28
+ end
29
+
15
30
  def test_initialize_should_register_layout_as_default_when_layout_is_specified_as_the_option
16
- report = Report::Base.new :layout => data_file('basic_layout1.tlf')
17
- assert_equal report.default_layout.filename, data_file('basic_layout1.tlf')
31
+ report = Report::Base.new layout: data_file('layout_text1.tlf')
32
+ assert_equal report.default_layout.filename, data_file('layout_text1.tlf')
18
33
  end
19
-
34
+
20
35
  def test_initialize_should_initialize_new_Report_without_default_layout
21
36
  assert_nil @report.default_layout
22
37
  end
23
-
38
+
24
39
  def test_use_layout_should_register_default_layout_when_default_property_is_omitted
25
- @report.use_layout(data_file('basic_layout1.tlf'))
26
-
27
- assert_equal @report.default_layout.filename, data_file('basic_layout1.tlf')
40
+ @report.use_layout(data_file('layout_text1.tlf'))
41
+
42
+ assert_equal @report.default_layout.filename, data_file('layout_text1.tlf')
28
43
  end
29
-
44
+
30
45
  def test_use_layout_should_register_default_layout_when_default_property_is_true
31
- @report.use_layout(data_file('basic_layout2.tlf'), :default => true)
32
-
33
- assert_equal @report.default_layout.filename, data_file('basic_layout2.tlf')
46
+ @report.use_layout(data_file('layout_text2.tlf'), default: true)
47
+
48
+ assert_equal @report.default_layout.filename, data_file('layout_text2.tlf')
34
49
  end
35
-
50
+
36
51
  def test_start_new_page_should_properly_create_a_new_Page_and_return
37
- @report.use_layout(data_file('basic_layout1'))
38
-
39
- assert_instance_of ThinReports::Core::Page, @report.start_new_page
52
+ @report.use_layout(data_file('layout_text1'))
53
+
54
+ assert_instance_of Thinreports::Report::Page, @report.start_new_page
40
55
  end
41
-
56
+
42
57
  def test_start_new_page_should_raise_when_the_layout_has_not_been_registered_yet
43
- assert_raises ThinReports::Errors::NoRegisteredLayoutFound do
44
- @report.start_new_page(:layout => :unknown)
58
+ assert_raises Thinreports::Errors::NoRegisteredLayoutFound do
59
+ @report.start_new_page(layout: :unknown)
45
60
  end
46
61
  end
47
-
62
+
48
63
  def test_start_new_page_should_create_a_new_page_using_a_default_layout
49
- @report.use_layout(data_file('basic_layout1.tlf'), :default => true)
50
-
51
- assert_equal @report.start_new_page.layout.filename, data_file('basic_layout1.tlf')
64
+ @report.use_layout(data_file('layout_text1.tlf'), default: true)
65
+
66
+ assert_equal @report.start_new_page.layout.filename, data_file('layout_text1.tlf')
52
67
  end
53
-
68
+
54
69
  def test_start_new_page_should_create_a_new_page_using_a_layout_with_specified_id
55
- @report.use_layout(data_file('basic_layout1.tlf'), :id => :foo)
56
-
57
- assert_equal @report.start_new_page(:layout => :foo).layout.filename,
58
- data_file('basic_layout1.tlf')
70
+ @report.use_layout(data_file('layout_text1.tlf'), id: :foo)
71
+
72
+ assert_equal @report.start_new_page(layout: :foo).layout.filename,
73
+ data_file('layout_text1.tlf')
59
74
  end
60
-
75
+
61
76
  def test_start_new_page_should_create_a_new_page_using_a_specified_layoutfile
62
- new_page = @report.start_new_page(:layout => data_file('basic_layout1.tlf'))
63
- assert_equal new_page.layout.filename, data_file('basic_layout1.tlf')
77
+ new_page = @report.start_new_page(layout: data_file('layout_text1.tlf'))
78
+ assert_equal new_page.layout.filename, data_file('layout_text1.tlf')
64
79
  end
65
80
 
66
81
  def test_start_new_page_with_count_option
67
- @report.use_layout data_file('basic_layout1.tlf'), :default => true
82
+ @report.use_layout data_file('layout_text1.tlf'), default: true
68
83
 
69
- new_page = @report.start_new_page :count => false
84
+ new_page = @report.start_new_page count: false
70
85
  assert_nil new_page.no
71
86
  assert_equal @report.page_count, 0
72
87
 
73
- new_page = @report.start_new_page :count => true
88
+ new_page = @report.start_new_page count: true
74
89
  assert_equal new_page.no, 1
75
90
  assert_equal @report.page_count, 1
76
91
 
@@ -78,144 +93,104 @@ class ThinReports::Report::TestBase < MiniTest::Unit::TestCase
78
93
  assert_equal new_page.no, 2
79
94
  assert_equal @report.page_count, 2
80
95
  end
81
-
96
+
82
97
  def test_add_blank_page_should_properly_create_a_new_blank_page
83
- @report.use_layout(data_file('basic_layout1'))
84
-
85
- assert_instance_of ThinReports::Core::BlankPage, @report.add_blank_page
98
+ @report.use_layout(data_file('layout_text1'))
99
+
100
+ assert_instance_of Thinreports::Report::BlankPage, @report.add_blank_page
86
101
  end
87
-
102
+
88
103
  def test_layout_should_return_the_default_layout_with_no_arguments
89
- @report.use_layout(data_file('basic_layout1.tlf'), :default => true)
90
-
91
- assert_equal @report.layout.filename, data_file('basic_layout1.tlf')
104
+ @report.use_layout(data_file('layout_text1.tlf'), default: true)
105
+
106
+ assert_equal @report.layout.filename, data_file('layout_text1.tlf')
92
107
  end
93
-
108
+
94
109
  def test_layout_should_raise_when_the_specified_layout_is_not_found
95
- assert_raises ThinReports::Errors::UnknownLayoutId do
110
+ assert_raises Thinreports::Errors::UnknownLayoutId do
96
111
  @report.layout(:unknown_layout_id)
97
112
  end
98
113
  end
99
-
114
+
100
115
  def test_layout_should_return_the_layout_with_specified_id
101
- @report.use_layout(data_file('basic_layout2.tlf'), :id => :foo)
102
-
103
- assert_equal @report.layout(:foo).filename, data_file('basic_layout2.tlf')
104
- end
105
-
106
- def test_generate_should_properly_initialize_Generator_and_call_generate_method_when_type_is_specified
107
- flexmock(ThinReports::Generator).
108
- should_receive(:new).
109
- with(:pdf, @report, {:option => :value}).
110
- and_return(flexmock(:generate => 'Success')).once
111
-
112
- assert_equal @report.generate(:pdf, :option => :value), 'Success'
113
- end
114
-
115
- def test_generate_should_properly_initialize_Generator_and_call_generate_method_when_type_is_omitted
116
- flexmock(ThinReports::Generator).
117
- should_receive(:new).
118
- with(:pdf, @report, {:option => :value}).
119
- and_return(flexmock(:generate => 'Success')).once
120
-
121
- assert_equal @report.generate(:option => :value), 'Success'
116
+ @report.use_layout(data_file('layout_text2.tlf'), id: :foo)
117
+
118
+ assert_equal @report.layout(:foo).filename, data_file('layout_text2.tlf')
122
119
  end
123
120
 
124
- def test_generate_should_call_generate_file_method_when_filename_option_is_given
125
- flexmock(ThinReports::Generator).
126
- should_receive(:new).
127
- with(:pdf, @report, {}).
128
- and_return(flexmock(:generate_file => 'Success')).once
121
+ def test_generate_with_filename
122
+ report = Report::Base.new layout: data_file('layout_text1.tlf')
129
123
 
130
- assert_equal @report.generate(:filename => 'foo.pdf'), 'Success'
124
+ report.generate :pdf, filename: temp_path.join('result1.pdf')
125
+ report.generate filename: temp_path.join('result2.pdf')
126
+
127
+ assert File.exists?(temp_path.join('result1.pdf'))
128
+ assert File.exists?(temp_path.join('result2.pdf'))
129
+
130
+ assert_equal File.read(temp_path.join('result1.pdf')),
131
+ File.read(temp_path.join('result2.pdf'))
131
132
  end
132
133
 
133
- def test_generate_file_should_warn_the_DEPRECATION_WARNING
134
- report = create_basic_report('basic_layout1')
134
+ def test_events_should_return_Report_Events
135
+ assert_instance_of Thinreports::Report::Events, @report.events
136
+ end
135
137
 
138
+ def test_events_should_deprecated
136
139
  out, err = capture_io do
137
- report.generate_file(temp_file)
140
+ @report.events
138
141
  end
139
- assert_match /DEPRECATION/, err
140
- end
141
-
142
- def test_generate_file_should_properly_initialize_Generator_and_call_generate_file_method_when_type_is_specified
143
- generator = flexmock('generator')
144
- generator.should_receive(:generate_file).with('output.pdf').once
145
-
146
- flexmock(ThinReports::Generator).
147
- should_receive(:new).
148
- with(:pdf, @report, {}).
149
- and_return(generator).once
150
-
151
- @report.generate_file(:pdf, 'output.pdf')
152
- end
153
-
154
- def test_generate_file_should_properly_initialize_Generator_and_call_generate_file_method_when_type_is_omitted
155
- generator = flexmock('generator')
156
- generator.should_receive(:generate_file).with('output.pdf').once
157
-
158
- flexmock(ThinReports::Generator).
159
- should_receive(:new).
160
- with(:pdf, @report, {:option => :value}).
161
- and_return(generator).once
162
-
163
- @report.generate_file('output.pdf', :option => :value)
164
- end
165
-
166
- def test_events_should_return_Report_Events
167
- assert_instance_of ThinReports::Report::Events, @report.events
142
+ assert_includes err, '[DEPRECATION]'
168
143
  end
169
-
144
+
170
145
  def test_page_should_return_the_current_page
171
- @report.use_layout(data_file('basic_layout1.tlf'))
146
+ @report.use_layout(data_file('layout_text1.tlf'))
172
147
  @report.start_new_page
173
-
174
- assert_instance_of ThinReports::Core::Page, @report.page
148
+
149
+ assert_instance_of Thinreports::Report::Page, @report.page
175
150
  end
176
-
151
+
177
152
  def test_page_count_should_return_total_page_count
178
- @report.use_layout(data_file('basic_layout1.tlf'))
153
+ @report.use_layout(data_file('layout_text1.tlf'))
179
154
  2.times { @report.start_new_page }
180
-
155
+
181
156
  assert_equal @report.page_count, 2
182
157
  end
183
-
158
+
184
159
  def test_finalize_should_finalize_report
185
160
  @report.finalize
186
161
  assert_equal @report.finalized?, true
187
162
  end
188
-
163
+
189
164
  def test_finalized_asker_should_return_false_when_report_has_not_been_finalized_yet
190
165
  assert_equal @report.finalized?, false
191
166
  end
192
-
167
+
193
168
  def test_finalized_asker_should_return_true_when_report_is_already_finalized
194
169
  @report.finalize
195
170
  assert_equal @report.finalized?, true
196
171
  end
197
-
172
+
198
173
  def test_list_should_create_new_page_when_page_is_not_created
199
- @report.use_layout(data_file('basic_list_layout.tlf'))
174
+ @report.use_layout(data_file('layout_list.tlf'))
200
175
  @report.list(:list)
201
-
176
+
202
177
  refute_nil @report.page
203
178
  end
204
-
179
+
205
180
  def test_list_should_create_new_page_when_page_is_finalized
206
181
  @report.tap do |r|
207
- r.use_layout(data_file('basic_list_layout.tlf'))
182
+ r.use_layout(data_file('layout_list.tlf'))
208
183
  r.start_new_page
209
184
  r.page.finalize
210
185
  end
211
186
  @report.list(:list)
212
-
187
+
213
188
  assert_equal @report.page.finalized?, false
214
189
  end
215
-
190
+
216
191
  def test_list_should_properly_return_shape_with_the_specified_id
217
- @report.use_layout(data_file('basic_list_layout.tlf'))
218
-
192
+ @report.use_layout(data_file('layout_list.tlf'))
193
+
219
194
  assert_equal @report.list(:list).id, 'list'
220
195
  end
221
196
 
@@ -224,130 +199,76 @@ class ThinReports::Report::TestBase < MiniTest::Unit::TestCase
224
199
  @report.start_page_number_from 10
225
200
  assert_equal @report.start_page_number, 10
226
201
  end
227
-
202
+
228
203
  def test_Base_create_should_finalize_report
229
204
  report = Report::Base.create do |r|
230
205
  assert_instance_of Report::Base, r
231
206
  end
232
207
  assert_equal report.finalized?, true
233
208
  end
234
-
209
+
235
210
  def test_Base_create_should_raise_when_no_block_given
236
211
  assert_raises ArgumentError do
237
212
  Report::Base.create
238
213
  end
239
214
  end
240
-
241
- def test_Base_generate_should_properly_generate_when_type_is_specified
242
- flexmock(Report::Base).new_instances.
243
- should_receive(:generate).
244
- with(:pdf, :option => :value).once
245
-
246
- flexmock(Report::Base).
247
- should_receive(:create).
248
- with({:layout => 'layout.tlf'}, Proc).
249
- and_return(Report::Base.new).once
250
-
251
- Report::Base.generate(:pdf, :report => {:layout => 'layout.tlf'},
252
- :generator => {:option => :value}) {}
253
- end
254
-
255
- def test_Base_generate_should_properly_generate_when_type_is_omitted
256
- flexmock(Report::Base).new_instances.
257
- should_receive(:generate).
258
- with({}).once
259
-
260
- flexmock(Report::Base).
261
- should_receive(:create).
262
- with({}, Proc).
263
- and_return(Report::Base.new).once
264
-
265
- Report::Base.generate {}
266
- end
267
-
268
- def test_Base_generate_file_should_properly_generate_file_when_type_is_specified
269
- flexmock(Report::Base).new_instances.
270
- should_receive(:generate_file).
271
- with(:pdf, 'output.pdf', {}).once
272
-
273
- flexmock(Report::Base).
274
- should_receive(:create).
275
- with({:layout => 'layout.tlf'}, Proc).
276
- and_return(Report::Base.new).once
277
-
278
- Report::Base.generate_file(:pdf, 'output.pdf', :report => {:layout => 'layout.tlf'}) {}
279
- end
280
-
281
- def test_Base_generate_file_should_warn_the_DEPRICATION_WARNING
282
- out, err = capture_io do
283
- Report.generate_file(temp_file, :report => {:layout => data_file('basic_layout1')}) { start_new_page }
284
- end
285
- assert_match /DEPRECATION/, err
286
- end
287
-
288
- def test_Base_generate_file_should_properly_generate_file_when_type_is_omitted
289
- flexmock(Report::Base).new_instances.
290
- should_receive(:generate_file).
291
- with('output.pdf', :option => :value).once
292
-
293
- flexmock(Report::Base).
294
- should_receive(:create).
295
- with({}, Proc).
296
- and_return(Report::Base.new).once
297
-
298
- Report::Base.generate_file('output.pdf', :generator => {:option => :value}) {}
299
- end
300
-
215
+
216
+ def test_Base_generate_with_filename
217
+ layout_file = data_file 'layout_text1.tlf'
218
+
219
+ Report::Base.generate(:pdf, report: { layout: layout_file },
220
+ generator: { filename: temp_path.join('result1.pdf') }) {}
221
+ Report::Base.generate(report: { layout: layout_file },
222
+ generator: { filename: temp_path.join('result2.pdf') }) {}
223
+
224
+ assert_equal temp_path.join('result1.pdf').read,
225
+ temp_path.join('result2.pdf').read
226
+ end
227
+
301
228
  def test_Base_generate_should_raise_when_no_block_given
302
229
  assert_raises ArgumentError do
303
230
  Report::Base.generate(:pdf)
304
231
  end
305
232
  end
306
-
307
- def test_Base_generate_file_should_raise_when_no_block_given
308
- assert_raises ArgumentError do
309
- Report::Base.generate_file(:pdf, 'output.pdf')
310
- end
311
- end
312
-
233
+
313
234
  def test_Base_extract_options_should_return_as_report_option_the_value_which_has_report_in_a_key
314
- report, generator = Report::Base.send(:extract_options!, [{:report => {:layout => 'hoge.tlf'}}])
235
+ report, generator = Report::Base.send(:extract_options!, [{report: {layout: 'hoge.tlf'}}])
315
236
  assert_equal report[:layout], 'hoge.tlf'
316
237
  end
317
-
238
+
318
239
  def test_Base_extract_options_should_operate_an_argument_destructively
319
- args = [:pdf, 'output.pdf', {:report => {:layout => 'foo.tlf'}}]
240
+ args = [:pdf, 'output.pdf', {report: {layout: 'foo.tlf'}}]
320
241
  Report::Base.send(:extract_options!, args)
321
242
  assert_equal args, [:pdf, 'output.pdf']
322
243
  end
323
-
244
+
324
245
  def test_Base_extract_options_should_include_the_layout_key_in_the_report_option
325
- report, generator = Report::Base.send(:extract_options!, [{:layout => 'hoge.tlf'}])
246
+ report, generator = Report::Base.send(:extract_options!, [{layout: 'hoge.tlf'}])
326
247
  assert_equal report[:layout], 'hoge.tlf'
327
248
  end
328
-
249
+
329
250
  def test_Base_extract_options_should_give_priority_to_the_value_of_the_layout_key_over_in_the_report_option
330
251
  report, generator = Report::Base.send(:extract_options!,
331
- [{:report => {:layout => 'foo.tlf'}, :layout => 'hoge.tlf'}])
252
+ [{report: {layout: 'foo.tlf'}, layout: 'hoge.tlf'}])
332
253
  assert_equal report[:layout], 'hoge.tlf'
333
254
  end
334
-
255
+
335
256
  def test_Base_extract_options_should_return_as_generator_option_the_value_which_has_generator_in_a_key
336
257
  report, generator = Report::Base.send(:extract_options!,
337
- [{:generator => {:option => 'value'}}])
258
+ [{generator: {option: 'value'}}])
338
259
  assert_equal generator[:option], 'value'
339
260
  end
340
-
261
+
341
262
  def test_Base_extract_options_should_give_priority_to_the_value_of_other_keys_over_in_the_generator_option
342
263
  report, generator = Report::Base.send(:extract_options!,
343
- [{:generator => {:option => 'value1'}, :option => 'value2'}])
264
+ [{generator: {option: 'value1'}, option: 'value2'}])
344
265
  assert_equal generator[:option], 'value2'
345
266
  end
346
-
267
+
347
268
  def test_Base_extract_options_should_return_all_the_values_except_the_report_option_as_a_generator_option
348
269
  report, generator = Report::Base.send(:extract_options!,
349
- [{:report => {:layout => 'foo.tlf'}, :layout => 'hoge.tlf',
350
- :generator_opt1 => 'value1', :generator_opt2 => 'value2'}])
270
+ [{report: {layout: 'foo.tlf'}, layout: 'hoge.tlf',
271
+ generator_opt1: 'value1', generator_opt2: 'value2'}])
351
272
  assert_equal generator.values_at(:generator_opt1, :generator_opt2),
352
273
  ['value1', 'value2']
353
274
  end