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
@@ -1,87 +0,0 @@
|
|
1
|
-
module Vedeu
|
2
|
-
|
3
|
-
# Allows the storing of event aliases. Each alias can contain multiple event
|
4
|
-
# names.
|
5
|
-
#
|
6
|
-
module EventAliases
|
7
|
-
|
8
|
-
extend self
|
9
|
-
|
10
|
-
# @param alias_name [Symbol]
|
11
|
-
# @param event_name [Symbol]
|
12
|
-
# @return [Hash<Symbol => Array<Symbol>>]
|
13
|
-
def add(alias_name, event_name)
|
14
|
-
storage[alias_name] << event_name
|
15
|
-
end
|
16
|
-
alias_method :bind_alias, :add
|
17
|
-
|
18
|
-
# Return a boolean indicating whether the storage is empty.
|
19
|
-
#
|
20
|
-
# @return [Boolean]
|
21
|
-
def empty?
|
22
|
-
storage.empty?
|
23
|
-
end
|
24
|
-
|
25
|
-
# @param alias_name [Symbol]
|
26
|
-
# @return [Array<Symbol>]
|
27
|
-
def find(alias_name)
|
28
|
-
storage[alias_name]
|
29
|
-
end
|
30
|
-
|
31
|
-
# Returns a boolean indicating whether the alias is registered.
|
32
|
-
#
|
33
|
-
# @param alias_name [Symbol]
|
34
|
-
# @return [Boolean]
|
35
|
-
def registered?(alias_name)
|
36
|
-
return false if alias_name.nil? || alias_name.empty?
|
37
|
-
return false if empty?
|
38
|
-
|
39
|
-
storage.include?(alias_name)
|
40
|
-
end
|
41
|
-
|
42
|
-
# @param alias_name [Symbol]
|
43
|
-
# @return [FalseClass|Hash<Symbol => Array<Symbol>>]
|
44
|
-
def remove(alias_name)
|
45
|
-
return false if empty?
|
46
|
-
return false unless registered?(alias_name)
|
47
|
-
|
48
|
-
storage.delete(alias_name)
|
49
|
-
storage
|
50
|
-
end
|
51
|
-
alias_method :unbind_alias, :remove
|
52
|
-
|
53
|
-
# @return [Hash<Symbol => Array<Symbol>>]
|
54
|
-
def reset
|
55
|
-
@storage = in_memory
|
56
|
-
end
|
57
|
-
alias_method :reset!, :reset
|
58
|
-
|
59
|
-
# Access to the storage for this repository.
|
60
|
-
#
|
61
|
-
# @return [Hash<Symbol => Array<Symbol>>]
|
62
|
-
def storage
|
63
|
-
@storage ||= in_memory
|
64
|
-
end
|
65
|
-
|
66
|
-
# @param alias_name [Symbol]
|
67
|
-
# @param args [void]
|
68
|
-
# @return [FalseClass|Array<void>|void]
|
69
|
-
def trigger(alias_name, *args)
|
70
|
-
return [] unless registered?(alias_name)
|
71
|
-
|
72
|
-
storage[alias_name].map do |event_name|
|
73
|
-
Vedeu.log(type: :debug, message: "#{event_name}")
|
74
|
-
Vedeu::Trigger.trigger(event_name, *args)
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
private
|
79
|
-
|
80
|
-
# @return [Hash<Symbol => Array<Symbol>>]
|
81
|
-
def in_memory
|
82
|
-
Hash.new { |hash, key| hash[key] = [] }
|
83
|
-
end
|
84
|
-
|
85
|
-
end # EventAliases
|
86
|
-
|
87
|
-
end # Vedeu
|
data/lib/vedeu/events/events.rb
DELETED
@@ -1,26 +0,0 @@
|
|
1
|
-
module Vedeu
|
2
|
-
|
3
|
-
# Allows the storing of events.
|
4
|
-
#
|
5
|
-
class Events < Vedeu::Repository
|
6
|
-
|
7
|
-
singleton_class.send(:alias_method, :events, :repository)
|
8
|
-
|
9
|
-
class << self
|
10
|
-
|
11
|
-
# Remove all stored models from the repository.
|
12
|
-
#
|
13
|
-
# @example
|
14
|
-
# Vedeu.events.reset!
|
15
|
-
#
|
16
|
-
# @return [Vedeu::Events]
|
17
|
-
def reset!
|
18
|
-
@events = new(Vedeu::EventCollection)
|
19
|
-
end
|
20
|
-
alias_method :reset, :reset!
|
21
|
-
|
22
|
-
end # Eigenclass
|
23
|
-
|
24
|
-
end # Events
|
25
|
-
|
26
|
-
end # Vedeu
|
@@ -1,169 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
module Vedeu
|
4
|
-
|
5
|
-
describe ColourTranslator do
|
6
|
-
|
7
|
-
let(:described) { Vedeu::ColourTranslator }
|
8
|
-
let(:instance) { described.new(colour) }
|
9
|
-
let(:colour) { '#ff0000' }
|
10
|
-
|
11
|
-
describe '#initialize' do
|
12
|
-
it { instance.must_be_instance_of(described) }
|
13
|
-
it { instance.instance_variable_get('@colour').must_equal(colour) }
|
14
|
-
end
|
15
|
-
|
16
|
-
describe 'accessors' do
|
17
|
-
it { instance.must_respond_to(:colour) }
|
18
|
-
it { instance.must_respond_to(:value) }
|
19
|
-
end
|
20
|
-
|
21
|
-
describe '.coerce' do
|
22
|
-
let(:_value) {}
|
23
|
-
|
24
|
-
subject { described.coerce(_value) }
|
25
|
-
|
26
|
-
context 'when the value is nil' do
|
27
|
-
it { subject.must_be_instance_of(Vedeu::ColourTranslator) }
|
28
|
-
|
29
|
-
it {
|
30
|
-
Vedeu::Background.coerce(_value).
|
31
|
-
must_be_instance_of(Vedeu::Background)
|
32
|
-
}
|
33
|
-
it { Vedeu::Background.coerce(_value).colour.must_equal('') }
|
34
|
-
it {
|
35
|
-
Vedeu::Foreground.coerce(_value).
|
36
|
-
must_be_instance_of(Vedeu::Foreground)
|
37
|
-
}
|
38
|
-
it { Vedeu::Foreground.coerce(_value).colour.must_equal('') }
|
39
|
-
end
|
40
|
-
|
41
|
-
context 'when the value is a Vedeu::Background' do
|
42
|
-
let(:_value) { Vedeu::Background.new }
|
43
|
-
|
44
|
-
it { subject.must_equal(_value) }
|
45
|
-
end
|
46
|
-
|
47
|
-
context 'when the value is a Vedeu::Foreground' do
|
48
|
-
let(:_value) { Vedeu::Foreground.new }
|
49
|
-
|
50
|
-
it { subject.must_equal(_value) }
|
51
|
-
end
|
52
|
-
|
53
|
-
context 'when the value is not a polymorphic Colour' do
|
54
|
-
let(:_value) { '#aadd00' }
|
55
|
-
|
56
|
-
it { subject.must_be_instance_of(Vedeu::ColourTranslator) }
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
describe '#empty?' do
|
61
|
-
subject { instance.empty? }
|
62
|
-
|
63
|
-
context 'when there is no colour' do
|
64
|
-
let(:colour) {}
|
65
|
-
|
66
|
-
it { subject.must_equal(true) }
|
67
|
-
end
|
68
|
-
|
69
|
-
context 'when there is a colour' do
|
70
|
-
it { subject.must_equal(false) }
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
describe '#eql?' do
|
75
|
-
let(:other) { instance }
|
76
|
-
|
77
|
-
subject { instance.eql?(other) }
|
78
|
-
|
79
|
-
it { subject.must_equal(true) }
|
80
|
-
|
81
|
-
context 'when different to other' do
|
82
|
-
let(:other) { described.new('#ff00ff') }
|
83
|
-
|
84
|
-
it { subject.must_equal(false) }
|
85
|
-
end
|
86
|
-
end
|
87
|
-
|
88
|
-
describe '#escape_sequence' do
|
89
|
-
subject { instance.escape_sequence }
|
90
|
-
|
91
|
-
context 'when no colour is given' do
|
92
|
-
let(:colour) {}
|
93
|
-
|
94
|
-
it { subject.must_equal('') }
|
95
|
-
end
|
96
|
-
|
97
|
-
context 'when the colour is a terminal named colour; e.g. :red' do
|
98
|
-
let(:colour) { :red }
|
99
|
-
|
100
|
-
it 'raises an exception since the subclasses Background and ' \
|
101
|
-
'Foreground handle this' do
|
102
|
-
proc { subject }.must_raise(Vedeu::NotImplemented)
|
103
|
-
end
|
104
|
-
end
|
105
|
-
|
106
|
-
context 'when the colour is a terminal numbered colour; e.g. 122' do
|
107
|
-
let(:colour) { 122 }
|
108
|
-
|
109
|
-
it 'raises an exception since the subclasses Background and ' \
|
110
|
-
'Foreground handle this' do
|
111
|
-
proc { subject }.must_raise(Vedeu::NotImplemented)
|
112
|
-
end
|
113
|
-
end
|
114
|
-
|
115
|
-
context 'when the colour is a HTML/CSS colour (RGB specified)' do
|
116
|
-
let(:colour) { '#ff0000' }
|
117
|
-
|
118
|
-
it 'raises an exception since the subclasses Background and ' \
|
119
|
-
'Foreground handle this' do
|
120
|
-
proc { subject }.must_raise(Vedeu::NotImplemented)
|
121
|
-
end
|
122
|
-
end
|
123
|
-
|
124
|
-
context 'when the colour is not supported' do
|
125
|
-
let(:colour) { [:not_supported] }
|
126
|
-
|
127
|
-
before { instance.stubs(:registered?).returns(false) }
|
128
|
-
|
129
|
-
it { subject.must_equal('') }
|
130
|
-
end
|
131
|
-
end
|
132
|
-
|
133
|
-
describe '#to_html' do
|
134
|
-
subject { instance.to_html }
|
135
|
-
|
136
|
-
context 'when no colour is given' do
|
137
|
-
let(:colour) {}
|
138
|
-
|
139
|
-
it { subject.must_equal('') }
|
140
|
-
end
|
141
|
-
|
142
|
-
context 'when the colour is a terminal named colour; e.g. :red' do
|
143
|
-
let(:colour) { :red }
|
144
|
-
|
145
|
-
it { subject.must_equal('') }
|
146
|
-
end
|
147
|
-
|
148
|
-
context 'when the colour is a terminal numbered colour; e.g. 122' do
|
149
|
-
let(:colour) { 122 }
|
150
|
-
|
151
|
-
it { subject.must_equal('') }
|
152
|
-
end
|
153
|
-
|
154
|
-
context 'when the colour is a HTML/CSS colour (RGB specified)' do
|
155
|
-
let(:colour) { '#ff0000' }
|
156
|
-
|
157
|
-
it { subject.must_equal('#ff0000') }
|
158
|
-
end
|
159
|
-
|
160
|
-
context 'when the colour is not supported' do
|
161
|
-
let(:colour) { [:not_supported] }
|
162
|
-
|
163
|
-
it { subject.must_equal('') }
|
164
|
-
end
|
165
|
-
end
|
166
|
-
|
167
|
-
end # ColourTranslator
|
168
|
-
|
169
|
-
end # Vedeu
|
@@ -1,93 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
module Vedeu
|
4
|
-
|
5
|
-
describe Colours do
|
6
|
-
|
7
|
-
let(:described) { Vedeu::Colours }
|
8
|
-
let(:instance) { described.new }
|
9
|
-
|
10
|
-
describe '#initialize' do
|
11
|
-
it { instance.must_be_instance_of(described) }
|
12
|
-
it { instance.instance_variable_get('@storage').must_equal({}) }
|
13
|
-
end
|
14
|
-
|
15
|
-
describe 'accessors' do
|
16
|
-
it { instance.must_respond_to(:storage) }
|
17
|
-
end
|
18
|
-
|
19
|
-
describe '#register' do
|
20
|
-
let(:colour) { 'ff0000' }
|
21
|
-
let(:escape_sequence) { 'fake_escape_sequence' }
|
22
|
-
|
23
|
-
subject { instance.register(colour, escape_sequence) }
|
24
|
-
|
25
|
-
it { subject.must_equal('fake_escape_sequence') }
|
26
|
-
end
|
27
|
-
|
28
|
-
describe '#registered?' do
|
29
|
-
let(:colour) {}
|
30
|
-
|
31
|
-
subject { instance.registered?(colour) }
|
32
|
-
|
33
|
-
context 'when the colour is registered' do
|
34
|
-
let(:colour) { '#aa0000' }
|
35
|
-
|
36
|
-
before { instance.register(colour, 'fake_escape_sequence') }
|
37
|
-
|
38
|
-
it { subject.must_equal(true) }
|
39
|
-
end
|
40
|
-
|
41
|
-
context 'when the colour is not registered' do
|
42
|
-
it { subject.must_equal(false) }
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
describe '#reset!' do
|
47
|
-
subject { instance.reset! }
|
48
|
-
|
49
|
-
it { subject.must_be_instance_of(Hash) }
|
50
|
-
|
51
|
-
it { subject.must_equal({}) }
|
52
|
-
end
|
53
|
-
|
54
|
-
describe '#retrieve' do
|
55
|
-
let(:colour) {}
|
56
|
-
|
57
|
-
subject { instance.retrieve(colour) }
|
58
|
-
|
59
|
-
context 'when the colour can be found' do
|
60
|
-
let(:colour) { '#bb0000' }
|
61
|
-
|
62
|
-
before { instance.register(colour, 'fake_escape_sequence') }
|
63
|
-
|
64
|
-
it { subject.must_equal('fake_escape_sequence') }
|
65
|
-
end
|
66
|
-
|
67
|
-
context 'when the colour cannot be found' do
|
68
|
-
it { subject.must_equal('') }
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
describe '#retrieve_or_register' do
|
73
|
-
let(:colour) { '#cc0000' }
|
74
|
-
let(:escape_sequence) { 'escape_sequence' }
|
75
|
-
|
76
|
-
subject { instance.retrieve_or_register(colour, escape_sequence) }
|
77
|
-
|
78
|
-
context 'when the colour is registered' do
|
79
|
-
let(:colour) { '#cc0000' }
|
80
|
-
|
81
|
-
before { instance.register(colour, 'fake_escape_sequence') }
|
82
|
-
|
83
|
-
it { subject.must_equal('fake_escape_sequence') }
|
84
|
-
end
|
85
|
-
|
86
|
-
context 'when the colour is not registered' do
|
87
|
-
it { subject.must_equal('escape_sequence') }
|
88
|
-
end
|
89
|
-
end
|
90
|
-
|
91
|
-
end # Colours
|
92
|
-
|
93
|
-
end # Vedeu
|
@@ -1,140 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
module Vedeu
|
4
|
-
|
5
|
-
describe EventAliases do
|
6
|
-
|
7
|
-
let(:described) { Vedeu::EventAliases }
|
8
|
-
|
9
|
-
before { Vedeu::EventAliases.reset }
|
10
|
-
after { Vedeu::Bindings.setup! }
|
11
|
-
|
12
|
-
describe '.add' do
|
13
|
-
let(:alias_name) { :alias_test }
|
14
|
-
let(:event_name) { :event_test }
|
15
|
-
|
16
|
-
subject { described.add(alias_name, event_name) }
|
17
|
-
|
18
|
-
it { described.must_respond_to(:bind_alias) }
|
19
|
-
|
20
|
-
context 'when the alias is already registered' do
|
21
|
-
before { Vedeu::EventAliases.add(:alias_test, :event_test) }
|
22
|
-
|
23
|
-
it { subject.must_equal([:event_test, :event_test]) }
|
24
|
-
end
|
25
|
-
|
26
|
-
context 'when the alias is not already registered' do
|
27
|
-
it { subject.must_equal([:event_test]) }
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
describe '.empty?' do
|
32
|
-
subject { described.empty? }
|
33
|
-
|
34
|
-
context 'when no aliases are registered' do
|
35
|
-
before { Vedeu::EventAliases.reset }
|
36
|
-
|
37
|
-
it { subject.must_equal(true) }
|
38
|
-
end
|
39
|
-
|
40
|
-
context 'when aliases are registered' do
|
41
|
-
before { Vedeu::EventAliases.add(:alias_test, :event_test) }
|
42
|
-
|
43
|
-
it { subject.must_equal(false) }
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
describe '.find' do
|
48
|
-
# @todo Add more tests
|
49
|
-
# it { skip }
|
50
|
-
end
|
51
|
-
|
52
|
-
describe '.registered?' do
|
53
|
-
let(:alias_name) { :alias_test }
|
54
|
-
|
55
|
-
subject { described.registered?(alias_name) }
|
56
|
-
|
57
|
-
context 'when the alias is registered' do
|
58
|
-
before { Vedeu::EventAliases.add(:alias_test, :event_test) }
|
59
|
-
|
60
|
-
it { subject.must_equal(true) }
|
61
|
-
end
|
62
|
-
|
63
|
-
context 'when the alias is not registered' do
|
64
|
-
it { subject.must_equal(false) }
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
describe '.remove' do
|
69
|
-
let(:alias_name) { :alias_test }
|
70
|
-
|
71
|
-
before { Vedeu::EventAliases.reset }
|
72
|
-
|
73
|
-
subject { described.remove(alias_name) }
|
74
|
-
|
75
|
-
it { described.must_respond_to(:unbind_alias) }
|
76
|
-
|
77
|
-
context 'when no aliases are registered' do
|
78
|
-
it { subject.must_equal(false) }
|
79
|
-
end
|
80
|
-
|
81
|
-
context 'when the alias is not registered' do
|
82
|
-
before { Vedeu::EventAliases.add(:other_alias_test, :event_test) }
|
83
|
-
|
84
|
-
it { subject.must_equal(false) }
|
85
|
-
end
|
86
|
-
|
87
|
-
context 'when the alias is registered' do
|
88
|
-
before { Vedeu::EventAliases.add(:alias_test, :event_test) }
|
89
|
-
|
90
|
-
it { subject.must_equal({}) }
|
91
|
-
end
|
92
|
-
end
|
93
|
-
|
94
|
-
describe '.reset' do
|
95
|
-
subject { described.reset }
|
96
|
-
|
97
|
-
it { described.must_respond_to(:reset!) }
|
98
|
-
|
99
|
-
it { subject.must_equal({}) }
|
100
|
-
end
|
101
|
-
|
102
|
-
describe '.storage' do
|
103
|
-
before { Vedeu::EventAliases.reset }
|
104
|
-
|
105
|
-
subject { described.storage }
|
106
|
-
|
107
|
-
it { subject.must_equal({}) }
|
108
|
-
end
|
109
|
-
|
110
|
-
describe '.trigger' do
|
111
|
-
let(:alias_name) { :some_alias }
|
112
|
-
let(:args) {}
|
113
|
-
|
114
|
-
subject { described.trigger(alias_name, *args) }
|
115
|
-
|
116
|
-
context 'when the alias name is registered' do
|
117
|
-
before do
|
118
|
-
Vedeu::Trigger.stubs(:trigger)
|
119
|
-
|
120
|
-
described.add(:some_alias, :some_event)
|
121
|
-
described.add(:some_alias, :other_event)
|
122
|
-
end
|
123
|
-
|
124
|
-
it {
|
125
|
-
Vedeu::Trigger.expects(:trigger).with(:some_event, nil)
|
126
|
-
Vedeu::Trigger.expects(:trigger).with(:other_event, nil)
|
127
|
-
subject
|
128
|
-
}
|
129
|
-
end
|
130
|
-
|
131
|
-
context 'when the alias name is not registered' do
|
132
|
-
let(:alias_name) {}
|
133
|
-
|
134
|
-
it { subject.must_equal([]) }
|
135
|
-
end
|
136
|
-
end
|
137
|
-
|
138
|
-
end # EventAliases
|
139
|
-
|
140
|
-
end # Vedeu
|