vedeu 0.2.11 → 0.2.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/examples/borders_app.rb +171 -0
- data/lib/vedeu.rb +1 -1
- data/lib/vedeu/api/interface.rb +12 -0
- data/lib/vedeu/api/menu.rb +1 -1
- data/lib/vedeu/colours/colour.rb +1 -1
- data/lib/vedeu/models/border.rb +238 -0
- data/lib/vedeu/models/char.rb +1 -1
- data/lib/vedeu/models/composition.rb +1 -1
- data/lib/vedeu/models/geometry.rb +1 -1
- data/lib/vedeu/models/line.rb +1 -1
- data/lib/vedeu/models/stream.rb +1 -1
- data/lib/vedeu/output/output.rb +1 -1
- data/lib/vedeu/output/viewport.rb +34 -3
- data/lib/vedeu/repositories/models/cursor.rb +34 -7
- data/lib/vedeu/repositories/models/event.rb +1 -1
- data/lib/vedeu/repositories/models/group.rb +1 -1
- data/lib/vedeu/repositories/models/interface.rb +14 -6
- data/lib/vedeu/repositories/models/keymap.rb +1 -1
- data/lib/vedeu/repositories/models/offset.rb +1 -1
- data/lib/vedeu/support/trace.rb +1 -1
- data/test/integration/views/basic_view_test.rb +19 -0
- data/test/lib/vedeu/api/api_test.rb +6 -5
- data/test/lib/vedeu/api/helpers_test.rb +2 -6
- data/test/lib/vedeu/api/interface_test.rb +53 -45
- data/test/lib/vedeu/api/menu_test.rb +6 -0
- data/test/lib/vedeu/api/stream_test.rb +1 -3
- data/test/lib/vedeu/application_test.rb +6 -12
- data/test/lib/vedeu/colours/colour_test.rb +16 -5
- data/test/lib/vedeu/colours/translator_test.rb +7 -2
- data/test/lib/vedeu/configuration/cli_test.rb +9 -0
- data/test/lib/vedeu/input/input_test.rb +5 -5
- data/test/lib/vedeu/launcher_test.rb +9 -3
- data/test/lib/vedeu/models/border_test.rb +197 -0
- data/test/lib/vedeu/models/char_test.rb +18 -15
- data/test/lib/vedeu/models/composition_test.rb +6 -7
- data/test/lib/vedeu/models/geometry_test.rb +43 -49
- data/test/lib/vedeu/models/key_test.rb +7 -5
- data/test/lib/vedeu/models/line_test.rb +12 -16
- data/test/lib/vedeu/models/stream_test.rb +20 -10
- data/test/lib/vedeu/models/style_test.rb +9 -10
- data/test/lib/vedeu/output/compositor_test.rb +7 -22
- data/test/lib/vedeu/output/output_test.rb +34 -33
- data/test/lib/vedeu/output/viewport_test.rb +6 -6
- data/test/lib/vedeu/repositories/models/buffer_test.rb +13 -18
- data/test/lib/vedeu/repositories/models/cursor_test.rb +21 -21
- data/test/lib/vedeu/repositories/models/event_test.rb +10 -4
- data/test/lib/vedeu/{models → repositories/models}/group_test.rb +8 -9
- data/test/lib/vedeu/repositories/models/interface_test.rb +37 -17
- data/test/lib/vedeu/repositories/models/keymap_test.rb +6 -6
- data/test/lib/vedeu/repositories/models/menu_test.rb +6 -3
- data/test/lib/vedeu/repositories/models/offset_test.rb +6 -3
- data/test/lib/vedeu/support/bounding_area_test.rb +28 -36
- data/test/lib/vedeu/support/grid_test.rb +8 -0
- data/test/lib/vedeu/support/keymap_validator_test.rb +5 -8
- data/test/lib/vedeu/support/position_test.rb +3 -3
- data/test/lib/vedeu/support/registrar_test.rb +13 -7
- data/test/lib/vedeu/support/sentence_test.rb +9 -2
- data/test/lib/vedeu/support/trace_test.rb +5 -3
- data/test/test_helper.rb +12 -0
- data/vedeu.gemspec +1 -1
- metadata +8 -7
- data/lib/vedeu/output/view.rb +0 -64
- data/test/lib/vedeu/output/view_test.rb +0 -21
@@ -7,9 +7,7 @@ module Vedeu
|
|
7
7
|
describe Helpers do
|
8
8
|
|
9
9
|
describe '#background' do
|
10
|
-
it '
|
11
|
-
HelpersTestClass.new.background('#00ff00').must_be_instance_of(Hash)
|
12
|
-
end
|
10
|
+
it { return_type_for(HelpersTestClass.new.background('#00ff00'), Hash) }
|
13
11
|
|
14
12
|
it 'returns the value assigned' do
|
15
13
|
HelpersTestClass.new.background('#00ff00').must_equal({ background: '#00ff00' })
|
@@ -21,9 +19,7 @@ module Vedeu
|
|
21
19
|
end
|
22
20
|
|
23
21
|
describe '#foreground' do
|
24
|
-
it '
|
25
|
-
HelpersTestClass.new.foreground('#00ff00').must_be_instance_of(Hash)
|
26
|
-
end
|
22
|
+
it { return_type_for(HelpersTestClass.new.foreground('#00ff00'), Hash) }
|
27
23
|
|
28
24
|
it 'returns the value assigned' do
|
29
25
|
HelpersTestClass.new.foreground('#00ff00').must_equal({ foreground: '#00ff00' })
|
@@ -20,18 +20,19 @@ module Vedeu
|
|
20
20
|
colour foreground: '#aadd00', background: '#222222'
|
21
21
|
end.must_equal(
|
22
22
|
{
|
23
|
-
|
24
|
-
cursor: :hide,
|
25
|
-
group: '',
|
26
|
-
lines: [],
|
23
|
+
border: {},
|
27
24
|
colour: {
|
28
25
|
foreground: '#aadd00',
|
29
26
|
background: '#222222'
|
30
27
|
},
|
31
|
-
|
32
|
-
geometry: {},
|
28
|
+
cursor: :hide,
|
33
29
|
delay: 0.0,
|
30
|
+
geometry: {},
|
31
|
+
group: '',
|
32
|
+
lines: [],
|
33
|
+
name: '',
|
34
34
|
parent: nil,
|
35
|
+
style: '',
|
35
36
|
}
|
36
37
|
)
|
37
38
|
end
|
@@ -41,15 +42,16 @@ module Vedeu
|
|
41
42
|
style 'underline'
|
42
43
|
end.must_equal(
|
43
44
|
{
|
44
|
-
|
45
|
+
border: {},
|
46
|
+
colour: {},
|
45
47
|
cursor: :hide,
|
48
|
+
delay: 0.0,
|
49
|
+
geometry: {},
|
46
50
|
group: '',
|
47
51
|
lines: [],
|
48
|
-
|
49
|
-
style: "underline",
|
50
|
-
geometry: {},
|
51
|
-
delay: 0.0,
|
52
|
+
name: '',
|
52
53
|
parent: nil,
|
54
|
+
style: "underline",
|
53
55
|
}
|
54
56
|
)
|
55
57
|
end
|
@@ -66,17 +68,18 @@ module Vedeu
|
|
66
68
|
name 'my_other_interface'
|
67
69
|
y use('my_interface').south
|
68
70
|
end.must_equal({
|
69
|
-
|
70
|
-
cursor: :hide,
|
71
|
-
group: '',
|
72
|
-
lines: [],
|
71
|
+
border: {},
|
73
72
|
colour: {},
|
74
|
-
|
73
|
+
cursor: :hide,
|
74
|
+
delay: 0.0,
|
75
75
|
geometry: {
|
76
76
|
y: 11
|
77
77
|
},
|
78
|
-
|
78
|
+
group: '',
|
79
|
+
lines: [],
|
80
|
+
name: "my_other_interface",
|
79
81
|
parent: nil,
|
82
|
+
style: '',
|
80
83
|
})
|
81
84
|
end
|
82
85
|
end
|
@@ -87,15 +90,16 @@ module Vedeu
|
|
87
90
|
delay 1.0
|
88
91
|
end.must_equal(
|
89
92
|
{
|
90
|
-
|
93
|
+
border: {},
|
94
|
+
colour: {},
|
91
95
|
cursor: :hide,
|
96
|
+
delay: 1.0,
|
97
|
+
geometry: {},
|
92
98
|
group: '',
|
93
99
|
lines: [],
|
94
|
-
|
95
|
-
style: '',
|
96
|
-
geometry: {},
|
97
|
-
delay: 1.0,
|
100
|
+
name: '',
|
98
101
|
parent: nil,
|
102
|
+
style: '',
|
99
103
|
})
|
100
104
|
end
|
101
105
|
|
@@ -105,15 +109,16 @@ module Vedeu
|
|
105
109
|
group 'my_group'
|
106
110
|
end.must_equal(
|
107
111
|
{
|
108
|
-
|
112
|
+
border: {},
|
113
|
+
colour: {},
|
109
114
|
cursor: :hide,
|
115
|
+
delay: 0.0,
|
116
|
+
geometry: {},
|
110
117
|
group: "my_group",
|
111
118
|
lines: [],
|
112
|
-
|
113
|
-
style: '',
|
114
|
-
geometry: {},
|
115
|
-
delay: 0.0,
|
119
|
+
name: '',
|
116
120
|
parent: nil,
|
121
|
+
style: '',
|
117
122
|
}
|
118
123
|
)
|
119
124
|
end
|
@@ -246,24 +251,25 @@ module Vedeu
|
|
246
251
|
interface.must_be_instance_of(API::Interface)
|
247
252
|
interface.attributes.must_equal(
|
248
253
|
{
|
249
|
-
|
254
|
+
border: {},
|
255
|
+
colour: {},
|
250
256
|
cursor: :hide,
|
257
|
+
delay: 0.0,
|
258
|
+
geometry: {},
|
251
259
|
group: '',
|
252
260
|
lines: [
|
253
261
|
{
|
254
262
|
colour: {},
|
263
|
+
parent: interface.view_attributes,
|
255
264
|
streams: {
|
256
265
|
text: ''
|
257
266
|
},
|
258
267
|
style: [],
|
259
|
-
parent: interface.view_attributes,
|
260
268
|
}
|
261
269
|
],
|
262
|
-
|
263
|
-
style: '',
|
264
|
-
geometry: {},
|
265
|
-
delay: 0.0,
|
270
|
+
name: 'carbon',
|
266
271
|
parent: nil,
|
272
|
+
style: '',
|
267
273
|
}
|
268
274
|
)
|
269
275
|
end
|
@@ -275,24 +281,25 @@ module Vedeu
|
|
275
281
|
interface.must_be_instance_of(API::Interface)
|
276
282
|
interface.attributes.must_equal(
|
277
283
|
{
|
278
|
-
|
284
|
+
border: {},
|
285
|
+
colour: {},
|
279
286
|
cursor: :hide,
|
287
|
+
delay: 0.0,
|
288
|
+
geometry: {},
|
280
289
|
group: '',
|
281
290
|
lines: [
|
282
291
|
{
|
283
292
|
colour: {},
|
293
|
+
parent: interface.view_attributes,
|
284
294
|
streams: {
|
285
295
|
text: "This is some text..."
|
286
296
|
},
|
287
297
|
style: [],
|
288
|
-
parent: interface.view_attributes,
|
289
298
|
}
|
290
299
|
],
|
291
|
-
|
292
|
-
style: '',
|
293
|
-
geometry: {},
|
294
|
-
delay: 0.0,
|
300
|
+
name: 'carbon',
|
295
301
|
parent: nil,
|
302
|
+
style: '',
|
296
303
|
}
|
297
304
|
)
|
298
305
|
end
|
@@ -306,26 +313,27 @@ module Vedeu
|
|
306
313
|
interface.must_be_instance_of(API::Interface)
|
307
314
|
interface.attributes.must_equal(
|
308
315
|
{
|
309
|
-
|
316
|
+
border: {},
|
317
|
+
colour: {},
|
310
318
|
cursor: :hide,
|
319
|
+
delay: 0.0,
|
320
|
+
geometry: {},
|
311
321
|
group: '',
|
312
322
|
lines: [
|
313
323
|
{
|
314
324
|
colour: {},
|
325
|
+
parent: interface.view_attributes,
|
315
326
|
streams: [
|
316
327
|
{
|
317
328
|
text: "This is different text..."
|
318
329
|
}
|
319
330
|
],
|
320
331
|
style: [],
|
321
|
-
parent: interface.view_attributes,
|
322
332
|
}
|
323
333
|
],
|
324
|
-
|
334
|
+
name: "silicon",
|
335
|
+
parent: nil,
|
325
336
|
style: '',
|
326
|
-
geometry: {},
|
327
|
-
delay: 0.0,
|
328
|
-
parent: nil
|
329
337
|
}
|
330
338
|
)
|
331
339
|
end
|
@@ -37,6 +37,12 @@ module Vedeu
|
|
37
37
|
it 'returns an instance of itself' do
|
38
38
|
Menu.new.must_be_instance_of(Menu)
|
39
39
|
end
|
40
|
+
|
41
|
+
it 'assigns the attributes' do
|
42
|
+
attributes = { name: '', items: [] }
|
43
|
+
subject = Menu.new(attributes)
|
44
|
+
assigns(subject, '@attributes', attributes)
|
45
|
+
end
|
40
46
|
end
|
41
47
|
|
42
48
|
describe '#items' do
|
@@ -7,9 +7,7 @@ module Vedeu
|
|
7
7
|
describe Stream do
|
8
8
|
|
9
9
|
describe '#align' do
|
10
|
-
it
|
11
|
-
Stream.new.align(:left).must_be_instance_of(Symbol)
|
12
|
-
end
|
10
|
+
it { return_type_for(Stream.new.align(:left), Symbol) }
|
13
11
|
|
14
12
|
it 'returns the value assigned' do
|
15
13
|
Stream.new.align(:left).must_equal(:left)
|
@@ -4,17 +4,15 @@ module Vedeu
|
|
4
4
|
|
5
5
|
describe Application do
|
6
6
|
|
7
|
+
let(:described) { Application.new }
|
8
|
+
|
7
9
|
before { Terminal.stubs(:open).returns(['']) }
|
8
10
|
|
9
11
|
describe '.start' do
|
10
|
-
it
|
11
|
-
Application.start.must_be_instance_of(Array)
|
12
|
-
end
|
12
|
+
it { return_type_for(Application.start, Array) }
|
13
13
|
|
14
14
|
context 'alias method: .restart' do
|
15
|
-
it
|
16
|
-
Application.restart.must_be_instance_of(Array)
|
17
|
-
end
|
15
|
+
it { return_type_for(Application.restart, Array) }
|
18
16
|
end
|
19
17
|
end
|
20
18
|
|
@@ -25,15 +23,11 @@ module Vedeu
|
|
25
23
|
end
|
26
24
|
|
27
25
|
describe '#initialize' do
|
28
|
-
it
|
29
|
-
Application.new.must_be_instance_of(Application)
|
30
|
-
end
|
26
|
+
it { return_type_for(described, Application) }
|
31
27
|
end
|
32
28
|
|
33
29
|
describe '#start' do
|
34
|
-
it
|
35
|
-
Application.new.start.must_be_instance_of(Array)
|
36
|
-
end
|
30
|
+
it { return_type_for(described.start, Array) }
|
37
31
|
end
|
38
32
|
|
39
33
|
end # Application
|
@@ -4,15 +4,22 @@ module Vedeu
|
|
4
4
|
|
5
5
|
describe Colour do
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
7
|
+
let(:described) { Colour.new(attributes) }
|
8
|
+
let(:attributes) {
|
9
|
+
{
|
10
|
+
background: '',
|
11
|
+
foreground: ''
|
12
|
+
}
|
13
|
+
}
|
10
14
|
|
11
|
-
|
12
|
-
|
15
|
+
describe '#initialize' do
|
16
|
+
it { return_type_for(described, Colour) }
|
17
|
+
it { assigns(described, '@attributes', attributes) }
|
13
18
|
end
|
14
19
|
|
15
20
|
describe '#background' do
|
21
|
+
it { return_type_for(described.background, String) }
|
22
|
+
|
16
23
|
it 'returns an escape sequence' do
|
17
24
|
Colour.new({
|
18
25
|
background: '#000000'
|
@@ -25,6 +32,8 @@ module Vedeu
|
|
25
32
|
end
|
26
33
|
|
27
34
|
describe '#foreground' do
|
35
|
+
it { return_type_for(described.foreground, String) }
|
36
|
+
|
28
37
|
it 'returns an escape sequence' do
|
29
38
|
Colour.new({
|
30
39
|
foreground: '#ff0000'
|
@@ -37,6 +46,8 @@ module Vedeu
|
|
37
46
|
end
|
38
47
|
|
39
48
|
describe '#to_s' do
|
49
|
+
it { return_type_for(described.to_s, String) }
|
50
|
+
|
40
51
|
it 'returns an escape sequence' do
|
41
52
|
Colour.new({
|
42
53
|
foreground: '#ff0000',
|
@@ -4,11 +4,16 @@ module Vedeu
|
|
4
4
|
|
5
5
|
describe Translator do
|
6
6
|
|
7
|
+
colour = '#ff0000'
|
8
|
+
described = Translator.new(colour)
|
9
|
+
|
7
10
|
describe '#initialize' do
|
8
11
|
it 'returns an instance of itself' do
|
9
|
-
|
12
|
+
described.must_be_instance_of(Translator)
|
13
|
+
end
|
10
14
|
|
11
|
-
|
15
|
+
it 'assigns the colour' do
|
16
|
+
assigns(described, '@colour', colour)
|
12
17
|
end
|
13
18
|
end
|
14
19
|
|
@@ -6,9 +6,18 @@ module Vedeu
|
|
6
6
|
|
7
7
|
describe CLI do
|
8
8
|
|
9
|
+
let(:described) { CLI.new(args) }
|
10
|
+
let(:args) { [] }
|
11
|
+
|
9
12
|
before { Configuration.reset! }
|
10
13
|
after { test_configuration }
|
11
14
|
|
15
|
+
describe '#initialize' do
|
16
|
+
it { return_type_for(described, CLI) }
|
17
|
+
it { assigns(described, '@args', args) }
|
18
|
+
it { assigns(described, '@options', {}) }
|
19
|
+
end
|
20
|
+
|
12
21
|
describe '#colour_mode' do
|
13
22
|
it '--colour-mode' do
|
14
23
|
Configuration.configure(['--colour-mode', '16777216'])
|
@@ -3,15 +3,15 @@ require 'test_helper'
|
|
3
3
|
module Vedeu
|
4
4
|
|
5
5
|
describe Input do
|
6
|
-
let(:reader)
|
7
|
-
let(:keypress)
|
6
|
+
let(:reader) { mock }
|
7
|
+
let(:keypress) { 'a' }
|
8
|
+
let(:described) { Input.new(reader) }
|
8
9
|
|
9
10
|
before { reader.stubs(:read).returns(keypress) }
|
10
11
|
|
11
12
|
describe '#initialize' do
|
12
|
-
it
|
13
|
-
|
14
|
-
end
|
13
|
+
it { return_type_for(described, Input) }
|
14
|
+
it { assigns(described, '@reader', reader) }
|
15
15
|
end
|
16
16
|
|
17
17
|
describe '.capture' do
|
@@ -3,6 +3,8 @@ require 'test_helper'
|
|
3
3
|
module Vedeu
|
4
4
|
|
5
5
|
describe Launcher do
|
6
|
+
let(:described) { Launcher.new }
|
7
|
+
|
6
8
|
before do
|
7
9
|
Configuration.stubs(:configure)
|
8
10
|
Application.stubs(:start)
|
@@ -15,9 +17,13 @@ module Vedeu
|
|
15
17
|
end
|
16
18
|
|
17
19
|
describe '#initialize' do
|
18
|
-
it
|
19
|
-
|
20
|
-
|
20
|
+
it { return_type_for(described, Launcher) }
|
21
|
+
it { assigns(described, '@argv', []) }
|
22
|
+
it { assigns(described, '@stdin', STDIN) }
|
23
|
+
it { assigns(described, '@stdout', STDOUT) }
|
24
|
+
it { assigns(described, '@stderr', STDERR) }
|
25
|
+
it { assigns(described, '@kernel', Kernel) }
|
26
|
+
it { assigns(described, '@exit_code', 1) }
|
21
27
|
end
|
22
28
|
|
23
29
|
describe '#execute!' do
|
@@ -0,0 +1,197 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Vedeu
|
4
|
+
|
5
|
+
describe Border do
|
6
|
+
|
7
|
+
let(:described) { Border.new(interface, attributes) }
|
8
|
+
let(:interface) { Interface.new({
|
9
|
+
geometry: {
|
10
|
+
width: 8,
|
11
|
+
height: 5
|
12
|
+
},
|
13
|
+
lines: [
|
14
|
+
{ streams: [{ text: 'Beryllium' }] },
|
15
|
+
{ streams: [{ text: 'Magnesium' }] },
|
16
|
+
{ streams: [{ text: 'Plutonium' }] },
|
17
|
+
{ streams: [{ text: 'Potassium' }] },
|
18
|
+
{ streams: [{ text: 'Lanthanum' }] },
|
19
|
+
{ streams: [{ text: 'Strontium' }] },
|
20
|
+
]
|
21
|
+
})
|
22
|
+
}
|
23
|
+
let(:attributes) { { } }
|
24
|
+
let(:options) { { } }
|
25
|
+
|
26
|
+
describe '#initialize' do
|
27
|
+
it { return_type_for(described, Border) }
|
28
|
+
it { assigns(described, '@interface', interface) }
|
29
|
+
it { assigns(described, '@attributes', {
|
30
|
+
enabled: false,
|
31
|
+
show_bottom: true,
|
32
|
+
show_left: true,
|
33
|
+
show_right: true,
|
34
|
+
show_top: true,
|
35
|
+
bottom_right: 'j',
|
36
|
+
top_right: 'k',
|
37
|
+
top_left: 'l',
|
38
|
+
bottom_left: 'm',
|
39
|
+
horizontal: 'q',
|
40
|
+
colour: {},
|
41
|
+
style: [],
|
42
|
+
vertical: 'x'
|
43
|
+
})
|
44
|
+
}
|
45
|
+
end
|
46
|
+
|
47
|
+
describe '#bottom?' do
|
48
|
+
it { return_type_for(described.bottom?, TrueClass) }
|
49
|
+
end
|
50
|
+
|
51
|
+
describe '#left?' do
|
52
|
+
it { return_type_for(described.left?, TrueClass) }
|
53
|
+
end
|
54
|
+
|
55
|
+
describe '#right?' do
|
56
|
+
it { return_type_for(described.right?, TrueClass) }
|
57
|
+
end
|
58
|
+
|
59
|
+
describe '#top?' do
|
60
|
+
it { return_type_for(described.top?, TrueClass) }
|
61
|
+
end
|
62
|
+
|
63
|
+
describe '#to_s' do
|
64
|
+
context 'when all borders should be shown' do
|
65
|
+
it 'returns the escape sequences to draw a border' do
|
66
|
+
Border.new(interface, { enabled: true }).to_s.must_equal(
|
67
|
+
"\e(0l\e(B\e(0q\e(B\e(0q\e(B\e(0q\e(B\e(0q\e(B\e(0q\e(B\e(0q\e(B\e(0k\e(B\n" \
|
68
|
+
"\e(0x\e(BBeryll\e(0x\e(B\n" \
|
69
|
+
"\e(0x\e(BMagnes\e(0x\e(B\n" \
|
70
|
+
"\e(0x\e(BPluton\e(0x\e(B\n" \
|
71
|
+
"\e(0m\e(B\e(0q\e(B\e(0q\e(B\e(0q\e(B\e(0q\e(B\e(0q\e(B\e(0q\e(B\e(0j\e(B"
|
72
|
+
)
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
context 'when no borders are shown' do
|
77
|
+
it 'returns the escape sequences to draw a border' do
|
78
|
+
Border.new(interface, { enabled: true,
|
79
|
+
show_bottom: false,
|
80
|
+
show_left: false,
|
81
|
+
show_right: false,
|
82
|
+
show_top: false }).to_s.must_equal(
|
83
|
+
"Berylliu\n" \
|
84
|
+
"Magnesiu\n" \
|
85
|
+
"Plutoniu\n" \
|
86
|
+
"Potassiu\n" \
|
87
|
+
"Lanthanu"
|
88
|
+
)
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
context 'when the left and right border is not shown' do
|
93
|
+
it 'returns the escape sequences to draw a border' do
|
94
|
+
Border.new(interface, { enabled: true,
|
95
|
+
show_left: false,
|
96
|
+
show_right: false }).to_s.must_equal(
|
97
|
+
"\e(0q\e(B\e(0q\e(B\e(0q\e(B\e(0q\e(B\e(0q\e(B\e(0q\e(B\e(0q\e(B\e(0q\e(B\n" \
|
98
|
+
"Berylliu\n" \
|
99
|
+
"Magnesiu\n" \
|
100
|
+
"Plutoniu\n" \
|
101
|
+
"\e(0q\e(B\e(0q\e(B\e(0q\e(B\e(0q\e(B\e(0q\e(B\e(0q\e(B\e(0q\e(B\e(0q\e(B"
|
102
|
+
)
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
context 'when the top and bottom border is not shown' do
|
107
|
+
it 'returns the escape sequences to draw a border' do
|
108
|
+
Border.new(interface, { enabled: true,
|
109
|
+
show_bottom: false,
|
110
|
+
show_top: false }).to_s.must_equal(
|
111
|
+
"\e(0x\e(BBeryll\e(0x\e(B\n" \
|
112
|
+
"\e(0x\e(BMagnes\e(0x\e(B\n" \
|
113
|
+
"\e(0x\e(BPluton\e(0x\e(B\n" \
|
114
|
+
"\e(0x\e(BPotass\e(0x\e(B\n" \
|
115
|
+
"\e(0x\e(BLantha\e(0x\e(B"
|
116
|
+
)
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
context 'when the left border is shown, all others not shown' do
|
121
|
+
it 'returns the escape sequences to draw a border' do
|
122
|
+
Border.new(interface, { enabled: true,
|
123
|
+
show_bottom: false,
|
124
|
+
show_right: false,
|
125
|
+
show_top: false }).to_s.must_equal(
|
126
|
+
"\e(0x\e(BBerylli\n" \
|
127
|
+
"\e(0x\e(BMagnesi\n" \
|
128
|
+
"\e(0x\e(BPlutoni\n" \
|
129
|
+
"\e(0x\e(BPotassi\n" \
|
130
|
+
"\e(0x\e(BLanthan"
|
131
|
+
)
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
context 'when the right border is shown, all others not shown' do
|
136
|
+
it 'returns the escape sequences to draw a border' do
|
137
|
+
Border.new(interface, { enabled: true,
|
138
|
+
show_bottom: false,
|
139
|
+
show_left: false,
|
140
|
+
show_top: false }).to_s.must_equal(
|
141
|
+
"Berylli\e(0x\e(B\n" \
|
142
|
+
"Magnesi\e(0x\e(B\n" \
|
143
|
+
"Plutoni\e(0x\e(B\n" \
|
144
|
+
"Potassi\e(0x\e(B\n" \
|
145
|
+
"Lanthan\e(0x\e(B" \
|
146
|
+
)
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
150
|
+
context 'when the top border is shown, all others not shown' do
|
151
|
+
it 'returns the escape sequences to draw a border' do
|
152
|
+
Border.new(interface, { enabled: true,
|
153
|
+
show_bottom: false,
|
154
|
+
show_left: false,
|
155
|
+
show_right: false }).to_s.must_equal(
|
156
|
+
"\e(0q\e(B\e(0q\e(B\e(0q\e(B\e(0q\e(B\e(0q\e(B\e(0q\e(B\e(0q\e(B\e(0q\e(B\n" \
|
157
|
+
"Berylliu\n" \
|
158
|
+
"Magnesiu\n" \
|
159
|
+
"Plutoniu\n" \
|
160
|
+
"Potassiu"
|
161
|
+
)
|
162
|
+
end
|
163
|
+
end
|
164
|
+
|
165
|
+
context 'when the bottom border is shown, all others not shown' do
|
166
|
+
it 'returns the escape sequences to draw a border' do
|
167
|
+
Border.new(interface, { enabled: true,
|
168
|
+
show_left: false,
|
169
|
+
show_right: false,
|
170
|
+
show_top: false }).to_s.must_equal(
|
171
|
+
"Berylliu\n" \
|
172
|
+
"Magnesiu\n" \
|
173
|
+
"Plutoniu\n" \
|
174
|
+
"Potassiu\n" \
|
175
|
+
"\e(0q\e(B\e(0q\e(B\e(0q\e(B\e(0q\e(B\e(0q\e(B\e(0q\e(B\e(0q\e(B\e(0q\e(B"
|
176
|
+
)
|
177
|
+
end
|
178
|
+
end
|
179
|
+
end
|
180
|
+
|
181
|
+
describe '#to_viewport' do
|
182
|
+
it 'returns a value like Viewport#show but with borders' do
|
183
|
+
Border.new(interface, { enabled: true }).to_viewport.must_equal(
|
184
|
+
[
|
185
|
+
["\e(0l\e(B", "\e(0q\e(B", "\e(0q\e(B", "\e(0q\e(B", "\e(0q\e(B", "\e(0q\e(B", "\e(0q\e(B", "\e(0k\e(B"],
|
186
|
+
["\e(0x\e(B", "B", "e", "r", "y", "l", "l", "\e(0x\e(B"],
|
187
|
+
["\e(0x\e(B", "M", "a", "g", "n", "e", "s", "\e(0x\e(B"],
|
188
|
+
["\e(0x\e(B", "P", "l", "u", "t", "o", "n", "\e(0x\e(B"],
|
189
|
+
["\e(0m\e(B", "\e(0q\e(B", "\e(0q\e(B", "\e(0q\e(B", "\e(0q\e(B", "\e(0q\e(B", "\e(0q\e(B", "\e(0j\e(B"]
|
190
|
+
]
|
191
|
+
)
|
192
|
+
end
|
193
|
+
end
|
194
|
+
|
195
|
+
end # Border
|
196
|
+
|
197
|
+
end # Vedeu
|