vedeu 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.yardopts +1 -0
- data/README.md +1 -2
- data/Rakefile +5 -5
- data/bin/vedeu +8 -4
- data/docs/api.md +3 -1
- data/docs/events.md +43 -29
- data/docs/getting_started.md +2 -0
- data/examples/cursor_app/cursor_app.rb +85 -0
- data/examples/lines_app/lines_app.rb +60 -0
- data/lib/vedeu.rb +9 -3
- data/lib/vedeu/api/api.rb +28 -7
- data/lib/vedeu/api/composition.rb +2 -0
- data/lib/vedeu/api/helpers.rb +2 -0
- data/lib/vedeu/api/interface.rb +2 -20
- data/lib/vedeu/api/keymap.rb +2 -0
- data/lib/vedeu/api/line.rb +2 -0
- data/lib/vedeu/api/menu.rb +3 -1
- data/lib/vedeu/api/stream.rb +25 -2
- data/lib/vedeu/application.rb +4 -4
- data/lib/vedeu/configuration/api.rb +327 -0
- data/lib/vedeu/configuration/cli.rb +110 -0
- data/lib/vedeu/{configuration.rb → configuration/configuration.rb} +49 -99
- data/lib/vedeu/launcher.rb +0 -1
- data/lib/vedeu/models/attributes/colour_translator.rb +2 -2
- data/lib/vedeu/models/colour.rb +0 -1
- data/lib/vedeu/models/composition.rb +2 -8
- data/lib/vedeu/models/cursor.rb +261 -0
- data/lib/vedeu/models/geometry.rb +11 -19
- data/lib/vedeu/models/interface.rb +2 -12
- data/lib/vedeu/models/keymap.rb +2 -0
- data/lib/vedeu/models/line.rb +2 -0
- data/lib/vedeu/models/stream.rb +2 -0
- data/lib/vedeu/models/style.rb +2 -0
- data/lib/vedeu/output/clear.rb +0 -1
- data/lib/vedeu/output/compositor.rb +0 -1
- data/lib/vedeu/output/refresh.rb +3 -0
- data/lib/vedeu/output/render.rb +12 -6
- data/lib/vedeu/output/view.rb +1 -0
- data/lib/vedeu/repositories/cursors.rb +98 -0
- data/lib/vedeu/repositories/events.rb +0 -1
- data/lib/vedeu/repositories/focus.rb +18 -0
- data/lib/vedeu/repositories/menus.rb +4 -4
- data/lib/vedeu/support/common.rb +2 -1
- data/lib/vedeu/support/event.rb +1 -10
- data/lib/vedeu/support/grid.rb +1 -2
- data/lib/vedeu/{repositories → support}/keymap_validator.rb +5 -4
- data/lib/vedeu/support/log.rb +3 -0
- data/lib/vedeu/support/menu.rb +4 -1
- data/lib/vedeu/support/registrar.rb +2 -1
- data/test/integration/defining_interfaces_test.rb +0 -1
- data/test/integration/views/basic_view_test.rb +741 -739
- data/test/lib/vedeu/api/api_test.rb +14 -3
- data/test/lib/vedeu/api/helpers_test.rb +3 -3
- data/test/lib/vedeu/api/interface_test.rb +17 -70
- data/test/lib/vedeu/api/keymap_test.rb +2 -0
- data/test/lib/vedeu/api/line_test.rb +4 -4
- data/test/lib/vedeu/api/menu_test.rb +6 -5
- data/test/lib/vedeu/api/stream_test.rb +18 -0
- data/test/lib/vedeu/configuration/api_test.rb +248 -0
- data/test/lib/vedeu/configuration/cli_test.rb +88 -0
- data/test/lib/vedeu/configuration/configuration_test.rb +67 -0
- data/test/lib/vedeu/input/input_test.rb +2 -2
- data/test/lib/vedeu/models/attributes/background_test.rb +3 -3
- data/test/lib/vedeu/models/attributes/foreground_test.rb +3 -3
- data/test/lib/vedeu/models/composition_test.rb +0 -222
- data/test/lib/vedeu/models/cursor_test.rb +164 -0
- data/test/lib/vedeu/models/interface_test.rb +0 -11
- data/test/lib/vedeu/output/compositor_test.rb +2 -4
- data/test/lib/vedeu/output/render_test.rb +4 -41
- data/test/lib/vedeu/repositories/cursors_test.rb +13 -0
- data/test/lib/vedeu/repositories/focus_test.rb +14 -4
- data/test/lib/vedeu/repositories/menus_test.rb +36 -29
- data/test/lib/vedeu/{repositories → support}/keymap_validator_test.rb +0 -0
- data/test/lib/vedeu/support/menu_test.rb +3 -3
- data/test/lib/vedeu/support/registrar_test.rb +6 -0
- data/test/lib/vedeu/support/terminal_test.rb +2 -2
- data/test/test_helper.rb +1 -1
- data/vedeu.gemspec +1 -1
- metadata +23 -14
- data/elements.txt +0 -118
- data/lib/vedeu/support/cursor.rb +0 -96
- data/test/lib/vedeu/configuration_test.rb +0 -154
- data/test/lib/vedeu/support/cursor_test.rb +0 -79
- data/test/support/model_test_data.json +0 -437
@@ -6,6 +6,12 @@ module Vedeu
|
|
6
6
|
|
7
7
|
before { Event.stubs(:new).returns(event) }
|
8
8
|
|
9
|
+
describe '.configure' do
|
10
|
+
it 'raises an exception unless a block was given' do
|
11
|
+
proc { Vedeu.configure }.must_raise(InvalidSyntax)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
9
15
|
describe '.defined' do
|
10
16
|
it 'returns a reference to the API::Defined module' do
|
11
17
|
Vedeu.defined.must_equal(Vedeu::API::Defined)
|
@@ -28,6 +34,12 @@ module Vedeu
|
|
28
34
|
end
|
29
35
|
end
|
30
36
|
|
37
|
+
describe '.focus' do
|
38
|
+
it 'sets the named interface to be focussed' do
|
39
|
+
skip
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
31
43
|
describe '.height' do
|
32
44
|
it 'returns the terminal height' do
|
33
45
|
IO.console.stub(:winsize, [24, 40]) do
|
@@ -139,12 +151,11 @@ module Vedeu
|
|
139
151
|
{
|
140
152
|
interfaces: [{
|
141
153
|
name: "some_interface",
|
142
|
-
group:
|
154
|
+
group: '',
|
143
155
|
lines: [],
|
144
156
|
colour: {},
|
145
|
-
style:
|
157
|
+
style: '',
|
146
158
|
geometry: {},
|
147
|
-
cursor: true,
|
148
159
|
delay: 0.0,
|
149
160
|
parent: {}
|
150
161
|
}]
|
@@ -48,7 +48,7 @@ module Vedeu
|
|
48
48
|
HelpersTestClass.new.style do
|
49
49
|
#...
|
50
50
|
end.must_equal(
|
51
|
-
[{ colour: {}, style: [], text:
|
51
|
+
[{ colour: {}, style: [], text: '', width: nil, align: :left, parent: nil, }]
|
52
52
|
)
|
53
53
|
end
|
54
54
|
|
@@ -60,7 +60,7 @@ module Vedeu
|
|
60
60
|
{
|
61
61
|
colour: {},
|
62
62
|
style: ['italic'],
|
63
|
-
text:
|
63
|
+
text: '',
|
64
64
|
width: nil,
|
65
65
|
align: :left,
|
66
66
|
parent: nil,
|
@@ -77,7 +77,7 @@ module Vedeu
|
|
77
77
|
{
|
78
78
|
colour: {},
|
79
79
|
style: ['italic', 'blink'],
|
80
|
-
text:
|
80
|
+
text: '',
|
81
81
|
width: nil,
|
82
82
|
align: :left,
|
83
83
|
parent: nil,
|
@@ -21,12 +21,11 @@ module Vedeu
|
|
21
21
|
group: '',
|
22
22
|
lines: [],
|
23
23
|
colour: {
|
24
|
-
foreground:
|
25
|
-
background:
|
24
|
+
foreground: '#aadd00',
|
25
|
+
background: '#222222'
|
26
26
|
},
|
27
|
-
style:
|
27
|
+
style: '',
|
28
28
|
geometry: {},
|
29
|
-
cursor: true,
|
30
29
|
delay: 0.0,
|
31
30
|
parent: nil,
|
32
31
|
}
|
@@ -44,7 +43,6 @@ module Vedeu
|
|
44
43
|
colour: {},
|
45
44
|
style: "underline",
|
46
45
|
geometry: {},
|
47
|
-
cursor: true,
|
48
46
|
delay: 0.0,
|
49
47
|
parent: nil,
|
50
48
|
}
|
@@ -64,14 +62,13 @@ module Vedeu
|
|
64
62
|
y use('my_interface').south
|
65
63
|
end.must_equal({
|
66
64
|
name: "my_other_interface",
|
67
|
-
group:
|
65
|
+
group: '',
|
68
66
|
lines: [],
|
69
67
|
colour: {},
|
70
|
-
style:
|
68
|
+
style: '',
|
71
69
|
geometry: {
|
72
70
|
y: 11
|
73
71
|
},
|
74
|
-
cursor: true,
|
75
72
|
delay: 0.0,
|
76
73
|
parent: nil,
|
77
74
|
})
|
@@ -88,9 +85,8 @@ module Vedeu
|
|
88
85
|
group: '',
|
89
86
|
lines: [],
|
90
87
|
colour: {},
|
91
|
-
style:
|
88
|
+
style: '',
|
92
89
|
geometry: {},
|
93
|
-
cursor: true,
|
94
90
|
delay: 1.0,
|
95
91
|
parent: nil,
|
96
92
|
})
|
@@ -102,32 +98,12 @@ module Vedeu
|
|
102
98
|
group 'my_group'
|
103
99
|
end.must_equal(
|
104
100
|
{
|
105
|
-
name:
|
101
|
+
name: '',
|
106
102
|
group: "my_group",
|
107
103
|
lines: [],
|
108
104
|
colour: {},
|
109
|
-
style:
|
110
|
-
geometry: {},
|
111
|
-
cursor: true,
|
112
|
-
delay: 0.0,
|
113
|
-
parent: nil,
|
114
|
-
}
|
115
|
-
)
|
116
|
-
end
|
117
|
-
|
118
|
-
it 'allows the setting of the cursor for the interface to be shown ' \
|
119
|
-
'or hidden' do
|
120
|
-
Interface.build do
|
121
|
-
cursor false
|
122
|
-
end.must_equal(
|
123
|
-
{
|
124
|
-
name: "",
|
125
|
-
group: "",
|
126
|
-
lines: [],
|
127
|
-
colour: {},
|
128
|
-
style: "",
|
105
|
+
style: '',
|
129
106
|
geometry: {},
|
130
|
-
cursor: false,
|
131
107
|
delay: 0.0,
|
132
108
|
parent: nil,
|
133
109
|
}
|
@@ -161,32 +137,6 @@ module Vedeu
|
|
161
137
|
end
|
162
138
|
end
|
163
139
|
|
164
|
-
describe '#cursor' do
|
165
|
-
it 'raises an exception if the value is invalid' do
|
166
|
-
proc {
|
167
|
-
Vedeu.interface 'beryllium' do
|
168
|
-
cursor :invalid
|
169
|
-
end
|
170
|
-
}.must_raise(InvalidSyntax)
|
171
|
-
end
|
172
|
-
|
173
|
-
it 'sets the cursor to true (visible)' do
|
174
|
-
Vedeu.interface 'beryllium' do
|
175
|
-
cursor true
|
176
|
-
end
|
177
|
-
|
178
|
-
Vedeu.use('beryllium').attributes[:cursor].must_equal(true)
|
179
|
-
end
|
180
|
-
|
181
|
-
it 'sets the cursor to false (hidden)' do
|
182
|
-
Vedeu.interface 'beryllium' do
|
183
|
-
cursor false
|
184
|
-
end
|
185
|
-
|
186
|
-
Vedeu.use('beryllium').attributes[:cursor].must_equal(false)
|
187
|
-
end
|
188
|
-
end
|
189
|
-
|
190
140
|
describe '#delay' do
|
191
141
|
it 'sets the delay attribute' do
|
192
142
|
Vedeu.interface 'cobalt' do
|
@@ -221,22 +171,21 @@ module Vedeu
|
|
221
171
|
interface.must_be_instance_of(API::Interface)
|
222
172
|
interface.attributes.must_equal(
|
223
173
|
{
|
224
|
-
name:
|
225
|
-
group:
|
174
|
+
name: 'carbon',
|
175
|
+
group: '',
|
226
176
|
lines: [
|
227
177
|
{
|
228
178
|
colour: {},
|
229
179
|
streams: {
|
230
|
-
text:
|
180
|
+
text: ''
|
231
181
|
},
|
232
182
|
style: [],
|
233
183
|
parent: interface.view_attributes,
|
234
184
|
}
|
235
185
|
],
|
236
186
|
colour: {},
|
237
|
-
style:
|
187
|
+
style: '',
|
238
188
|
geometry: {},
|
239
|
-
cursor: true,
|
240
189
|
delay: 0.0,
|
241
190
|
parent: nil,
|
242
191
|
}
|
@@ -250,8 +199,8 @@ module Vedeu
|
|
250
199
|
interface.must_be_instance_of(API::Interface)
|
251
200
|
interface.attributes.must_equal(
|
252
201
|
{
|
253
|
-
name:
|
254
|
-
group:
|
202
|
+
name: 'carbon',
|
203
|
+
group: '',
|
255
204
|
lines: [
|
256
205
|
{
|
257
206
|
colour: {},
|
@@ -263,9 +212,8 @@ module Vedeu
|
|
263
212
|
}
|
264
213
|
],
|
265
214
|
colour: {},
|
266
|
-
style:
|
215
|
+
style: '',
|
267
216
|
geometry: {},
|
268
|
-
cursor: true,
|
269
217
|
delay: 0.0,
|
270
218
|
parent: nil,
|
271
219
|
}
|
@@ -282,7 +230,7 @@ module Vedeu
|
|
282
230
|
interface.attributes.must_equal(
|
283
231
|
{
|
284
232
|
name: "silicon",
|
285
|
-
group:
|
233
|
+
group: '',
|
286
234
|
lines: [
|
287
235
|
{
|
288
236
|
colour: {},
|
@@ -296,9 +244,8 @@ module Vedeu
|
|
296
244
|
}
|
297
245
|
],
|
298
246
|
colour: {},
|
299
|
-
style:
|
247
|
+
style: '',
|
300
248
|
geometry: {},
|
301
|
-
cursor: true,
|
302
249
|
delay: 0.0,
|
303
250
|
parent: nil
|
304
251
|
}
|
@@ -48,28 +48,28 @@ module Vedeu
|
|
48
48
|
describe '#foreground' do
|
49
49
|
it 'returns the value assigned' do
|
50
50
|
attrs = Line.new.foreground('#ff0000')
|
51
|
-
attrs.first[:colour].must_equal({ foreground:
|
51
|
+
attrs.first[:colour].must_equal({ foreground: '#ff0000' })
|
52
52
|
end
|
53
53
|
|
54
54
|
it 'returns the value assigned with a block' do
|
55
55
|
attrs = Line.new.foreground('#00ff00') do
|
56
56
|
# ...
|
57
57
|
end
|
58
|
-
attrs.first[:colour].must_equal({ foreground:
|
58
|
+
attrs.first[:colour].must_equal({ foreground: '#00ff00' })
|
59
59
|
end
|
60
60
|
end
|
61
61
|
|
62
62
|
describe '#background' do
|
63
63
|
it 'returns the value assigned' do
|
64
64
|
attrs = Line.new.background('#00ff00')
|
65
|
-
attrs.first[:colour].must_equal({ background:
|
65
|
+
attrs.first[:colour].must_equal({ background: '#00ff00' })
|
66
66
|
end
|
67
67
|
|
68
68
|
it 'returns the value assigned with a block' do
|
69
69
|
attrs = Line.new.background('#0000ff') do
|
70
70
|
# ...
|
71
71
|
end
|
72
|
-
attrs.first[:colour].must_equal({ background:
|
72
|
+
attrs.first[:colour].must_equal({ background: '#0000ff' })
|
73
73
|
end
|
74
74
|
end
|
75
75
|
end
|
@@ -38,15 +38,16 @@ module Vedeu
|
|
38
38
|
end
|
39
39
|
|
40
40
|
describe '#items' do
|
41
|
-
it 'returns an
|
42
|
-
|
43
|
-
menu.items.must_be_instance_of(Vedeu::Menu)
|
41
|
+
it 'returns an empty collection when no items are provided' do
|
42
|
+
Menu.new.items.must_equal([])
|
44
43
|
end
|
45
44
|
|
46
45
|
it 'assigns the instance of Vedeu::Menu to the attributes' do
|
46
|
+
items = [:sodium, :magnesium, :aluminium, :silicon]
|
47
|
+
|
47
48
|
menu = Menu.new
|
48
|
-
menu.items(
|
49
|
-
menu.attributes[:items].
|
49
|
+
menu.items(items)
|
50
|
+
menu.attributes[:items].must_equal(items)
|
50
51
|
end
|
51
52
|
end
|
52
53
|
|
@@ -17,6 +17,24 @@ module Vedeu
|
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
20
|
+
describe '#left' do
|
21
|
+
it 'returns a Symbol' do
|
22
|
+
Stream.new.left.must_equal(:left)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
describe '#right' do
|
27
|
+
it 'returns a Symbol' do
|
28
|
+
Stream.new.right.must_equal(:right)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
describe '#centre' do
|
33
|
+
it 'returns a Symbol' do
|
34
|
+
Stream.new.centre.must_equal(:centre)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
20
38
|
describe '#text' do
|
21
39
|
it 'returns the value assigned' do
|
22
40
|
Stream.new.text('Some text...').must_equal('Some text...')
|
@@ -0,0 +1,248 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Vedeu
|
4
|
+
module Configuration
|
5
|
+
|
6
|
+
describe API do
|
7
|
+
|
8
|
+
before { Configuration.reset }
|
9
|
+
after { Configuration.reset }
|
10
|
+
|
11
|
+
describe '.configure' do
|
12
|
+
it 'returns the default configuration' do
|
13
|
+
Vedeu.configure do
|
14
|
+
# ...
|
15
|
+
end.must_equal(
|
16
|
+
{
|
17
|
+
colour_mode: 16777216,
|
18
|
+
debug: false,
|
19
|
+
interactive: true,
|
20
|
+
once: false,
|
21
|
+
system_keys: {
|
22
|
+
exit: 'q',
|
23
|
+
focus_next: :tab,
|
24
|
+
focus_prev: :shift_tab,
|
25
|
+
mode_switch: :escape
|
26
|
+
},
|
27
|
+
terminal_mode: :raw,
|
28
|
+
trace: false
|
29
|
+
}
|
30
|
+
)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
describe '#interactive!' do
|
35
|
+
it 'sets the option to the desired value' do
|
36
|
+
configuration = Vedeu.configure { interactive! }
|
37
|
+
configuration[:interactive].must_equal(true)
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'sets the option to the desired value' do
|
41
|
+
configuration = Vedeu.configure { interactive(false) }
|
42
|
+
configuration[:interactive].must_equal(false)
|
43
|
+
end
|
44
|
+
|
45
|
+
it 'sets the option to the desired value' do
|
46
|
+
configuration = Vedeu.configure { interactive(true) }
|
47
|
+
configuration[:interactive].must_equal(true)
|
48
|
+
end
|
49
|
+
|
50
|
+
it 'sets the option to the desired value' do
|
51
|
+
configuration = Vedeu.configure { interactive }
|
52
|
+
configuration[:interactive].must_equal(true)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
describe '#standalone!' do
|
57
|
+
it 'sets the option to the desired value' do
|
58
|
+
configuration = Vedeu.configure { standalone! }
|
59
|
+
configuration[:interactive].must_equal(false)
|
60
|
+
end
|
61
|
+
|
62
|
+
it 'sets the option to the desired value' do
|
63
|
+
configuration = Vedeu.configure { standalone(false) }
|
64
|
+
configuration[:interactive].must_equal(true)
|
65
|
+
end
|
66
|
+
|
67
|
+
it 'sets the option to the desired value' do
|
68
|
+
configuration = Vedeu.configure { standalone(true) }
|
69
|
+
configuration[:interactive].must_equal(false)
|
70
|
+
end
|
71
|
+
|
72
|
+
it 'sets the option to the desired value' do
|
73
|
+
configuration = Vedeu.configure { standalone }
|
74
|
+
configuration[:interactive].must_equal(false)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
describe '#run_once!' do
|
79
|
+
it 'sets the option to the desired value' do
|
80
|
+
configuration = Vedeu.configure { run_once! }
|
81
|
+
configuration[:once].must_equal(true)
|
82
|
+
end
|
83
|
+
|
84
|
+
it 'sets the option to the desired value' do
|
85
|
+
configuration = Vedeu.configure { run_once(false) }
|
86
|
+
configuration[:once].must_equal(false)
|
87
|
+
end
|
88
|
+
|
89
|
+
it 'sets the option to the desired value' do
|
90
|
+
configuration = Vedeu.configure { run_once(true) }
|
91
|
+
configuration[:once].must_equal(true)
|
92
|
+
end
|
93
|
+
|
94
|
+
it 'sets the option to the desired value' do
|
95
|
+
configuration = Vedeu.configure { run_once }
|
96
|
+
configuration[:once].must_equal(true)
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
describe '#cooked!' do
|
101
|
+
it 'sets the option to the desired value' do
|
102
|
+
configuration = Vedeu.configure { cooked! }
|
103
|
+
configuration[:terminal_mode].must_equal(:cooked)
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
describe '#raw!' do
|
108
|
+
it 'sets the option to the desired value' do
|
109
|
+
configuration = Vedeu.configure { raw! }
|
110
|
+
configuration[:terminal_mode].must_equal(:raw)
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
describe '#debug!' do
|
115
|
+
it 'sets the option to the desired value' do
|
116
|
+
configuration = Vedeu.configure { debug! }
|
117
|
+
configuration[:debug].must_equal(true)
|
118
|
+
end
|
119
|
+
|
120
|
+
it 'sets the option to the desired value' do
|
121
|
+
configuration = Vedeu.configure { debug(true) }
|
122
|
+
configuration[:debug].must_equal(true)
|
123
|
+
end
|
124
|
+
|
125
|
+
it 'sets the option to the desired value' do
|
126
|
+
configuration = Vedeu.configure { debug(false) }
|
127
|
+
configuration[:debug].must_equal(false)
|
128
|
+
end
|
129
|
+
|
130
|
+
it 'sets the option to the desired value' do
|
131
|
+
configuration = Vedeu.configure { trace(true) }
|
132
|
+
configuration[:debug].must_equal(true)
|
133
|
+
end
|
134
|
+
|
135
|
+
it 'sets the option to the desired value' do
|
136
|
+
configuration = Vedeu.configure do
|
137
|
+
debug(false)
|
138
|
+
trace(true)
|
139
|
+
end
|
140
|
+
|
141
|
+
configuration[:debug].must_equal(true)
|
142
|
+
end
|
143
|
+
|
144
|
+
it 'sets the option to the desired value' do
|
145
|
+
configuration = Vedeu.configure do
|
146
|
+
debug(true)
|
147
|
+
trace(false)
|
148
|
+
end
|
149
|
+
|
150
|
+
configuration[:debug].must_equal(true)
|
151
|
+
end
|
152
|
+
|
153
|
+
it 'sets the option to the desired value' do
|
154
|
+
configuration = Vedeu.configure do
|
155
|
+
debug(false)
|
156
|
+
trace(false)
|
157
|
+
end
|
158
|
+
|
159
|
+
configuration[:debug].must_equal(false)
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
163
|
+
describe '#trace!' do
|
164
|
+
it 'sets the option to the desired value' do
|
165
|
+
configuration = Vedeu.configure { trace! }
|
166
|
+
|
167
|
+
configuration[:trace].must_equal(true)
|
168
|
+
end
|
169
|
+
|
170
|
+
it 'sets the option to the desired value' do
|
171
|
+
configuration = Vedeu.configure { trace(false) }
|
172
|
+
|
173
|
+
configuration[:trace].must_equal(false)
|
174
|
+
configuration[:debug].must_equal(false)
|
175
|
+
end
|
176
|
+
|
177
|
+
it 'sets the option to the desired value' do
|
178
|
+
configuration = Vedeu.configure { trace(true) }
|
179
|
+
|
180
|
+
configuration[:trace].must_equal(true)
|
181
|
+
configuration[:debug].must_equal(true)
|
182
|
+
end
|
183
|
+
end
|
184
|
+
|
185
|
+
describe '#colour_mode' do
|
186
|
+
it 'raises an exception for an invalid value' do
|
187
|
+
proc {
|
188
|
+
Vedeu.configure { colour_mode(nil) }
|
189
|
+
}.must_raise(InvalidSyntax)
|
190
|
+
end
|
191
|
+
|
192
|
+
it 'raises an exception for an invalid value' do
|
193
|
+
proc {
|
194
|
+
Vedeu.configure { colour_mode('') }
|
195
|
+
}.must_raise(InvalidSyntax)
|
196
|
+
end
|
197
|
+
|
198
|
+
it 'raises an exception for an invalid value' do
|
199
|
+
proc {
|
200
|
+
Vedeu.configure { colour_mode(1234) }
|
201
|
+
}.must_raise(InvalidSyntax)
|
202
|
+
end
|
203
|
+
|
204
|
+
it 'sets the option to the desired value' do
|
205
|
+
configuration = Vedeu.configure { colour_mode(256) }
|
206
|
+
configuration[:colour_mode].must_equal(256)
|
207
|
+
end
|
208
|
+
end
|
209
|
+
|
210
|
+
describe 'redefining system keys' do
|
211
|
+
methods_and_keys = {
|
212
|
+
exit_key: :exit,
|
213
|
+
focus_next_key: :focus_next,
|
214
|
+
focus_prev_key: :focus_prev,
|
215
|
+
mode_switch_key: :mode_switch,
|
216
|
+
}
|
217
|
+
|
218
|
+
context 'when using an invalid value' do
|
219
|
+
invalid_params = [nil, '', 123, 'oops']
|
220
|
+
|
221
|
+
methods_and_keys.each do |meth, _|
|
222
|
+
invalid_params.each do |param|
|
223
|
+
it 'raises an exception with an invalid parameter' do
|
224
|
+
proc { Vedeu.configure { send(meth, param) } }.must_raise(InvalidSyntax)
|
225
|
+
end
|
226
|
+
end
|
227
|
+
end
|
228
|
+
end
|
229
|
+
|
230
|
+
context 'when using a valid value' do
|
231
|
+
valid_params = ['v', :f1]
|
232
|
+
|
233
|
+
methods_and_keys.each do |meth, key|
|
234
|
+
valid_params.each do |param|
|
235
|
+
it 'sets the system key to the desired value' do
|
236
|
+
configuration = Vedeu.configure { send(meth, param) }
|
237
|
+
|
238
|
+
configuration[:system_keys][key].must_equal(param)
|
239
|
+
end
|
240
|
+
end
|
241
|
+
end
|
242
|
+
end
|
243
|
+
end
|
244
|
+
|
245
|
+
end
|
246
|
+
|
247
|
+
end
|
248
|
+
end
|