thinreports 0.10.3 → 0.11.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 (150) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/test.yml +39 -0
  3. data/CHANGELOG.md +20 -0
  4. data/Dockerfile +12 -0
  5. data/Gemfile +5 -0
  6. data/README.md +37 -13
  7. data/Rakefile +1 -0
  8. data/lib/thinreports/core/shape/image_block.rb +1 -1
  9. data/lib/thinreports/core/shape/list.rb +1 -1
  10. data/lib/thinreports/core/shape/page_number.rb +1 -1
  11. data/lib/thinreports/core/shape/text.rb +1 -1
  12. data/lib/thinreports/core/shape/text_block.rb +1 -1
  13. data/lib/thinreports/core/shape/text_block/formatter/number.rb +6 -1
  14. data/lib/thinreports/core/shape/text_block/internal.rb +0 -2
  15. data/lib/thinreports/generator/pdf/prawn_ext/width_of.rb +6 -0
  16. data/lib/thinreports/layout/base.rb +1 -1
  17. data/lib/thinreports/layout/version.rb +1 -1
  18. data/lib/thinreports/report/internal.rb +2 -0
  19. data/lib/thinreports/version.rb +1 -1
  20. data/thinreports.gemspec +5 -9
  21. metadata +6 -204
  22. data/.travis.yml +0 -32
  23. data/test/data/font.ttf +0 -0
  24. data/test/data/image_normal.jpg +0 -0
  25. data/test/data/image_normal.png +0 -0
  26. data/test/data/image_normal_jpg_noext +0 -0
  27. data/test/data/image_normal_png_noext +0 -0
  28. data/test/data/image_pallete_based.png +0 -0
  29. data/test/data/legacy_layout/all-items.tlf +0 -1
  30. data/test/features/dynamic_style/expect.pdf +0 -3714
  31. data/test/features/dynamic_style/image.png +0 -0
  32. data/test/features/dynamic_style/templates/styles.tlf +0 -1835
  33. data/test/features/dynamic_style/templates/styles_in_list.tlf +0 -344
  34. data/test/features/dynamic_style/test_dynamic_style.rb +0 -152
  35. data/test/features/eudc/eudc.ttf +0 -0
  36. data/test/features/eudc/expect.pdf +0 -0
  37. data/test/features/eudc/template.tlf +0 -180
  38. data/test/features/eudc/test_eudc.rb +0 -27
  39. data/test/features/feature_test.rb +0 -58
  40. data/test/features/graphics/expect.pdf +0 -475
  41. data/test/features/graphics/template.tlf +0 -309
  42. data/test/features/graphics/test_graphics.rb +0 -12
  43. data/test/features/hidden_item/expect.pdf +0 -0
  44. data/test/features/hidden_item/template.tlf +0 -449
  45. data/test/features/hidden_item/test_hidden_item.rb +0 -12
  46. data/test/features/image_block/expect.pdf +0 -0
  47. data/test/features/image_block/img200x100.png +0 -0
  48. data/test/features/image_block/img50x50.png +0 -0
  49. data/test/features/image_block/template.tlf +0 -661
  50. data/test/features/image_block/test_image_block.rb +0 -35
  51. data/test/features/list_events/expect.pdf +0 -659
  52. data/test/features/list_events/template.tlf +0 -361
  53. data/test/features/list_events/test_list_events.rb +0 -36
  54. data/test/features/list_manually/expect.pdf +0 -599
  55. data/test/features/list_manually/template.tlf +0 -132
  56. data/test/features/list_manually/test_list_manually.rb +0 -25
  57. data/test/features/page_number/expect.pdf +0 -400
  58. data/test/features/page_number/template.tlf +0 -215
  59. data/test/features/page_number/test_page_number.rb +0 -24
  60. data/test/features/page_number_with_list/expect.pdf +0 -721
  61. data/test/features/page_number_with_list/template.tlf +0 -254
  62. data/test/features/page_number_with_list/test_page_number_with_list.rb +0 -21
  63. data/test/features/palleted_png/expect.pdf +0 -0
  64. data/test/features/palleted_png/palleted_png.png +0 -0
  65. data/test/features/palleted_png/template.tlf +0 -47
  66. data/test/features/palleted_png/test_palleted_png.rb +0 -14
  67. data/test/features/report_callbacks/expect.pdf +0 -169
  68. data/test/features/report_callbacks/template.tlf +0 -147
  69. data/test/features/report_callbacks/test_report_callbacks.rb +0 -18
  70. data/test/features/text_align/expect.pdf +0 -0
  71. data/test/features/text_align/template.tlf +0 -241
  72. data/test/features/text_align/test_text_align.rb +0 -12
  73. data/test/features/text_block_overflow/expect.pdf +0 -0
  74. data/test/features/text_block_overflow/template.tlf +0 -538
  75. data/test/features/text_block_overflow/test_text_block_overflow.rb +0 -25
  76. data/test/features/text_block_singleline/expect.pdf +0 -0
  77. data/test/features/text_block_singleline/template.tlf +0 -170
  78. data/test/features/text_block_singleline/test_text_block_singleline.rb +0 -15
  79. data/test/features/text_block_style/expect.pdf +0 -1391
  80. data/test/features/text_block_style/templates/basic_styles.tlf +0 -889
  81. data/test/features/text_block_style/templates/font_size.tlf +0 -383
  82. data/test/features/text_block_style/test_text_block_style.rb +0 -47
  83. data/test/features/text_character_spacing/expect.pdf +0 -0
  84. data/test/features/text_character_spacing/template.tlf +0 -293
  85. data/test/features/text_character_spacing/test_text_character_spacing.rb +0 -12
  86. data/test/features/text_word_wrap/expect.pdf +0 -0
  87. data/test/features/text_word_wrap/template.tlf +0 -297
  88. data/test/features/text_word_wrap/test_text_word_wrap.rb +0 -30
  89. data/test/schema_helper.rb +0 -122
  90. data/test/test_helper.rb +0 -39
  91. data/test/units/core/format/test_base.rb +0 -152
  92. data/test/units/core/shape/base/test_internal.rb +0 -87
  93. data/test/units/core/shape/basic/test_block_format.rb +0 -23
  94. data/test/units/core/shape/basic/test_block_interface.rb +0 -29
  95. data/test/units/core/shape/basic/test_block_internal.rb +0 -55
  96. data/test/units/core/shape/basic/test_format.rb +0 -37
  97. data/test/units/core/shape/basic/test_interface.rb +0 -108
  98. data/test/units/core/shape/basic/test_internal.rb +0 -55
  99. data/test/units/core/shape/image_block/test_interface.rb +0 -24
  100. data/test/units/core/shape/image_block/test_internal.rb +0 -31
  101. data/test/units/core/shape/list/test_format.rb +0 -111
  102. data/test/units/core/shape/list/test_manager.rb +0 -67
  103. data/test/units/core/shape/list/test_page.rb +0 -156
  104. data/test/units/core/shape/list/test_page_state.rb +0 -31
  105. data/test/units/core/shape/list/test_section_format.rb +0 -36
  106. data/test/units/core/shape/list/test_section_interface.rb +0 -75
  107. data/test/units/core/shape/list/test_section_internal.rb +0 -50
  108. data/test/units/core/shape/manager/test_format.rb +0 -38
  109. data/test/units/core/shape/manager/test_internal.rb +0 -132
  110. data/test/units/core/shape/manager/test_target.rb +0 -140
  111. data/test/units/core/shape/page_number/test_format.rb +0 -55
  112. data/test/units/core/shape/page_number/test_interface.rb +0 -33
  113. data/test/units/core/shape/page_number/test_internal.rb +0 -81
  114. data/test/units/core/shape/styles/test_base.rb +0 -191
  115. data/test/units/core/shape/styles/test_basic.rb +0 -24
  116. data/test/units/core/shape/styles/test_graphic.rb +0 -50
  117. data/test/units/core/shape/styles/test_text.rb +0 -97
  118. data/test/units/core/shape/text/test_format.rb +0 -44
  119. data/test/units/core/shape/text/test_internal.rb +0 -20
  120. data/test/units/core/shape/text_block/formatter/test_basic.rb +0 -24
  121. data/test/units/core/shape/text_block/formatter/test_datetime.rb +0 -49
  122. data/test/units/core/shape/text_block/formatter/test_number.rb +0 -76
  123. data/test/units/core/shape/text_block/formatter/test_padding.rb +0 -77
  124. data/test/units/core/shape/text_block/test_format.rb +0 -169
  125. data/test/units/core/shape/text_block/test_formatter.rb +0 -28
  126. data/test/units/core/shape/text_block/test_interface.rb +0 -63
  127. data/test/units/core/shape/text_block/test_internal.rb +0 -128
  128. data/test/units/core/test_shape.rb +0 -52
  129. data/test/units/core/test_utils.rb +0 -68
  130. data/test/units/generator/pdf/document/graphics/test_attributes.rb +0 -135
  131. data/test/units/generator/pdf/document/graphics/test_basic.rb +0 -46
  132. data/test/units/generator/pdf/document/graphics/test_image.rb +0 -46
  133. data/test/units/generator/pdf/document/graphics/test_text.rb +0 -171
  134. data/test/units/generator/pdf/document/test_font.rb +0 -110
  135. data/test/units/generator/pdf/document/test_graphics.rb +0 -42
  136. data/test/units/generator/pdf/document/test_page.rb +0 -122
  137. data/test/units/generator/pdf/document/test_parse_color.rb +0 -30
  138. data/test/units/generator/pdf/prawn_ext/test_calc_image_dimensions.rb +0 -41
  139. data/test/units/generator/pdf/prawn_ext/test_width_of.rb +0 -22
  140. data/test/units/generator/pdf/test_document.rb +0 -22
  141. data/test/units/generator/test_pdf.rb +0 -26
  142. data/test/units/layout/test_base.rb +0 -41
  143. data/test/units/layout/test_format.rb +0 -100
  144. data/test/units/layout/test_legacy_schema.rb +0 -576
  145. data/test/units/layout/test_version.rb +0 -26
  146. data/test/units/report/test_base.rb +0 -248
  147. data/test/units/report/test_internal.rb +0 -206
  148. data/test/units/test_config.rb +0 -36
  149. data/test/units/test_layout.rb +0 -12
  150. data/test/units/test_report.rb +0 -18
