vedeu 0.0.30 → 0.0.31

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 (69) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +4 -4
  3. data/lib/vedeu/configuration.rb +2 -2
  4. data/lib/vedeu/launcher.rb +2 -2
  5. data/lib/vedeu/models/command.rb +1 -1
  6. data/lib/vedeu/models/interface.rb +4 -0
  7. data/lib/vedeu/output/interface_renderer.rb +1 -1
  8. data/lib/vedeu/output/template.rb +23 -0
  9. data/lib/vedeu/output/text_adaptor.rb +1 -1
  10. data/lib/vedeu/process/process.rb +5 -1
  11. data/lib/vedeu/repository/command_repository.rb +3 -5
  12. data/lib/vedeu/repository/event_repository.rb +27 -0
  13. data/lib/vedeu/repository/interface_repository.rb +8 -6
  14. data/lib/vedeu/repository/storage.rb +2 -0
  15. data/lib/vedeu/support/esc.rb +2 -1
  16. data/lib/vedeu/support/geometry.rb +11 -23
  17. data/lib/vedeu/support/parser.rb +1 -1
  18. data/lib/vedeu/support/queue.rb +3 -1
  19. data/lib/vedeu.rb +18 -1
  20. data/test/example_app/bin/app +9 -0
  21. data/test/example_app/lib/app.rb +63 -0
  22. data/test/lib/vedeu/application_test.rb +6 -36
  23. data/test/lib/vedeu/configuration_test.rb +5 -31
  24. data/test/lib/vedeu/input/input_test.rb +4 -16
  25. data/test/lib/vedeu/launcher_test.rb +6 -15
  26. data/test/lib/vedeu/models/background_test.rb +5 -21
  27. data/test/lib/vedeu/models/colour_test.rb +18 -49
  28. data/test/lib/vedeu/models/command_test.rb +19 -83
  29. data/test/lib/vedeu/models/composition_test.rb +78 -175
  30. data/test/lib/vedeu/models/foreground_test.rb +4 -21
  31. data/test/lib/vedeu/models/interface_collection_test.rb +13 -45
  32. data/test/lib/vedeu/models/interface_test.rb +71 -195
  33. data/test/lib/vedeu/models/line_collection_test.rb +13 -52
  34. data/test/lib/vedeu/models/line_test.rb +17 -61
  35. data/test/lib/vedeu/models/presentation_test.rb +6 -19
  36. data/test/lib/vedeu/models/stream_collection_test.rb +10 -42
  37. data/test/lib/vedeu/models/stream_test.rb +16 -54
  38. data/test/lib/vedeu/models/style_collection_test.rb +1 -10
  39. data/test/lib/vedeu/output/interface_renderer_test.rb +7 -38
  40. data/test/lib/vedeu/output/output_test.rb +1 -18
  41. data/test/lib/vedeu/output/template.rb +20 -0
  42. data/test/lib/vedeu/output/text_adaptor_test.rb +9 -46
  43. data/test/lib/vedeu/process/process_test.rb +36 -38
  44. data/test/lib/vedeu/repository/command_repository_test.rb +16 -45
  45. data/test/lib/vedeu/repository/interface_repository_test.rb +36 -74
  46. data/test/lib/vedeu/repository/repository_test.rb +9 -33
  47. data/test/lib/vedeu/repository/storage_test.rb +7 -42
  48. data/test/lib/vedeu/support/esc_test.rb +46 -130
  49. data/test/lib/vedeu/support/event_repository_test.rb +31 -0
  50. data/test/lib/vedeu/support/exit_test.rb +1 -9
  51. data/test/lib/vedeu/support/geometry_test.rb +81 -105
  52. data/test/lib/vedeu/support/parser_test.rb +10 -54
  53. data/test/lib/vedeu/support/parsing/hash_parser_test.rb +18 -33
  54. data/test/lib/vedeu/support/parsing/json_parser_test.rb +4 -23
  55. data/test/lib/vedeu/support/queue_test.rb +33 -57
  56. data/test/lib/vedeu/support/terminal_test.rb +21 -52
  57. data/test/lib/vedeu/support/translator_test.rb +16 -33
  58. data/test/lib/vedeu/support/wordwrap_test.rb +29 -46
  59. data/test/lib/vedeu_test.rb +3 -5
  60. data/test/support/template.erb +3 -0
  61. data/test/test_helper.rb +1 -12
  62. data/vedeu.gemspec +8 -10
  63. metadata +26 -38
  64. data/lib/vedeu/support/events.rb +0 -21
  65. data/lib/vedeu/version.rb +0 -3
  66. data/test/lib/vedeu/support/events_test.rb +0 -45
  67. data/test/lib/vedeu/version_test.rb +0 -12
  68. data/test/support/output_1.json +0 -9
  69. data/test/support/output_1.rb +0 -14
