vedeu 0.5.4 → 0.5.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/docs/dsl.md +3 -3
- data/examples/borders_app.rb +2 -0
- data/examples/colours_app.rb +2 -0
- data/examples/configuration_app.rb +2 -0
- data/examples/drb_app.rb +2 -0
- data/examples/focus_app.rb +2 -0
- data/examples/hello_world.rb +2 -0
- data/examples/material_colours_app.rb +2 -0
- data/lib/vedeu.rb +2 -0
- data/lib/vedeu/all.rb +4 -13
- data/lib/vedeu/api.rb +7 -6
- data/lib/vedeu/borders/border.rb +1 -1
- data/lib/vedeu/borders/render_border.rb +18 -18
- data/lib/vedeu/buffers/buffer.rb +18 -28
- data/lib/vedeu/colours/colour.rb +1 -1
- data/lib/vedeu/colours/colour_translator.rb +1 -1
- data/lib/vedeu/cursor/cursor.rb +9 -6
- data/lib/vedeu/dsl/border.rb +1 -1
- data/lib/vedeu/dsl/composition.rb +5 -5
- data/lib/vedeu/dsl/geometry.rb +1 -1
- data/lib/vedeu/dsl/group.rb +1 -1
- data/lib/vedeu/dsl/interface.rb +69 -93
- data/lib/vedeu/dsl/keymap.rb +1 -1
- data/lib/vedeu/dsl/line.rb +11 -11
- data/lib/vedeu/dsl/shared.rb +81 -0
- data/lib/vedeu/dsl/stream.rb +3 -3
- data/lib/vedeu/dsl/view.rb +76 -64
- data/lib/vedeu/models/escape.rb +1 -1
- data/lib/vedeu/models/interface.rb +3 -57
- data/lib/vedeu/models/menu.rb +1 -1
- data/lib/vedeu/models/views/all.rb +22 -0
- data/lib/vedeu/models/views/char.rb +175 -0
- data/lib/vedeu/models/views/chars.rb +13 -0
- data/lib/vedeu/models/views/composition.rb +73 -0
- data/lib/vedeu/models/views/line.rb +111 -0
- data/lib/vedeu/models/views/lines.rb +13 -0
- data/lib/vedeu/models/views/stream.rb +122 -0
- data/lib/vedeu/models/views/streams.rb +13 -0
- data/lib/vedeu/models/views/view.rb +157 -0
- data/lib/vedeu/models/views/view_collection.rb +13 -0
- data/lib/vedeu/null/view.rb +67 -0
- data/lib/vedeu/output/clear/named_interface.rb +4 -4
- data/lib/vedeu/output/compressor.rb +6 -6
- data/lib/vedeu/output/html_char.rb +6 -6
- data/lib/vedeu/output/output.rb +3 -3
- data/lib/vedeu/output/presentation.rb +1 -1
- data/lib/vedeu/output/renderers/escape_sequence.rb +1 -1
- data/lib/vedeu/output/renderers/file.rb +1 -1
- data/lib/vedeu/output/renderers/html.rb +3 -3
- data/lib/vedeu/output/renderers/json.rb +4 -4
- data/lib/vedeu/output/renderers/null.rb +1 -1
- data/lib/vedeu/output/renderers/terminal.rb +5 -5
- data/lib/vedeu/output/renderers/text.rb +3 -3
- data/lib/vedeu/output/style.rb +1 -1
- data/lib/vedeu/output/text.rb +20 -15
- data/lib/vedeu/output/viewport.rb +16 -23
- data/lib/vedeu/output/virtual_buffer.rb +9 -8
- data/lib/vedeu/output/virtual_terminal.rb +11 -11
- data/lib/vedeu/output/wordwrap.rb +5 -5
- data/lib/vedeu/runtime/application.rb +1 -1
- data/lib/vedeu/runtime/main_loop.rb +1 -1
- data/lib/vedeu/templating/helpers.rb +11 -10
- data/lib/vedeu/templating/template.rb +1 -1
- data/lib/vedeu/templating/view_template.rb +6 -6
- data/lib/vedeu/version.rb +1 -2
- data/test/lib/vedeu/api_test.rb +30 -30
- data/test/lib/vedeu/buffers/buffer_test.rb +5 -139
- data/test/lib/vedeu/colours/colour_translator_test.rb +3 -3
- data/test/lib/vedeu/configuration/api_test.rb +3 -3
- data/test/lib/vedeu/cursor/refresh_cursor_test.rb +1 -1
- data/test/lib/vedeu/dsl/composition_test.rb +7 -7
- data/test/lib/vedeu/dsl/group_test.rb +2 -2
- data/test/lib/vedeu/dsl/interface_test.rb +31 -21
- data/test/lib/vedeu/dsl/keymap_test.rb +4 -4
- data/test/lib/vedeu/dsl/line_test.rb +8 -8
- data/test/lib/vedeu/dsl/stream_test.rb +4 -4
- data/test/lib/vedeu/dsl/text_test.rb +11 -11
- data/test/lib/vedeu/dsl/view_test.rb +24 -29
- data/test/lib/vedeu/geometry/grid_test.rb +4 -4
- data/test/lib/vedeu/input/key_test.rb +1 -1
- data/test/lib/vedeu/internal_api_test.rb +18 -18
- data/test/lib/vedeu/models/focus_test.rb +54 -54
- data/test/lib/vedeu/models/interface_test.rb +11 -105
- data/test/lib/vedeu/models/menu_test.rb +1 -1
- data/test/lib/vedeu/models/views/char_test.rb +257 -0
- data/test/lib/vedeu/models/views/chars_test.rb +22 -0
- data/test/lib/vedeu/models/views/composition_test.rb +61 -0
- data/test/lib/vedeu/models/views/line_test.rb +189 -0
- data/test/lib/vedeu/models/views/lines_test.rb +22 -0
- data/test/lib/vedeu/models/views/stream_test.rb +138 -0
- data/test/lib/vedeu/models/views/streams_test.rb +22 -0
- data/test/lib/vedeu/models/views/view_test.rb +40 -0
- data/test/lib/vedeu/null/view_test.rb +12 -0
- data/test/lib/vedeu/output/clear/named_interface_test.rb +4 -4
- data/test/lib/vedeu/output/compressor_test.rb +28 -28
- data/test/lib/vedeu/output/html_char_test.rb +2 -2
- data/test/lib/vedeu/output/presentation_test.rb +10 -14
- data/test/lib/vedeu/output/renderers/escape_sequence_test.rb +20 -4
- data/test/lib/vedeu/output/renderers/html_test.rb +4 -4
- data/test/lib/vedeu/output/renderers/json_test.rb +3 -3
- data/test/lib/vedeu/output/text_test.rb +10 -10
- data/test/lib/vedeu/output/viewport_test.rb +21 -23
- data/test/lib/vedeu/output/virtual_buffer_test.rb +1 -1
- data/test/lib/vedeu/output/virtual_terminal_test.rb +1 -1
- data/test/lib/vedeu/output/wordwrap_test.rb +9 -9
- data/test/lib/vedeu/repositories/repository_test.rb +2 -2
- data/test/lib/vedeu/templating/helpers_test.rb +6 -39
- data/test/lib/vedeu/templating/template_test.rb +2 -2
- data/test/lib/vedeu/templating/view_template_test.rb +91 -91
- data/test/lib/vedeu/terminal_test.rb +1 -1
- metadata +33 -27
- data/lib/vedeu/buffers/display_buffer.rb +0 -39
- data/lib/vedeu/models/char.rb +0 -170
- data/lib/vedeu/models/chars.rb +0 -9
- data/lib/vedeu/models/composition.rb +0 -66
- data/lib/vedeu/models/line.rb +0 -112
- data/lib/vedeu/models/lines.rb +0 -9
- data/lib/vedeu/models/stream.rb +0 -122
- data/lib/vedeu/models/streams.rb +0 -9
- data/test/lib/vedeu/buffers/display_buffer_test.rb +0 -61
- data/test/lib/vedeu/models/char_test.rb +0 -253
- data/test/lib/vedeu/models/chars_test.rb +0 -18
- data/test/lib/vedeu/models/composition_test.rb +0 -57
- data/test/lib/vedeu/models/line_test.rb +0 -189
- data/test/lib/vedeu/models/lines_test.rb +0 -18
- data/test/lib/vedeu/models/stream_test.rb +0 -141
- data/test/lib/vedeu/models/streams_test.rb +0 -18
@@ -0,0 +1,257 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Vedeu
|
4
|
+
|
5
|
+
module Views
|
6
|
+
|
7
|
+
describe Char do
|
8
|
+
|
9
|
+
let(:described) { Vedeu::Views::Char }
|
10
|
+
let(:instance) { described.new(attributes) }
|
11
|
+
let(:attributes) {
|
12
|
+
{
|
13
|
+
border: border,
|
14
|
+
colour: colour,
|
15
|
+
parent: parent,
|
16
|
+
position: position,
|
17
|
+
style: style,
|
18
|
+
value: _value,
|
19
|
+
}
|
20
|
+
}
|
21
|
+
let(:_value) { 'a' }
|
22
|
+
let(:parent) { Vedeu::Views::Line.new(parent_attributes) }
|
23
|
+
let(:parent_attributes) {
|
24
|
+
{
|
25
|
+
streams: [],
|
26
|
+
parent: nil,
|
27
|
+
colour: parent_colour,
|
28
|
+
style: parent_style,
|
29
|
+
}
|
30
|
+
}
|
31
|
+
let(:border) { nil }
|
32
|
+
let(:colour) { nil }
|
33
|
+
let(:style) { nil }
|
34
|
+
let(:position) { nil }
|
35
|
+
let(:parent_colour) { nil }
|
36
|
+
let(:parent_style) { nil }
|
37
|
+
|
38
|
+
describe '#initialize' do
|
39
|
+
it { instance.must_be_instance_of(described) }
|
40
|
+
it { instance.instance_variable_get('@border').must_equal(border) }
|
41
|
+
it { instance.instance_variable_get('@parent').must_equal(parent) }
|
42
|
+
it { instance.instance_variable_get('@value').must_equal(_value) }
|
43
|
+
|
44
|
+
it { instance.must_respond_to(:value) }
|
45
|
+
end
|
46
|
+
|
47
|
+
describe 'accessors' do
|
48
|
+
it { instance.must_respond_to(:border) }
|
49
|
+
it { instance.must_respond_to(:border=) }
|
50
|
+
it { instance.must_respond_to(:parent) }
|
51
|
+
it { instance.must_respond_to(:parent=) }
|
52
|
+
it { instance.must_respond_to(:attributes) }
|
53
|
+
it { instance.must_respond_to(:value=) }
|
54
|
+
end
|
55
|
+
|
56
|
+
describe '#chars' do
|
57
|
+
subject { instance.chars }
|
58
|
+
|
59
|
+
it { subject.must_be_instance_of(Array) }
|
60
|
+
end
|
61
|
+
|
62
|
+
describe '#eql?' do
|
63
|
+
let(:other) { instance }
|
64
|
+
|
65
|
+
subject { instance.eql?(other) }
|
66
|
+
|
67
|
+
it { subject.must_equal(true) }
|
68
|
+
|
69
|
+
context 'when different to other' do
|
70
|
+
let(:other) { described.new(value: 'b') }
|
71
|
+
|
72
|
+
it { subject.must_equal(false) }
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
describe '#inspect' do
|
77
|
+
let(:colour) { Vedeu::Colour.new(foreground: '#00ff00',
|
78
|
+
background: '#005500') }
|
79
|
+
let(:position) { Vedeu::Position[17, 2] }
|
80
|
+
let(:style) { Vedeu::Style.new('underline') }
|
81
|
+
|
82
|
+
|
83
|
+
subject { instance.inspect }
|
84
|
+
|
85
|
+
it { subject.must_equal(
|
86
|
+
"<Vedeu::Views::Char '" \
|
87
|
+
"\\e[17;2H" \
|
88
|
+
"\\e[38;2;0;255;0m" \
|
89
|
+
"\\e[48;2;0;85;0m" \
|
90
|
+
"\\e[4ma" \
|
91
|
+
"'>"
|
92
|
+
) }
|
93
|
+
end
|
94
|
+
|
95
|
+
describe '#position' do
|
96
|
+
subject { instance.position }
|
97
|
+
end
|
98
|
+
|
99
|
+
describe '#position=' do
|
100
|
+
subject { instance.position=(value) }
|
101
|
+
end
|
102
|
+
|
103
|
+
describe '#to_hash' do
|
104
|
+
subject { instance.to_hash }
|
105
|
+
|
106
|
+
it { subject.must_be_instance_of(Hash) }
|
107
|
+
|
108
|
+
it { subject.must_equal(
|
109
|
+
border: '',
|
110
|
+
colour: {
|
111
|
+
background: '',
|
112
|
+
foreground: '',
|
113
|
+
},
|
114
|
+
parent: {
|
115
|
+
background: '',
|
116
|
+
foreground: '',
|
117
|
+
style: '',
|
118
|
+
},
|
119
|
+
position: {
|
120
|
+
y: nil,
|
121
|
+
x: nil
|
122
|
+
},
|
123
|
+
style: '',
|
124
|
+
value: 'a')
|
125
|
+
}
|
126
|
+
end
|
127
|
+
|
128
|
+
describe '#to_html' do
|
129
|
+
subject { instance.to_html }
|
130
|
+
|
131
|
+
it { subject.must_be_instance_of(String) }
|
132
|
+
end
|
133
|
+
|
134
|
+
describe '#to_s' do
|
135
|
+
subject { instance.to_s }
|
136
|
+
|
137
|
+
it { subject.must_be_instance_of(String) }
|
138
|
+
|
139
|
+
context 'when a position is specified' do
|
140
|
+
let(:position) { Vedeu::Position[17, 2] }
|
141
|
+
|
142
|
+
it { subject.must_equal("\e[17;2Ha") }
|
143
|
+
end
|
144
|
+
|
145
|
+
context 'when a position is not specified' do
|
146
|
+
let(:position) {}
|
147
|
+
|
148
|
+
it { subject.must_equal('a') }
|
149
|
+
end
|
150
|
+
|
151
|
+
context 'when a colour is specified' do
|
152
|
+
let(:colour) { Vedeu::Colour.new(foreground: '#00ff00',
|
153
|
+
background: '#005500') }
|
154
|
+
|
155
|
+
context 'and a parent colour is specified' do
|
156
|
+
let(:parent_colour) { Vedeu::Colour.new(foreground: '#ff0000',
|
157
|
+
background: '#550000') }
|
158
|
+
|
159
|
+
it { subject.must_equal("\e[38;2;0;255;0m\e[48;2;0;85;0ma") }
|
160
|
+
end
|
161
|
+
|
162
|
+
context 'and a parent colour is not specified' do
|
163
|
+
let(:parent_colour) {}
|
164
|
+
|
165
|
+
it { subject.must_equal("\e[38;2;0;255;0m\e[48;2;0;85;0ma") }
|
166
|
+
end
|
167
|
+
end
|
168
|
+
|
169
|
+
context 'when a colour is not specified' do
|
170
|
+
let(:colour) {}
|
171
|
+
|
172
|
+
it { subject.must_equal('a') }
|
173
|
+
end
|
174
|
+
|
175
|
+
context 'when a style is specified' do
|
176
|
+
let(:style) { Vedeu::Style.new('underline') }
|
177
|
+
|
178
|
+
context 'when a parent style is specified' do
|
179
|
+
let(:parent_style) { Vedeu::Style.new('bold') }
|
180
|
+
|
181
|
+
it { subject.must_equal("\e[4ma") }
|
182
|
+
end
|
183
|
+
|
184
|
+
context 'when a parent style is not specified' do
|
185
|
+
let(:parent_style) {}
|
186
|
+
|
187
|
+
it { subject.must_equal("\e[4ma") }
|
188
|
+
end
|
189
|
+
end
|
190
|
+
|
191
|
+
context 'when a style is not specified' do
|
192
|
+
let(:style) {}
|
193
|
+
|
194
|
+
it { subject.must_equal('a') }
|
195
|
+
end
|
196
|
+
|
197
|
+
context 'when the value is nil' do
|
198
|
+
let(:_value) {}
|
199
|
+
|
200
|
+
it { subject.must_equal('') }
|
201
|
+
end
|
202
|
+
end
|
203
|
+
|
204
|
+
describe '#value' do
|
205
|
+
subject { instance.value }
|
206
|
+
|
207
|
+
it { subject.must_be_instance_of(String) }
|
208
|
+
|
209
|
+
context 'when the border attribute is defined' do
|
210
|
+
let(:border) { :top_left }
|
211
|
+
let(:_value) { "\x6C" }
|
212
|
+
|
213
|
+
it { subject.must_equal("\e(0l\e(B") }
|
214
|
+
end
|
215
|
+
|
216
|
+
context 'when the border attributes is not defined' do
|
217
|
+
it { subject.must_equal('a') }
|
218
|
+
end
|
219
|
+
end
|
220
|
+
|
221
|
+
describe '#x' do
|
222
|
+
let(:position) { Vedeu::Position[17, 2] }
|
223
|
+
|
224
|
+
subject { instance.x }
|
225
|
+
|
226
|
+
context 'when a position is set' do
|
227
|
+
it { subject.must_equal(2) }
|
228
|
+
end
|
229
|
+
|
230
|
+
context 'when a position is not set' do
|
231
|
+
let(:position) {}
|
232
|
+
|
233
|
+
it { subject.must_equal(nil) }
|
234
|
+
end
|
235
|
+
end
|
236
|
+
|
237
|
+
describe '#y' do
|
238
|
+
let(:position) { Vedeu::Position[17, 2] }
|
239
|
+
|
240
|
+
subject { instance.y }
|
241
|
+
|
242
|
+
context 'when a position is set' do
|
243
|
+
it { subject.must_equal(17) }
|
244
|
+
end
|
245
|
+
|
246
|
+
context 'when a position is not set' do
|
247
|
+
let(:position) {}
|
248
|
+
|
249
|
+
it { subject.must_equal(nil) }
|
250
|
+
end
|
251
|
+
end
|
252
|
+
|
253
|
+
end # Char
|
254
|
+
|
255
|
+
end # Views
|
256
|
+
|
257
|
+
end # Vedeu
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Vedeu
|
4
|
+
|
5
|
+
module Views
|
6
|
+
|
7
|
+
describe Chars do
|
8
|
+
|
9
|
+
let(:described) { Vedeu::Views::Chars }
|
10
|
+
let(:instance) { described.new }
|
11
|
+
|
12
|
+
it { described.superclass.must_equal(Vedeu::Collection) }
|
13
|
+
|
14
|
+
describe '#initialize' do
|
15
|
+
it { instance.must_be_instance_of(described) }
|
16
|
+
end
|
17
|
+
|
18
|
+
end # Chars
|
19
|
+
|
20
|
+
end # Views
|
21
|
+
|
22
|
+
end # Vedeu
|
@@ -0,0 +1,61 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Vedeu
|
4
|
+
|
5
|
+
module Views
|
6
|
+
|
7
|
+
describe Composition do
|
8
|
+
|
9
|
+
let(:described) { Vedeu::Views::Composition }
|
10
|
+
let(:instance) { described.new(attributes) }
|
11
|
+
let(:attributes) {
|
12
|
+
{
|
13
|
+
views: views,
|
14
|
+
colour: colour,
|
15
|
+
style: style,
|
16
|
+
}
|
17
|
+
}
|
18
|
+
let(:views) { [] }
|
19
|
+
let(:colour) {}
|
20
|
+
let(:style) {}
|
21
|
+
|
22
|
+
describe '.build' do
|
23
|
+
subject {
|
24
|
+
described.build({}) do
|
25
|
+
# ...
|
26
|
+
end
|
27
|
+
}
|
28
|
+
|
29
|
+
it { subject.must_be_instance_of(described) }
|
30
|
+
end
|
31
|
+
|
32
|
+
describe '#initialize' do
|
33
|
+
it { instance.must_be_instance_of(described) }
|
34
|
+
it { instance.instance_variable_get('@views').must_equal(views) }
|
35
|
+
end
|
36
|
+
|
37
|
+
describe '#add' do
|
38
|
+
let(:child) { Vedeu::Views::View.new }
|
39
|
+
|
40
|
+
subject { instance.add(child) }
|
41
|
+
|
42
|
+
it { subject.must_be_instance_of(Vedeu::Views::ViewCollection) }
|
43
|
+
end
|
44
|
+
|
45
|
+
describe '#views' do
|
46
|
+
subject { instance.views }
|
47
|
+
|
48
|
+
it { subject.must_be_instance_of(Vedeu::Views::ViewCollection) }
|
49
|
+
end
|
50
|
+
|
51
|
+
describe '#parent' do
|
52
|
+
subject { instance.parent }
|
53
|
+
|
54
|
+
it { subject.must_be_instance_of(NilClass) }
|
55
|
+
end
|
56
|
+
|
57
|
+
end # Composition
|
58
|
+
|
59
|
+
end # Views
|
60
|
+
|
61
|
+
end # Vedeu
|
@@ -0,0 +1,189 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Vedeu
|
4
|
+
|
5
|
+
module Views
|
6
|
+
|
7
|
+
describe Line do
|
8
|
+
|
9
|
+
let(:described) { Vedeu::Views::Line }
|
10
|
+
let(:instance) { described.new(attributes) }
|
11
|
+
let(:attributes) {
|
12
|
+
{
|
13
|
+
streams: streams,
|
14
|
+
parent: parent,
|
15
|
+
colour: colour,
|
16
|
+
style: style,
|
17
|
+
}
|
18
|
+
}
|
19
|
+
let(:streams) {
|
20
|
+
[
|
21
|
+
Vedeu::Views::Stream.new(value: 'Something interesting ',
|
22
|
+
parent: streams_parent,
|
23
|
+
colour: Vedeu::Colour.new(foreground: '#ffff00'),
|
24
|
+
style: Vedeu::Style.new('normal')),
|
25
|
+
Vedeu::Views::Stream.new(value: 'on this line ',
|
26
|
+
parent: streams_parent,
|
27
|
+
colour: Vedeu::Colour.new(foreground: '#00ff00'),
|
28
|
+
style: Vedeu::Style.new('normal')),
|
29
|
+
Vedeu::Views::Stream.new(value: 'would be cool, eh?',
|
30
|
+
parent: streams_parent,
|
31
|
+
colour: Vedeu::Colour.new(foreground: '#0000ff'),
|
32
|
+
style: Vedeu::Style.new('normal'))
|
33
|
+
]
|
34
|
+
}
|
35
|
+
|
36
|
+
let(:streams_parent) {
|
37
|
+
Vedeu::Views::Line.new(streams: nil,
|
38
|
+
parent: parent,
|
39
|
+
colour: colour,
|
40
|
+
style: style)
|
41
|
+
}
|
42
|
+
|
43
|
+
let(:parent) { Vedeu::Views::View.new(name: 'Vedeu::Line') }
|
44
|
+
let(:colour) {
|
45
|
+
Vedeu::Colour.new(foreground: '#ff0000', background: '#000000')
|
46
|
+
}
|
47
|
+
let(:style) { Vedeu::Style.new('normal') }
|
48
|
+
|
49
|
+
describe '#initialize' do
|
50
|
+
it { instance.must_be_instance_of(described) }
|
51
|
+
it { instance.instance_variable_get('@streams').must_equal(streams) }
|
52
|
+
it { instance.instance_variable_get('@parent').must_equal(parent) }
|
53
|
+
end
|
54
|
+
|
55
|
+
describe 'accessors' do
|
56
|
+
it { instance.must_respond_to(:parent) }
|
57
|
+
it { instance.must_respond_to(:parent=) }
|
58
|
+
it { instance.must_respond_to(:attributes) }
|
59
|
+
end
|
60
|
+
|
61
|
+
describe '#add' do
|
62
|
+
subject { instance.add(child) }
|
63
|
+
|
64
|
+
it { instance.must_respond_to(:add) }
|
65
|
+
|
66
|
+
it { instance.must_respond_to(:<<) }
|
67
|
+
end
|
68
|
+
|
69
|
+
describe '#chars' do
|
70
|
+
subject { instance.chars }
|
71
|
+
|
72
|
+
it { subject.must_be_instance_of(Array) }
|
73
|
+
|
74
|
+
context 'when there is no content' do
|
75
|
+
let(:streams) { [] }
|
76
|
+
|
77
|
+
it { subject.must_equal([]) }
|
78
|
+
end
|
79
|
+
|
80
|
+
context 'when there is content' do
|
81
|
+
it { subject.size.must_equal(53) }
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
describe '#empty?' do
|
86
|
+
subject { instance.empty? }
|
87
|
+
|
88
|
+
context 'when there is no content' do
|
89
|
+
let(:streams) { [] }
|
90
|
+
|
91
|
+
it { subject.must_be_instance_of(TrueClass) }
|
92
|
+
end
|
93
|
+
|
94
|
+
context 'when there is content' do
|
95
|
+
it { subject.must_be_instance_of(FalseClass) }
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
describe '#eql?' do
|
100
|
+
let(:other) { instance }
|
101
|
+
|
102
|
+
subject { instance.eql?(other) }
|
103
|
+
|
104
|
+
it { subject.must_equal(true) }
|
105
|
+
|
106
|
+
context 'when different to other' do
|
107
|
+
let(:other) { described.new(streams: [:other]) }
|
108
|
+
|
109
|
+
it { subject.must_equal(false) }
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
describe '#name' do
|
114
|
+
subject { instance.name }
|
115
|
+
|
116
|
+
context 'when a parent is defined' do
|
117
|
+
it { subject.must_be_instance_of(String) }
|
118
|
+
end
|
119
|
+
|
120
|
+
context 'when a parent is not defined' do
|
121
|
+
before { instance.stubs(:parent) }
|
122
|
+
|
123
|
+
it { subject.must_be_instance_of(NilClass) }
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
describe '#size' do
|
128
|
+
subject { instance.size }
|
129
|
+
|
130
|
+
it { subject.must_be_instance_of(Fixnum) }
|
131
|
+
|
132
|
+
it 'returns the size of the line' do
|
133
|
+
subject.must_equal(53)
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
describe '#streams' do
|
138
|
+
subject { instance.streams }
|
139
|
+
|
140
|
+
it { instance.must_respond_to(:value) }
|
141
|
+
|
142
|
+
it { subject.must_be_instance_of(Vedeu::Views::Streams) }
|
143
|
+
end
|
144
|
+
|
145
|
+
describe '#to_s' do
|
146
|
+
subject { instance.to_s }
|
147
|
+
|
148
|
+
it { subject.must_be_instance_of(String) }
|
149
|
+
|
150
|
+
it 'returns the line complete with formatting' do
|
151
|
+
# (starts in Line colour)
|
152
|
+
# (starts in Line style)
|
153
|
+
# Stream 1 colour
|
154
|
+
# Stream 1 style
|
155
|
+
# Stream 1 value
|
156
|
+
# (resets style to Line style)
|
157
|
+
# (resets colour to Line colour)
|
158
|
+
# Stream 2 colour
|
159
|
+
# Stream 2 style
|
160
|
+
# Stream 2 value
|
161
|
+
# (resets style to Line style)
|
162
|
+
# (resets colour to Line colour)
|
163
|
+
# Stream 3 colour
|
164
|
+
# Stream 3 style
|
165
|
+
# Stream 3 value
|
166
|
+
# (resets style to Line style)
|
167
|
+
# (resets colour to Line colour)
|
168
|
+
|
169
|
+
subject.must_equal(
|
170
|
+
"\e[38;2;255;0;0m\e[48;2;0;0;0m" \
|
171
|
+
"\e[24m\e[22m\e[27m" \
|
172
|
+
"\e[38;2;255;255;0m" \
|
173
|
+
"\e[24m\e[22m\e[27m" \
|
174
|
+
'Something interesting ' \
|
175
|
+
"\e[38;2;0;255;0m" \
|
176
|
+
"\e[24m\e[22m\e[27m" \
|
177
|
+
'on this line ' \
|
178
|
+
"\e[38;2;0;0;255m" \
|
179
|
+
"\e[24m\e[22m\e[27m" \
|
180
|
+
'would be cool, eh?'
|
181
|
+
)
|
182
|
+
end
|
183
|
+
end
|
184
|
+
|
185
|
+
end # Line
|
186
|
+
|
187
|
+
end # Views
|
188
|
+
|
189
|
+
end # Vedeu
|