vedeu 0.0.25 → 0.0.26

Sign up to get free protection for your applications and to get access to all the features.
Files changed (157) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +10 -9
  3. data/Rakefile +0 -10
  4. data/bin/composition +1 -1
  5. data/examples/single_interface_app.rb +7 -4
  6. data/lib/vedeu.rb +19 -48
  7. data/lib/vedeu/application.rb +8 -7
  8. data/lib/vedeu/configuration.rb +4 -4
  9. data/lib/vedeu/input/input.rb +3 -0
  10. data/lib/vedeu/launcher.rb +3 -0
  11. data/lib/vedeu/models/background.rb +13 -0
  12. data/lib/vedeu/models/coercions.rb +21 -0
  13. data/lib/vedeu/models/colour.rb +22 -0
  14. data/lib/vedeu/{repository → models}/command.rb +2 -0
  15. data/lib/vedeu/models/composition.rb +30 -0
  16. data/lib/vedeu/models/foreground.rb +13 -0
  17. data/lib/vedeu/models/interface.rb +62 -0
  18. data/lib/vedeu/models/interface_collection.rb +24 -0
  19. data/lib/vedeu/models/line.rb +22 -0
  20. data/lib/vedeu/models/line_collection.rb +27 -0
  21. data/lib/vedeu/models/presentation.rb +13 -0
  22. data/lib/vedeu/models/stream.rb +21 -0
  23. data/lib/vedeu/models/stream_collection.rb +27 -0
  24. data/lib/vedeu/models/style_collection.rb +23 -0
  25. data/lib/vedeu/output/interface_renderer.rb +62 -0
  26. data/lib/vedeu/output/output.rb +6 -5
  27. data/lib/vedeu/process/process.rb +15 -31
  28. data/lib/vedeu/repository/command_repository.rb +13 -14
  29. data/lib/vedeu/repository/interface_repository.rb +12 -13
  30. data/lib/vedeu/repository/repository.rb +2 -0
  31. data/lib/vedeu/{output → support}/cursor.rb +2 -0
  32. data/lib/vedeu/support/esc.rb +112 -0
  33. data/lib/vedeu/support/events.rb +21 -0
  34. data/lib/vedeu/support/geometry.rb +66 -0
  35. data/lib/vedeu/support/parser.rb +27 -0
  36. data/lib/vedeu/support/terminal.rb +31 -134
  37. data/lib/vedeu/{output → support}/translator.rb +12 -8
  38. data/lib/vedeu/{output → support}/wordwrap.rb +2 -4
  39. data/lib/vedeu/version.rb +1 -1
  40. data/test/lib/vedeu/application_test.rb +7 -2
  41. data/test/lib/vedeu/configuration_test.rb +13 -8
  42. data/test/lib/vedeu/input/input_test.rb +2 -1
  43. data/test/lib/vedeu/launcher_test.rb +7 -2
  44. data/test/lib/vedeu/models/background_test.rb +35 -0
  45. data/test/lib/vedeu/models/colour_test.rb +71 -0
  46. data/test/lib/vedeu/models/command_test.rb +109 -0
  47. data/test/lib/vedeu/models/composition_test.rb +187 -0
  48. data/test/lib/vedeu/models/foreground_test.rb +35 -0
  49. data/test/lib/vedeu/models/interface_collection_test.rb +57 -0
  50. data/test/lib/vedeu/models/interface_test.rb +220 -0
  51. data/test/lib/vedeu/models/line_collection_test.rb +69 -0
  52. data/test/lib/vedeu/models/line_test.rb +76 -0
  53. data/test/lib/vedeu/models/presentation_test.rb +8 -0
  54. data/test/lib/vedeu/models/stream_collection_test.rb +57 -0
  55. data/test/lib/vedeu/models/stream_test.rb +76 -0
  56. data/test/lib/vedeu/models/style_collection_test.rb +22 -0
  57. data/test/lib/vedeu/output/interface_renderer_test.rb +12 -0
  58. data/test/lib/vedeu/output/output_test.rb +15 -30
  59. data/test/lib/vedeu/process/process_test.rb +22 -44
  60. data/test/lib/vedeu/repository/command_repository_test.rb +22 -16
  61. data/test/lib/vedeu/repository/interface_repository_test.rb +62 -14
  62. data/test/lib/vedeu/repository/repository_test.rb +1 -0
  63. data/test/lib/vedeu/repository/storage_test.rb +13 -6
  64. data/test/lib/vedeu/{output → support}/cursor_test.rb +1 -0
  65. data/test/lib/vedeu/support/esc_test.rb +348 -0
  66. data/test/lib/vedeu/support/events_test.rb +37 -0
  67. data/test/lib/vedeu/support/exit_test.rb +1 -0
  68. data/test/lib/vedeu/support/geometry_test.rb +131 -0
  69. data/test/lib/vedeu/support/parser_test.rb +56 -0
  70. data/test/lib/vedeu/support/queue_test.rb +1 -0
  71. data/test/lib/vedeu/support/terminal_test.rb +1 -119
  72. data/test/lib/vedeu/{output → support}/translator_test.rb +17 -12
  73. data/test/lib/vedeu/{output → support}/wordwrap_test.rb +1 -0
  74. data/test/lib/vedeu/version_test.rb +1 -0
  75. data/test/lib/vedeu_test.rb +1 -0
  76. data/{lib/vedeu/repository → test/support}/dummy_command.rb +0 -0
  77. data/{lib/vedeu/repository → test/support}/dummy_interface.rb +0 -0
  78. data/test/support/json/int1_lin1_str1.json +10 -0
  79. data/test/support/json/int1_lin1_str3.json +18 -0
  80. data/test/support/json/int1_lin2_str1.json +17 -0
  81. data/test/support/json/int1_lin2_str3.json +33 -0
  82. data/test/support/json/int1_lin2_str3_styles.json +43 -0
  83. data/test/support/json/int2_lin1_str1.json +20 -0
  84. data/test/support/json/int2_lin1_str3.json +36 -0
  85. data/test/support/json/int2_lin2_str1.json +34 -0
  86. data/test/support/json/int2_lin2_str3.json +66 -0
  87. data/test/support/json/int2_lin2_str3_styles.json +158 -0
  88. data/test/support/output_1.json +9 -0
  89. data/test/support/output_1.rb +14 -0
  90. data/test/support/output_2.json +1 -0
  91. data/test/support/output_2.rb +19 -0
  92. data/test/test_helper.rb +0 -2
  93. data/vedeu.gemspec +0 -3
  94. metadata +98 -150
  95. data/config/cucumber.yml +0 -8
  96. data/documentation/composition.ebnf +0 -7
  97. data/documentation/diagram/ColourDirective.png +0 -0
  98. data/documentation/diagram/Directive.png +0 -0
  99. data/documentation/diagram/Interface.png +0 -0
  100. data/documentation/diagram/Output.png +0 -0
  101. data/documentation/diagram/PositionDirective.png +0 -0
  102. data/documentation/diagram/Stream.png +0 -0
  103. data/documentation/diagram/StyleDirective.png +0 -0
  104. data/documentation/diagram/rr-1.35.837.png +0 -0
  105. data/documentation/index.html +0 -325
  106. data/features/getting_started.feature +0 -10
  107. data/features/step_definitions/vedeu_steps.rb +0 -11
  108. data/features/support/env.rb +0 -12
  109. data/lib/vedeu/output/background.rb +0 -27
  110. data/lib/vedeu/output/base.rb +0 -57
  111. data/lib/vedeu/output/buffer/composition.rb +0 -24
  112. data/lib/vedeu/output/buffer/formatting.rb +0 -25
  113. data/lib/vedeu/output/buffer/interface.rb +0 -14
  114. data/lib/vedeu/output/buffer/line.rb +0 -14
  115. data/lib/vedeu/output/buffer/stream.rb +0 -14
  116. data/lib/vedeu/output/buffer/style.rb +0 -11
  117. data/lib/vedeu/output/colour.rb +0 -39
  118. data/lib/vedeu/output/compositor.rb +0 -72
  119. data/lib/vedeu/output/directive.rb +0 -63
  120. data/lib/vedeu/output/esc.rb +0 -61
  121. data/lib/vedeu/output/foreground.rb +0 -27
  122. data/lib/vedeu/output/geometry.rb +0 -71
  123. data/lib/vedeu/output/layer.rb +0 -9
  124. data/lib/vedeu/output/menu.rb +0 -26
  125. data/lib/vedeu/output/position.rb +0 -35
  126. data/lib/vedeu/output/style.rb +0 -38
  127. data/lib/vedeu/repository/interface.rb +0 -62
  128. data/lib/vedeu/support/json_parser.rb +0 -25
  129. data/lib/vedeu/support/options.rb +0 -4
  130. data/test/lib/vedeu/output/background_test.rb +0 -67
  131. data/test/lib/vedeu/output/base_test.rb +0 -8
  132. data/test/lib/vedeu/output/buffer/composition_test.rb +0 -57
  133. data/test/lib/vedeu/output/buffer/formatting_test.rb +0 -9
  134. data/test/lib/vedeu/output/buffer/interface_test.rb +0 -38
  135. data/test/lib/vedeu/output/buffer/line_test.rb +0 -64
  136. data/test/lib/vedeu/output/buffer/stream_test.rb +0 -61
  137. data/test/lib/vedeu/output/buffer/style_test.rb +0 -8
  138. data/test/lib/vedeu/output/colour_test.rb +0 -104
  139. data/test/lib/vedeu/output/compositor_test.rb +0 -247
  140. data/test/lib/vedeu/output/directive_test.rb +0 -82
  141. data/test/lib/vedeu/output/esc_test.rb +0 -175
  142. data/test/lib/vedeu/output/foreground_test.rb +0 -67
  143. data/test/lib/vedeu/output/geometry_test.rb +0 -190
  144. data/test/lib/vedeu/output/layer_test.rb +0 -35
  145. data/test/lib/vedeu/output/menu_test.rb +0 -13
  146. data/test/lib/vedeu/output/position_test.rb +0 -48
  147. data/test/lib/vedeu/output/style_test.rb +0 -132
  148. data/test/lib/vedeu/repository/command_test.rb +0 -73
  149. data/test/lib/vedeu/repository/dummy_command_test.rb +0 -27
  150. data/test/lib/vedeu/repository/dummy_interface_test.rb +0 -7
  151. data/test/lib/vedeu/repository/interface_test.rb +0 -79
  152. data/test/lib/vedeu/support/json_parser_test.rb +0 -45
  153. data/test/support/composition.json +0 -47
  154. data/test/support/composition.rb +0 -5
  155. data/test/support/composition.xml +0 -36
  156. data/test/support/multi_interface.json +0 -34
  157. data/test/support/single_interface.json +0 -19