@@ -4,57 +4,25 @@ require_relative '../../../../lib/vedeu/models/composition'
4
4
 
5
5
  module Vedeu
6
6
  describe InterfaceCollection do
7
- let(:described_class) { InterfaceCollection }
8
-
9
7
  describe '#coerce' do
10
- let(:subject) { Vedeu::Composition.new({ interfaces: interfaces }).interfaces }
11
- let(:interfaces) {}
12
-
13
- context 'when there are no interfaces' 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
8
+ it 'returns a Array' do
9
+ Composition.new.interfaces.must_be_instance_of(Array)
21
10
  end
22
11
 
23
- context 'when there is a single interface' do
24
- let(:interfaces) { { name: 'dummy' } }
25
-
26
- it 'returns an Array' do
27
- subject.must_be_instance_of(Array)
28
- end
29
-
30
- it 'returns a collection of Interface objects' do
31
- subject.first.must_be_instance_of(Interface)
32
- end
33
-
34
- it 'contains a single Interface object' do
35
- subject.size.must_equal(1)
36
- end
12
+ it 'returns an empty collection when there are no interfaces' do
13
+ Composition.new.interfaces.must_equal([])
37
14
  end
38
15
 
39
- context 'when there are multiple interfaces' do
40
- let(:interfaces) {
41
- [
42
- { name: 'dumb' },
43
- { name: 'dumber' }
44
- ]
45
- }
46
-
47
- it 'returns an Array' do
48
- subject.must_be_instance_of(Array)
49
- end
50
-
51
- it 'returns a collection of Interface objects' do
52
- subject.first.must_be_instance_of(Interface)
53
- end
16
+ it 'returns a collection of Interface objects when there is a single interface' do
17
+ skip
18
+ Composition.new({ name: 'dummy' }).interfaces.first.must_be_instance_of(Interface)
19
+ end
54
20
 
55
- it 'contains multiple Line objects' do
56
- subject.size.must_equal(2)
57
- end
21
+ it 'returns a collection of Interface objects when there are multiple interfaces' do
22
+ Composition.new({ interfaces: [
23
+ { name: 'dumb' },
24
+ { name: 'dumber' }
25
+ ]}).interfaces.size.must_equal(2)
58
26
  end
59
27
  end
60
28
  end
@@ -3,237 +3,113 @@ require_relative '../../../../lib/vedeu/models/interface'
3
3
 
4
4
  module Vedeu
5
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)
6
+ it 'has a name attribute' do
7
+ Interface.new({ name: 'dummy' }).name.must_equal('dummy')
24
8
  end
25
9
 
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
10
+ it 'has a lines attribute' do
11
+ Interface.new({ lines: [] }).lines.must_equal([])
32
12
  end
33
13
 
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
14
+ it 'has a colour attribute' do
15
+ Interface.new({
16
+ colour: {
17
+ foreground: '#ff0000',
18
+ background: '#000000'
19
+ }
20
+ }).colour.must_be_instance_of(Colour)
44
21
  end
45
22
 
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
23
+ it 'has a y attribute' do
24
+ Interface.new({ y: 17 }).y.must_equal(17)
25
+ Interface.new.y.must_equal(1)
56
26
  end
57
27
 
