vedeu 0.0.30 → 0.0.31
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +4 -4
- data/lib/vedeu/configuration.rb +2 -2
- data/lib/vedeu/launcher.rb +2 -2
- data/lib/vedeu/models/command.rb +1 -1
- data/lib/vedeu/models/interface.rb +4 -0
- data/lib/vedeu/output/interface_renderer.rb +1 -1
- data/lib/vedeu/output/template.rb +23 -0
- data/lib/vedeu/output/text_adaptor.rb +1 -1
- data/lib/vedeu/process/process.rb +5 -1
- data/lib/vedeu/repository/command_repository.rb +3 -5
- data/lib/vedeu/repository/event_repository.rb +27 -0
- data/lib/vedeu/repository/interface_repository.rb +8 -6
- data/lib/vedeu/repository/storage.rb +2 -0
- data/lib/vedeu/support/esc.rb +2 -1
- data/lib/vedeu/support/geometry.rb +11 -23
- data/lib/vedeu/support/parser.rb +1 -1
- data/lib/vedeu/support/queue.rb +3 -1
- data/lib/vedeu.rb +18 -1
- data/test/example_app/bin/app +9 -0
- data/test/example_app/lib/app.rb +63 -0
- data/test/lib/vedeu/application_test.rb +6 -36
- data/test/lib/vedeu/configuration_test.rb +5 -31
- data/test/lib/vedeu/input/input_test.rb +4 -16
- data/test/lib/vedeu/launcher_test.rb +6 -15
- data/test/lib/vedeu/models/background_test.rb +5 -21
- data/test/lib/vedeu/models/colour_test.rb +18 -49
- data/test/lib/vedeu/models/command_test.rb +19 -83
- data/test/lib/vedeu/models/composition_test.rb +78 -175
- data/test/lib/vedeu/models/foreground_test.rb +4 -21
- data/test/lib/vedeu/models/interface_collection_test.rb +13 -45
- data/test/lib/vedeu/models/interface_test.rb +71 -195
- data/test/lib/vedeu/models/line_collection_test.rb +13 -52
- data/test/lib/vedeu/models/line_test.rb +17 -61
- data/test/lib/vedeu/models/presentation_test.rb +6 -19
- data/test/lib/vedeu/models/stream_collection_test.rb +10 -42
- data/test/lib/vedeu/models/stream_test.rb +16 -54
- data/test/lib/vedeu/models/style_collection_test.rb +1 -10
- data/test/lib/vedeu/output/interface_renderer_test.rb +7 -38
- data/test/lib/vedeu/output/output_test.rb +1 -18
- data/test/lib/vedeu/output/template.rb +20 -0
- data/test/lib/vedeu/output/text_adaptor_test.rb +9 -46
- data/test/lib/vedeu/process/process_test.rb +36 -38
- data/test/lib/vedeu/repository/command_repository_test.rb +16 -45
- data/test/lib/vedeu/repository/interface_repository_test.rb +36 -74
- data/test/lib/vedeu/repository/repository_test.rb +9 -33
- data/test/lib/vedeu/repository/storage_test.rb +7 -42
- data/test/lib/vedeu/support/esc_test.rb +46 -130
- data/test/lib/vedeu/support/event_repository_test.rb +31 -0
- data/test/lib/vedeu/support/exit_test.rb +1 -9
- data/test/lib/vedeu/support/geometry_test.rb +81 -105
- data/test/lib/vedeu/support/parser_test.rb +10 -54
- data/test/lib/vedeu/support/parsing/hash_parser_test.rb +18 -33
- data/test/lib/vedeu/support/parsing/json_parser_test.rb +4 -23
- data/test/lib/vedeu/support/queue_test.rb +33 -57
- data/test/lib/vedeu/support/terminal_test.rb +21 -52
- data/test/lib/vedeu/support/translator_test.rb +16 -33
- data/test/lib/vedeu/support/wordwrap_test.rb +29 -46
- data/test/lib/vedeu_test.rb +3 -5
- data/test/support/template.erb +3 -0
- data/test/test_helper.rb +1 -12
- data/vedeu.gemspec +8 -10
- metadata +26 -38
- data/lib/vedeu/support/events.rb +0 -21
- data/lib/vedeu/version.rb +0 -3
- data/test/lib/vedeu/support/events_test.rb +0 -45
- data/test/lib/vedeu/version_test.rb +0 -12
- data/test/support/output_1.json +0 -9
- 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
|
-
|
11
|
-
|
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
|
-
|
24
|
-
|
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
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
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
|
-
|
56
|
-
|
57
|
-
|
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
|
-
|
7
|
-
|
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
|
-
|
27
|
-
|
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
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
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
|
-
|
47
|
-
|
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
|
-
|
59
|
-
|
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
|
-
|
63
|
-
|
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
|
-
|
85
|
-
|
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
|
-
|
107
|
-
|
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
|
-
|
145
|
-
|
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
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
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(:
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
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
|
-
|
195
|
-
|
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
|
-
|
200
|
-
|
201
|
-
|
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
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
11
|
-
|
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
|
-
|
24
|
-
|
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
|
-
|
36
|
-
|
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
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
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
|
-
|
7
|
-
|
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
|
-
|
27
|
-
|
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
|
-
|
35
|
-
|
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
|
-
|
43
|
-
|
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
|
-
|
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
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
11
|
-
|
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
|
-
|
24
|
-
|
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
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
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
|