@@ -0,0 +1,220 @@
1
+ require_relative '../../../test_helper'
2
+ require_relative '../../../../lib/vedeu/models/interface'
3
+
4
+ module Vedeu
5
+ describe Interface do
6
+ let(:described_class) { Interface }
7
+ let(:described_instance) { described_class.new(attributes) }
8
+ let(:attributes) {
9
+ {
10
+ name: 'dummy',
11
+ lines: [],
12
+ colour: {
13
+ foreground: '#ff0000',
14
+ background: '#000000'
15
+ },
16
+ width: 7,
17
+ height: 3
18
+ }
19
+ }
20
+
21
+ before do
22
+ Terminal.stubs(:width).returns(40)
23
+ Terminal.stubs(:height).returns(25)
24
+ end
25
+
26
+ describe '#initialize' do
27
+ let(:subject) { described_instance }
28
+
29
+ it 'returns a Interface instance' do
30
+ subject.must_be_instance_of(Interface)
31
+ end
32
+ end
33
+
34
+ describe '#name' do
35
+ let(:subject) { described_instance.name }
36
+
37
+ it 'returns a String' do
38
+ subject.must_be_instance_of(String)
39
+ end
40
+
41
+ it 'has a name attribute' do
42
+ subject.must_equal('dummy')
43
+ end
44
+ end
45
+
46
+ describe '#lines' do
47
+ let(:subject) { described_instance.lines }
48
+
49
+ it 'returns an Array' do
50
+ subject.must_be_instance_of(Array)
51
+ end
52
+
53
+ it 'has a lines attribute' do
54
+ subject.must_equal([])
55
+ end
56
+ end
57
+
58
+ describe '#colour' do
59
+ let(:subject) { described_instance.colour }
60
+ end
61
+
62
+ describe '#y' do
63
+ let(:subject) { described_instance.y }
64
+
65
+ it 'returns a Fixnum' do
66
+ subject.must_be_instance_of(Fixnum)
67
+ end
68
+
69
+ context 'using a value' do
70
+ let(:attributes) { { y: 17 } }
71
+
72
+ it 'returns the value' do
73
+ subject.must_equal(17)
74
+ end
75
+ end
76
+
77
+ context 'using the default' do
78
+ it 'returns the default' do
79
+ subject.must_equal(1)
80
+ end
81
+ end
82
+ end
83
+
84
+ describe '#x' do
85
+ let(:subject) { described_instance.x }
86
+
87
+ it 'returns a Fixnum' do
88
+ subject.must_be_instance_of(Fixnum)
89
+ end
90
+
91
+ context 'using a value' do
92
+ let(:attributes) { { x: 33 } }
93
+
94
+ it 'returns the value' do
95
+ subject.must_equal(33)
96
+ end
97
+ end
98
+
99
+ context 'using the default' do
100
+ it 'return the default' do
101
+ subject.must_equal(1)
102
+ end
103
+ end
104
+ end
105
+
106
+ describe '#z' do
107
+ let(:subject) { described_instance.z }
108
+
109
+ it 'returns a Fixnum' do
110
+ subject.must_be_instance_of(Fixnum)
111
+ end
112
+
113
+ context 'using a value' do
114
+ let(:attributes) { { z: 2 } }
115
+
116
+ it 'returns the value' do
117
+ subject.must_equal(2)
118
+ end
119
+ end
120
+
121
+ context 'using the default' do
122
+ it 'return the default' do
123
+ subject.must_equal(1)
124
+ end
125
+ end
126
+ end
127
+
128
+ describe '#width' do
129
+ let(:subject) { described_instance.width }
130
+
131
+ it 'returns a Fixnum' do
132
+ subject.must_be_instance_of(Fixnum)
133
+ end
134
+
135
+ context 'using a value' do
136
+ let(:attributes) { { width: 50 } }
137
+
138
+ it 'returns the value' do
139
+ subject.must_equal(50)
140
+ end
141
+ end
142
+ end
143
+
144
+ describe '#height' do
145
+ let(:subject) { described_instance.height }
146
+
147
+ it 'returns a Fixnum' do
148
+ subject.must_be_instance_of(Fixnum)
149
+ end
150
+
151
+ context 'using a value' do
152
+ let(:attributes) { { height: 20 } }
153
+
154
+ it 'returns the value' do
155
+ subject.must_equal(20)
156
+ end
157
+ end
158
+ end
159
+
160
+ describe '#current' do
161
+ let(:subject) { described_instance.current }
162
+
163
+ it 'returns a String' do
164
+ subject.must_be_instance_of(String)
165
+ end
166
+ end
167
+
168
+ describe '#cursor' do
169
+ let(:subject) { described_instance.cursor }
170
+
171
+ it 'returns a TrueClass' do
172
+ subject.must_be_instance_of(TrueClass)
173
+ end
174
+
175
+ context 'when the cursor is off' do
176
+ before { described_instance.cursor=(false) }
177
+
178
+ it 'returns a FalseClass' do
179
+ subject.must_be_instance_of(FalseClass)
180
+ end
181
+ end
182
+ end
183
+
184
+ describe '#refresh' do
185
+ let(:subject) { described_instance.refresh }
186
+
187
+ it 'returns a String' do
188
+ subject.must_be_instance_of(String)
189
+ end
190
+
191
+ it 'returns a String' do
192
+ subject.must_equal("\e[38;5;196m\e[48;5;16m\e[1;1H \e[1;1H\e[2;1H \e[2;1H\e[3;1H \e[3;1H")
193
+ end
194
+ end
195
+
196
+ describe '#to_s' do
197
+ let(:subject) { described_instance.to_s }
198
+
199
+ it 'returns an String' do
200
+ subject.must_be_instance_of(String)
201
+ end
202
+
203
+ it 'returns an String' do
204
+ subject.must_equal("\e[38;5;196m\e[48;5;16m\e[1;1H \e[1;1H\e[2;1H \e[2;1H\e[3;1H \e[3;1H")
205
+ end
206
+ end
207
+
208
+ describe '#to_json' do
209
+ let(:subject) { described_instance.to_json }
210
+
211
+ it 'returns an String' do
212
+ subject.must_be_instance_of(String)
213
+ end
214
+
215
+ it 'returns an String' do
216
+ subject.must_equal("{\"colour\":{\"foreground\":\"\\u001b[38;5;196m\",\"background\":\"\\u001b[48;5;16m\"},\"style\":\"\",\"name\":\"dummy\",\"lines\":[],\"y\":1,\"x\":1,\"z\":1,\"width\":7,\"height\":3,\"current\":\"\",\"cursor\":true}")
217
+ end
218
+ end
219
+ end
220
+ end
@@ -0,0 +1,69 @@
1
+ require_relative '../../../test_helper'
2
+ require_relative '../../../../lib/vedeu/models/line_collection'
3
+ require_relative '../../../../lib/vedeu/models/interface'
4
+
5
+ module Vedeu
6
+ describe LineCollection do
7
+ let(:described_class) { LineCollection }
8
+
9
+ describe '#coerce' do
10
+ let(:subject) { Vedeu::Interface.new({ lines: lines }).lines }
11
+ let(:lines) {}
12
+
13
+ context 'when there are no lines' do
14
+ it 'returns a Array' do
15
+ subject.must_be_instance_of(Array)
16
+ end
17
+
18
+ it 'returns an empty array' do
19
+ subject.must_equal([])
20
+ end
21
+ end
22
+
23
+ context 'when the line is just a String' do
24
+ let(:lines) { 'some text' }
25
+
26
+ it 'returns an Array' do
27
+ subject.must_be_instance_of(Array)
28
+ end
29
+
30
+ it 'contains a single Line object' do
31
+ subject.size.must_equal(1)
32
+ end
33
+ end
34
+
35
+ context 'when there is a single line' do
36
+ let(:lines) { { streams: { text: 'some text' } } }
37
+
38
+ it 'returns an Array' do
39
+ subject.must_be_instance_of(Array)
40
+ end
41
+
42
+ it 'contains a single Line object' do
43
+ subject.size.must_equal(1)
44
+ end
45
+ end
46
+
47
+ context 'when there are multiple lines' do
48
+ let(:lines) {
49
+ [
50
+ { text: 'some text' },
51
+ { text: 'some more text' }
52
+ ]
53
+ }
54
+
55
+ it 'returns an Array' do
56
+ subject.must_be_instance_of(Array)
57
+ end
58
+
59
+ it 'returns a collection of Line objects' do
60
+ subject.first.must_be_instance_of(Line)
61
+ end
62
+
63
+ it 'contains multiple Line objects' do
64
+ subject.size.must_equal(2)
65
+ end
66
+ end
67
+ end
68
+ end
69
+ end
@@ -0,0 +1,76 @@
1
+ require_relative '../../../test_helper'
2
+ require_relative '../../../../lib/vedeu/models/line'
3
+
4
+ module Vedeu
5
+ describe Line do
6
+ let(:described_class) { Line }
7
+ let(:described_instance) { described_class.new(attributes) }
8
+ let(:subject) { described_instance }
9
+ let(:attributes) {
10
+ {
11
+ style: 'normal',
12
+ colour: { foreground: '#ff0000', background: '#000000' },
13
+ stream: []
14
+ }
15
+ }
16
+
17
+ describe '#initialize' do
18
+ let(:subject) { described_instance }
19
+
20
+ it 'returns a Line instance' do
21
+ subject.must_be_instance_of(Line)
22
+ end
23
+ end
24
+
25
+ describe '#style' do
26
+ let(:subject) { described_instance.style }
27
+
28
+ it 'has a style attribute' do
29
+ subject.must_be_instance_of(String)
30
+ end
31
+ end
32
+
33
+ describe '#colour' do
34
+ let(:subject) { described_instance.colour }
35
+
36
+ it 'has a colour attribute' do
37
+ subject.must_be_instance_of(Colour)
38
+ end
39
+ end
40
+
41
+ describe '#streams' do
42
+ let(:subject) { described_instance.streams }
43
+
44
+ it 'has a streams attribute' do
45
+ subject.must_be_instance_of(Array)
46
+
47
+ subject.must_equal([])
48
+ end
49
+ end
50
+
51
+ describe '#to_json' do
52
+ let(:subject) { described_instance.to_json }
53
+
54
+ it 'returns an String' do
55
+ subject.must_be_instance_of(String)
56
+ end
57
+
58
+ it 'returns an String' do
59
+ subject.must_equal("{\"colour\":{\"foreground\":\"\\u001b[38;5;196m\",\"background\":\"\\u001b[48;5;16m\"},\"style\":\"\\u001b[24m\\u001b[21m\\u001b[27m\",\"streams\":[]}")
60
+ end
61
+ end
62
+
63
+ describe '#to_s' do
64
+ let(:subject) { described_instance.to_s }
65
+
66
+ it 'returns an String' do
67
+ subject.must_be_instance_of(String)
68
+ end
69
+
70
+ it 'returns an String' do
71
+ subject.must_equal("\e[38;5;196m\e[48;5;16m\e[24m\e[21m\e[27m")
72
+ end
73
+ end
74
+ end
75
+ end
76
+
@@ -0,0 +1,8 @@
1
+ require_relative '../../../test_helper'
2
+ require_relative '../../../../lib/vedeu/models/presentation'
3
+
4
+ module Vedeu
5
+ describe Presentation do
6
+ let(:described_module) { Presentation }
7
+ end
8
+ end
@@ -0,0 +1,57 @@
1
+ require_relative '../../../test_helper'
2
+ require_relative '../../../../lib/vedeu/models/stream_collection'
3
+ require_relative '../../../../lib/vedeu/models/line'
4
+
5
+ module Vedeu
6
+ describe StreamCollection do
7
+ let(:described_class) { StreamCollection }
8
+
9
+ describe '#coerce' do
10
+ let(:subject) { Vedeu::Line.new({ streams: streams }).streams }
11
+ let(:streams) {}
12
+
13
+ context 'when there is no stream' do
14
+ it 'returns a Array' do
15
+ subject.must_be_instance_of(Array)
16
+ end
17
+
18
+ it 'returns an empty array' do
19
+ subject.must_equal([])
20
+ end
21
+ end
22
+
23
+ context 'when there is a single stream' do
24
+ let(:streams) { "some text" }
25
+
26
+ it 'returns an Array' do
27
+ subject.must_be_instance_of(Array)
28
+ end
29
+
30
+ it 'contains a single Stream object' do
31
+ subject.size.must_equal(1)
32
+ end
33
+ end
34
+
35
+ context 'when there are multiple streams' do
36
+ let(:streams) {
37
+ [
38
+ { text: 'some text' },
39
+ { text: 'some more text' }
40
+ ]
41
+ }
42
+
43
+ it 'returns an Array' do
44
+ subject.must_be_instance_of(Array)
45
+ end
46
+
47
+ it 'returns a collection of Stream objects' do
48
+ subject.first.must_be_instance_of(Stream)
49
+ end
50
+
51
+ it 'contains multiple Stream objects' do
52
+ subject.size.must_equal(2)
53
+ end
54
+ end
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,76 @@
1
+ require_relative '../../../test_helper'
2
+ require_relative '../../../../lib/vedeu/models/stream'
3
+
4
+ module Vedeu
5
+ describe Stream do
6
+ let(:described_class) { Stream }
7
+ let(:described_instance) { described_class.new(attributes) }
8
+ let(:attributes) {
9
+ {
10
+ style: 'normal',
11
+ colour: { foreground: '#ff0000', background: '#000000' },
12
+ text: 'Some text'
13
+ }
14
+ }
15
+
16
+ describe '#initialize' do
17
+ let(:subject) { described_instance }
18
+
19
+ it 'returns a Stream instance' do
20
+ subject.must_be_instance_of(Stream)
21
+ end
22
+ end
23
+
24
+ describe '#colour' do
25
+ let(:subject) { described_instance.colour }
26
+
27
+ it 'has a colour attribute' do
28
+ subject.must_be_instance_of(Colour)
29
+ end
30
+ end
31
+
32
+ describe '#text' do
33
+ let(:subject) { described_instance.text }
34
+
35
+ it 'returns a String' do
36
+ subject.must_be_instance_of(String)
37
+ end
38
+
39
+ it 'has a text attribute' do
40
+ subject.must_equal('Some text')
41
+ end
42
+ end
43
+
44
+ describe '#style' do
45
+ let(:subject) { described_instance.style }
46
+
47
+ it 'has a style attribute' do
48
+ subject.must_be_instance_of(String)
49
+ end
50
+ end
51
+
52
+ describe '#to_s' do
53
+ let(:subject) { described_instance.to_s }
54
+
55
+ it 'returns a String' do
56
+ subject.must_be_instance_of(String)
57
+ end
58
+
59
+ it 'returns a String' do
60
+ subject.must_equal("\e[38;5;196m\e[48;5;16m\e[24m\e[21m\e[27mSome text")
61
+ end
62
+ end
63
+
64
+ describe '#to_json' do
65
+ let(:subject) { described_instance.to_json }
66
+
67
+ it 'returns a String' do
68
+ subject.must_be_instance_of(String)
69
+ end
70
+
71
+ it 'returns a String' do
72
+ subject.must_equal("{\"colour\":{\"foreground\":\"\\u001b[38;5;196m\",\"background\":\"\\u001b[48;5;16m\"},\"style\":\"\\u001b[24m\\u001b[21m\\u001b[27m\",\"text\":\"Some text\"}")
73
+ end
74
+ end
75
+ end
76
+ end