58
- describe '#colour' do
59
- let(:subject) { described_instance.colour }
28
+ it 'has an x attribute' do
29
+ Interface.new({ x: 33 }).x.must_equal(33)
30
+ Interface.new.x.must_equal(1)
60
31
  end
61
32
 
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
33
+ it 'has a z attribute' do
34
+ Interface.new({ z: 2 }).z.must_equal(2)
35
+ Interface.new.z.must_equal(1)
82
36
  end
83
37
 
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
38
+ it 'has a width attribute' do
39
+ Interface.new({ width: 50 }).width.must_equal(50)
104
40
  end
105
41
 
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
42
+ it 'has a height attribute' do
43
+ Interface.new({ height: 20 }).height.must_equal(20)
142
44
  end
143
45
 
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
46
+ it 'has a current attribute' do
47
+ Interface.new({ current: '' }).current.must_equal('')
166
48
  end
167
49
 
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
50
+ it 'has a cursor attribute' do
51
+ Interface.new({ cursor: true }).cursor.must_be :==, true
52
+ Interface.new({ cursor: false }).cursor.must_be :==, false
53
+ Interface.new.cursor.must_be :==, true
182
54
  end
183
55
 
184
56
  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
- context 'when content is queued up to be displayed' do
192
- before { described_instance.enqueue("\e[38;5;196m\e[48;5;16m\e[1;1HContent\e[1;1H\e[2;1HContent\e[2;1H\e[3;1HContent\e[3;1H") }
57
+ let(:attributes) {
58
+ {
59
+ name: 'dummy',
60
+ lines: [],
61
+ colour: {
62
+ foreground: '#ff0000',
63
+ background: '#000000'
64
+ },
65
+ width: 3,
66
+ height: 3
67
+ }
68
+ }
193
69
 
194
- it 'returns the fresh content' do
195
- subject.must_equal("\e[38;5;196m\e[48;5;16m\e[1;1HContent\e[1;1H\e[2;1HContent\e[2;1H\e[3;1HContent\e[3;1H")
196
- end
70
+ it 'returns a blank interface when there is no content to display (initial state)' do
71
+ Interface.new(attributes).refresh.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")
197
72
  end
198
73
 
199
- context 'when there is no content to display (initial state)' do
200
- it 'returns a blank interface' do
201
- 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")
202
- end
74
+ it 'returns the fresh content when content is queued up to be displayed' do
75
+ @interface = Interface.new(attributes).enqueue("\e[38;5;196m\e[48;5;16m\e[1;1HContent\e[1;1H\e[2;1HContent\e[2;1H\e[3;1HContent\e[3;1H")
76
+ @interface.refresh.must_equal("\e[38;5;196m\e[48;5;16m\e[1;1HContent\e[1;1H\e[2;1HContent\e[2;1H\e[3;1HContent\e[3;1H")
203
77
  end
204
78
 
205
- context 'when there is stale content from last run' do
206
- before do
207
- described_instance.current = "\e[38;5;196m\e[48;5;16m\e[1;1HOld\e[1;1H\e[2;1HContent\e[2;1H\e[3;1Here\e[3;1H"
208
- end
209
-
210
- it 'returns the previously shown content' do
211
- subject.must_equal("\e[38;5;196m\e[48;5;16m\e[1;1HOld\e[1;1H\e[2;1HContent\e[2;1H\e[3;1Here\e[3;1H")
212
- end
79
+ it 'returns the previously shown content when there is stale content from last run' do
80
+ @interface = Interface.new(attributes)
81
+ @interface.current = "\e[38;5;196m\e[48;5;16m\e[1;1HOld\e[1;1H\e[2;1HContent\e[2;1H\e[3;1Here\e[3;1H"
82
+ @interface.refresh.must_equal("\e[38;5;196m\e[48;5;16m\e[1;1HOld\e[1;1H\e[2;1HContent\e[2;1H\e[3;1Here\e[3;1H")
213
83
  end
214
84
  end
215
85
 
216
86
  describe '#to_s' do
217
- let(:subject) { described_instance.to_s }
218
-
219
- it 'returns an String' do
220
- subject.must_be_instance_of(String)
221
- end
222
-
223
87
  it 'returns an String' do
