vedeu 0.2.3 → 0.2.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/docs/api.md +2 -0
- data/docs/events.md +0 -4
- data/examples/cursor_app/cursor_app.rb +56 -44
- data/lib/vedeu/api/api.rb +4 -6
- data/lib/vedeu/api/composition.rb +3 -7
- data/lib/vedeu/api/interface.rb +2 -3
- data/lib/vedeu/api/menu.rb +5 -3
- data/lib/vedeu/api/stream.rb +34 -0
- data/lib/vedeu/application.rb +4 -7
- data/lib/vedeu/configuration/api.rb +0 -5
- data/lib/vedeu/configuration/cli.rb +0 -1
- data/lib/vedeu/configuration/configuration.rb +0 -12
- data/lib/vedeu/input/input.rb +0 -3
- data/lib/vedeu/launcher.rb +0 -1
- data/lib/vedeu/models/{attributes/background.rb → background.rb} +0 -4
- data/lib/vedeu/models/char.rb +43 -0
- data/lib/vedeu/models/colour.rb +0 -1
- data/lib/vedeu/models/composition.rb +4 -3
- data/lib/vedeu/models/cursor.rb +70 -146
- data/lib/vedeu/models/{attributes/foreground.rb → foreground.rb} +0 -4
- data/lib/vedeu/models/geometry.rb +19 -20
- data/lib/vedeu/models/interface.rb +36 -5
- data/lib/vedeu/models/keymap.rb +7 -4
- data/lib/vedeu/models/line.rb +31 -11
- data/lib/vedeu/models/offset.rb +84 -0
- data/lib/vedeu/models/stream.rb +37 -13
- data/lib/vedeu/models/style.rb +0 -1
- data/lib/vedeu/output/area.rb +284 -0
- data/lib/vedeu/output/clear.rb +2 -4
- data/lib/vedeu/output/compositor.rb +0 -4
- data/lib/vedeu/output/refresh.rb +1 -2
- data/lib/vedeu/output/render.rb +12 -163
- data/lib/vedeu/output/view.rb +0 -2
- data/lib/vedeu/output/viewport.rb +132 -0
- data/lib/vedeu/repositories/buffers.rb +11 -22
- data/lib/vedeu/repositories/cursors.rb +20 -47
- data/lib/vedeu/repositories/events.rb +2 -1
- data/lib/vedeu/repositories/focus.rb +16 -16
- data/lib/vedeu/repositories/groups.rb +1 -4
- data/lib/vedeu/repositories/interfaces.rb +10 -3
- data/lib/vedeu/repositories/keymaps.rb +0 -3
- data/lib/vedeu/repositories/menus.rb +0 -2
- data/lib/vedeu/repositories/offsets.rb +47 -0
- data/lib/vedeu/{models/attributes → support}/coercions.rb +0 -0
- data/lib/vedeu/{models/attributes → support}/colour_translator.rb +0 -16
- data/lib/vedeu/support/esc.rb +0 -22
- data/lib/vedeu/support/event.rb +1 -17
- data/lib/vedeu/support/exceptions.rb +0 -3
- data/lib/vedeu/support/grid.rb +0 -3
- data/lib/vedeu/support/log.rb +13 -14
- data/lib/vedeu/support/move.rb +50 -0
- data/lib/vedeu/support/position.rb +17 -9
- data/lib/vedeu/{models/attributes → support}/presentation.rb +1 -4
- data/lib/vedeu/support/registrar.rb +2 -2
- data/lib/vedeu/support/repository.rb +23 -2
- data/lib/vedeu/support/terminal.rb +0 -2
- data/lib/vedeu/support/trace.rb +0 -11
- data/lib/vedeu.rb +11 -5
- data/test/lib/vedeu/api/api_test.rb +14 -5
- data/test/lib/vedeu/api/composition_test.rb +9 -26
- data/test/lib/vedeu/api/keymap_test.rb +1 -1
- data/test/lib/vedeu/api/menu_test.rb +6 -0
- data/test/lib/vedeu/api/stream_test.rb +32 -0
- data/test/lib/vedeu/models/{attributes/background_test.rb → background_test.rb} +0 -0
- data/test/lib/vedeu/models/char_test.rb +46 -0
- data/test/lib/vedeu/models/composition_test.rb +7 -0
- data/test/lib/vedeu/models/cursor_test.rb +63 -80
- data/test/lib/vedeu/models/{attributes/foreground_test.rb → foreground_test.rb} +0 -0
- data/test/lib/vedeu/models/geometry_test.rb +8 -10
- data/test/lib/vedeu/models/interface_test.rb +26 -21
- data/test/lib/vedeu/models/keymap_test.rb +6 -0
- data/test/lib/vedeu/models/line_test.rb +82 -3
- data/test/lib/vedeu/models/offset_test.rb +121 -0
- data/test/lib/vedeu/models/stream_test.rb +107 -8
- data/test/lib/vedeu/output/area_test.rb +242 -0
- data/test/lib/vedeu/output/compositor_test.rb +12 -3
- data/test/lib/vedeu/output/render_test.rb +34 -39
- data/test/lib/vedeu/output/viewport_test.rb +36 -0
- data/test/lib/vedeu/repositories/cursors_test.rb +32 -9
- data/test/lib/vedeu/repositories/focus_test.rb +8 -0
- data/test/lib/vedeu/repositories/offsets_test.rb +32 -0
- data/test/lib/vedeu/{models/attributes → support}/coercions_test.rb +0 -0
- data/test/lib/vedeu/{models/attributes → support}/colour_translator_test.rb +0 -0
- data/test/lib/vedeu/support/move_test.rb +35 -0
- data/test/lib/vedeu/{models/attributes → support}/presentation_test.rb +0 -0
- data/test/lib/vedeu/support/registrar_test.rb +6 -0
- data/test/lib/vedeu_test.rb +5 -0
- data/vedeu.gemspec +1 -1
- metadata +37 -17
File without changes
|
@@ -27,11 +27,11 @@ module Vedeu
|
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
30
|
-
describe '#
|
30
|
+
describe '#width' do
|
31
31
|
it 'returns the viewport width when the interface fits the terminal' do
|
32
32
|
IO.console.stub(:winsize, [25, 80]) do
|
33
33
|
geometry = Geometry.new({ width: 60, height: 1, x: 5, y: 1 })
|
34
|
-
geometry.
|
34
|
+
geometry.width.must_equal(60)
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
@@ -39,23 +39,23 @@ module Vedeu
|
|
39
39
|
'terminal' do
|
40
40
|
IO.console.stub(:winsize, [25, 60]) do
|
41
41
|
geometry = Geometry.new({ width: 60, height: 1, x: 5, y: 1 })
|
42
|
-
geometry.
|
42
|
+
geometry.width.must_equal(55)
|
43
43
|
end
|
44
44
|
end
|
45
45
|
|
46
46
|
it 'returns an unusable viewport width when the terminal is tiny' do
|
47
47
|
IO.console.stub(:winsize, [25, -10]) do
|
48
48
|
geometry = Geometry.new({ width: 60, height: 1, x: 5, y: 1 })
|
49
|
-
geometry.
|
49
|
+
geometry.width.must_equal(1)
|
50
50
|
end
|
51
51
|
end
|
52
52
|
end
|
53
53
|
|
54
|
-
describe '#
|
54
|
+
describe '#height' do
|
55
55
|
it 'returns the viewport height when the interface fits the terminal' do
|
56
56
|
IO.console.stub(:winsize, [25, 80]) do
|
57
57
|
geometry = Geometry.new({ width: 5, height: 20, x: 1, y: 5 })
|
58
|
-
geometry.
|
58
|
+
geometry.height.must_equal(20)
|
59
59
|
end
|
60
60
|
end
|
61
61
|
|
@@ -63,14 +63,14 @@ module Vedeu
|
|
63
63
|
'terminal' do
|
64
64
|
IO.console.stub(:winsize, [15, 80]) do
|
65
65
|
geometry = Geometry.new({ width: 5, height: 20, x: 1, y: 5 })
|
66
|
-
geometry.
|
66
|
+
geometry.height.must_equal(10)
|
67
67
|
end
|
68
68
|
end
|
69
69
|
|
70
70
|
it 'returns an unusable viewport height when the terminal is tiny' do
|
71
71
|
IO.console.stub(:winsize, [-10, 80]) do
|
72
72
|
geometry = Geometry.new({ width: 60, height: 20, x: 1, y: 5 })
|
73
|
-
geometry.
|
73
|
+
geometry.height.must_equal(1)
|
74
74
|
end
|
75
75
|
end
|
76
76
|
end
|
@@ -259,8 +259,6 @@ module Vedeu
|
|
259
259
|
width: 6,
|
260
260
|
x: 3,
|
261
261
|
y: 3,
|
262
|
-
viewport_height: 6,
|
263
|
-
viewport_width: 6,
|
264
262
|
top: 3,
|
265
263
|
right: 9,
|
266
264
|
bottom: 9,
|
@@ -2,33 +2,26 @@ require 'test_helper'
|
|
2
2
|
|
3
3
|
module Vedeu
|
4
4
|
describe Interface do
|
5
|
-
let(:interface) {
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
height: 15,
|
19
|
-
}
|
20
|
-
})
|
21
|
-
}
|
5
|
+
let(:interface) { Vedeu.use('#initialize') }
|
6
|
+
|
7
|
+
before do
|
8
|
+
Interfaces.reset
|
9
|
+
Vedeu.interface('#initialize') do
|
10
|
+
group 'my_group'
|
11
|
+
colour foreground: '#ff0000', background: '#000000'
|
12
|
+
y 3
|
13
|
+
x 5
|
14
|
+
width 10
|
15
|
+
height 15
|
16
|
+
end
|
17
|
+
end
|
22
18
|
|
23
19
|
describe '#initialize' do
|
24
20
|
it 'returns an instance of itself' do
|
25
|
-
|
26
|
-
|
27
|
-
Interface.new(attributes).must_be_instance_of(Interface)
|
21
|
+
interface.must_be_instance_of(Interface)
|
28
22
|
end
|
29
23
|
end
|
30
24
|
|
31
|
-
|
32
25
|
describe '#attributes' do
|
33
26
|
it 'returns the value' do
|
34
27
|
interface.attributes.must_equal(
|
@@ -54,6 +47,12 @@ module Vedeu
|
|
54
47
|
end
|
55
48
|
end
|
56
49
|
|
50
|
+
describe '#cursor' do
|
51
|
+
it 'returns a Cursor' do
|
52
|
+
interface.cursor.must_be_instance_of(Cursor)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
57
56
|
describe '#name' do
|
58
57
|
it 'returns the value' do
|
59
58
|
interface.name.must_equal('#initialize')
|
@@ -98,5 +97,11 @@ module Vedeu
|
|
98
97
|
end
|
99
98
|
end
|
100
99
|
|
100
|
+
describe '#method_missing' do
|
101
|
+
it 'returns nil' do
|
102
|
+
interface.some_missing_method(:test).must_equal(nil)
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
101
106
|
end
|
102
107
|
end
|
@@ -9,11 +9,21 @@ module Vedeu
|
|
9
9
|
foreground: '#ff0000',
|
10
10
|
background: '#000000'
|
11
11
|
},
|
12
|
-
streams:
|
12
|
+
streams: streams,
|
13
13
|
style: 'normal',
|
14
14
|
parent: nil,
|
15
15
|
}
|
16
16
|
}
|
17
|
+
let(:streams) {
|
18
|
+
[
|
19
|
+
Stream.new({
|
20
|
+
colour: { foreground: '#ff0000' }, text: 'Something interesting ' }),
|
21
|
+
Stream.new({
|
22
|
+
colour: { foreground: '#00ff00' }, text: 'on this line ' }),
|
23
|
+
Stream.new({
|
24
|
+
colour: { foreground: '#0000ff' }, text: 'would be cool, eh?' })
|
25
|
+
]
|
26
|
+
}
|
17
27
|
|
18
28
|
describe '#initialize' do
|
19
29
|
it 'returns an instance of itself' do
|
@@ -27,9 +37,70 @@ module Vedeu
|
|
27
37
|
end
|
28
38
|
end
|
29
39
|
|
40
|
+
describe '#chars' do
|
41
|
+
it 'returns an Array' do
|
42
|
+
line.chars.must_be_instance_of(Array)
|
43
|
+
end
|
44
|
+
|
45
|
+
context 'when there is no content' do
|
46
|
+
before { line.stubs(:size).returns(0) }
|
47
|
+
|
48
|
+
it { line.chars.must_equal([]) }
|
49
|
+
end
|
50
|
+
|
51
|
+
context 'when there is content' do
|
52
|
+
it 'returns an Array' do
|
53
|
+
line.chars.must_equal(
|
54
|
+
[
|
55
|
+
"\e[38;2;255;0;0mS", "\e[38;2;255;0;0mo", "\e[38;2;255;0;0mm",
|
56
|
+
"\e[38;2;255;0;0me", "\e[38;2;255;0;0mt", "\e[38;2;255;0;0mh",
|
57
|
+
"\e[38;2;255;0;0mi", "\e[38;2;255;0;0mn", "\e[38;2;255;0;0mg",
|
58
|
+
"\e[38;2;255;0;0m ", "\e[38;2;255;0;0mi", "\e[38;2;255;0;0mn",
|
59
|
+
"\e[38;2;255;0;0mt", "\e[38;2;255;0;0me", "\e[38;2;255;0;0mr",
|
60
|
+
"\e[38;2;255;0;0me", "\e[38;2;255;0;0ms", "\e[38;2;255;0;0mt",
|
61
|
+
"\e[38;2;255;0;0mi", "\e[38;2;255;0;0mn", "\e[38;2;255;0;0mg",
|
62
|
+
"\e[38;2;255;0;0m ", "\e[38;2;0;255;0mo", "\e[38;2;0;255;0mn",
|
63
|
+
"\e[38;2;0;255;0m ", "\e[38;2;0;255;0mt", "\e[38;2;0;255;0mh",
|
64
|
+
"\e[38;2;0;255;0mi", "\e[38;2;0;255;0ms", "\e[38;2;0;255;0m ",
|
65
|
+
"\e[38;2;0;255;0ml", "\e[38;2;0;255;0mi", "\e[38;2;0;255;0mn",
|
66
|
+
"\e[38;2;0;255;0me", "\e[38;2;0;255;0m ", "\e[38;2;0;0;255mw",
|
67
|
+
"\e[38;2;0;0;255mo", "\e[38;2;0;0;255mu", "\e[38;2;0;0;255ml",
|
68
|
+
"\e[38;2;0;0;255md", "\e[38;2;0;0;255m ", "\e[38;2;0;0;255mb",
|
69
|
+
"\e[38;2;0;0;255me", "\e[38;2;0;0;255m ", "\e[38;2;0;0;255mc",
|
70
|
+
"\e[38;2;0;0;255mo", "\e[38;2;0;0;255mo", "\e[38;2;0;0;255ml",
|
71
|
+
"\e[38;2;0;0;255m,", "\e[38;2;0;0;255m ", "\e[38;2;0;0;255me",
|
72
|
+
"\e[38;2;0;0;255mh", "\e[38;2;0;0;255m?"
|
73
|
+
]
|
74
|
+
)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
describe '#empty?' do
|
80
|
+
context 'when there is no content' do
|
81
|
+
before { line.stubs(:size).returns(0) }
|
82
|
+
|
83
|
+
it { line.empty?.must_equal(true) }
|
84
|
+
end
|
85
|
+
|
86
|
+
it 'returns false when there is content' do
|
87
|
+
line.empty?.must_equal(false)
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
describe '#size' do
|
92
|
+
it 'returns a Fixnum' do
|
93
|
+
line.size.must_be_instance_of(Fixnum)
|
94
|
+
end
|
95
|
+
|
96
|
+
it 'returns the size of the line' do
|
97
|
+
line.size.must_equal(53)
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
30
101
|
describe '#streams' do
|
31
102
|
it 'has a streams attribute' do
|
32
|
-
line.streams.
|
103
|
+
line.streams.must_be_instance_of(Array)
|
33
104
|
end
|
34
105
|
end
|
35
106
|
|
@@ -37,9 +108,17 @@ module Vedeu
|
|
37
108
|
it 'returns a String' do
|
38
109
|
line.to_s.must_equal(
|
39
110
|
"\e[38;2;255;0;0m\e[48;2;0;0;0m" \
|
40
|
-
"\e[24m\e[22m\e[27m"
|
111
|
+
"\e[24m\e[22m\e[27m\e[38;2;255;0;0mSomething interesting "\
|
112
|
+
"\e[38;2;0;255;0mon this line " \
|
113
|
+
"\e[38;2;0;0;255mwould be cool, eh?"
|
41
114
|
)
|
42
115
|
end
|
43
116
|
end
|
117
|
+
|
118
|
+
describe '#method_missing' do
|
119
|
+
it 'returns nil' do
|
120
|
+
Line.new.some_missing_method(:test).must_equal(nil)
|
121
|
+
end
|
122
|
+
end
|
44
123
|
end
|
45
124
|
end
|
@@ -0,0 +1,121 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Vedeu
|
4
|
+
describe Offset do
|
5
|
+
let(:offset) { Offset.new(attributes) }
|
6
|
+
let(:attributes) { {} }
|
7
|
+
|
8
|
+
before { Offsets.reset }
|
9
|
+
|
10
|
+
describe '#initialize' do
|
11
|
+
it 'returns a new instance of Offset' do
|
12
|
+
offset.must_be_instance_of(Offset)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
describe '#attributes' do
|
17
|
+
it 'returns the attributes' do
|
18
|
+
skip
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe '#move' do
|
23
|
+
let(:attributes) { { name: 'roentgenium' } }
|
24
|
+
|
25
|
+
context 'left' do
|
26
|
+
it 'does not move past the leftmost position' do
|
27
|
+
offset.move(0, -1).x.must_equal(0)
|
28
|
+
end
|
29
|
+
|
30
|
+
context 'when it can move left' do
|
31
|
+
let(:attributes) { { name: 'roentgenium', x: 5 } }
|
32
|
+
|
33
|
+
it 'moves left' do
|
34
|
+
offset.move(0, -1).x.must_equal(4)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
context 'right' do
|
40
|
+
it 'moves right' do
|
41
|
+
offset.move(0, 1).x.must_equal(1)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
context 'up' do
|
46
|
+
it 'does not move past the upmost position' do
|
47
|
+
offset.move(-1, 0).y.must_equal(0)
|
48
|
+
end
|
49
|
+
|
50
|
+
context 'when it can move up' do
|
51
|
+
let(:attributes) { { name: 'roentgenium', y: 5 } }
|
52
|
+
|
53
|
+
it 'moves up' do
|
54
|
+
offset.move(-1, 0).y.must_equal(4)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
context 'down' do
|
60
|
+
it 'moves down' do
|
61
|
+
offset.move(1, 0).y.must_equal(1)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
describe '#name' do
|
67
|
+
it 'has a default value of empty string' do
|
68
|
+
offset.name.must_equal('')
|
69
|
+
end
|
70
|
+
|
71
|
+
context 'when a value is set' do
|
72
|
+
let(:attributes) { { name: 'roentgenium' } }
|
73
|
+
|
74
|
+
it 'returns that value' do
|
75
|
+
offset.name.must_equal('roentgenium')
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
describe '#y' do
|
81
|
+
it 'has a default value of 0' do
|
82
|
+
offset.y.must_equal(0)
|
83
|
+
end
|
84
|
+
|
85
|
+
context 'when a value is set' do
|
86
|
+
let(:attributes) { { y: 3 } }
|
87
|
+
|
88
|
+
it 'returns that value' do
|
89
|
+
offset.y.must_equal(3)
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
context 'when a value is set that is < 0' do
|
94
|
+
let(:attributes) { { y: -2 } }
|
95
|
+
|
96
|
+
it { offset.y.must_equal(0) }
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
describe '#x' do
|
101
|
+
it 'has a default value of 0' do
|
102
|
+
offset.x.must_equal(0)
|
103
|
+
end
|
104
|
+
|
105
|
+
context 'when a value is set' do
|
106
|
+
let(:attributes) { { x: 2 } }
|
107
|
+
|
108
|
+
it 'returns that value' do
|
109
|
+
offset.x.must_equal(2)
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
context 'when a value is set that is < 0' do
|
114
|
+
let(:attributes) { { x: -2 } }
|
115
|
+
|
116
|
+
it { offset.x.must_equal(0) }
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
end
|
121
|
+
end
|
@@ -4,19 +4,25 @@ module Vedeu
|
|
4
4
|
describe Stream do
|
5
5
|
let(:stream) {
|
6
6
|
Stream.new({
|
7
|
-
colour:
|
8
|
-
|
9
|
-
|
10
|
-
},
|
11
|
-
text: 'Some text',
|
7
|
+
colour: colour,
|
8
|
+
parent: parent,
|
9
|
+
text: text,
|
12
10
|
style: style,
|
13
11
|
width: width,
|
14
12
|
align: align
|
15
13
|
})
|
16
14
|
}
|
17
|
-
let(:
|
18
|
-
|
19
|
-
|
15
|
+
let(:colour) {
|
16
|
+
{
|
17
|
+
foreground: '#ff0000',
|
18
|
+
background: '#000000'
|
19
|
+
}
|
20
|
+
}
|
21
|
+
let(:parent) { nil }
|
22
|
+
let(:style) { 'normal' }
|
23
|
+
let(:text) { 'Some text'}
|
24
|
+
let(:align) { :left }
|
25
|
+
let(:width) { 9 }
|
20
26
|
|
21
27
|
describe '#initialize' do
|
22
28
|
it 'returns an instance of itself' do
|
@@ -25,6 +31,92 @@ module Vedeu
|
|
25
31
|
end
|
26
32
|
end
|
27
33
|
|
34
|
+
describe '#chars' do
|
35
|
+
let(:parent) {
|
36
|
+
{
|
37
|
+
colour: {
|
38
|
+
foreground: '#ffff00',
|
39
|
+
background: '#0000ff'
|
40
|
+
},
|
41
|
+
style: []
|
42
|
+
}
|
43
|
+
}
|
44
|
+
|
45
|
+
it 'returns an Array' do
|
46
|
+
stream.chars.must_be_instance_of(Array)
|
47
|
+
end
|
48
|
+
|
49
|
+
context 'when there is content' do
|
50
|
+
it 'returns a collection of strings containing escape sequences and ' \
|
51
|
+
'content' do
|
52
|
+
stream.chars.must_equal(
|
53
|
+
[
|
54
|
+
"\e[38;2;255;0;0m\e[48;2;0;0;0m\e[24m\e[22m\e[27mS\e[38;2;255;255;0m\e[48;2;0;0;255m",
|
55
|
+
"\e[38;2;255;0;0m\e[48;2;0;0;0m\e[24m\e[22m\e[27mo\e[38;2;255;255;0m\e[48;2;0;0;255m",
|
56
|
+
"\e[38;2;255;0;0m\e[48;2;0;0;0m\e[24m\e[22m\e[27mm\e[38;2;255;255;0m\e[48;2;0;0;255m",
|
57
|
+
"\e[38;2;255;0;0m\e[48;2;0;0;0m\e[24m\e[22m\e[27me\e[38;2;255;255;0m\e[48;2;0;0;255m",
|
58
|
+
"\e[38;2;255;0;0m\e[48;2;0;0;0m\e[24m\e[22m\e[27m \e[38;2;255;255;0m\e[48;2;0;0;255m",
|
59
|
+
"\e[38;2;255;0;0m\e[48;2;0;0;0m\e[24m\e[22m\e[27mt\e[38;2;255;255;0m\e[48;2;0;0;255m",
|
60
|
+
"\e[38;2;255;0;0m\e[48;2;0;0;0m\e[24m\e[22m\e[27me\e[38;2;255;255;0m\e[48;2;0;0;255m",
|
61
|
+
"\e[38;2;255;0;0m\e[48;2;0;0;0m\e[24m\e[22m\e[27mx\e[38;2;255;255;0m\e[48;2;0;0;255m",
|
62
|
+
"\e[38;2;255;0;0m\e[48;2;0;0;0m\e[24m\e[22m\e[27mt\e[38;2;255;255;0m\e[48;2;0;0;255m"
|
63
|
+
]
|
64
|
+
)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
context 'when there is no content' do
|
69
|
+
let(:text) { '' }
|
70
|
+
let(:width) { nil }
|
71
|
+
|
72
|
+
it 'returns an empty collection' do
|
73
|
+
stream.chars.must_equal([])
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
context 'when there is no content but a width is set' do
|
78
|
+
let(:text) { '' }
|
79
|
+
|
80
|
+
it 'returns style and colours as appropriate' do
|
81
|
+
stream.chars.must_equal(
|
82
|
+
[
|
83
|
+
"\e[38;2;255;0;0m\e[48;2;0;0;0m\e[24m\e[22m\e[27m \e[38;2;255;255;0m\e[48;2;0;0;255m",
|
84
|
+
"\e[38;2;255;0;0m\e[48;2;0;0;0m\e[24m\e[22m\e[27m \e[38;2;255;255;0m\e[48;2;0;0;255m",
|
85
|
+
"\e[38;2;255;0;0m\e[48;2;0;0;0m\e[24m\e[22m\e[27m \e[38;2;255;255;0m\e[48;2;0;0;255m",
|
86
|
+
"\e[38;2;255;0;0m\e[48;2;0;0;0m\e[24m\e[22m\e[27m \e[38;2;255;255;0m\e[48;2;0;0;255m",
|
87
|
+
"\e[38;2;255;0;0m\e[48;2;0;0;0m\e[24m\e[22m\e[27m \e[38;2;255;255;0m\e[48;2;0;0;255m",
|
88
|
+
"\e[38;2;255;0;0m\e[48;2;0;0;0m\e[24m\e[22m\e[27m \e[38;2;255;255;0m\e[48;2;0;0;255m",
|
89
|
+
"\e[38;2;255;0;0m\e[48;2;0;0;0m\e[24m\e[22m\e[27m \e[38;2;255;255;0m\e[48;2;0;0;255m",
|
90
|
+
"\e[38;2;255;0;0m\e[48;2;0;0;0m\e[24m\e[22m\e[27m \e[38;2;255;255;0m\e[48;2;0;0;255m",
|
91
|
+
"\e[38;2;255;0;0m\e[48;2;0;0;0m\e[24m\e[22m\e[27m \e[38;2;255;255;0m\e[48;2;0;0;255m"
|
92
|
+
]
|
93
|
+
)
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
describe '#empty?' do
|
99
|
+
context 'when there is no content' do
|
100
|
+
before { stream.stubs(:size).returns(0) }
|
101
|
+
|
102
|
+
it { stream.empty?.must_equal(true) }
|
103
|
+
end
|
104
|
+
|
105
|
+
it 'returns false when there is content' do
|
106
|
+
stream.empty?.must_equal(false)
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
describe '#size' do
|
111
|
+
it 'returns a Fixnum' do
|
112
|
+
stream.size.must_be_instance_of(Fixnum)
|
113
|
+
end
|
114
|
+
|
115
|
+
it 'returns the size of the stream' do
|
116
|
+
stream.size.must_equal(9)
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
28
120
|
describe '#text' do
|
29
121
|
it 'has a text attribute' do
|
30
122
|
stream.text.must_equal('Some text')
|
@@ -118,5 +210,12 @@ module Vedeu
|
|
118
210
|
end
|
119
211
|
end
|
120
212
|
end
|
213
|
+
|
214
|
+
describe '#method_missing' do
|
215
|
+
it 'returns nil' do
|
216
|
+
Composition.new.some_missing_method(:test).must_equal(nil)
|
217
|
+
end
|
218
|
+
end
|
219
|
+
|
121
220
|
end
|
122
221
|
end
|