vedeu 0.6.7 → 0.6.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE.txt +1 -1
- data/docs/dsl.md +4 -4
- data/lib/vedeu/all.rb +6 -18
- data/lib/vedeu/api.rb +14 -13
- data/lib/vedeu/bindings/system.rb +5 -4
- data/lib/vedeu/buffers/virtual_buffer.rb +13 -11
- data/lib/vedeu/configuration/api.rb +4 -3
- data/lib/vedeu/cursors/cursor.rb +23 -18
- data/lib/vedeu/distributed/client.rb +11 -6
- data/lib/vedeu/distributed/server.rb +4 -3
- data/lib/vedeu/dsl/keymap.rb +6 -6
- data/lib/vedeu/editor/all.rb +19 -0
- data/lib/vedeu/{input/editor → editor}/capture.rb +1 -1
- data/lib/vedeu/{input/editor → editor}/cropper.rb +0 -0
- data/lib/vedeu/{input/editor → editor}/cursor.rb +0 -0
- data/lib/vedeu/{input/editor → editor}/document.rb +0 -0
- data/lib/vedeu/{input/editor → editor}/documents.rb +0 -0
- data/lib/vedeu/{input/editor → editor}/editor.rb +0 -0
- data/lib/vedeu/{input/editor → editor}/insert.rb +0 -0
- data/lib/vedeu/{input/editor → editor}/line.rb +0 -0
- data/lib/vedeu/{input/editor → editor}/lines.rb +0 -0
- data/lib/vedeu/error.rb +21 -18
- data/lib/vedeu/esc/borders.rb +6 -4
- data/lib/vedeu/esc/colours.rb +13 -12
- data/lib/vedeu/esc/esc.rb +11 -10
- data/lib/vedeu/input/all.rb +15 -0
- data/lib/vedeu/input/input.rb +55 -52
- data/lib/vedeu/input/key.rb +36 -30
- data/lib/vedeu/input/keymap.rb +101 -92
- data/lib/vedeu/input/keymaps.rb +10 -6
- data/lib/vedeu/input/keys.rb +8 -4
- data/lib/vedeu/input/mapper.rb +125 -121
- data/lib/vedeu/input/translator.rb +159 -0
- data/lib/vedeu/internal_api.rb +16 -15
- data/lib/vedeu/logging/all.rb +13 -0
- data/lib/vedeu/logging/debug.rb +84 -0
- data/lib/vedeu/logging/lockless_log_device.rb +65 -0
- data/lib/vedeu/logging/log.rb +179 -0
- data/lib/vedeu/logging/mono_logger.rb +26 -0
- data/lib/vedeu/logging/timer.rb +68 -0
- data/lib/vedeu/menus/all.rb +12 -0
- data/lib/vedeu/{dsl/menu.rb → menus/dsl.rb} +19 -18
- data/lib/vedeu/menus/menu.rb +234 -0
- data/lib/vedeu/{null/menu.rb → menus/null.rb} +6 -6
- data/lib/vedeu/menus/repository.rb +18 -0
- data/lib/vedeu/models/cell.rb +62 -55
- data/lib/vedeu/models/escape.rb +55 -50
- data/lib/vedeu/models/page.rb +74 -69
- data/lib/vedeu/models/row.rb +55 -51
- data/lib/vedeu/models/views/all.rb +1 -0
- data/lib/vedeu/models/views/char.rb +1 -1
- data/lib/vedeu/models/views/html_char.rb +165 -0
- data/lib/vedeu/output/renderers/html.rb +5 -4
- data/lib/vedeu/repositories/model.rb +2 -0
- data/lib/vedeu/runtime/application.rb +110 -103
- data/lib/vedeu/runtime/bootstrap.rb +109 -103
- data/lib/vedeu/runtime/flags.rb +45 -41
- data/lib/vedeu/runtime/launcher.rb +1 -1
- data/lib/vedeu/runtime/main_loop.rb +51 -46
- data/lib/vedeu/runtime/traps.rb +20 -16
- data/lib/vedeu/version.rb +1 -1
- data/lib/vedeu.rb +2 -2
- data/test/lib/vedeu/buffers/virtual_buffer_test.rb +1 -1
- data/test/lib/vedeu/cursors/cursor_test.rb +11 -5
- data/test/lib/vedeu/dsl/interface_test.rb +1 -1
- data/test/lib/vedeu/dsl/keymap_test.rb +2 -2
- data/test/lib/vedeu/{input/editor → editor}/capture_test.rb +0 -0
- data/test/lib/vedeu/{input/editor → editor}/cropper_test.rb +0 -0
- data/test/lib/vedeu/{input/editor → editor}/cursor_test.rb +0 -0
- data/test/lib/vedeu/{input/editor → editor}/document_test.rb +0 -0
- data/test/lib/vedeu/{input/editor → editor}/documents_test.rb +0 -0
- data/test/lib/vedeu/{input/editor → editor}/editor_test.rb +0 -0
- data/test/lib/vedeu/{input/editor → editor}/insert_test.rb +0 -0
- data/test/lib/vedeu/{input/editor → editor}/line_test.rb +0 -0
- data/test/lib/vedeu/{input/editor → editor}/lines_test.rb +0 -0
- data/test/lib/vedeu/input/input_test.rb +58 -54
- data/test/lib/vedeu/input/key_test.rb +29 -25
- data/test/lib/vedeu/input/keymap_test.rb +74 -70
- data/test/lib/vedeu/input/keymaps_test.rb +8 -4
- data/test/lib/vedeu/input/keys_test.rb +12 -8
- data/test/lib/vedeu/input/mapper_test.rb +64 -56
- data/test/lib/vedeu/input/translator_test.rb +36 -0
- data/test/lib/vedeu/logging/debug_test.rb +39 -0
- data/test/lib/vedeu/logging/lockless_log_device_test.rb +42 -0
- data/test/lib/vedeu/logging/log_test.rb +52 -0
- data/test/lib/vedeu/logging/mono_logger_test.rb +43 -0
- data/test/lib/vedeu/logging/timer_test.rb +44 -0
- data/test/lib/vedeu/{dsl/menu_test.rb → menus/dsl_test.rb} +6 -6
- data/test/lib/vedeu/menus/menu_test.rb +305 -0
- data/test/lib/vedeu/{null/menu_test.rb → menus/null_test.rb} +5 -5
- data/test/lib/vedeu/menus/repository_test.rb +17 -0
- data/test/lib/vedeu/models/cell_test.rb +54 -50
- data/test/lib/vedeu/models/escape_test.rb +49 -45
- data/test/lib/vedeu/models/page_test.rb +167 -160
- data/test/lib/vedeu/models/row_test.rb +71 -67
- data/test/lib/vedeu/models/views/html_char_test.rb +110 -0
- data/test/lib/vedeu/output/compressor_test.rb +44 -22
- data/test/lib/vedeu/output/renderers_test.rb +4 -2
- data/test/lib/vedeu/runtime/application_test.rb +36 -32
- data/test/lib/vedeu/runtime/bootstrap_test.rb +31 -26
- data/test/lib/vedeu/runtime/flags_test.rb +33 -29
- data/test/lib/vedeu/runtime/launcher_test.rb +4 -2
- data/test/lib/vedeu/runtime/main_loop_test.rb +28 -24
- data/test/lib/vedeu/runtime/traps_test.rb +8 -4
- data/test/test_helper.rb +4 -2
- metadata +66 -63
- data/lib/vedeu/input/editor/all.rb +0 -19
- data/lib/vedeu/input/input_translator.rb +0 -155
- data/lib/vedeu/log/debug.rb +0 -79
- data/lib/vedeu/log/lockless_log_device.rb +0 -61
- data/lib/vedeu/log/log.rb +0 -172
- data/lib/vedeu/log/mono_logger.rb +0 -21
- data/lib/vedeu/log/timer.rb +0 -63
- data/lib/vedeu/models/menu.rb +0 -217
- data/lib/vedeu/models/menus.rb +0 -14
- data/lib/vedeu/output/html_char.rb +0 -161
- data/test/lib/vedeu/input/input_translator_test.rb +0 -32
- data/test/lib/vedeu/log/debug_test.rb +0 -35
- data/test/lib/vedeu/log/lockless_log_device_test.rb +0 -29
- data/test/lib/vedeu/log/log_test.rb +0 -48
- data/test/lib/vedeu/log/mono_logger_test.rb +0 -31
- data/test/lib/vedeu/log/timer_test.rb +0 -40
- data/test/lib/vedeu/models/menu_test.rb +0 -301
- data/test/lib/vedeu/models/menus_test.rb +0 -13
- data/test/lib/vedeu/output/html_char_test.rb +0 -106
@@ -0,0 +1,305 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Vedeu
|
4
|
+
|
5
|
+
module Menus
|
6
|
+
|
7
|
+
describe Menu do
|
8
|
+
|
9
|
+
let(:described) { Vedeu::Menus::Menu }
|
10
|
+
let(:instance) { described.new(attributes) }
|
11
|
+
let(:attributes) {
|
12
|
+
{
|
13
|
+
collection: collection,
|
14
|
+
name: menu_name,
|
15
|
+
current: current,
|
16
|
+
selected: selected,
|
17
|
+
}
|
18
|
+
}
|
19
|
+
let(:collection) { ['hydrogen', 'carbon', 'nitrogen', 'oxygen'] }
|
20
|
+
let(:menu_name) { 'elements' }
|
21
|
+
let(:current) { 0 }
|
22
|
+
let(:selected) {}
|
23
|
+
|
24
|
+
describe '.menu' do
|
25
|
+
subject {
|
26
|
+
described.menu('elements') do
|
27
|
+
# ...
|
28
|
+
end
|
29
|
+
}
|
30
|
+
|
31
|
+
it { subject.must_be_instance_of(described) }
|
32
|
+
|
33
|
+
context 'when the block is not given' do
|
34
|
+
subject { described.menu }
|
35
|
+
|
36
|
+
it { proc { subject }.must_raise(Vedeu::Error::InvalidSyntax) }
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
describe '#initialize' do
|
41
|
+
it { instance.must_be_instance_of(described) }
|
42
|
+
it {
|
43
|
+
instance.instance_variable_get('@collection').must_equal(collection)
|
44
|
+
}
|
45
|
+
it { instance.instance_variable_get('@name').must_equal('elements') }
|
46
|
+
it { instance.instance_variable_get('@current').must_equal(0) }
|
47
|
+
it { instance.instance_variable_get('@selected').must_equal(nil) }
|
48
|
+
it do
|
49
|
+
instance.instance_variable_get('@repository').must_equal(Vedeu.menus)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
describe 'accessors' do
|
54
|
+
it { instance.must_respond_to(:collection) }
|
55
|
+
it { instance.must_respond_to(:collection=) }
|
56
|
+
it { instance.must_respond_to(:current=) }
|
57
|
+
it { instance.must_respond_to(:name) }
|
58
|
+
it { instance.must_respond_to(:name=) }
|
59
|
+
end
|
60
|
+
|
61
|
+
describe '#current' do
|
62
|
+
subject { instance.current }
|
63
|
+
|
64
|
+
it 'returns the current index' do
|
65
|
+
subject.must_equal(0)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
describe '#selected' do
|
70
|
+
subject { instance.selected }
|
71
|
+
|
72
|
+
it 'returns nil when no item is selected' do
|
73
|
+
subject.must_equal(nil)
|
74
|
+
end
|
75
|
+
|
76
|
+
it 'returns the selected index when an item is selected' do
|
77
|
+
instance.next_item
|
78
|
+
instance.select_item
|
79
|
+
|
80
|
+
subject.must_equal(1)
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
describe '#selected=' do
|
85
|
+
it { instance.must_respond_to(:selected=) }
|
86
|
+
end
|
87
|
+
|
88
|
+
describe '#current_item' do
|
89
|
+
subject { instance.current_item }
|
90
|
+
|
91
|
+
it 'returns the current item from the collection' do
|
92
|
+
subject.must_equal('hydrogen')
|
93
|
+
end
|
94
|
+
|
95
|
+
it 'when the current item has changed' do
|
96
|
+
instance.next_item
|
97
|
+
instance.next_item
|
98
|
+
|
99
|
+
subject.must_equal('nitrogen')
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
describe '#selected_item' do
|
104
|
+
subject { instance.selected_item }
|
105
|
+
|
106
|
+
it 'returns nil when nothing is selected' do
|
107
|
+
subject.must_equal(nil)
|
108
|
+
end
|
109
|
+
|
110
|
+
it 'returns the selected item from the collection' do
|
111
|
+
instance.next_item
|
112
|
+
instance.select_item
|
113
|
+
|
114
|
+
subject.must_equal('carbon')
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
describe '#items' do
|
119
|
+
it 'returns a collection of items' do
|
120
|
+
instance.items.must_equal(
|
121
|
+
[
|
122
|
+
[false, true, 'hydrogen'],
|
123
|
+
[false, false, 'carbon'],
|
124
|
+
[false, false, 'nitrogen'],
|
125
|
+
[false, false, 'oxygen']
|
126
|
+
]
|
127
|
+
)
|
128
|
+
end
|
129
|
+
|
130
|
+
it 'returns a collection of items when the current has ' \
|
131
|
+
'changed' do
|
132
|
+
instance.next_item
|
133
|
+
instance.items.must_equal(
|
134
|
+
[
|
135
|
+
[false, false, 'hydrogen'],
|
136
|
+
[false, true, 'carbon'],
|
137
|
+
[false, false, 'nitrogen'],
|
138
|
+
[false, false, 'oxygen']
|
139
|
+
]
|
140
|
+
)
|
141
|
+
end
|
142
|
+
|
143
|
+
it 'returns a collection of items when an item is selected' do
|
144
|
+
instance.next_item
|
145
|
+
instance.select_item
|
146
|
+
instance.items.must_equal(
|
147
|
+
[
|
148
|
+
[false, false, 'hydrogen'],
|
149
|
+
[true, true, 'carbon'],
|
150
|
+
[false, false, 'nitrogen'],
|
151
|
+
[false, false, 'oxygen']
|
152
|
+
]
|
153
|
+
)
|
154
|
+
end
|
155
|
+
|
156
|
+
it 'returns a collection of items when the current has ' \
|
157
|
+
'changed and an item is selected' do
|
158
|
+
instance.next_item
|
159
|
+
instance.select_item
|
160
|
+
instance.next_item
|
161
|
+
instance.next_item
|
162
|
+
instance.items.must_equal(
|
163
|
+
[
|
164
|
+
[false, false, 'hydrogen'],
|
165
|
+
[true, false, 'carbon'],
|
166
|
+
[false, false, 'nitrogen'],
|
167
|
+
[false, true, 'oxygen']
|
168
|
+
]
|
169
|
+
)
|
170
|
+
end
|
171
|
+
end
|
172
|
+
|
173
|
+
describe '#view' do
|
174
|
+
it 'returns a collection of items when the start position ' \
|
175
|
+
'has changed' do
|
176
|
+
instance.top_item
|
177
|
+
instance.next_item
|
178
|
+
instance.view.must_equal(
|
179
|
+
[
|
180
|
+
[false, true, 'carbon'],
|
181
|
+
[false, false, 'nitrogen'],
|
182
|
+
[false, false, 'oxygen']
|
183
|
+
]
|
184
|
+
)
|
185
|
+
end
|
186
|
+
end
|
187
|
+
|
188
|
+
describe '#top_item' do
|
189
|
+
it 'sets current to the index of the first item' do
|
190
|
+
instance.next_item
|
191
|
+
instance.top_item
|
192
|
+
instance.current.must_equal(0)
|
193
|
+
end
|
194
|
+
|
195
|
+
it 'returns the items' do
|
196
|
+
instance.top_item.must_equal(instance.items)
|
197
|
+
end
|
198
|
+
end
|
199
|
+
|
200
|
+
describe '#bottom_item' do
|
201
|
+
it 'sets current to the index of the last item' do
|
202
|
+
instance.bottom_item
|
203
|
+
instance.current.must_equal(3)
|
204
|
+
end
|
205
|
+
|
206
|
+
it 'returns the items' do
|
207
|
+
instance.bottom_item.must_equal(instance.items)
|
208
|
+
end
|
209
|
+
end
|
210
|
+
|
211
|
+
describe '#next_item' do
|
212
|
+
it 'sets the current to the index of the next item' do
|
213
|
+
instance.next_item
|
214
|
+
instance.current.must_equal(1)
|
215
|
+
end
|
216
|
+
|
217
|
+
it 'returns the items' do
|
218
|
+
instance.next_item.must_equal(instance.items)
|
219
|
+
end
|
220
|
+
|
221
|
+
it 'does not loop' do
|
222
|
+
instance.next_item
|
223
|
+
instance.next_item
|
224
|
+
instance.next_item
|
225
|
+
instance.next_item
|
226
|
+
instance.next_item
|
227
|
+
instance.current.must_equal(3)
|
228
|
+
end
|
229
|
+
end
|
230
|
+
|
231
|
+
describe '#prev_item' do
|
232
|
+
it 'does not loop' do
|
233
|
+
instance.prev_item
|
234
|
+
instance.current.must_equal(0)
|
235
|
+
end
|
236
|
+
|
237
|
+
it 'sets the current to the index of the previous item' do
|
238
|
+
instance.next_item
|
239
|
+
instance.next_item
|
240
|
+
instance.prev_item
|
241
|
+
instance.current.must_equal(1)
|
242
|
+
end
|
243
|
+
|
244
|
+
it 'returns the items' do
|
245
|
+
instance.prev_item.must_equal(instance.items)
|
246
|
+
end
|
247
|
+
|
248
|
+
it 'does not loop' do
|
249
|
+
instance.next_item
|
250
|
+
instance.next_item
|
251
|
+
instance.next_item
|
252
|
+
instance.prev_item
|
253
|
+
instance.prev_item
|
254
|
+
instance.current.must_equal(1)
|
255
|
+
end
|
256
|
+
end
|
257
|
+
|
258
|
+
describe '#select_item' do
|
259
|
+
it 'sets the selected index to the current index' do
|
260
|
+
instance.select_item
|
261
|
+
instance.selected.must_equal(0)
|
262
|
+
end
|
263
|
+
|
264
|
+
it 'sets the selected index to the current index' do
|
265
|
+
instance.next_item
|
266
|
+
instance.select_item
|
267
|
+
instance.selected.must_equal(1)
|
268
|
+
end
|
269
|
+
|
270
|
+
it 'returns the items' do
|
271
|
+
instance.select_item.must_equal(instance.items)
|
272
|
+
end
|
273
|
+
end
|
274
|
+
|
275
|
+
describe '#deselect_item' do
|
276
|
+
it 'sets the selected index to nil' do
|
277
|
+
instance.next_item
|
278
|
+
instance.next_item
|
279
|
+
instance.select_item
|
280
|
+
instance.deselect_item
|
281
|
+
instance.selected.must_equal(nil)
|
282
|
+
end
|
283
|
+
|
284
|
+
it 'returns the items' do
|
285
|
+
instance.deselect_item.must_equal(instance.items)
|
286
|
+
end
|
287
|
+
end
|
288
|
+
|
289
|
+
describe '#last' do
|
290
|
+
it 'returns the index of the last item' do
|
291
|
+
instance.last.must_equal(3)
|
292
|
+
end
|
293
|
+
end
|
294
|
+
|
295
|
+
describe '#size' do
|
296
|
+
it 'returns the collection size' do
|
297
|
+
instance.size.must_equal(4)
|
298
|
+
end
|
299
|
+
end
|
300
|
+
|
301
|
+
end # Menu
|
302
|
+
|
303
|
+
end # Menus
|
304
|
+
|
305
|
+
end # Vedeu
|
@@ -2,11 +2,11 @@ require 'test_helper'
|
|
2
2
|
|
3
3
|
module Vedeu
|
4
4
|
|
5
|
-
module
|
5
|
+
module Menus
|
6
6
|
|
7
|
-
describe
|
7
|
+
describe Null do
|
8
8
|
|
9
|
-
let(:described) { Vedeu::Null
|
9
|
+
let(:described) { Vedeu::Menus::Null }
|
10
10
|
let(:instance) { described.new(attributes) }
|
11
11
|
let(:_name) { 'null_menu' }
|
12
12
|
let(:attributes) {
|
@@ -23,8 +23,8 @@ module Vedeu
|
|
23
23
|
it { instance.instance_variable_get('@name').must_equal(_name) }
|
24
24
|
end
|
25
25
|
|
26
|
-
end #
|
26
|
+
end # Null
|
27
27
|
|
28
|
-
end #
|
28
|
+
end # Menus
|
29
29
|
|
30
30
|
end # Vedeu
|
@@ -2,58 +2,62 @@ require 'test_helper'
|
|
2
2
|
|
3
3
|
module Vedeu
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
{
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
5
|
+
module Models
|
6
|
+
|
7
|
+
describe Cell do
|
8
|
+
|
9
|
+
let(:described) { Vedeu::Models::Cell }
|
10
|
+
let(:instance) { described.new(attributes) }
|
11
|
+
let(:attributes) {
|
12
|
+
{
|
13
|
+
colour: colour,
|
14
|
+
style: style,
|
15
|
+
value: _value,
|
16
|
+
x: x,
|
17
|
+
y: y,
|
18
|
+
}
|
16
19
|
}
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
it { instance.instance_variable_get('@y').must_equal(y) }
|
31
|
-
end
|
32
|
-
|
33
|
-
describe 'accessors' do
|
34
|
-
it { instance.must_respond_to(:colour) }
|
35
|
-
it { instance.must_respond_to(:style) }
|
36
|
-
it { instance.must_respond_to(:value) }
|
37
|
-
it { instance.must_respond_to(:x) }
|
38
|
-
it { instance.must_respond_to(:y) }
|
39
|
-
end
|
40
|
-
|
41
|
-
describe '#eql?' do
|
42
|
-
let(:other) { described.new(value: nil) }
|
43
|
-
|
44
|
-
subject { instance.eql?(other) }
|
45
|
-
|
46
|
-
it { subject.must_respond_to(:==) }
|
47
|
-
|
48
|
-
it { subject.must_equal(true) }
|
49
|
-
|
50
|
-
context 'when different to other' do
|
51
|
-
let(:other) { described.new(value: 'b') }
|
52
|
-
|
53
|
-
it { subject.must_equal(false) }
|
20
|
+
let(:colour) { Vedeu::Colours::Colour.new(background: '#000000') }
|
21
|
+
let(:style) {}
|
22
|
+
let(:_value) {}
|
23
|
+
let(:x) {}
|
24
|
+
let(:y) {}
|
25
|
+
|
26
|
+
describe '#initialize' do
|
27
|
+
it { instance.must_be_instance_of(described) }
|
28
|
+
it { instance.instance_variable_get('@colour').must_equal(colour) }
|
29
|
+
it { instance.instance_variable_get('@style').must_equal(style) }
|
30
|
+
it { instance.instance_variable_get('@value').must_equal(_value) }
|
31
|
+
it { instance.instance_variable_get('@x').must_equal(x) }
|
32
|
+
it { instance.instance_variable_get('@y').must_equal(y) }
|
54
33
|
end
|
55
|
-
end
|
56
34
|
|
57
|
-
|
35
|
+
describe 'accessors' do
|
36
|
+
it { instance.must_respond_to(:colour) }
|
37
|
+
it { instance.must_respond_to(:style) }
|
38
|
+
it { instance.must_respond_to(:value) }
|
39
|
+
it { instance.must_respond_to(:x) }
|
40
|
+
it { instance.must_respond_to(:y) }
|
41
|
+
end
|
42
|
+
|
43
|
+
describe '#eql?' do
|
44
|
+
let(:other) { described.new(value: nil) }
|
45
|
+
|
46
|
+
subject { instance.eql?(other) }
|
47
|
+
|
48
|
+
it { subject.must_respond_to(:==) }
|
49
|
+
|
50
|
+
it { subject.must_equal(true) }
|
51
|
+
|
52
|
+
context 'when different to other' do
|
53
|
+
let(:other) { described.new(value: 'b') }
|
54
|
+
|
55
|
+
it { subject.must_equal(false) }
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
end # Cell
|
60
|
+
|
61
|
+
end # Models
|
58
62
|
|
59
63
|
end # Vedeu
|
@@ -2,66 +2,70 @@ require 'test_helper'
|
|
2
2
|
|
3
3
|
module Vedeu
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
{
|
11
|
-
|
12
|
-
|
5
|
+
module Models
|
6
|
+
|
7
|
+
describe Escape do
|
8
|
+
|
9
|
+
let(:described) { Vedeu::Models::Escape }
|
10
|
+
let(:instance) { described.new(attributes) }
|
11
|
+
let(:attributes) {
|
12
|
+
{
|
13
|
+
value: _value,
|
14
|
+
position: position,
|
15
|
+
}
|
13
16
|
}
|
14
|
-
|
15
|
-
|
16
|
-
let(:position) { [2, 6] }
|
17
|
+
let(:_value) { "\e[?25h" }
|
18
|
+
let(:position) { [2, 6] }
|
17
19
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
20
|
+
describe '#initialize' do
|
21
|
+
it { instance.must_be_instance_of(described) }
|
22
|
+
it { instance.instance_variable_get('@value').must_equal(_value) }
|
23
|
+
end
|
22
24
|
|
23
|
-
|
24
|
-
|
25
|
-
|
25
|
+
describe 'accessors' do
|
26
|
+
it { instance.must_respond_to(:value) }
|
27
|
+
end
|
26
28
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
29
|
+
describe '#null' do
|
30
|
+
it { instance.null.must_equal(nil) }
|
31
|
+
it { instance.background.must_equal(nil) }
|
32
|
+
it { instance.colour.must_equal(nil) }
|
33
|
+
it { instance.foreground.must_equal(nil) }
|
34
|
+
it { instance.style.must_equal(nil) }
|
35
|
+
end
|
34
36
|
|
35
|
-
|
36
|
-
|
37
|
+
describe '#eql?' do
|
38
|
+
let(:other) { instance }
|
37
39
|
|
38
|
-
|
40
|
+
subject { instance.eql?(other) }
|
39
41
|
|
40
|
-
|
42
|
+
it { subject.must_equal(true) }
|
41
43
|
|
42
|
-
|
43
|
-
|
44
|
+
context 'when different to other' do
|
45
|
+
let(:other) { described.new(value: 'b') }
|
44
46
|
|
45
|
-
|
47
|
+
it { subject.must_equal(false) }
|
48
|
+
end
|
49
|
+
|
50
|
+
it { instance.must_respond_to(:==) }
|
46
51
|
end
|
47
52
|
|
48
|
-
|
49
|
-
|
53
|
+
describe '#position' do
|
54
|
+
it { instance.position.must_be_instance_of(Vedeu::Geometry::Position) }
|
55
|
+
end
|
50
56
|
|
51
|
-
|
52
|
-
|
53
|
-
|
57
|
+
describe '#value' do
|
58
|
+
it { instance.value.must_be_instance_of(String) }
|
59
|
+
end
|
54
60
|
|
55
|
-
|
56
|
-
|
57
|
-
end
|
61
|
+
describe '#to_s' do
|
62
|
+
subject { instance.to_s }
|
58
63
|
|
59
|
-
|
60
|
-
|
64
|
+
it { instance.must_respond_to(:to_str) }
|
65
|
+
end
|
61
66
|
|
62
|
-
|
63
|
-
end
|
67
|
+
end # Escape
|
64
68
|
|
65
|
-
end #
|
69
|
+
end # Models
|
66
70
|
|
67
71
|
end # Vedeu
|