224
- 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")
88
+ Interface.new({
89
+ name: 'dummy',
90
+ lines: [],
91
+ colour: {
92
+ foreground: '#ff0000',
93
+ background: '#000000'
94
+ },
95
+ width: 3,
96
+ height: 3
97
+ }).to_s.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")
225
98
  end
226
99
  end
227
100
 
228
101
  describe '#to_json' do
229
- let(:subject) { described_instance.to_json }
230
-
231
- it 'returns an String' do
232
- subject.must_be_instance_of(String)
233
- end
234
-
235
102
  it 'returns an String' do
236
- 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,\"cursor\":true}")
103
+ Interface.new({
104
+ name: 'dummy',
105
+ lines: [],
106
+ colour: {
107
+ foreground: '#ff0000',
108
+ background: '#000000'
109
+ },
110
+ width: 3,
111
+ height: 3
112
+ }).to_json.must_equal("{\"colour\":{\"foreground\":\"\\u001b[38;5;196m\",\"background\":\"\\u001b[48;5;16m\"},\"style\":\"\",\"name\":\"dummy\",\"lines\":[],\"y\":1,\"x\":1,\"z\":1,\"width\":3,\"height\":3,\"cursor\":true}")
237
113
  end
238
114
  end
239
115
  end
@@ -4,65 +4,26 @@ require_relative '../../../../lib/vedeu/models/interface'
4
4
 
5
5
  module Vedeu
6
6
  describe LineCollection do
7
- let(:described_class) { LineCollection }
8
-
9
7
  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
8
+ it 'returns an empty collection when there are no lines' do
9
+ Interface.new({ lines: {} }).lines.must_equal([])
21
10
  end
22
11
 
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
12
+ it 'contains a single Line object when the line is just a String' do
13
+ Interface.new({ lines: 'some text' }).lines.size
14
+ .must_equal(1)
33
15
  end
34
16
 
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
17
+ it 'contains a single Line object when there is a single line' do
18
+ Interface.new({ lines: { streams: { text: 'some text' } } })
19
+ .lines.size.must_equal(1)
45
20
  end
46
21
 
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
22
+ it 'contains multiple Line objects when there are multiple lines' do
23
+ Interface.new({ lines: [
24
+ { text: 'some text' },
25
+ { text: 'some more text' }
26
+ ] }).lines.size.must_equal(2)
66
27
  end
67
28
  end
68
29
  end
@@ -3,83 +3,39 @@ require_relative '../../../../lib/vedeu/models/line'
3
3
 
4
4
  module Vedeu
5
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
- model: {},
12
- style: 'normal',
13
- colour: { foreground: '#ff0000', background: '#000000' },
14
- stream: [],
15
- }
16
- }
17
-
18
- describe '#initialize' do
19
- let(:subject) { described_instance }
20
-
21
- it 'returns a Line instance' do
22
- subject.must_be_instance_of(Line)
23
- end
6
+ it 'has a style attribute' do
7
+ Line.new(style: 'normal').style.must_be_instance_of(String)
24
8
  end
25
9
 
26
- describe '#style' do
27
- let(:subject) { described_instance.style }
28
-
29
- it 'has a style attribute' do
30
- subject.must_be_instance_of(String)
31
- end
10
+ it 'has a colour attribute' do
11
+ Line.new(colour: { foreground: '#ff0000', background: '#000000' }).colour.must_be_instance_of(Colour)
32
12
  end
33
13
 
34
- describe '#colour' do
35
- let(:subject) { described_instance.colour }
36
-
37
- it 'has a colour attribute' do
38
- subject.must_be_instance_of(Colour)
39
- end
14
+ it 'has a model attribute' do
15
+ Line.new(model: {}).model.must_be_instance_of(Hash)
40
16
  end
41
17
 
42
- describe '#model' do
43
- let(:subject) { described_instance.model }
44
-
45
- it 'has a model attribute' do
46
- subject.must_be_instance_of(Hash)
47
- end
48
- end
49
-
50
- describe '#streams' do
51
- let(:subject) { described_instance.streams }
52
-
53
- it 'has a streams attribute' do
54
- subject.must_be_instance_of(Array)
55
-
56
- subject.must_equal([])
57
- end
18
+ it 'has a streams attribute' do
19
+ Line.new(streams: []).streams.must_equal([])
58
20
  end
