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
@@ -2,234 +2,241 @@ require 'test_helper'
|
|
2
2
|
|
3
3
|
module Vedeu
|
4
4
|
|
5
|
-
|
5
|
+
module Models
|
6
6
|
|
7
|
-
|
8
|
-
let(:instance) { described.new(rows) }
|
9
|
-
let(:rows) {
|
10
|
-
[
|
11
|
-
[:hydrogen, :helium, :lithium],
|
12
|
-
[:beryllium, :boron, :carbon],
|
13
|
-
[:nitrogen, :oxygen, :fluorine],
|
14
|
-
]
|
15
|
-
}
|
7
|
+
describe Page do
|
16
8
|
|
17
|
-
|
18
|
-
|
9
|
+
let(:described) { Vedeu::Models::Page }
|
10
|
+
let(:instance) { described.new(rows) }
|
11
|
+
let(:rows) {
|
12
|
+
[
|
13
|
+
[:hydrogen, :helium, :lithium],
|
14
|
+
[:beryllium, :boron, :carbon],
|
15
|
+
[:nitrogen, :oxygen, :fluorine],
|
16
|
+
]
|
17
|
+
}
|
19
18
|
|
20
|
-
|
21
|
-
|
19
|
+
describe '#initialize' do
|
20
|
+
it { instance.must_be_instance_of(described) }
|
22
21
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
context 'when there are rows' do
|
27
|
-
it { instance.instance_variable_get('@rows').must_equal(rows) }
|
28
|
-
end
|
29
|
-
end
|
22
|
+
context 'when there are no rows' do
|
23
|
+
let(:rows) {}
|
30
24
|
|
31
|
-
|
32
|
-
|
25
|
+
it { instance.instance_variable_get('@rows').must_equal([]) }
|
26
|
+
end
|
33
27
|
|
34
|
-
|
28
|
+
context 'when there are rows' do
|
29
|
+
it { instance.instance_variable_get('@rows').must_equal(rows) }
|
30
|
+
end
|
31
|
+
end
|
35
32
|
|
36
|
-
|
33
|
+
describe '.coerce' do
|
34
|
+
let(:_value) {}
|
37
35
|
|
38
|
-
|
39
|
-
let(:_value) { Vedeu::Page.new }
|
36
|
+
subject { described.coerce(_value) }
|
40
37
|
|
41
|
-
it { subject.
|
42
|
-
end
|
38
|
+
it { proc { subject }.must_raise(Vedeu::Error::InvalidSyntax) }
|
43
39
|
|
44
|
-
|
45
|
-
|
46
|
-
let(:expected) { Vedeu::Page.new([_value]) }
|
40
|
+
context 'when the value is a Vedeu::Models::Page' do
|
41
|
+
let(:_value) { described.new }
|
47
42
|
|
48
|
-
|
49
|
-
|
43
|
+
it { subject.must_equal(_value) }
|
44
|
+
end
|
50
45
|
|
51
|
-
|
52
|
-
|
53
|
-
let(:
|
54
|
-
let(:expected) { Vedeu::Page.coerce(Vedeu::Row.coerce(_value)) }
|
46
|
+
context 'when the value is a Vedeu::Models::Row' do
|
47
|
+
let(:_value) { Vedeu::Models::Row.new }
|
48
|
+
let(:expected) { described.new([_value]) }
|
55
49
|
|
56
|
-
it { subject.must_be_instance_of(Vedeu::Page) }
|
57
50
|
it { subject.must_equal(expected) }
|
58
51
|
end
|
59
52
|
|
60
|
-
context '
|
61
|
-
context 'is
|
62
|
-
let(:_value) { [
|
63
|
-
let(:expected) {
|
53
|
+
context 'when the value is an Array' do
|
54
|
+
context 'and the value is empty' do
|
55
|
+
let(:_value) { [] }
|
56
|
+
let(:expected) {
|
57
|
+
described.coerce(Vedeu::Models::Row.coerce(_value))
|
58
|
+
}
|
64
59
|
|
65
|
-
it { subject.must_be_instance_of(
|
60
|
+
it { subject.must_be_instance_of(described) }
|
66
61
|
it { subject.must_equal(expected) }
|
67
62
|
end
|
68
63
|
|
69
|
-
context '
|
70
|
-
|
71
|
-
[
|
72
|
-
|
73
|
-
Vedeu::Row.new([:lithium, :beryllium]),
|
74
|
-
]
|
75
|
-
}
|
76
|
-
let(:expected) { Vedeu::Page.new(_value) }
|
64
|
+
context 'and the value is not empty, the content is' do
|
65
|
+
context 'is an empty Array' do
|
66
|
+
let(:_value) { [[]] }
|
67
|
+
let(:expected) { described.coerce(Vedeu::Models::Row.coerce([])) }
|
77
68
|
|
78
|
-
|
79
|
-
|
69
|
+
it { subject.must_be_instance_of(described) }
|
70
|
+
it { subject.must_equal(expected) }
|
71
|
+
end
|
80
72
|
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
let(:expected) {
|
90
|
-
Vedeu::Page.new([
|
91
|
-
Vedeu::Row.new([:hydrogen, :helium]),
|
92
|
-
Vedeu::Row.new([:lithium]),
|
93
|
-
Vedeu::Row.new([:beryllium, :boron]),
|
94
|
-
])
|
95
|
-
}
|
73
|
+
context 'an array of Vedeu::Models::Row objects' do
|
74
|
+
let(:_value) {
|
75
|
+
[
|
76
|
+
Vedeu::Models::Row.new([:hydrogen, :helium]),
|
77
|
+
Vedeu::Models::Row.new([:lithium, :beryllium]),
|
78
|
+
]
|
79
|
+
}
|
80
|
+
let(:expected) { described.new(_value) }
|
96
81
|
|
97
|
-
|
98
|
-
|
82
|
+
it { subject.must_equal(expected) }
|
83
|
+
end
|
99
84
|
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
85
|
+
context 'a mix of Vedeu::Models::Row objects and other objects' do
|
86
|
+
let(:_value) {
|
87
|
+
[
|
88
|
+
Vedeu::Models::Row.new([:hydrogen, :helium]),
|
89
|
+
[:lithium],
|
90
|
+
Vedeu::Models::Row.new([:beryllium, :boron]),
|
91
|
+
]
|
92
|
+
}
|
93
|
+
let(:expected) {
|
94
|
+
described.new([
|
95
|
+
Vedeu::Models::Row.new([:hydrogen, :helium]),
|
96
|
+
Vedeu::Models::Row.new([:lithium]),
|
97
|
+
Vedeu::Models::Row.new([:beryllium, :boron]),
|
98
|
+
])
|
99
|
+
}
|
100
|
+
|
101
|
+
it { subject.must_equal(expected) }
|
102
|
+
end
|
103
|
+
|
104
|
+
context 'a mix of Vedeu::Models::Row objects, other objects and ' \
|
105
|
+
'nils' do
|
106
|
+
let(:_value) {
|
107
|
+
[
|
108
|
+
Vedeu::Models::Row.new([:hydrogen, :helium]),
|
109
|
+
nil,
|
110
|
+
[:lithium],
|
111
|
+
Vedeu::Models::Row.new([:beryllium, :boron]),
|
112
|
+
[nil, :carbon],
|
113
|
+
]
|
114
|
+
}
|
115
|
+
let(:expected) {
|
116
|
+
described.new([
|
117
|
+
Vedeu::Models::Row.new([:hydrogen, :helium]),
|
118
|
+
Vedeu::Models::Row.new([]),
|
119
|
+
Vedeu::Models::Row.new([:lithium]),
|
120
|
+
Vedeu::Models::Row.new([:beryllium, :boron]),
|
121
|
+
Vedeu::Models::Row.new([:carbon]),
|
122
|
+
])
|
123
|
+
}
|
124
|
+
|
125
|
+
it { subject.must_equal(expected) }
|
126
|
+
end
|
119
127
|
|
120
|
-
it { subject.must_equal(expected) }
|
121
128
|
end
|
122
129
|
|
123
130
|
end
|
124
|
-
|
125
131
|
end
|
126
|
-
end
|
127
132
|
|
128
|
-
|
129
|
-
|
133
|
+
describe '#each' do
|
134
|
+
subject { instance.each }
|
130
135
|
|
131
|
-
|
132
|
-
|
136
|
+
it { subject.must_be_instance_of(Enumerator) }
|
137
|
+
end
|
133
138
|
|
134
|
-
|
135
|
-
|
139
|
+
describe '#eql?' do
|
140
|
+
let(:other) { instance }
|
136
141
|
|
137
|
-
|
142
|
+
subject { instance.eql?(other) }
|
138
143
|
|
139
|
-
|
144
|
+
it { subject.must_equal(true) }
|
140
145
|
|
141
|
-
|
142
|
-
|
146
|
+
context 'when different to other' do
|
147
|
+
let(:other) { described.new([:hydrogen]) }
|
143
148
|
|
144
|
-
|
149
|
+
it { subject.must_equal(false) }
|
150
|
+
end
|
145
151
|
end
|
146
|
-
end
|
147
152
|
|
148
|
-
|
149
|
-
|
153
|
+
describe '#row' do
|
154
|
+
let(:index) {}
|
150
155
|
|
151
|
-
|
156
|
+
subject { instance.row(index) }
|
152
157
|
|
153
|
-
|
154
|
-
|
155
|
-
|
158
|
+
context 'when the index is nil' do
|
159
|
+
it { subject.must_equal(nil) }
|
160
|
+
end
|
156
161
|
|
157
|
-
|
158
|
-
|
159
|
-
|
162
|
+
context 'when the index is not nil' do
|
163
|
+
context 'and the index is in range' do
|
164
|
+
let(:index) { 1 }
|
160
165
|
|
161
|
-
|
162
|
-
|
166
|
+
it { subject.must_equal([:beryllium, :boron, :carbon]) }
|
167
|
+
end
|
163
168
|
|
164
|
-
|
165
|
-
|
169
|
+
context 'and the index is out of range' do
|
170
|
+
let(:index) { 4 }
|
166
171
|
|
167
|
-
|
168
|
-
|
172
|
+
it { subject.must_equal(nil) }
|
173
|
+
end
|
169
174
|
|
170
|
-
|
171
|
-
|
175
|
+
context 'and the index is out of range' do
|
176
|
+
let(:index) { -4 }
|
172
177
|
|
173
|
-
|
178
|
+
it { subject.must_equal(nil) }
|
179
|
+
end
|
174
180
|
end
|
175
181
|
end
|
176
|
-
end
|
177
182
|
|
178
|
-
|
179
|
-
|
180
|
-
|
183
|
+
describe '#cell' do
|
184
|
+
let(:row_index) {}
|
185
|
+
let(:cell_index) {}
|
181
186
|
|
182
|
-
|
183
|
-
|
184
|
-
context 'when the row_index is nil' do
|
185
|
-
it { subject.must_equal(nil) }
|
186
|
-
end
|
187
|
+
subject { instance.cell(row_index, cell_index) }
|
187
188
|
|
188
|
-
|
189
|
-
|
189
|
+
context 'when the row_index is nil' do
|
190
|
+
it { subject.must_equal(nil) }
|
191
|
+
end
|
190
192
|
|
191
|
-
context '
|
193
|
+
context 'when the row_index is not nil' do
|
192
194
|
let(:row_index) { 1 }
|
193
195
|
|
194
|
-
context '
|
195
|
-
|
196
|
-
end
|
197
|
-
|
198
|
-
context 'when the cell_index is not nil' do
|
199
|
-
context 'and the cell_index is in range' do
|
200
|
-
let(:cell_index) { 2 }
|
196
|
+
context 'and the row_index is in range' do
|
197
|
+
let(:row_index) { 1 }
|
201
198
|
|
202
|
-
|
199
|
+
context 'when the cell_index is nil' do
|
200
|
+
it { subject.must_equal(nil) }
|
203
201
|
end
|
204
202
|
|
205
|
-
context '
|
206
|
-
|
203
|
+
context 'when the cell_index is not nil' do
|
204
|
+
context 'and the cell_index is in range' do
|
205
|
+
let(:cell_index) { 2 }
|
207
206
|
|
208
|
-
|
209
|
-
|
207
|
+
it { subject.must_equal(:carbon) }
|
208
|
+
end
|
210
209
|
|
211
|
-
|
212
|
-
|
210
|
+
context 'and the cell_index is out of range' do
|
211
|
+
let(:cell_index) { 4 }
|
213
212
|
|
214
|
-
|
213
|
+
it { subject.must_equal(nil) }
|
214
|
+
end
|
215
|
+
|
216
|
+
context 'and the cell_index is out of range' do
|
217
|
+
let(:cell_index) { -4 }
|
218
|
+
|
219
|
+
it { subject.must_equal(nil) }
|
220
|
+
end
|
215
221
|
end
|
216
222
|
end
|
217
|
-
end
|
218
223
|
|
219
|
-
|
220
|
-
|
224
|
+
context 'and the row_index is out of range' do
|
225
|
+
let(:row_index) { 4 }
|
221
226
|
|
222
|
-
|
223
|
-
|
227
|
+
it { subject.must_equal(nil) }
|
228
|
+
end
|
224
229
|
|
225
|
-
|
226
|
-
|
230
|
+
context 'and the row_index is out of range' do
|
231
|
+
let(:row_index) { -4 }
|
227
232
|
|
228
|
-
|
233
|
+
it { subject.must_equal(nil) }
|
234
|
+
end
|
229
235
|
end
|
230
236
|
end
|
231
|
-
end
|
232
237
|
|
233
|
-
|
238
|
+
end # Page
|
239
|
+
|
240
|
+
end # Models
|
234
241
|
|
235
242
|
end # Vedeu
|
@@ -2,110 +2,114 @@ require 'test_helper'
|
|
2
2
|
|
3
3
|
module Vedeu
|
4
4
|
|
5
|
-
|
5
|
+
module Models
|
6
6
|
|
7
|
-
|
8
|
-
let(:instance) { described.new(cells) }
|
9
|
-
let(:cells) { [:hydrogen, :helium, :lithium] }
|
7
|
+
describe Row do
|
10
8
|
|
11
|
-
|
12
|
-
|
9
|
+
let(:described) { Vedeu::Models::Row }
|
10
|
+
let(:instance) { described.new(cells) }
|
11
|
+
let(:cells) { [:hydrogen, :helium, :lithium] }
|
13
12
|
|
14
|
-
|
15
|
-
|
13
|
+
describe '#initialize' do
|
14
|
+
it { instance.must_be_instance_of(described) }
|
16
15
|
|
17
|
-
|
18
|
-
|
16
|
+
context 'when there are no cells' do
|
17
|
+
let(:cells) {}
|
18
|
+
|
19
|
+
it { instance.instance_variable_get('@cells').must_equal([]) }
|
20
|
+
end
|
19
21
|
|
20
|
-
|
21
|
-
|
22
|
+
context 'when there are cells' do
|
23
|
+
it { instance.instance_variable_get('@cells').must_equal(cells) }
|
24
|
+
end
|
22
25
|
end
|
23
|
-
end
|
24
26
|
|
25
|
-
|
26
|
-
|
27
|
+
describe '.coerce' do
|
28
|
+
subject { described.coerce(_value) }
|
27
29
|
|
28
|
-
|
29
|
-
|
30
|
+
context 'when the value is a Vedeu::Models::Row' do
|
31
|
+
let(:_value) { described.new }
|
30
32
|
|
31
|
-
|
32
|
-
|
33
|
+
it { subject.must_equal(_value) }
|
34
|
+
end
|
33
35
|
|
34
|
-
|
35
|
-
|
36
|
+
context 'when the value is an Array' do
|
37
|
+
let(:_value) { [:hydrogen, :helium, :lithium] }
|
36
38
|
|
37
|
-
|
38
|
-
|
39
|
+
it { subject.must_equal(described.new(_value)) }
|
40
|
+
end
|
39
41
|
|
40
|
-
|
41
|
-
|
42
|
+
context 'when the value is an Array containing nil objects' do
|
43
|
+
let(:_value) { [:hydrogen, nil, :lithium] }
|
42
44
|
|
43
|
-
|
44
|
-
|
45
|
+
it { subject.must_equal(described.new([:hydrogen, :lithium])) }
|
46
|
+
end
|
45
47
|
|
46
|
-
|
47
|
-
|
48
|
+
context 'when the value is nil' do
|
49
|
+
let(:_value) {}
|
48
50
|
|
49
|
-
|
50
|
-
|
51
|
+
it { subject.must_equal(described.new) }
|
52
|
+
end
|
51
53
|
|
52
|
-
|
53
|
-
|
54
|
+
context 'when the value is anything else' do
|
55
|
+
let(:_value) { :beryllium }
|
54
56
|
|
55
|
-
|
57
|
+
it { subject.must_equal(described.new([_value])) }
|
58
|
+
end
|
56
59
|
end
|
57
|
-
end
|
58
60
|
|
59
|
-
|
60
|
-
|
61
|
+
describe '#each' do
|
62
|
+
subject { instance.each }
|
61
63
|
|
62
|
-
|
63
|
-
|
64
|
+
it { subject.must_be_instance_of(Enumerator) }
|
65
|
+
end
|
64
66
|
|
65
|
-
|
66
|
-
|
67
|
+
describe '#eql?' do
|
68
|
+
let(:other) { instance }
|
67
69
|
|
68
|
-
|
70
|
+
subject { instance.eql?(other) }
|
69
71
|
|
70
|
-
|
72
|
+
it { subject.must_equal(true) }
|
71
73
|
|
72
|
-
|
73
|
-
|
74
|
+
context 'when different to other' do
|
75
|
+
let(:other) { described.new([:hydrogen]) }
|
74
76
|
|
75
|
-
|
77
|
+
it { subject.must_equal(false) }
|
78
|
+
end
|
76
79
|
end
|
77
|
-
end
|
78
80
|
|
79
|
-
|
80
|
-
|
81
|
+
describe '#cell' do
|
82
|
+
let(:index) {}
|
81
83
|
|
82
|
-
|
84
|
+
subject { instance.cell(index) }
|
83
85
|
|
84
|
-
|
85
|
-
|
86
|
-
|
86
|
+
context 'when the index is nil' do
|
87
|
+
it { subject.must_equal(nil) }
|
88
|
+
end
|
87
89
|
|
88
|
-
|
89
|
-
|
90
|
-
|
90
|
+
context 'when the index is not nil' do
|
91
|
+
context 'and the index is in range' do
|
92
|
+
let(:index) { 1 }
|
91
93
|
|
92
|
-
|
93
|
-
|
94
|
+
it { subject.must_equal(:helium) }
|
95
|
+
end
|
94
96
|
|
95
|
-
|
96
|
-
|
97
|
+
context 'and the index is out of range' do
|
98
|
+
let(:index) { 4 }
|
97
99
|
|
98
|
-
|
99
|
-
|
100
|
+
it { subject.must_equal(nil) }
|
101
|
+
end
|
100
102
|
|
101
|
-
|
102
|
-
|
103
|
+
context 'and the index is out of range' do
|
104
|
+
let(:index) { -4 }
|
103
105
|
|
104
|
-
|
106
|
+
it { subject.must_equal(nil) }
|
107
|
+
end
|
105
108
|
end
|
106
109
|
end
|
107
|
-
end
|
108
110
|
|
109
|
-
|
111
|
+
end # Row
|
112
|
+
|
113
|
+
end # Models
|
110
114
|
|
111
115
|
end # Vedeu
|