vedeu 0.6.4 → 0.6.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (118) hide show
  1. checksums.yaml +4 -4
  2. data/.codeclimate.yml +40 -0
  3. data/README.md +1 -0
  4. data/docs/dsl.md +24 -24
  5. data/lib/vedeu/all.rb +21 -44
  6. data/lib/vedeu/api.rb +13 -13
  7. data/lib/vedeu/application/application_controller.rb +2 -0
  8. data/lib/vedeu/bindings/movement.rb +53 -18
  9. data/lib/vedeu/bindings/refresh.rb +1 -1
  10. data/lib/vedeu/bindings/system.rb +2 -2
  11. data/lib/vedeu/bindings/visibility.rb +3 -3
  12. data/lib/vedeu/borders/all.rb +13 -0
  13. data/lib/vedeu/borders/border.rb +209 -202
  14. data/lib/vedeu/{dsl/border.rb → borders/dsl.rb} +15 -15
  15. data/lib/vedeu/{null/border.rb → borders/null.rb} +9 -9
  16. data/lib/vedeu/borders/render.rb +347 -0
  17. data/lib/vedeu/borders/repository.rb +19 -0
  18. data/lib/vedeu/buffers/all.rb +13 -0
  19. data/lib/vedeu/buffers/buffer.rb +182 -176
  20. data/lib/vedeu/{null/buffer.rb → buffers/null.rb} +8 -8
  21. data/lib/vedeu/buffers/repository.rb +24 -0
  22. data/lib/vedeu/buffers/virtual_buffer.rb +2 -2
  23. data/lib/vedeu/cursors/all.rb +11 -0
  24. data/lib/vedeu/cursors/cursor.rb +276 -0
  25. data/lib/vedeu/cursors/refresh.rb +84 -0
  26. data/lib/vedeu/cursors/repository.rb +34 -0
  27. data/lib/vedeu/dsl/interface.rb +9 -9
  28. data/lib/vedeu/dsl/shared.rb +11 -11
  29. data/lib/vedeu/{exceptions.rb → error.rb} +2 -2
  30. data/lib/vedeu/esc/esc.rb +1 -1
  31. data/lib/vedeu/geometry/all.rb +18 -0
  32. data/lib/vedeu/geometry/area.rb +170 -160
  33. data/lib/vedeu/geometry/coordinate.rb +61 -39
  34. data/lib/vedeu/geometry/dimension.rb +139 -132
  35. data/lib/vedeu/{dsl/geometry.rb → geometry/dsl.rb} +11 -11
  36. data/lib/vedeu/geometry/generic_coordinate.rb +159 -153
  37. data/lib/vedeu/geometry/geometry.rb +310 -212
  38. data/lib/vedeu/geometry/grid.rb +73 -69
  39. data/lib/vedeu/{null/geometry.rb → geometry/null.rb} +10 -10
  40. data/lib/vedeu/geometry/position.rb +124 -120
  41. data/lib/vedeu/geometry/repository.rb +19 -0
  42. data/lib/vedeu/input/editor/document.rb +2 -2
  43. data/lib/vedeu/internal_api.rb +8 -8
  44. data/lib/vedeu/models/escape.rb +2 -2
  45. data/lib/vedeu/models/interface.rb +1 -1
  46. data/lib/vedeu/models/page.rb +89 -0
  47. data/lib/vedeu/models/row.rb +66 -0
  48. data/lib/vedeu/models/toggleable.rb +1 -1
  49. data/lib/vedeu/models/views/char.rb +7 -6
  50. data/lib/vedeu/models/views/line.rb +1 -1
  51. data/lib/vedeu/models/views/view.rb +2 -2
  52. data/lib/vedeu/options.rb +19 -0
  53. data/lib/vedeu/output/clear/named_interface.rb +1 -1
  54. data/lib/vedeu/output/direct.rb +1 -1
  55. data/lib/vedeu/output/presentation.rb +2 -1
  56. data/lib/vedeu/output/viewport.rb +3 -3
  57. data/lib/vedeu/repositories/model.rb +9 -1
  58. data/lib/vedeu/repositories/repository.rb +5 -0
  59. data/lib/vedeu/terminal/terminal.rb +3 -3
  60. data/lib/vedeu/version.rb +1 -1
  61. data/test/lib/vedeu/borders/border_test.rb +299 -291
  62. data/test/lib/vedeu/{dsl/border_test.rb → borders/dsl_test.rb} +6 -6
  63. data/test/lib/vedeu/{null/border_test.rb → borders/null_test.rb} +6 -6
  64. data/test/lib/vedeu/borders/render_test.rb +125 -0
  65. data/test/lib/vedeu/borders/repository_test.rb +17 -0
  66. data/test/lib/vedeu/buffers/buffer_test.rb +116 -112
  67. data/test/lib/vedeu/{null/buffer_test.rb → buffers/null_test.rb} +5 -5
  68. data/test/lib/vedeu/buffers/repository_test.rb +18 -0
  69. data/test/lib/vedeu/cursors/cursor_test.rb +370 -0
  70. data/test/lib/vedeu/cursors/refresh_test.rb +69 -0
  71. data/test/lib/vedeu/cursors/repository_test.rb +41 -0
  72. data/test/lib/vedeu/dsl/interface_test.rb +5 -5
  73. data/test/lib/vedeu/{exceptions_test.rb → error_test.rb} +0 -0
  74. data/test/lib/vedeu/geometry/area_test.rb +141 -137
  75. data/test/lib/vedeu/geometry/coordinate_test.rb +93 -89
  76. data/test/lib/vedeu/geometry/dimension_test.rb +137 -133
  77. data/test/lib/vedeu/{dsl/geometry_test.rb → geometry/dsl_test.rb} +17 -17
  78. data/test/lib/vedeu/geometry/generic_coordinate_test.rb +32 -28
  79. data/test/lib/vedeu/geometry/geometry_test.rb +282 -157
  80. data/test/lib/vedeu/geometry/grid_test.rb +35 -31
  81. data/test/lib/vedeu/{null/geometry_test.rb → geometry/null_test.rb} +5 -5
  82. data/test/lib/vedeu/geometry/position_test.rb +146 -142
  83. data/test/lib/vedeu/geometry/repository_test.rb +19 -0
  84. data/test/lib/vedeu/input/editor/document_test.rb +1 -1
  85. data/test/lib/vedeu/models/escape_test.rb +1 -1
  86. data/test/lib/vedeu/models/interface_test.rb +2 -2
  87. data/test/lib/vedeu/models/page_test.rb +235 -0
  88. data/test/lib/vedeu/models/row_test.rb +111 -0
  89. data/test/lib/vedeu/models/views/char_test.rb +3 -3
  90. data/test/lib/vedeu/options_test.rb +57 -0
  91. data/test/lib/vedeu/output/clear/named_interface_test.rb +1 -1
  92. data/test/lib/vedeu/output/renderers/json_test.rb +1 -1
  93. data/test/lib/vedeu/output/viewport_test.rb +15 -9
  94. data/test/lib/vedeu/refresh/refresh_buffer_test.rb +12 -12
  95. data/test/lib/vedeu/repositories/repositories_test.rb +1 -1
  96. data/test/lib/vedeu/repositories/repository_test.rb +7 -0
  97. data/test/lib/vedeu/terminal/terminal_test.rb +1 -1
  98. data/test/test_helper.rb +1 -1
  99. data/vedeu.gemspec +2 -2
  100. metadata +57 -63
  101. data/lib/vedeu/borders/borders.rb +0 -15
  102. data/lib/vedeu/borders/render_border.rb +0 -331
  103. data/lib/vedeu/buffers/buffers.rb +0 -20
  104. data/lib/vedeu/cursor/cursor.rb +0 -174
  105. data/lib/vedeu/cursor/cursors.rb +0 -30
  106. data/lib/vedeu/cursor/move.rb +0 -239
  107. data/lib/vedeu/cursor/reposition.rb +0 -78
  108. data/lib/vedeu/geometry/geometries.rb +0 -15
  109. data/lib/vedeu/refresh/refresh_cursor.rb +0 -92
  110. data/test/lib/vedeu/borders/borders_test.rb +0 -13
  111. data/test/lib/vedeu/borders/render_border_test.rb +0 -121
  112. data/test/lib/vedeu/buffers/buffers_test.rb +0 -14
  113. data/test/lib/vedeu/cursor/cursor_test.rb +0 -246
  114. data/test/lib/vedeu/cursor/cursors_test.rb +0 -37
  115. data/test/lib/vedeu/cursor/move_test.rb +0 -301
  116. data/test/lib/vedeu/cursor/reposition_test.rb +0 -63
  117. data/test/lib/vedeu/geometry/geometries_test.rb +0 -15
  118. data/test/lib/vedeu/refresh/refresh_cursor_test.rb +0 -65
