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
@@ -1,29 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
module Vedeu
|
4
|
-
|
5
|
-
describe LocklessLogDevice do
|
6
|
-
|
7
|
-
let(:described) { Vedeu::LocklessLogDevice }
|
8
|
-
let(:instance) { described.new(file_or_filename) }
|
9
|
-
let(:file_or_filename) {}
|
10
|
-
|
11
|
-
describe '#initialize' do
|
12
|
-
# it { instance.must_be_instance_of(described) }
|
13
|
-
# it {
|
14
|
-
# instance.instance_variable_get('@file_or_filename').
|
15
|
-
# must_equal(file_or_filename)
|
16
|
-
# }
|
17
|
-
end
|
18
|
-
|
19
|
-
describe '#write' do
|
20
|
-
subject { instance.write(message) }
|
21
|
-
end
|
22
|
-
|
23
|
-
describe '#close' do
|
24
|
-
subject { instance.close }
|
25
|
-
end
|
26
|
-
|
27
|
-
end # LocklessLogDevice
|
28
|
-
|
29
|
-
end # Vedeu
|
@@ -1,48 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
module Vedeu
|
4
|
-
|
5
|
-
describe Log do
|
6
|
-
|
7
|
-
let(:described) { Vedeu::Log }
|
8
|
-
let(:_message) { 'Some message...' }
|
9
|
-
let(:force) { false }
|
10
|
-
let(:type) { :info }
|
11
|
-
|
12
|
-
describe '.log' do
|
13
|
-
subject { described.log(message: _message, force: force, type: type) }
|
14
|
-
|
15
|
-
it { subject.must_equal(
|
16
|
-
"\e[97m[info] \e[39m\e[39mSome message...\e[39m"
|
17
|
-
) }
|
18
|
-
end
|
19
|
-
|
20
|
-
describe '.log_stdout' do
|
21
|
-
let(:type) { :create }
|
22
|
-
let(:_message) { 'Logging to stdout...' }
|
23
|
-
|
24
|
-
subject { described.log_stdout(type: type, message: _message) }
|
25
|
-
|
26
|
-
it {
|
27
|
-
capture_io { subject }.must_equal(
|
28
|
-
["\e[92m[create] \e[39m\e[32mLogging to stdout...\e[39m\n", ""]
|
29
|
-
)
|
30
|
-
}
|
31
|
-
end
|
32
|
-
|
33
|
-
describe '.log_stdout' do
|
34
|
-
let(:type) { :debug }
|
35
|
-
let(:_message) { 'Logging to stderr...' }
|
36
|
-
|
37
|
-
subject { described.log_stderr(type: type, message: _message) }
|
38
|
-
|
39
|
-
it {
|
40
|
-
capture_io { subject }.must_equal(
|
41
|
-
["", "\e[91m[debug] \e[39m\e[31mLogging to stderr...\e[39m\n"]
|
42
|
-
)
|
43
|
-
}
|
44
|
-
end
|
45
|
-
|
46
|
-
end # Log
|
47
|
-
|
48
|
-
end # Vedeu
|
@@ -1,31 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
module Vedeu
|
4
|
-
|
5
|
-
describe MonoLogger do
|
6
|
-
|
7
|
-
let(:described) { Vedeu::MonoLogger }
|
8
|
-
let(:instance) { described.new(logdev) }
|
9
|
-
let(:logdev) {}
|
10
|
-
|
11
|
-
describe '#initialize' do
|
12
|
-
it { instance.must_be_instance_of(described) }
|
13
|
-
it { instance.instance_variable_get('@level').must_equal(Logger::DEBUG) }
|
14
|
-
it {
|
15
|
-
instance.instance_variable_get('@default_formatter').
|
16
|
-
must_be_instance_of(Logger::Formatter)
|
17
|
-
}
|
18
|
-
it { instance.instance_variable_get('@Formatter').must_equal(nil) }
|
19
|
-
|
20
|
-
context 'when a log device is given' do
|
21
|
-
# it { instance.instance_variable_get('@logdev').must_be_instance_of(Vedeu::LocklessLogDevice) }
|
22
|
-
end
|
23
|
-
|
24
|
-
context 'when a log device is not given' do
|
25
|
-
# it { instance.instance_variable_get('@logdev').must_be_instance_of(Vedeu::LocklessLogDevice) }
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
end # MonoLogger
|
30
|
-
|
31
|
-
end # Vedeu
|
@@ -1,40 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
module Vedeu
|
4
|
-
|
5
|
-
describe Timer do
|
6
|
-
|
7
|
-
let(:described) { Vedeu::Timer }
|
8
|
-
let(:instance) { described.new(_message) }
|
9
|
-
let(:_message) { 'Testing' }
|
10
|
-
let(:_time) { mock('Time') }
|
11
|
-
let(:started) { 1434492219.5238185 }
|
12
|
-
|
13
|
-
before do
|
14
|
-
Time.stubs(:now).returns(_time)
|
15
|
-
_time.stubs(:to_f).returns(started)
|
16
|
-
end
|
17
|
-
|
18
|
-
describe '#initialize' do
|
19
|
-
it { instance.must_be_instance_of(described) }
|
20
|
-
it { instance.instance_variable_get('@message').must_equal(_message) }
|
21
|
-
it { instance.instance_variable_get('@started').must_equal(started) }
|
22
|
-
end
|
23
|
-
|
24
|
-
describe '.timer' do
|
25
|
-
it { described.must_respond_to(:timer) }
|
26
|
-
end
|
27
|
-
|
28
|
-
describe '#measure' do
|
29
|
-
subject { instance.measure { } }
|
30
|
-
|
31
|
-
it {
|
32
|
-
Vedeu.expects(:log).with(type: :timer,
|
33
|
-
message: "Testing took 0.0ms.")
|
34
|
-
subject
|
35
|
-
}
|
36
|
-
end
|
37
|
-
|
38
|
-
end # Timer
|
39
|
-
|
40
|
-
end # Vedeu
|
@@ -1,301 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
module Vedeu
|
4
|
-
|
5
|
-
describe Menu do
|
6
|
-
|
7
|
-
let(:described) { Vedeu::Menu }
|
8
|
-
let(:instance) { described.new(attributes) }
|
9
|
-
let(:attributes) {
|
10
|
-
{
|
11
|
-
collection: collection,
|
12
|
-
name: menu_name,
|
13
|
-
current: current,
|
14
|
-
selected: selected,
|
15
|
-
}
|
16
|
-
}
|
17
|
-
let(:collection) { ['hydrogen', 'carbon', 'nitrogen', 'oxygen'] }
|
18
|
-
let(:menu_name) { 'elements' }
|
19
|
-
let(:current) { 0 }
|
20
|
-
let(:selected) {}
|
21
|
-
|
22
|
-
describe '.menu' do
|
23
|
-
subject {
|
24
|
-
described.menu('elements') do
|
25
|
-
# ...
|
26
|
-
end
|
27
|
-
}
|
28
|
-
|
29
|
-
it { subject.must_be_instance_of(described) }
|
30
|
-
|
31
|
-
context 'when the block is not given' do
|
32
|
-
subject { described.menu }
|
33
|
-
|
34
|
-
it { proc { subject }.must_raise(Vedeu::Error::InvalidSyntax) }
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
describe '#initialize' do
|
39
|
-
it { instance.must_be_instance_of(described) }
|
40
|
-
it {
|
41
|
-
instance.instance_variable_get('@collection').must_equal(collection)
|
42
|
-
}
|
43
|
-
it { instance.instance_variable_get('@name').must_equal('elements') }
|
44
|
-
it { instance.instance_variable_get('@current').must_equal(0) }
|
45
|
-
it { instance.instance_variable_get('@selected').must_equal(nil) }
|
46
|
-
it do
|
47
|
-
instance.instance_variable_get('@repository').must_equal(Vedeu.menus)
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
describe 'accessors' do
|
52
|
-
it { instance.must_respond_to(:collection) }
|
53
|
-
it { instance.must_respond_to(:collection=) }
|
54
|
-
it { instance.must_respond_to(:current=) }
|
55
|
-
it { instance.must_respond_to(:name) }
|
56
|
-
it { instance.must_respond_to(:name=) }
|
57
|
-
end
|
58
|
-
|
59
|
-
describe '#current' do
|
60
|
-
subject { instance.current }
|
61
|
-
|
62
|
-
it 'returns the current index' do
|
63
|
-
subject.must_equal(0)
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
describe '#selected' do
|
68
|
-
subject { instance.selected }
|
69
|
-
|
70
|
-
it 'returns nil when no item is selected' do
|
71
|
-
subject.must_equal(nil)
|
72
|
-
end
|
73
|
-
|
74
|
-
it 'returns the selected index when an item is selected' do
|
75
|
-
instance.next_item
|
76
|
-
instance.select_item
|
77
|
-
|
78
|
-
subject.must_equal(1)
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
|
-
describe '#selected=' do
|
83
|
-
it { instance.must_respond_to(:selected=) }
|
84
|
-
end
|
85
|
-
|
86
|
-
describe '#current_item' do
|
87
|
-
subject { instance.current_item }
|
88
|
-
|
89
|
-
it 'returns the current item from the collection' do
|
90
|
-
subject.must_equal('hydrogen')
|
91
|
-
end
|
92
|
-
|
93
|
-
it 'when the current item has changed' do
|
94
|
-
instance.next_item
|
95
|
-
instance.next_item
|
96
|
-
|
97
|
-
subject.must_equal('nitrogen')
|
98
|
-
end
|
99
|
-
end
|
100
|
-
|
101
|
-
describe '#selected_item' do
|
102
|
-
subject { instance.selected_item }
|
103
|
-
|
104
|
-
it 'returns nil when nothing is selected' do
|
105
|
-
subject.must_equal(nil)
|
106
|
-
end
|
107
|
-
|
108
|
-
it 'returns the selected item from the collection' do
|
109
|
-
instance.next_item
|
110
|
-
instance.select_item
|
111
|
-
|
112
|
-
subject.must_equal('carbon')
|
113
|
-
end
|
114
|
-
end
|
115
|
-
|
116
|
-
describe '#items' do
|
117
|
-
it 'returns a collection of items' do
|
118
|
-
instance.items.must_equal(
|
119
|
-
[
|
120
|
-
[false, true, 'hydrogen'],
|
121
|
-
[false, false, 'carbon'],
|
122
|
-
[false, false, 'nitrogen'],
|
123
|
-
[false, false, 'oxygen']
|
124
|
-
]
|
125
|
-
)
|
126
|
-
end
|
127
|
-
|
128
|
-
it 'returns a collection of items when the current has ' \
|
129
|
-
'changed' do
|
130
|
-
instance.next_item
|
131
|
-
instance.items.must_equal(
|
132
|
-
[
|
133
|
-
[false, false, 'hydrogen'],
|
134
|
-
[false, true, 'carbon'],
|
135
|
-
[false, false, 'nitrogen'],
|
136
|
-
[false, false, 'oxygen']
|
137
|
-
]
|
138
|
-
)
|
139
|
-
end
|
140
|
-
|
141
|
-
it 'returns a collection of items when an item is selected' do
|
142
|
-
instance.next_item
|
143
|
-
instance.select_item
|
144
|
-
instance.items.must_equal(
|
145
|
-
[
|
146
|
-
[false, false, 'hydrogen'],
|
147
|
-
[true, true, 'carbon'],
|
148
|
-
[false, false, 'nitrogen'],
|
149
|
-
[false, false, 'oxygen']
|
150
|
-
]
|
151
|
-
)
|
152
|
-
end
|
153
|
-
|
154
|
-
it 'returns a collection of items when the current has ' \
|
155
|
-
'changed and an item is selected' do
|
156
|
-
instance.next_item
|
157
|
-
instance.select_item
|
158
|
-
instance.next_item
|
159
|
-
instance.next_item
|
160
|
-
instance.items.must_equal(
|
161
|
-
[
|
162
|
-
[false, false, 'hydrogen'],
|
163
|
-
[true, false, 'carbon'],
|
164
|
-
[false, false, 'nitrogen'],
|
165
|
-
[false, true, 'oxygen']
|
166
|
-
]
|
167
|
-
)
|
168
|
-
end
|
169
|
-
end
|
170
|
-
|
171
|
-
describe '#view' do
|
172
|
-
it 'returns a collection of items when the start position ' \
|
173
|
-
'has changed' do
|
174
|
-
instance.top_item
|
175
|
-
instance.next_item
|
176
|
-
instance.view.must_equal(
|
177
|
-
[
|
178
|
-
[false, true, 'carbon'],
|
179
|
-
[false, false, 'nitrogen'],
|
180
|
-
[false, false, 'oxygen']
|
181
|
-
]
|
182
|
-
)
|
183
|
-
end
|
184
|
-
end
|
185
|
-
|
186
|
-
describe '#top_item' do
|
187
|
-
it 'sets current to the index of the first item' do
|
188
|
-
instance.next_item
|
189
|
-
instance.top_item
|
190
|
-
instance.current.must_equal(0)
|
191
|
-
end
|
192
|
-
|
193
|
-
it 'returns the items' do
|
194
|
-
instance.top_item.must_equal(instance.items)
|
195
|
-
end
|
196
|
-
end
|
197
|
-
|
198
|
-
describe '#bottom_item' do
|
199
|
-
it 'sets current to the index of the last item' do
|
200
|
-
instance.bottom_item
|
201
|
-
instance.current.must_equal(3)
|
202
|
-
end
|
203
|
-
|
204
|
-
it 'returns the items' do
|
205
|
-
instance.bottom_item.must_equal(instance.items)
|
206
|
-
end
|
207
|
-
end
|
208
|
-
|
209
|
-
describe '#next_item' do
|
210
|
-
it 'sets the current to the index of the next item' do
|
211
|
-
instance.next_item
|
212
|
-
instance.current.must_equal(1)
|
213
|
-
end
|
214
|
-
|
215
|
-
it 'returns the items' do
|
216
|
-
instance.next_item.must_equal(instance.items)
|
217
|
-
end
|
218
|
-
|
219
|
-
it 'does not loop' do
|
220
|
-
instance.next_item
|
221
|
-
instance.next_item
|
222
|
-
instance.next_item
|
223
|
-
instance.next_item
|
224
|
-
instance.next_item
|
225
|
-
instance.current.must_equal(3)
|
226
|
-
end
|
227
|
-
end
|
228
|
-
|
229
|
-
describe '#prev_item' do
|
230
|
-
it 'does not loop' do
|
231
|
-
instance.prev_item
|
232
|
-
instance.current.must_equal(0)
|
233
|
-
end
|
234
|
-
|
235
|
-
it 'sets the current to the index of the previous item' do
|
236
|
-
instance.next_item
|
237
|
-
instance.next_item
|
238
|
-
instance.prev_item
|
239
|
-
instance.current.must_equal(1)
|
240
|
-
end
|
241
|
-
|
242
|
-
it 'returns the items' do
|
243
|
-
instance.prev_item.must_equal(instance.items)
|
244
|
-
end
|
245
|
-
|
246
|
-
it 'does not loop' do
|
247
|
-
instance.next_item
|
248
|
-
instance.next_item
|
249
|
-
instance.next_item
|
250
|
-
instance.prev_item
|
251
|
-
instance.prev_item
|
252
|
-
instance.current.must_equal(1)
|
253
|
-
end
|
254
|
-
end
|
255
|
-
|
256
|
-
describe '#select_item' do
|
257
|
-
it 'sets the selected index to the current index' do
|
258
|
-
instance.select_item
|
259
|
-
instance.selected.must_equal(0)
|
260
|
-
end
|
261
|
-
|
262
|
-
it 'sets the selected index to the current index' do
|
263
|
-
instance.next_item
|
264
|
-
instance.select_item
|
265
|
-
instance.selected.must_equal(1)
|
266
|
-
end
|
267
|
-
|
268
|
-
it 'returns the items' do
|
269
|
-
instance.select_item.must_equal(instance.items)
|
270
|
-
end
|
271
|
-
end
|
272
|
-
|
273
|
-
describe '#deselect_item' do
|
274
|
-
it 'sets the selected index to nil' do
|
275
|
-
instance.next_item
|
276
|
-
instance.next_item
|
277
|
-
instance.select_item
|
278
|
-
instance.deselect_item
|
279
|
-
instance.selected.must_equal(nil)
|
280
|
-
end
|
281
|
-
|
282
|
-
it 'returns the items' do
|
283
|
-
instance.deselect_item.must_equal(instance.items)
|
284
|
-
end
|
285
|
-
end
|
286
|
-
|
287
|
-
describe '#last' do
|
288
|
-
it 'returns the index of the last item' do
|
289
|
-
instance.last.must_equal(3)
|
290
|
-
end
|
291
|
-
end
|
292
|
-
|
293
|
-
describe '#size' do
|
294
|
-
it 'returns the collection size' do
|
295
|
-
instance.size.must_equal(4)
|
296
|
-
end
|
297
|
-
end
|
298
|
-
|
299
|
-
end # Menu
|
300
|
-
|
301
|
-
end # Vedeu
|
@@ -1,106 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
module Vedeu
|
4
|
-
|
5
|
-
describe HTMLChar do
|
6
|
-
|
7
|
-
let(:described) { Vedeu::HTMLChar }
|
8
|
-
let(:instance) { described.new(char, options) }
|
9
|
-
let(:char) { Vedeu::Views::Char.new(attributes) }
|
10
|
-
let(:options) {
|
11
|
-
{
|
12
|
-
start_tag: '<td',
|
13
|
-
end_tag: '</td>',
|
14
|
-
}
|
15
|
-
}
|
16
|
-
let(:attributes) {
|
17
|
-
{
|
18
|
-
border: border,
|
19
|
-
colour: colour,
|
20
|
-
parent: parent,
|
21
|
-
value: _value
|
22
|
-
}
|
23
|
-
}
|
24
|
-
let(:border) {}
|
25
|
-
let(:colour) {}
|
26
|
-
let(:parent) { Vedeu::Views::Line.new(colour: parent_colour) }
|
27
|
-
let(:parent_colour) {}
|
28
|
-
let(:_value) {}
|
29
|
-
|
30
|
-
describe '#initialize' do
|
31
|
-
it { instance.must_be_instance_of(described) }
|
32
|
-
it { instance.instance_variable_get('@char').must_equal(char) }
|
33
|
-
it { instance.instance_variable_get('@options').must_equal(options) }
|
34
|
-
end
|
35
|
-
|
36
|
-
describe '.render' do
|
37
|
-
subject { described.render(char, options) }
|
38
|
-
|
39
|
-
it { subject.must_be_instance_of(String) }
|
40
|
-
|
41
|
-
context 'when there is a border' do
|
42
|
-
let(:border) { :top_left }
|
43
|
-
|
44
|
-
context 'when there is a colour' do
|
45
|
-
let(:colour) {
|
46
|
-
Vedeu::Colours::Colour.new(background: '#220022',
|
47
|
-
foreground: '#aadd00')
|
48
|
-
}
|
49
|
-
|
50
|
-
it { subject.must_equal(
|
51
|
-
"<td style='" \
|
52
|
-
"border:1px #220022 solid;" \
|
53
|
-
"background:#220022;" \
|
54
|
-
"color:#aadd00;" \
|
55
|
-
"border-top:1px #aadd00 solid;" \
|
56
|
-
"border-left:1px #aadd00 solid;" \
|
57
|
-
"'> </td>"
|
58
|
-
) }
|
59
|
-
end
|
60
|
-
|
61
|
-
context 'when there is no colour' do
|
62
|
-
context 'when there is a parent colour' do
|
63
|
-
let(:parent_colour) {
|
64
|
-
Vedeu::Colours::Colour.new(background: '#002222',
|
65
|
-
foreground: '#dd2200')
|
66
|
-
}
|
67
|
-
|
68
|
-
it { subject.must_equal(
|
69
|
-
"<td style='" \
|
70
|
-
"border:1px #002222 solid;" \
|
71
|
-
"background:#002222;" \
|
72
|
-
"color:#dd2200;" \
|
73
|
-
"border-top:1px #dd2200 solid;" \
|
74
|
-
"border-left:1px #dd2200 solid;" \
|
75
|
-
"'> </td>"
|
76
|
-
) }
|
77
|
-
end
|
78
|
-
|
79
|
-
context 'when there is no parent colour' do
|
80
|
-
it { subject.must_equal("<td style=''> </td>") }
|
81
|
-
end
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
|
-
context 'when there is no border' do
|
86
|
-
context 'when there is no value' do
|
87
|
-
it { subject.must_equal('<td> </td>') }
|
88
|
-
end
|
89
|
-
|
90
|
-
context 'when the value is empty' do
|
91
|
-
let(:_value) { '' }
|
92
|
-
|
93
|
-
it { subject.must_equal('<td> </td>') }
|
94
|
-
end
|
95
|
-
|
96
|
-
context 'when there is a value' do
|
97
|
-
let(:_value) { 'a' }
|
98
|
-
|
99
|
-
it { subject.must_equal("<td style=''>a</td>") }
|
100
|
-
end
|
101
|
-
end
|
102
|
-
end
|
103
|
-
|
104
|
-
end # HTMLChar
|
105
|
-
|
106
|
-
end # Vedeu
|