59
21
 
60
22
  describe '#to_json' do
61
- let(:subject) { described_instance.to_json }
62
-
63
- it 'returns an String' do
64
- subject.must_be_instance_of(String)
65
- end
66
-
67
23
  it 'returns an String' do
68
- subject.must_equal("{\"colour\":{\"foreground\":\"\\u001b[38;5;196m\",\"background\":\"\\u001b[48;5;16m\"},\"style\":\"\\u001b[24m\\u001b[21m\\u001b[27m\",\"streams\":[]}")
24
+ Line.new({
25
+ style: 'normal',
26
+ colour: { foreground: '#ff0000', background: '#000000' },
27
+ streams: [],
28
+ }).to_json.must_equal("{\"colour\":{\"foreground\":\"\\u001b[38;5;196m\",\"background\":\"\\u001b[48;5;16m\"},\"style\":\"\\u001b[24m\\u001b[21m\\u001b[27m\",\"streams\":[]}")
69
29
  end
70
30
  end
71
31
 
72
32
  describe '#to_s' do
73
- let(:subject) { described_instance.to_s }
74
-
75
33
  it 'returns an String' do
76
- subject.must_be_instance_of(String)
77
- end
78
-
79
- it 'returns an String' do
80
- subject.must_equal("\e[38;5;196m\e[48;5;16m\e[24m\e[21m\e[27m")
34
+ Line.new({
35
+ style: 'normal',
36
+ colour: { foreground: '#ff0000', background: '#000000' },
37
+ }).to_s.must_equal("\e[38;5;196m\e[48;5;16m\e[24m\e[21m\e[27m")
81
38
  end
82
39
  end
83
40
  end
84
41
  end
85
-
@@ -7,32 +7,19 @@ module Vedeu
7
7
  end
8
8
 
9
9
  describe Presentation do
10
- let(:described_module) { Presentation }
11
- let(:described_instance) { TestPresentation.new(attributes) }
12
- let(:attributes) {
13
- {
14
- colour: {},
15
- style: ['bold', 'underline']
16
- }
17
- }
18
-
19
10
  describe '#colour' do
20
- let(:subject) { described_instance.colour }
21
-
22
11
  it 'returns a Colour instance' do
23
- subject.must_be_instance_of(Colour)
12
+ TestPresentation.new({
13
+ colour: { foreground: '#ff0000', background: '#333333' }
14
+ }).colour.must_be_instance_of(Colour)
24
15
  end
25
16
  end
26
17
 
27
18
  describe '#style' do
28
- let(:subject) { described_instance.style }
29
-
30
- it 'returns a String' do
31
- subject.must_be_instance_of(String)
32
- end
33
-
34
19
  it 'has a style attribute' do
35
- subject.must_equal("\e[1m\e[4m")
20
+ TestPresentation.new({
21
+ style: ['bold', 'underline']
22
+ }).style.must_equal("\e[1m\e[4m")
36
23
  end
37
24
  end
38
25
  end
@@ -4,53 +4,21 @@ require_relative '../../../../lib/vedeu/models/line'
4
4
 
5
5
  module Vedeu
6
6
  describe StreamCollection do
7
- let(:described_class) { StreamCollection }
8
-
9
7
  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
8
+ it 'returns an empty array when there is no stream' do
9
+ Line.new.streams.must_equal([])
21
10
  end
22
11
 
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
12
+ it 'contains a single Stream when there is a single stream' do
13
+ Line.new({ streams: 'some text' }).streams.size
14
+ .must_equal(1)
33
15
  end
34
16
 
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
17
+ it 'contains multiple Stream when there are multiple streams' do
18
+ Line.new({ streams: [
19
+ { text: 'some text' },
20
+ { text: 'some more text' }
21
+ ] }).streams.size.must_equal(2)
54
22
  end
55
23
  end
56
24
  end