@@ -1,31 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'test_helper'
4
-
5
- class Thinreports::Core::Shape::List::TestPageState < Minitest::Test
6
- include Thinreports::TestHelper
7
-
8
- # Alias
9
- List = Thinreports::Core::Shape::List
10
-
11
- def setup
12
- parent = mock('parent')
13
- format = mock('format')
14
-
15
- @state = List::PageState.new(parent, format)
16
- end
17
-
18
- def test_alias_class
19
- assert_same List::PageState, List::Internal
20
- end
21
-
22
- def test_type_of?
23
- assert_equal @state.type_of?('list'), true
24
- end
25
-
26
- def test_finalized!
27
- assert_equal @state.finalized?, false
28
- @state.finalized!
29
- assert_equal @state.finalized?, true
30
- end
31
- end
@@ -1,36 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'test_helper'
4
-
5
- class Thinreports::Core::Shape::List::TestSectionFormat < Minitest::Test
6
- include Thinreports::TestHelper
7
-
8
- LIST_SECTION_FORMAT = {
9
- 'enabled' => true,
10
- 'height' => 47.7,
11
- 'translate' => { 'x' => 0, 'y' => -64.2 },
12
- 'items' => [
13
- { 'type' => 'rect', 'id' => '' },
14
- { 'type' => 'text-block', 'id' => 'text_block' }
15
- ]
16
- }
17
-
18
- Shape = Thinreports::Core::Shape
19
- List = Thinreports::Core::Shape::List
20
-
21
- def test_attribute_readers
22
- format = List::SectionFormat.new(LIST_SECTION_FORMAT)
23
-
24
- assert_equal 47.7, format.height
25
- assert_equal 0, format.relative_left
26
- assert_equal(-64.2, format.relative_top)
27
- assert_equal true, format.display?
28
- end
29
-
30
- def test_initialize_items
31
- format = List::SectionFormat.new(LIST_SECTION_FORMAT)
32
-
33
- assert_equal 1, format.shapes.count
34
- assert_instance_of Shape::TextBlock::Format, format.shapes[:text_block]
35
- end
36
- end
@@ -1,75 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'test_helper'
4
-
5
- class Thinreports::Core::Shape::List::TestSectionInterface < Minitest::Test
6
- include Thinreports::TestHelper
7
-
8
- BASIC_SECTION_SCHEMA = {
9
- 'height' => 1.0,
10
- 'enabled' => true,
11
- 'items' => []
12
- }
13
-
14
- # Alias
15
- List = Thinreports::Core::Shape::List
16
-
17
- def setup
18
- @report = Thinreports::Report.new layout: layout_file.path
19
- end
20
-
21
- def create_interface(extra_section_schema = {})
22
- parent = @report.start_new_page
23
-
24
- List::SectionInterface.new(
25
- parent,
26
- List::SectionFormat.new(BASIC_SECTION_SCHEMA.merge(extra_section_schema)),
27
- :section
28
- )
29
- end
30
-
31
- def test_internal_should_return_instance_of_SectionInternal
32
- assert_instance_of List::SectionInternal, create_interface.internal
33
- end
34
-
35
- def test_initialize_should_properly_set_the_specified_section_name_to_internal
36
- assert_equal create_interface.internal.section_name, :section
37
- end
38
-
39
- def test_initialize_should_properly_initialize_manager
40
- assert_instance_of Thinreports::Core::Shape::Manager::Internal,
41
- create_interface.manager
42
- end
43
-
44
- def test_height_should_operate_as_delegator_of_internal
45
- list = create_interface('height' => 100)
46
- assert_same list.height, list.internal.height
47
- end
48
-
49
- def test_copied_interface_should_succeed_an_section_name_of_original
50
- list = create_interface
51
- new_parent = @report.start_new_page
52
-
53
- assert_same list.copy(new_parent).internal.section_name,
54
- list.internal.section_name
55
- end
56
-
57
- def test_copied_interface_should_have_all_the_copies_of_Shape_which_original_holds
58
- list = create_interface
59
- copied_list(list) do |new_list|
60
- assert_equal new_list.manager.shapes.size, 3
61
- end
62
- end
63
-
64
- def copied_list(list, &block)
65
- tblock = Thinreports::Core::Shape::TextBlock
66
- new_parent = @report.start_new_page
67
-
68
- %w( foo bar hoge ).each do |id|
69
- list.manager.format.shapes[id.to_sym] = tblock::Format.new('type' => 'text-block', 'id' => id)
70
- list.item(id).value(10)
71
- end
72
-
73
- block.call(list.copy(new_parent))
74
- end
75
- end
@@ -1,50 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'test_helper'
4
-
5
- class Thinreports::Core::Shape::List::TestSectionInternal < Minitest::Test
6
- include Thinreports::TestHelper
7
-
8
- BASIC_SECTION_SCHEMA = {
9
- 'height' => 1.0,
10
- 'enabled' => true,
11
- 'items' => []
12
- }
13
-
14
- # Alias
15
- List = Thinreports::Core::Shape::List
16
-
17
- def create_internal(extra_section_schema = {})
18
- report = Thinreports::Report.new layout: layout_file.path
19
-
20
- List::SectionInternal.new(
21
- report,
22
- List::SectionFormat.new(BASIC_SECTION_SCHEMA.merge(extra_section_schema))
23
- )
24
- end
25
-
26
- def test_height_should_operate_as_delegator_of_format
27
- list = create_internal('height' => 100)
28
- assert_same list.height, list.format.height
29
- end
30
-
31
- def test_relative_left_should_operate_as_delegator_of_format
32
- list = create_internal('translate' => {'x' => 10})
33
- assert_same list.relative_left, list.format.relative_left
34
- end
35
-
36
- def test_move_top_to_should_properly_set_value_to_states_as_relative_top
37
- list = create_internal
38
- list.move_top_to(200)
39
-
40
- assert_equal list.states[:relative_top], 200
41
- end
42
-
43
- def test_relative_top
44
- list = create_internal('translate' => { 'y' => 100 })
45
- assert_equal 0, list.relative_top
46
-
47
- list.move_top_to 50
48
- assert_equal 50, list.relative_top
49
- end
50
- end
@@ -1,38 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'test_helper'
4
-
5
- class Thinreports::Core::Shape::Manager::TestFormat < Minitest::Test
6
- include Thinreports::TestHelper
7
-
8
- class TestFormat < Thinreports::Core::Shape::Manager::Format; end
9
-
10
- def test_identifier_should_return_the_same_as_object_id_when_id_is_not_given
11
- format = TestFormat.new({})
12
- assert_equal format.identifier, format.object_id
13
- end
14
-
15
- def test_identifier_should_return_the_specified_id_when_id_is_given
16
- assert_equal TestFormat.new({}, :any_id).identifier, :any_id
17
- end
18
-
19
- def test_has_shape
20
- format = TestFormat.new({}) do |f|
21
- f.shapes[:foo] = 1
22
- end
23
- assert format.has_shape?(:foo)
24
- refute format.has_shape?(:unknown)
25
- end
26
-
27
- def test_find_shape_should_return_format_of_shape_when_shape_is_found
28
- format = TestFormat.new({}) do |f|
29
- f.shapes[:foo] = Thinreports::Core::Shape::TextBlock::Format.new('id' => 'foo',
30
- 'type' => 'text-block')
31
- end
32
- assert_equal format.find_shape(:foo).id, 'foo'
33
- end
34
-
35
- def test_find_shape_should_return_nil_when_shape_is_not_found
36
- assert_nil TestFormat.new({}).find_shape(:unknown)
37
- end
38
- end
@@ -1,132 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'test_helper'
4
-
5
- class Thinreports::Core::Shape::Manager::TestInternal < Minitest::Test
6
- include Thinreports::TestHelper
7
-
8
- # Alias
9
- Shape = Thinreports::Core::Shape
10
-
11
- def create_shape_format(type, id, other_config = {})
12
- Shape::Format(type).new({'id' => id,
13
- 'type' => type,
14
- 'display' => true}.merge(other_config))
15
- end
16
-
17
- def create_internal(&block)
18
- report = Thinreports::Report.new layout: layout_file.path
19
- format = report.layout.format
20
-
21
- block.call(format) if block_given?
22
-
23
- report.start_new_page.manager
24
- end
25
-
26
- def test_find_format_should_return_format_with_the_specified_Symbol_id
27
- assert_equal create_internal.find_format(:text_block).id, 'text_block'
28
- end
29
-
30
- def test_find_format_should_return_format_with_the_specified_String_id
31
- assert_equal create_internal.find_format('text_block').id, 'text_block'
32
- end
33
-
34
- def test_find_format_should_return_nil_when_format_with_specified_id_is_not_found
35
- assert_nil create_internal.find_format(:unknown)
36
- end
37
-
38
- def test_find_item_should_return_shape_with_the_specified_id
39
- assert_instance_of Shape::TextBlock::Interface, create_internal.find_item(:text_block)
40
- end
41
-
42
- def test_find_item_should_return_shape_in_shapes_registry_when_the_specified_shape_exists_in_registry
43
- internal = create_internal
44
- internal.find_item(:text_block)
45
-
46
- assert_same internal.find_item(:text_block), internal.shapes[:text_block]
47
- end
48
-
49
- def test_find_item_should_return_shape_when_passing_in_the_specified_only_filter
50
- internal = create_internal
51
- assert_equal internal.find_item(:text_block, only: 'text-block').id, 'text_block'
52
- end
53
-
54
- def test_find_item_should_return_nil_when_not_passing_in_the_specified_only_filter
55
- internal = create_internal
56
- assert_nil internal.find_item(:text_block, only: 'list')
57
- end
58
-
59
- def test_find_item_should_return_shape_when_passing_in_the_specified_except_filter
60
- internal = create_internal
61
- assert_equal internal.find_item(:default, except: 'text-block').id, 'default'
62
- end
63
-
64
- def test_find_item_should_return_shape_when_not_passing_in_the_specified_except_filter
65
- internal = create_internal
66
- assert_nil internal.find_item(:default, except: 'list')
67
- end
68
-
69
- def test_final_shape_should_return_nil_when_shape_is_not_found
70
- internal = create_internal
71
- assert_nil internal.final_shape(:unknown)
72
- end
73
-
74
- def test_final_shape_should_return_nil_when_shape_is_stored_in_shapes_and_hidden
75
- internal = create_internal
76
- internal.find_item(:text_block).hide
77
-
78
- assert_nil internal.final_shape(:text_block)
79
- end
80
-
81
- def test_final_shape_should_return_shape_when_shape_is_stored_in_shapes_and_TextBlock_with_value
82
- internal = create_internal
83
- internal.find_item(:text_block).value('value')
84
-
85
- assert_equal internal.final_shape(:text_block).id, 'text_block'
86
- end
87
-
88
- def test_final_shape_should_return_nil_when_shape_is_stored_in_shapes_and_TextBlock_with_no_value
89
- internal = create_internal
90
- internal.find_item(:text_block)
91
-
92
- assert_nil internal.final_shape(:text_block)
93
- end
94
-
95
- def test_final_shape_should_return_shape_when_shape_is_stored_in_shapes_and_ImageBlock_with_src
96
- internal = create_internal
97
- internal.find_item(:image_block).src('/path/to/image.png')
98
-
99
- assert_equal internal.final_shape(:image_block).id, 'image_block'
100
- end
101
-
102
- def test_final_shape_should_return_nil_when_shape_is_stored_in_shapes_and_ImageBlock_with_no_src
103
- internal = create_internal
104
- assert_nil internal.final_shape(:image_block)
105
- end
106
-
107
- def test_final_shape_should_return_nil_when_shape_isnot_stored_in_shapes_and_hidden
108
- assert_nil create_internal.final_shape(:text_block_hidden)
109
- end
110
-
111
- def test_final_shape_should_return_shape_when_shape_isnot_stored_in_shapes_and_not_Block
112
- assert_equal create_internal.final_shape(:rect_with_id).id, 'rect_with_id'
113
- end
114
-
115
- def test_final_shape_should_return_nil_when_shape_isnot_stored_in_shapes_and_ImageBlock
116
- internal = create_internal do |f|
117
- f.shapes[:iblock] = create_shape_format('image-block', 'iblock')
118
- end
119
-
120
- assert_nil internal.final_shape(:iblock)
121
- end
122
-
123
- def test_final_shape_should_return_shape_when_shape_isnot_stored_in_shapes_and_TextBlock_with_reference
124
- assert_equal create_internal.final_shape(:text_block_referenced).id, 'text_block_referenced'
125
- end
126
-
127
- def test_final_shape_should_return_nil_when_shape_isnot_stored_in_shapes_and_TextBlock_with_no_value_no_reference
128
- internal = create_internal
129
-
130
- assert_nil internal.final_shape(:t1)
131
- end
132
- end
@@ -1,140 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'test_helper'
4
-
5
- class Thinreports::Core::Shape::Manager::TestTarget < Minitest::Test
6
- include Thinreports::TestHelper
7
-
8
- # Alias
9
- Shape = Thinreports::Core::Shape
10
-
11
- class TestManager
12
- include Shape::Manager::Target
13
-
14
- attr_reader :layout, :report
15
-
16
- def initialize(report, layout)
17
- @report = report
18
- @layout = layout
19
-
20
- initialize_manager(layout.format) do |f|
21
- Shape::Interface(self, f)
22
- end
23
- end
24
- end
25
-
26
- def create_shape_format(type, id)
27
- Shape::Format(type).new('id' => id, 'type' => type)
28
- end
29
-
30
- def create_manager
31
- report = Thinreports::Report.new layout: layout_file.path
32
- layout = report.layout
33
-
34
- TestManager.new(report, layout)
35
- end
36
-
37
- def test_shorthand_for_finding_item
38
- manager = create_manager
39
-
40
- text_block1 = manager[:text_block]
41
- text_block1.value = 'block1'
42
-
43
- assert_instance_of Shape::TextBlock::Interface, manager[:text_block]
44
- assert_instance_of Shape::ImageBlock::Interface, manager[:image_block]
45
- assert_instance_of Shape::Basic::Interface, manager[:rect_with_id]
46
-
47
- assert_raises Thinreports::Errors::UnknownItemId do
48
- manager[:unknown_id]
49
- end
50
-
51
- assert_raises Thinreports::Errors::UnknownItemId do
52
- manager[:default]
53
- end
54
- end
55
-
56
- def test_shorthand_for_setting_value_to_block
57
- manager = create_manager
58
-
59
- manager[:text_block] = 'value of text block1'
60
- assert_equal 'value of text block1', manager.item(:text_block).value
61
-
62
- manager[:image_block] = '/path/to/image.png'
63
- assert_equal '/path/to/image.png', manager.item(:image_block).src
64
-
65
- assert_raises(NoMethodError) { manager[:rect_with_id] = 'value' }
66
- assert_raises(Thinreports::Errors::UnknownItemId) { manager[:default] = 'value' }
67
- end
68
-
69
- def test_manager_should_return_instance_of_ManagerInternal
70
- assert_instance_of Shape::Manager::Internal, create_manager.manager
71
- end
72
-
73
- def test_item_should_properly_return_shape_with_the_specified_Symbol_id
74
- assert_equal create_manager.item(:text_block).id, 'text_block'
75
- end
76
-
77
- def test_item_should_properly_return_shape_with_the_specified_String_id
78
- assert_equal create_manager.item('text_block').id, 'text_block'
79
- end
80
-
81
- def test_item_should_raise_when_the_shape_with_the_specified_id_is_not_found
82
- assert_raises Thinreports::Errors::UnknownItemId do
83
- create_manager.item(:unknown)
84
- end
85
- end
86
-
87
- def test_item_should_set_an_shape_as_argument_when_a_block_is_given
88
- id = nil
89
- create_manager.item(:text_block) {|s| id = s.id }
90
- assert_equal id, 'text_block'
91
- end
92
-
93
- def test_item_should_raise_when_type_of_shape_with_the_specified_id_is_list
94
- assert_raises Thinreports::Errors::UnknownItemId do
95
- create_manager.item(:default)
96
- end
97
- end
98
-
99
- def test_list_should_properly_return_list_with_the_specified_Symbol_id
100
- assert_equal create_manager.list(:default).id, 'default'
101
- end
102
-
103
- def test_list_should_properly_return_list_with_the_specified_String_id
104
- assert_equal create_manager.list('default').id, 'default'
105
- end
106
-
107
- def test_list_should_raise_when_type_of_shape_with_the_specified_id_is_not_list
108
- assert_raises Thinreports::Errors::UnknownItemId do
109
- create_manager.list(:text_block)
110
- end
111
- end
112
-
113
- def test_list_should_use_default_as_id_when_id_is_omitted
114
- assert_equal create_manager.list.id, 'default'
115
- end
116
-
117
- def test_values_should_properly_set_values_to_shapes_with_specified_id
118
- manager = create_manager
119
- manager.values(text_block: 1000)
120
-
121
- assert_equal manager.item(:text_block).value, 1000
122
- end
123
-
124
- def test_item_exists_asker_should_return_true_when_shape_with_specified_Symbol_id_is_found
125
- assert_equal create_manager.item_exists?(:text_block), true
126
- end
127
-
128
- def test_item_exists_asker_should_return_true_when_shape_with_specified_String_id_is_found
129
- assert_equal create_manager.item_exists?('text_block'), true
130
- end
131
-
132
- def test_item_exists_asker_should_return_false_when_shape_with_specified_id_not_found
133
- assert_equal create_manager.item_exists?('unknown'), false
134
- end
135
-
136
- def test_exists_asker_should_operate_like_as_item_exists_asker
137
- manager = create_manager
138
- assert_equal manager.exists?(:unknown), manager.item_exists?(:unknown)
139
- end
140
- end