@@ -1,13 +0,0 @@
1
- require 'test_helper'
2
-
3
- module Vedeu
4
-
5
- describe Borders do
6
-
7
- let(:described) { Vedeu::Borders }
8
-
9
- it { described.must_respond_to(:borders) }
10
-
11
- end # Borders
12
-
13
- end # Vedeu
@@ -1,121 +0,0 @@
1
- require 'test_helper'
2
-
3
- module Vedeu
4
-
5
- describe RenderBorder do
6
-
7
- let(:described) { Vedeu::RenderBorder }
8
- let(:instance) { described.new(border) }
9
- let(:border) {
10
- Vedeu::Border.new(enabled: enabled,
11
- name: _name,
12
- title: title,
13
- caption: caption,
14
- show_top: show_top,
15
- show_bottom: show_bottom,
16
- show_left: show_left,
17
- show_right: show_right)
18
- }
19
- let(:visible) { false }
20
- let(:enabled) { false }
21
- let(:_name) { 'Vedeu::RenderBorder' }
22
- let(:title) {}
23
- let(:caption) {}
24
- let(:show_top) { true }
25
- let(:show_bottom) { true }
26
- let(:show_left) { true }
27
- let(:show_right) { true }
28
-
29
- it { described.must_respond_to(:with) }
30
-
31
- describe '#initialize' do
32
- it { instance.must_be_instance_of(described) }
33
- it { instance.instance_variable_get('@border').must_equal(border) }
34
- end
35
-
36
- describe '#render' do
37
- let(:geometry) {
38
- Vedeu::Geometry.new(name: _name, x: 1, xn: 7, y: 1, yn: 4)
39
- }
40
- let(:interface) {
41
- Vedeu::Interface.new(name: _name, visible: visible)
42
- }
43
- before do
44
- Vedeu.geometries.stubs(:by_name).returns(geometry)
45
- Vedeu.interfaces.stubs(:by_name).returns(interface)
46
- end
47
-
48
- subject { instance.render }
49
-
50
- context 'when the interface is not visible' do
51
- it { subject.must_equal([]) }
52
- end
53
-
54
- context 'when the interface is visible' do
55
- let(:visible) { true }
56
-
57
- context 'when the border is not enabled' do
58
- it { subject.must_equal([]) }
59
- end
60
-
61
- context 'when the border is enabled' do
62
- let(:enabled) { true }
63
-
64
- context 'and a title is given' do
65
- let(:title) { 'T' }
66
-
67
- # @todo Add more tests.
68
- it { subject.size.must_equal(18) }
69
- end
70
-
71
- context 'and a title is not given' do
72
- # @todo Add more tests.
73
- it { subject.size.must_equal(18) }
74
- end
75
-
76
- context 'and a caption is given' do
77
- let(:caption) { 'C' }
78
-
79
- # @todo Add more tests.
80
- it { subject.size.must_equal(18) }
81
- end
82
-
83
- context 'and a caption is not given' do
84
- # @todo Add more tests.
85
- it { subject.size.must_equal(18) }
86
- end
87
-
88
- context 'and the left side is disabled' do
89
- let(:show_left) { false }
90
-
91
- # @todo Add more tests.
92
- it { subject.size.must_equal(16) }
93
- end
94
-
95
- context 'and the right side is disabled' do
96
- let(:show_right) { false }
97
-
98
- # @todo Add more tests.
99
- it { subject.size.must_equal(16) }
100
- end
101
-
102
- context 'and the top side is disabled' do
103
- let(:show_top) { false }
104
-
105
- # @todo Add more tests.
106
- it { subject.size.must_equal(13) }
107
- end
108
-
109
- context 'and the bottom side is disabled' do
110
- let(:show_bottom) { false }
111
-
112
- # @todo Add more tests.
113
- it { subject.size.must_equal(13) }
114
- end
115
- end
116
- end
117
- end
118
-
119
- end # RenderBorder
120
-
121
- end # Vedeu
@@ -1,14 +0,0 @@
1
- require 'test_helper'
2
-
3
- module Vedeu
4
-
5
- describe Buffers do
6
-
7
- let(:described) { Vedeu::Buffers }
8
- let(:instance) { described.buffers }
9
-
10
- it { described.must_respond_to(:buffers) }
11
-
12
- end # Buffers
13
-
14
- end # Vedeu
@@ -1,246 +0,0 @@
1
- require 'test_helper'
2
-
3
- module Vedeu
4
-
5
- describe Cursor do
6
-
7
- let(:described) { Vedeu::Cursor }
8
- let(:instance) { described.new(attributes) }
9
- let(:attributes) {
10
- {
11
- name: _name,
12
- ox: ox,
13
- oy: oy,
14
- repository: repository,
15
- visible: visible,
16
- x: x,
17
- y: y,
18
- }
19
- }
20
- let(:_name) { 'silver' }
21
- let(:ox) { 3 }
22
- let(:oy) { 2 }
23
- let(:repository) { Vedeu.cursors }
24
- let(:visible) { true }
25
- let(:x) { 19 }
26
- let(:y) { 8 }
27
- let(:border) { Vedeu::Border.new(name: _name, enabled: enabled) }
28
- let(:geometry) {
29
- Vedeu::Geometry.new(
30
- name: _name,
31
- x: 5,
32
- xn: 35,
33
- y: 5,
34
- yn: 10
35
- )
36
- }
37
- let(:enabled) { true }
38
-
39
- before do
40
- Vedeu.borders.stubs(:by_name).returns(border)
41
- Vedeu.geometries.stubs(:by_name).returns(geometry)
42
- end
43
-
44
- describe '#initialize' do
45
- subject { instance }
46
-
47
- it { subject.must_be_instance_of(described) }
48
- it { subject.instance_variable_get('@name').must_equal('silver') }
49
- it { subject.instance_variable_get('@ox').must_equal(3) }
50
- it { subject.instance_variable_get('@oy').must_equal(2) }
51
- it { subject.instance_variable_get('@repository').must_equal(repository) }
52
- it { subject.instance_variable_get('@visible').must_equal(true) }
53
- it { subject.instance_variable_get('@x').must_equal(19) }
54
- it { subject.instance_variable_get('@y').must_equal(8) }
55
- end
56
-
57
- describe 'accessors' do
58
- it { instance.must_respond_to(:attributes) }
59
- it { instance.must_respond_to(:name) }
60
- it { instance.must_respond_to(:ox) }
61
- it { instance.must_respond_to(:ox=) }
62
- it { instance.must_respond_to(:oy) }
63
- it { instance.must_respond_to(:oy=) }
64
- it { instance.must_respond_to(:state) }
65
- it { instance.must_respond_to(:x=) }
66
- it { instance.must_respond_to(:y=) }
67
- end
68
-
69
- describe '#hide' do
70
- let(:visible) { true }
71
- let(:hide_cursor) { Vedeu::Escape.new(value: Vedeu::Esc.hide_cursor) }
72
-
73
- before do
74
- Vedeu::Output.stubs(:render).
75
- with(hide_cursor).returns(hide_cursor)
76
- end
77
-
78
- subject { instance.hide }
79
-
80
- it { subject.must_be_instance_of(Vedeu::Escape) }
81
- end
82
-
83
- describe '#position' do
84
- subject { instance.position }
85
-
86
- it { subject.must_be_instance_of(Vedeu::Position) }
87
- end
88
-
89
- describe '#show' do
90
- let(:visible) { false }
91
- let(:show_cursor) { Vedeu::Escape.new(value: Vedeu::Esc.show_cursor) }
92
-
93
- before do
94
- Vedeu::Output.stubs(:render).
95
- with(show_cursor).returns(show_cursor)
96
- end
97
-
98
- subject { instance.show }
99
-
100
- it { subject.must_be_instance_of(Vedeu::Escape) }
101
- end
102
-
103
- describe '#to_s' do
104
- let(:visible) { true }
105
-
106
- subject { instance.to_s }
107
-
108
- it { instance.must_respond_to(:to_str) }
109
- it { subject.must_be_instance_of(String) }
110
-
111
- context 'when the cursor is visible' do
112
- it 'returns an visible cursor escape sequence with position' do
113
- subject.must_equal("\e[8;19H\e[?25h")
114
- end
115
- end
116
-
117
- context 'when the cursor is invisible' do
118
- let(:visible) { false }
119
-
120
- it 'returns the invisible cursor escape sequence with position' do
121
- subject.must_equal("\e[8;19H\e[?25l")
122
- end
123
- end
124
-
125
- context 'when a block is given' do
126
- subject {
127
- instance.to_s do
128
- # ...
129
- end
130
- }
131
-
132
- it 'returns the escape sequence to position and set the visibility ' \
133
- 'of the cursor and returns to that position after yielding the ' \
134
- 'block' do
135
- subject.must_equal("\e[8;19H\e[8;19H\e[?25h")
136
- end
137
- end
138
- end
139
-
140
- describe '#x' do
141
- subject { instance.x }
142
-
143
- context 'when x is less than tx' do
144
- let(:x) { -2 }
145
-
146
- it { subject.must_equal(6) }
147
- end
148
-
149
- context 'when x is less than left' do
150
- let(:x) { 2 }
151
-
152
- it { subject.must_equal(6) }
153
- end
154
-
155
- context 'when x is less than bx' do
156
- let(:x) { 5 }
157
-
158
- it { subject.must_equal(6) }
159
-
160
- context 'when border is not enabled' do
161
- let(:enabled) { false }
162
-
163
- it { subject.must_equal(5) }
164
- end
165
- end
166
-
167
- context 'when x is more than txn' do
168
- let(:x) { 47 }
169
-
170
- it { subject.must_equal(34) }
171
- end
172
-
173
- context 'when x is more than right' do
174
- let(:x) { 37 }
175
-
176
- it { subject.must_equal(34) }
177
- end
178
-
179
- context 'when x is more than bxn' do
180
- let(:x) { 35 }
181
-
182
- it { subject.must_equal(34) }
183
-
184
- context 'when border is not enabled' do
185
- let(:enabled) { false }
186
-
187
- it { subject.must_equal(35) }
188
- end
189
- end
190
- end
191
-
192
- describe '#y' do
193
- subject { instance.y }
194
-
195
- context 'when y is less than ty' do
196
- let(:y) { -2 }
197
-
198
- it { subject.must_equal(6) }
199
- end
200
-
201
- context 'when y is less than top' do
202
- let(:y) { 2 }
203
-
204
- it { subject.must_equal(6) }
205
- end
206
-
207
- context 'when y is less than by' do
208
- let(:y) { 5 }
209
-
210
- it { subject.must_equal(6) }
211
-
212
- context 'when border is not enabled' do
213
- let(:enabled) { false }
214
-
215
- it { subject.must_equal(5) }
216
- end
217
- end
218
-
219
- context 'when y is more than tyn' do
220
- let(:y) { 17 }
221
-
222
- it { subject.must_equal(9) }
223
- end
224
-
225
- context 'when y is more than bottom' do
226
- let(:y) { 12 }
227
-
228
- it { subject.must_equal(9) }
229
- end
230
-
231
- context 'when y is more than byn' do
232
- let(:y) { 10 }
233
-
234
- it { subject.must_equal(9) }
235
-
236
- context 'when border is not enabled' do
237
- let(:enabled) { false }
238
-
239
- it { subject.must_equal(10) }
240
- end
241
- end
242
- end
243
-
244
- end # Cursor
245
-
246
- end # Vedeu
@@ -1,37 +0,0 @@
1
- require 'test_helper'
2
-
3
- module Vedeu
4
-
5
- describe Cursors do
6
-
7
- let(:described) { Vedeu::Cursors }
8
-
9
- it { described.must_respond_to(:cursors) }
10
-
11
- describe '.cursor' do
12
- subject { Vedeu.cursor }
13
-
14
- context 'when there are cursors are defined' do
15
- before do
16
- Vedeu::Focus.reset
17
- Vedeu.cursors.reset
18
- Vedeu::Focus.add('Vedeu.cursor')
19
- Vedeu::Cursor.new(name: 'Vedeu.cursor').store
20
- end
21
-
22
- it { subject.must_be_instance_of(Vedeu::Cursor) }
23
- end
24
-
25
- context 'when there are no cursors defined' do
26
- before do
27
- Vedeu::Focus.reset
28
- Vedeu.cursors.reset
29
- end
30
-
31
- it { subject.must_be_instance_of(NilClass) }
32
- end
33
- end
34
-
35
- end # Cursors
36
-
37
- end # Vedeu
@@ -1,301 +0,0 @@
1
- require 'test_helper'
2
-
3
- module Vedeu
4
-
5
- describe Move do
6
-
7
- let(:described) { Vedeu::Move }
8
- let(:instance) { described.new(entity, _name, dy, dx) }
9
- let(:entity) { Vedeu::Cursor }
10
- let(:_name) { '' }
11
- let(:dy) { 0 }
12
- let(:dx) { 0 }
13
- let(:ox) { 0 }
14
- let(:oy) { 0 }
15
- let(:x) { 1 }
16
- let(:y) { 1 }
17
-
18
- let(:cursor) {
19
- Vedeu::Cursor.new(name: _name, ox: ox, oy: oy, visible: true, x: x, y: y)
20
- }
21
- let(:new_cursor) {
22
- Vedeu::Cursor.new
23
- }
24
- let(:border) {
25
- Vedeu::Border.new(name: '_name', enabled: enabled)
26
- }
27
- let(:enabled) { true }
28
- let(:geometry) {
29
- Vedeu::Geometry.new(name: _name, x: 5, xn: 10, y: 5, yn: 10)
30
- }
31
-
32
- before do
33
- IO.console.stubs(:winsize).returns([10, 40])
34
- IO.console.stubs(:print)
35
-
36
- Vedeu.borders.stubs(:by_name).returns(border)
37
- Vedeu.cursors.stubs(:by_name).returns(cursor)
38
- Vedeu.geometries.stubs(:by_name).returns(geometry)
39
-
40
- Vedeu.stubs(:trigger).with(:_refresh_cursor_, _name)
41
- end
42
-
43
- describe '#initialize' do
44
- it { instance.must_be_instance_of(described) }
45
- it { instance.instance_variable_get('@entity').must_equal(entity) }
46
- it { instance.instance_variable_get('@name').must_equal(_name) }
47
- it { instance.instance_variable_get('@dy').must_equal(dy) }
48
- it { instance.instance_variable_get('@dx').must_equal(dx) }
49
- end
50
-
51
- describe '.by_name' do
52
- let(:direction) { :down }
53
- let(:_name) { 'manganese' }
54
- let(:oy) { 2 }
55
- let(:ox) { 3 }
56
- let(:x) { 8 }
57
- let(:y) { 7 }
58
-
59
- before { Vedeu.stubs(:focus).returns('neon') }
60
-
61
- subject { described.by_name(entity, direction, _name) }
62
-
63
- it { subject.must_be_instance_of(Vedeu::Cursor) }
64
-
65
- context 'when the name is not specified' do
66
- let(:_name) {}
67
-
68
- it 'uses the current focussed interface name' do
69
- Vedeu::Move.expects(:send).with(:down, Vedeu::Cursor, 'neon')
70
- subject
71
- end
72
- end
73
-
74
- context 'when the name is specified' do
75
- let(:_name) { 'manganese' }
76
-
77
- context 'and the direction is down' do
78
- let(:direction) { :down }
79
-
80
- it { subject.oy.must_equal(3) }
81
- end
82
- context 'and the direction is left' do
83
- let(:direction) { :left }
84
-
85
- it { subject.ox.must_equal(2) }
86
- end
87
- context 'and the direction is right' do
88
- let(:direction) { :right }
89
-
90
- it { subject.ox.must_equal(4) }
91
- end
92
- context 'and the direction is up' do
93
- let(:direction) { :up }
94
-
95
- it { subject.oy.must_equal(1) }
96
- end
97
- end
98
- end
99
-
100
- describe '.down' do
101
- let(:_name) { 'move_down' }
102
-
103
- subject { described.down(entity, _name) }
104
-
105
- it { subject.must_be_instance_of(Vedeu::Cursor) }
106
-
107
- context 'when within the boundary of the interface' do
108
- let(:enabled) { false }
109
- let(:_name) { 'move_without_border' }
110
- let(:oy) { 15 }
111
-
112
- it 'does not move past the bottom of the interface' do
113
- subject.y.must_equal(10)
114
- end
115
- end
116
-
117
- context 'when within the border of the interface' do
118
- let(:enabled) { true }
119
- let(:_name) { 'move_with_border' }
120
- let(:oy) { 15 }
121
-
122
- it 'does not move past the bottom border' do
123
- subject.y.must_equal(9)
124
- end
125
- end
126
- end
127
-
128
- describe '.left' do
129
- let(:_name) { 'move_left' }
130
-
131
- subject { described.left(entity, _name) }
132
-
133
- it { subject.must_be_instance_of(Vedeu::Cursor) }
134
-
135
- context 'when within the boundary of the interface' do
136
- let(:enabled) { false }
137
- let(:_name) { 'move_without_border' }
138
-
139
- it 'does not move past the left of the interface' do
140
- subject.x.must_equal(5)
141
- end
142
- end
143
-
144
- context 'when within the border of the interface' do
145
- let(:enabled) { true }
146
- let(:_name) { 'move_with_border' }
147
-
148
- it 'does not move past the left border' do
149
- subject.x.must_equal(6)
150
- end
151
- end
152
- end
153
-
154
- describe '.right' do
155
- let(:_name) { 'move_right' }
156
-
157
- subject { described.right(entity, _name) }
158
-
159
- it { subject.must_be_instance_of(Vedeu::Cursor) }
160
-
161
- context 'when within the boundary of the interface' do
162
- let(:enabled) { false }
163
- let(:_name) { 'move_without_border' }
164
- let(:ox) { 15 }
165
-
166
- it 'does not move past the right of the interface' do
167
- subject.x.must_equal(10)
168
- end
169
- end
170
-
171
- context 'when within the border of the interface' do
172
- let(:enabled) { true }
173
- let(:_name) { 'move_with_border' }
174
- let(:ox) { 15 }
175
-
176
- it 'does not move past the right border' do
177
- subject.x.must_equal(9)
178
- end
179
- end
180
- end
181
-
182
- describe '.up' do
183
- let(:_name) { 'move_up' }
184
-
185
- subject { described.up(entity, _name) }
186
-
187
- it { subject.must_be_instance_of(Vedeu::Cursor) }
188
-
189
- context 'when within the boundary of the interface' do
190
- let(:enabled) { false }
191
- let(:_name) { 'move_without_border' }
192
-
193
- it 'does not move past the top of the interface' do
194
- subject.y.must_equal(5)
195
- end
196
- end
197
-
198
- context 'when within the border of the interface' do
199
- let(:enabled) { true }
200
- let(:_name) { 'move_with_border' }
201
-
202
- it 'does not move past the top border' do
203
- subject.y.must_equal(6)
204
- end
205
- end
206
- end
207
-
208
- describe '.origin' do
209
- let(:_name) { 'move_origin' }
210
-
211
- subject { described.origin(entity, _name) }
212
-
213
- it { subject.must_be_instance_of(Vedeu::Cursor) }
214
-
215
- context 'within the boundary of the interface' do
216
- let(:enabled) { false }
217
- let(:_name) { 'move_without_border' }
218
-
219
- it { subject.x.must_equal(5) }
220
- it { subject.y.must_equal(5) }
221
- end
222
-
223
- context 'within the border of the interface' do
224
- let(:enabled) { true }
225
- let(:_name) { 'move_with_border' }
226
-
227
- it { subject.x.must_equal(6) }
228
- it { subject.y.must_equal(6) }
229
- end
230
- end
231
-
232
- describe '#move' do
233
- let(:_name) { 'move_move' }
234
-
235
- before { Vedeu.stubs(:trigger) }
236
-
237
- subject { instance.move }
238
-
239
- context 'when the entity is a Vedeu::Geometry' do
240
- let(:entity) { Vedeu::Geometry }
241
-
242
- it { subject.must_be_instance_of(Vedeu::Geometry) }
243
- end
244
-
245
- context 'when the entity is a Vedeu::Cursor' do
246
- it { subject.must_be_instance_of(Vedeu::Cursor) }
247
- end
248
- end
249
-
250
- describe '#refresh' do
251
- before { Vedeu.stubs(:trigger) }
252
-
253
- subject { instance.refresh }
254
-
255
- context 'when the entity is a Vedeu::Geometry' do
256
- let(:entity) { Vedeu::Geometry }
257
-
258
- it {
259
- Vedeu.expects(:trigger)
260
- subject
261
- }
262
- end
263
-
264
- context 'when the entity is a Vedeu::Cursor' do
265
- it {
266
- Vedeu.expects(:trigger)
267
- subject
268
- }
269
- end
270
- end
271
-
272
- describe '#merged_attributes' do
273
- subject { instance.merged_attributes }
274
-
275
- it { subject.must_be_instance_of(Hash) }
276
-
277
- context 'when the entity is a Vedeu::Geometry' do
278
- let(:entity) { Vedeu::Geometry }
279
- let(:expected) {
280
- {
281
- centred: false,
282
- maximised: false,
283
- name: '',
284
- x: 5,
285
- y: 5,
286
- xn: 10,
287
- yn: 10
288
- }
289
- }
290
-
291
- it { subject.must_equal(expected) }
292
- end
293
-
294
- context 'when the entity is a Vedeu::Cursor' do
295
- it { subject.must_be_instance_of(Hash) }
296
- end
297
- end
298
-
299
- end # Move
300
-
301
- end # Vedeu