vedeu 0.6.1 → 0.6.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/vedeu/all.rb +2 -13
- data/lib/vedeu/api.rb +9 -9
- data/lib/vedeu/application/application_view.rb +3 -5
- data/lib/vedeu/bindings/bindings.rb +5 -1
- data/lib/vedeu/bindings/focus.rb +0 -5
- data/lib/vedeu/bindings/refresh.rb +0 -5
- data/lib/vedeu/bindings/system.rb +1 -6
- data/lib/vedeu/colours/all.rb +17 -0
- data/lib/vedeu/colours/background.rb +32 -28
- data/lib/vedeu/colours/backgrounds.rb +13 -9
- data/lib/vedeu/colours/colour.rb +106 -102
- data/lib/vedeu/colours/foreground.rb +32 -28
- data/lib/vedeu/colours/foregrounds.rb +13 -9
- data/lib/vedeu/colours/repository.rb +70 -0
- data/lib/vedeu/colours/translator.rb +267 -0
- data/lib/vedeu/configuration/api.rb +10 -7
- data/lib/vedeu/configuration/configuration.rb +2 -1
- data/lib/vedeu/dsl/border.rb +15 -2
- data/lib/vedeu/dsl/composition.rb +6 -4
- data/lib/vedeu/dsl/geometry.rb +14 -7
- data/lib/vedeu/dsl/group.rb +2 -2
- data/lib/vedeu/dsl/interface.rb +5 -3
- data/lib/vedeu/dsl/keymap.rb +9 -7
- data/lib/vedeu/dsl/line.rb +7 -4
- data/lib/vedeu/dsl/menu.rb +3 -0
- data/lib/vedeu/dsl/presentation.rb +20 -10
- data/lib/vedeu/dsl/shared.rb +4 -4
- data/lib/vedeu/dsl/stream.rb +2 -2
- data/lib/vedeu/dsl/text.rb +11 -5
- data/lib/vedeu/dsl/use.rb +2 -2
- data/lib/vedeu/dsl/view.rb +8 -6
- data/lib/vedeu/events/aliases.rb +91 -0
- data/lib/vedeu/events/all.rb +15 -0
- data/lib/vedeu/events/collection.rb +13 -0
- data/lib/vedeu/events/event.rb +244 -239
- data/lib/vedeu/events/repository.rb +30 -0
- data/lib/vedeu/events/trigger.rb +68 -64
- data/lib/vedeu/exceptions.rb +65 -54
- data/lib/vedeu/geometry/coordinate.rb +3 -1
- data/lib/vedeu/geometry/grid.rb +2 -4
- data/lib/vedeu/input/editor/all.rb +2 -1
- data/lib/vedeu/input/editor/{virtual_cursor.rb → cursor.rb} +10 -10
- data/lib/vedeu/input/editor/document.rb +7 -7
- data/lib/vedeu/input/editor/insert.rb +70 -0
- data/lib/vedeu/input/editor/line.rb +4 -16
- data/lib/vedeu/input/editor/lines.rb +2 -16
- data/lib/vedeu/input/input_translator.rb +2 -2
- data/lib/vedeu/input/key.rb +2 -2
- data/lib/vedeu/internal_api.rb +6 -6
- data/lib/vedeu/log/lockless_log_device.rb +0 -74
- data/lib/vedeu/models/focus.rb +3 -3
- data/lib/vedeu/models/interface.rb +3 -3
- data/lib/vedeu/models/menu.rb +2 -2
- data/lib/vedeu/models/views/char.rb +1 -1
- data/lib/vedeu/models/views/composition.rb +1 -1
- data/lib/vedeu/models/views/line.rb +1 -1
- data/lib/vedeu/models/views/stream.rb +1 -1
- data/lib/vedeu/models/views/view.rb +6 -7
- data/lib/vedeu/output/presentation/colour.rb +23 -21
- data/lib/vedeu/output/renderers/renderer_options.rb +2 -4
- data/lib/vedeu/output/text.rb +1 -1
- data/lib/vedeu/output/wordwrap.rb +18 -7
- data/lib/vedeu/plugins/plugin.rb +2 -2
- data/lib/vedeu/refresh/refresh_buffer.rb +3 -3
- data/lib/vedeu/refresh/refresh_group.rb +3 -3
- data/lib/vedeu/repositories/repository.rb +7 -6
- data/lib/vedeu/runtime/application.rb +1 -1
- data/lib/vedeu/runtime/main_loop.rb +3 -3
- data/lib/vedeu/runtime/router.rb +14 -11
- data/lib/vedeu/templating/helpers.rb +5 -5
- data/lib/vedeu/templating/template.rb +4 -4
- data/lib/vedeu/templating/view_template.rb +1 -1
- data/lib/vedeu/terminal/terminal.rb +2 -2
- data/lib/vedeu/version.rb +1 -1
- data/test/lib/vedeu/application/application_view_test.rb +1 -1
- data/test/lib/vedeu/colours/background_test.rb +93 -89
- data/test/lib/vedeu/colours/backgrounds_test.rb +11 -7
- data/test/lib/vedeu/colours/colour_test.rb +155 -151
- data/test/lib/vedeu/colours/foreground_test.rb +93 -89
- data/test/lib/vedeu/colours/foregrounds_test.rb +11 -7
- data/test/lib/vedeu/colours/repository_test.rb +97 -0
- data/test/lib/vedeu/colours/translator_test.rb +173 -0
- data/test/lib/vedeu/configuration/api_test.rb +4 -4
- data/test/lib/vedeu/dsl/border_test.rb +12 -0
- data/test/lib/vedeu/dsl/composition_test.rb +3 -3
- data/test/lib/vedeu/dsl/geometry_test.rb +11 -0
- data/test/lib/vedeu/dsl/group_test.rb +2 -2
- data/test/lib/vedeu/dsl/interface_test.rb +4 -4
- data/test/lib/vedeu/dsl/keymap_test.rb +8 -4
- data/test/lib/vedeu/dsl/line_test.rb +6 -3
- data/test/lib/vedeu/dsl/menu_test.rb +6 -0
- data/test/lib/vedeu/dsl/presentation_test.rb +16 -3
- data/test/lib/vedeu/dsl/stream_test.rb +1 -1
- data/test/lib/vedeu/dsl/text_test.rb +7 -0
- data/test/lib/vedeu/dsl/view_test.rb +3 -3
- data/test/lib/vedeu/events/aliases_test.rb +144 -0
- data/test/lib/vedeu/events/collection_test.rb +22 -0
- data/test/lib/vedeu/events/event_test.rb +84 -80
- data/test/lib/vedeu/events/repository_test.rb +28 -0
- data/test/lib/vedeu/events/trigger_test.rb +41 -37
- data/test/lib/vedeu/geometry/grid_test.rb +4 -4
- data/test/lib/vedeu/input/editor/{virtual_cursor_test.rb → cursor_test.rb} +3 -3
- data/test/lib/vedeu/input/editor/insert_test.rb +36 -0
- data/test/lib/vedeu/input/key_test.rb +1 -1
- data/test/lib/vedeu/models/cell_test.rb +1 -1
- data/test/lib/vedeu/models/focus_test.rb +4 -2
- data/test/lib/vedeu/models/menu_test.rb +1 -1
- data/test/lib/vedeu/models/views/char_test.rb +8 -4
- data/test/lib/vedeu/models/views/line_test.rb +4 -4
- data/test/lib/vedeu/models/views/stream_test.rb +3 -3
- data/test/lib/vedeu/models/views/view_test.rb +1 -1
- data/test/lib/vedeu/output/html_char_test.rb +4 -2
- data/test/lib/vedeu/output/presentation/colour_test.rb +5 -5
- data/test/lib/vedeu/output/presentation_test.rb +4 -4
- data/test/lib/vedeu/output/renderers/json_test.rb +4 -2
- data/test/lib/vedeu/plugins/plugin_test.rb +1 -1
- data/test/lib/vedeu/refresh/refresh_buffer_test.rb +1 -1
- data/test/lib/vedeu/refresh/refresh_group_test.rb +1 -1
- data/test/lib/vedeu/repositories/repository_test.rb +2 -2
- data/test/lib/vedeu/runtime/router_test.rb +6 -6
- data/test/lib/vedeu/templating/decoder_test.rb +2 -3
- data/test/lib/vedeu/templating/encoder_test.rb +2 -3
- data/test/lib/vedeu/templating/helpers_test.rb +6 -6
- data/test/lib/vedeu/templating/template_test.rb +2 -2
- data/test/lib/vedeu/templating/view_template_test.rb +13 -7
- data/test/lib/vedeu/terminal/terminal_test.rb +3 -3
- metadata +24 -19
- data/lib/vedeu/colours/colour_translator.rb +0 -260
- data/lib/vedeu/colours/colours.rb +0 -66
- data/lib/vedeu/events/event_aliases.rb +0 -87
- data/lib/vedeu/events/event_collection.rb +0 -9
- data/lib/vedeu/events/events.rb +0 -26
- data/test/lib/vedeu/colours/colour_translator_test.rb +0 -169
- data/test/lib/vedeu/colours/colours_test.rb +0 -93
- data/test/lib/vedeu/events/event_aliases_test.rb +0 -140
- data/test/lib/vedeu/events/event_collection_test.rb +0 -18
- data/test/lib/vedeu/events/events_test.rb +0 -24
@@ -23,6 +23,7 @@ module Vedeu
|
|
23
23
|
subject { instance.centred(true) }
|
24
24
|
|
25
25
|
it { instance.must_respond_to(:centred!) }
|
26
|
+
it { instance.must_respond_to(:centred=) }
|
26
27
|
|
27
28
|
it 'sets the attribute to the value' do
|
28
29
|
subject.must_equal(true)
|
@@ -76,6 +77,8 @@ module Vedeu
|
|
76
77
|
describe '#height' do
|
77
78
|
subject { instance.height(6) }
|
78
79
|
|
80
|
+
it { instance.must_respond_to(:height=) }
|
81
|
+
|
79
82
|
it 'sets the attribute to the value' do
|
80
83
|
subject.call.must_equal(6)
|
81
84
|
end
|
@@ -137,6 +140,8 @@ module Vedeu
|
|
137
140
|
describe '#width' do
|
138
141
|
subject { instance.width(25) }
|
139
142
|
|
143
|
+
it { instance.must_respond_to(:width=) }
|
144
|
+
|
140
145
|
it 'sets the attribute to the value' do
|
141
146
|
subject.call.must_equal(25)
|
142
147
|
end
|
@@ -159,6 +164,8 @@ module Vedeu
|
|
159
164
|
describe '#x' do
|
160
165
|
subject { instance.x(2) }
|
161
166
|
|
167
|
+
it { instance.must_respond_to(:x=) }
|
168
|
+
|
162
169
|
it 'sets the attribute to the value' do
|
163
170
|
subject.must_equal(2)
|
164
171
|
end
|
@@ -215,6 +222,8 @@ module Vedeu
|
|
215
222
|
describe '#y' do
|
216
223
|
subject { instance.y(5) }
|
217
224
|
|
225
|
+
it { instance.must_respond_to(:y=) }
|
226
|
+
|
218
227
|
it 'sets the attribute to the value' do
|
219
228
|
subject.must_equal(5)
|
220
229
|
end
|
@@ -271,6 +280,7 @@ module Vedeu
|
|
271
280
|
describe '#xn' do
|
272
281
|
subject { instance.xn(15) }
|
273
282
|
|
283
|
+
it { instance.must_respond_to(:xn=) }
|
274
284
|
it { subject.must_equal(15) }
|
275
285
|
|
276
286
|
context 'when a block is given' do
|
@@ -289,6 +299,7 @@ module Vedeu
|
|
289
299
|
describe '#yn' do
|
290
300
|
subject { instance.yn(8) }
|
291
301
|
|
302
|
+
it { instance.must_respond_to(:yn=) }
|
292
303
|
it { subject.must_equal(8) }
|
293
304
|
|
294
305
|
context 'when a block is given' do
|
@@ -31,7 +31,7 @@ module Vedeu
|
|
31
31
|
context 'when the block is not given' do
|
32
32
|
subject { described.group(group_name) }
|
33
33
|
|
34
|
-
it { proc { subject }.must_raise(Vedeu::InvalidSyntax) }
|
34
|
+
it { proc { subject }.must_raise(Vedeu::Error::InvalidSyntax) }
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
@@ -74,7 +74,7 @@ module Vedeu
|
|
74
74
|
end
|
75
75
|
}
|
76
76
|
|
77
|
-
it { proc { subject }.must_raise(Vedeu::MissingRequired) }
|
77
|
+
it { proc { subject }.must_raise(Vedeu::Error::MissingRequired) }
|
78
78
|
end
|
79
79
|
|
80
80
|
context 'it adds interface names to the group' do
|
@@ -34,7 +34,7 @@ module Vedeu
|
|
34
34
|
context 'when the block is not given' do
|
35
35
|
subject { described.interface('flourine') }
|
36
36
|
|
37
|
-
it { proc { subject }.must_raise(Vedeu::InvalidSyntax) }
|
37
|
+
it { proc { subject }.must_raise(Vedeu::Error::InvalidSyntax) }
|
38
38
|
end
|
39
39
|
|
40
40
|
context 'when the name is not given' do
|
@@ -44,7 +44,7 @@ module Vedeu
|
|
44
44
|
end
|
45
45
|
}
|
46
46
|
|
47
|
-
it { proc { subject }.must_raise(Vedeu::MissingRequired) }
|
47
|
+
it { proc { subject }.must_raise(Vedeu::Error::MissingRequired) }
|
48
48
|
end
|
49
49
|
end
|
50
50
|
|
@@ -54,7 +54,7 @@ module Vedeu
|
|
54
54
|
context 'when the block is not given' do
|
55
55
|
subject { instance.border }
|
56
56
|
|
57
|
-
it { proc { subject }.must_raise(Vedeu::InvalidSyntax) }
|
57
|
+
it { proc { subject }.must_raise(Vedeu::Error::InvalidSyntax) }
|
58
58
|
end
|
59
59
|
|
60
60
|
context 'when the block is given' do
|
@@ -182,7 +182,7 @@ module Vedeu
|
|
182
182
|
context 'when the required block is not provided' do
|
183
183
|
subject { instance.geometry }
|
184
184
|
|
185
|
-
it { proc { subject }.must_raise(Vedeu::InvalidSyntax) }
|
185
|
+
it { proc { subject }.must_raise(Vedeu::Error::InvalidSyntax) }
|
186
186
|
end
|
187
187
|
|
188
188
|
context 'when the block is given' do
|
@@ -20,28 +20,30 @@ module Vedeu
|
|
20
20
|
|
21
21
|
subject { instance.key(*value_or_values) { :some_action } }
|
22
22
|
|
23
|
+
it { instance.must_respond_to(:key=) }
|
24
|
+
|
23
25
|
context 'when a block was not given' do
|
24
26
|
subject { instance.key(value_or_values) }
|
25
27
|
|
26
|
-
it { proc { subject }.must_raise(Vedeu::InvalidSyntax) }
|
28
|
+
it { proc { subject }.must_raise(Vedeu::Error::InvalidSyntax) }
|
27
29
|
end
|
28
30
|
|
29
31
|
context 'when a key was not given' do
|
30
32
|
let(:value_or_values) {}
|
31
33
|
|
32
|
-
it { proc { subject }.must_raise(Vedeu::InvalidSyntax) }
|
34
|
+
it { proc { subject }.must_raise(Vedeu::Error::InvalidSyntax) }
|
33
35
|
end
|
34
36
|
|
35
37
|
context 'when an invalid key was given (nil)' do
|
36
38
|
let(:value_or_values) { ['v', nil] }
|
37
39
|
|
38
|
-
it { proc { subject }.must_raise(Vedeu::InvalidSyntax) }
|
40
|
+
it { proc { subject }.must_raise(Vedeu::Error::InvalidSyntax) }
|
39
41
|
end
|
40
42
|
|
41
43
|
context 'when an invalid key was given (empty)' do
|
42
44
|
let(:value_or_values) { ['v', ''] }
|
43
45
|
|
44
|
-
it { proc { subject }.must_raise(Vedeu::InvalidSyntax) }
|
46
|
+
it { proc { subject }.must_raise(Vedeu::Error::InvalidSyntax) }
|
45
47
|
end
|
46
48
|
|
47
49
|
context 'when the key is valid (not already defined)' do
|
@@ -59,6 +61,8 @@ module Vedeu
|
|
59
61
|
|
60
62
|
subject { instance.name(_value) }
|
61
63
|
|
64
|
+
it { instance.must_respond_to(:name=) }
|
65
|
+
|
62
66
|
it 'defines the name of the keymap' do
|
63
67
|
subject
|
64
68
|
model.name.must_equal(_value)
|
@@ -10,7 +10,7 @@ module Vedeu
|
|
10
10
|
let(:instance) { described.new(model) }
|
11
11
|
let(:model) { Vedeu::Views::Line.new(attributes) }
|
12
12
|
let(:client) {}
|
13
|
-
let(:colour) { Vedeu::Colour.new }
|
13
|
+
let(:colour) { Vedeu::Colours::Colour.new }
|
14
14
|
let(:parent) { Vedeu::Views::View.new }
|
15
15
|
let(:style) { Vedeu::Style.new }
|
16
16
|
let(:_value) { [] }
|
@@ -42,6 +42,7 @@ module Vedeu
|
|
42
42
|
|
43
43
|
it { subject.must_be_instance_of(Vedeu::Views::Lines) }
|
44
44
|
it { subject[0].must_be_instance_of(Vedeu::Views::Line) }
|
45
|
+
it { instance.must_respond_to(:line=) }
|
45
46
|
|
46
47
|
context 'when the block is given' do
|
47
48
|
end
|
@@ -56,7 +57,7 @@ module Vedeu
|
|
56
57
|
|
57
58
|
subject { instance.line(_value) }
|
58
59
|
|
59
|
-
it { proc { subject }.must_raise(Vedeu::InvalidSyntax) }
|
60
|
+
it { proc { subject }.must_raise(Vedeu::Error::InvalidSyntax) }
|
60
61
|
end
|
61
62
|
end
|
62
63
|
end
|
@@ -74,10 +75,12 @@ module Vedeu
|
|
74
75
|
end
|
75
76
|
|
76
77
|
context 'when the block is not given' do
|
77
|
-
it { proc { instance.streams }.must_raise(Vedeu::InvalidSyntax) }
|
78
|
+
it { proc { instance.streams }.must_raise(Vedeu::Error::InvalidSyntax) }
|
78
79
|
end
|
79
80
|
|
80
81
|
it { instance.must_respond_to(:stream) }
|
82
|
+
it { instance.must_respond_to(:stream=) }
|
83
|
+
it { instance.must_respond_to(:streams=) }
|
81
84
|
end
|
82
85
|
|
83
86
|
end # Line
|
@@ -28,6 +28,8 @@ module Vedeu
|
|
28
28
|
|
29
29
|
subject { instance.item(_value) }
|
30
30
|
|
31
|
+
it { instance.must_respond_to(:item=) }
|
32
|
+
|
31
33
|
context 'when items are provided' do
|
32
34
|
it { subject.must_equal([:sodium,
|
33
35
|
:magnesium,
|
@@ -42,6 +44,8 @@ module Vedeu
|
|
42
44
|
|
43
45
|
subject { instance.items(_value) }
|
44
46
|
|
47
|
+
it { instance.must_respond_to(:items=) }
|
48
|
+
|
45
49
|
context 'when no items are provided' do
|
46
50
|
it { subject.must_equal([]) }
|
47
51
|
end
|
@@ -58,6 +62,8 @@ module Vedeu
|
|
58
62
|
|
59
63
|
subject { instance.name(_value) }
|
60
64
|
|
65
|
+
it { instance.must_respond_to(:name=) }
|
66
|
+
|
61
67
|
it 'returns the name of the menu' do
|
62
68
|
subject
|
63
69
|
model.name.must_equal('metals')
|
@@ -37,7 +37,12 @@ module Vedeu
|
|
37
37
|
|
38
38
|
it { instance.must_respond_to(:bg) }
|
39
39
|
it { instance.must_respond_to(:bgcolor) }
|
40
|
-
it {
|
40
|
+
it { instance.must_respond_to(:bg=) }
|
41
|
+
it { instance.must_respond_to(:bgcolor=) }
|
42
|
+
it { instance.must_respond_to(:background=) }
|
43
|
+
it {
|
44
|
+
dsl.colour.background.must_be_instance_of(Vedeu::Colours::Background)
|
45
|
+
}
|
41
46
|
it { dsl.colour.background.colour.must_equal(background) }
|
42
47
|
end
|
43
48
|
|
@@ -53,7 +58,12 @@ module Vedeu
|
|
53
58
|
|
54
59
|
it { instance.must_respond_to(:fg) }
|
55
60
|
it { instance.must_respond_to(:fgcolor) }
|
56
|
-
it {
|
61
|
+
it { instance.must_respond_to(:fg=) }
|
62
|
+
it { instance.must_respond_to(:fgcolor=) }
|
63
|
+
it { instance.must_respond_to(:foreground=) }
|
64
|
+
it {
|
65
|
+
dsl.colour.foreground.must_be_instance_of(Vedeu::Colours::Foreground)
|
66
|
+
}
|
57
67
|
it { dsl.colour.foreground.colour.must_equal(foreground) }
|
58
68
|
end
|
59
69
|
|
@@ -62,7 +72,8 @@ module Vedeu
|
|
62
72
|
|
63
73
|
subject { instance.colour(attributes) }
|
64
74
|
|
65
|
-
it {
|
75
|
+
it { instance.must_respond_to(:colour=) }
|
76
|
+
it { subject.must_be_instance_of(Vedeu::Colours::Colour) }
|
66
77
|
|
67
78
|
context 'with an empty value' do
|
68
79
|
let(:attributes) { { background: background, foreground: '' } }
|
@@ -77,7 +88,9 @@ module Vedeu
|
|
77
88
|
|
78
89
|
subject { instance.style(args) }
|
79
90
|
|
91
|
+
it { instance.must_respond_to(:style=) }
|
80
92
|
it { instance.must_respond_to(:styles) }
|
93
|
+
it { instance.must_respond_to(:styles=) }
|
81
94
|
|
82
95
|
it { subject.must_be_instance_of(Vedeu::Style) }
|
83
96
|
end
|
@@ -21,6 +21,13 @@ module Vedeu
|
|
21
21
|
|
22
22
|
subject { instance.text(_value, options) }
|
23
23
|
|
24
|
+
it { instance.must_respond_to(:text=) }
|
25
|
+
it { instance.must_respond_to(:align=) }
|
26
|
+
it { instance.must_respond_to(:center=) }
|
27
|
+
it { instance.must_respond_to(:centre=) }
|
28
|
+
it { instance.must_respond_to(:left=) }
|
29
|
+
it { instance.must_respond_to(:right=) }
|
30
|
+
|
24
31
|
context 'when the model is a Vedeu::Views::View' do
|
25
32
|
let(:model) { Vedeu::Views::View.new }
|
26
33
|
let(:instance) { Vedeu::DSL::Interface.new(model) }
|
@@ -26,7 +26,7 @@ module Vedeu
|
|
26
26
|
context 'when the block is not given' do
|
27
27
|
subject { described.renders }
|
28
28
|
|
29
|
-
it { proc { subject }.must_raise(Vedeu::InvalidSyntax) }
|
29
|
+
it { proc { subject }.must_raise(Vedeu::Error::InvalidSyntax) }
|
30
30
|
end
|
31
31
|
|
32
32
|
context 'when the block is given' do
|
@@ -46,7 +46,7 @@ module Vedeu
|
|
46
46
|
context 'when the block is not given' do
|
47
47
|
subject { described.views }
|
48
48
|
|
49
|
-
it { proc { subject }.must_raise(Vedeu::InvalidSyntax) }
|
49
|
+
it { proc { subject }.must_raise(Vedeu::Error::InvalidSyntax) }
|
50
50
|
end
|
51
51
|
|
52
52
|
context 'when the block is given' do
|
@@ -66,7 +66,7 @@ module Vedeu
|
|
66
66
|
context 'when the required block is not provided' do
|
67
67
|
subject { instance.lines }
|
68
68
|
|
69
|
-
it { proc { subject }.must_raise(Vedeu::InvalidSyntax) }
|
69
|
+
it { proc { subject }.must_raise(Vedeu::Error::InvalidSyntax) }
|
70
70
|
end
|
71
71
|
|
72
72
|
it { instance.must_respond_to(:line) }
|
@@ -0,0 +1,144 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Vedeu
|
4
|
+
|
5
|
+
module Events
|
6
|
+
|
7
|
+
describe Aliases do
|
8
|
+
|
9
|
+
let(:described) { Vedeu::Events::Aliases }
|
10
|
+
|
11
|
+
before { described.reset }
|
12
|
+
after { Vedeu::Bindings.setup! }
|
13
|
+
|
14
|
+
describe '.add' do
|
15
|
+
let(:alias_name) { :alias_test }
|
16
|
+
let(:event_name) { :event_test }
|
17
|
+
|
18
|
+
subject { described.add(alias_name, event_name) }
|
19
|
+
|
20
|
+
it { described.must_respond_to(:bind_alias) }
|
21
|
+
|
22
|
+
context 'when the alias is already registered' do
|
23
|
+
before { described.add(:alias_test, :event_test) }
|
24
|
+
|
25
|
+
it { subject.must_equal([:event_test, :event_test]) }
|
26
|
+
end
|
27
|
+
|
28
|
+
context 'when the alias is not already registered' do
|
29
|
+
it { subject.must_equal([:event_test]) }
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
describe '.empty?' do
|
34
|
+
subject { described.empty? }
|
35
|
+
|
36
|
+
context 'when no aliases are registered' do
|
37
|
+
before { described.reset }
|
38
|
+
|
39
|
+
it { subject.must_equal(true) }
|
40
|
+
end
|
41
|
+
|
42
|
+
context 'when aliases are registered' do
|
43
|
+
before { described.add(:alias_test, :event_test) }
|
44
|
+
|
45
|
+
it { subject.must_equal(false) }
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
describe '.find' do
|
50
|
+
# @todo Add more tests
|
51
|
+
# it { skip }
|
52
|
+
end
|
53
|
+
|
54
|
+
describe '.registered?' do
|
55
|
+
let(:alias_name) { :alias_test }
|
56
|
+
|
57
|
+
subject { described.registered?(alias_name) }
|
58
|
+
|
59
|
+
context 'when the alias is registered' do
|
60
|
+
before { described.add(:alias_test, :event_test) }
|
61
|
+
|
62
|
+
it { subject.must_equal(true) }
|
63
|
+
end
|
64
|
+
|
65
|
+
context 'when the alias is not registered' do
|
66
|
+
it { subject.must_equal(false) }
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
describe '.remove' do
|
71
|
+
let(:alias_name) { :alias_test }
|
72
|
+
|
73
|
+
before { described.reset }
|
74
|
+
|
75
|
+
subject { described.remove(alias_name) }
|
76
|
+
|
77
|
+
it { described.must_respond_to(:unbind_alias) }
|
78
|
+
|
79
|
+
context 'when no aliases are registered' do
|
80
|
+
it { subject.must_equal(false) }
|
81
|
+
end
|
82
|
+
|
83
|
+
context 'when the alias is not registered' do
|
84
|
+
before { described.add(:other_alias_test, :event_test) }
|
85
|
+
|
86
|
+
it { subject.must_equal(false) }
|
87
|
+
end
|
88
|
+
|
89
|
+
context 'when the alias is registered' do
|
90
|
+
before { described.add(:alias_test, :event_test) }
|
91
|
+
|
92
|
+
it { subject.must_equal({}) }
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
describe '.reset' do
|
97
|
+
subject { described.reset }
|
98
|
+
|
99
|
+
it { described.must_respond_to(:reset!) }
|
100
|
+
|
101
|
+
it { subject.must_equal({}) }
|
102
|
+
end
|
103
|
+
|
104
|
+
describe '.storage' do
|
105
|
+
before { described.reset }
|
106
|
+
|
107
|
+
subject { described.storage }
|
108
|
+
|
109
|
+
it { subject.must_equal({}) }
|
110
|
+
end
|
111
|
+
|
112
|
+
describe '.trigger' do
|
113
|
+
let(:alias_name) { :some_alias }
|
114
|
+
let(:args) {}
|
115
|
+
|
116
|
+
subject { described.trigger(alias_name, *args) }
|
117
|
+
|
118
|
+
context 'when the alias name is registered' do
|
119
|
+
before do
|
120
|
+
Vedeu::Events::Trigger.stubs(:trigger)
|
121
|
+
|
122
|
+
described.add(:some_alias, :some_event)
|
123
|
+
described.add(:some_alias, :other_event)
|
124
|
+
end
|
125
|
+
|
126
|
+
it {
|
127
|
+
Vedeu::Events::Trigger.expects(:trigger).with(:some_event, nil)
|
128
|
+
Vedeu::Events::Trigger.expects(:trigger).with(:other_event, nil)
|
129
|
+
subject
|
130
|
+
}
|
131
|
+
end
|
132
|
+
|
133
|
+
context 'when the alias name is not registered' do
|
134
|
+
let(:alias_name) {}
|
135
|
+
|
136
|
+
it { subject.must_equal([]) }
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
140
|
+
end # Aliases
|
141
|
+
|
142
|
+
end # Events
|
143
|
+
|
144
|
+
end # Vedeu
|