vedeu 0.6.56 → 0.6.57

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +3 -0
  3. data/Guardfile +1 -1
  4. data/Rakefile +3 -3
  5. data/lib/vedeu/borders/all.rb +1 -0
  6. data/lib/vedeu/borders/border.rb +14 -80
  7. data/lib/vedeu/borders/caption.rb +17 -0
  8. data/lib/vedeu/borders/dsl.rb +2 -2
  9. data/lib/vedeu/borders/null.rb +14 -34
  10. data/lib/vedeu/borders/refresh.rb +28 -14
  11. data/lib/vedeu/borders/title.rb +0 -10
  12. data/lib/vedeu/buffers/buffer.rb +1 -1
  13. data/lib/vedeu/buffers/view.rb +7 -6
  14. data/lib/vedeu/colours/repository.rb +0 -15
  15. data/lib/vedeu/cursors/cursor.rb +6 -6
  16. data/lib/vedeu/cursors/refresh.rb +11 -19
  17. data/lib/vedeu/cursors/reposition.rb +3 -5
  18. data/lib/vedeu/editor/cropper.rb +9 -9
  19. data/lib/vedeu/editor/cursor.rb +5 -5
  20. data/lib/vedeu/editor/editor.rb +1 -1
  21. data/lib/vedeu/events/event.rb +1 -1
  22. data/lib/vedeu/events/trigger.rb +1 -1
  23. data/lib/vedeu/geometry/area.rb +94 -17
  24. data/lib/vedeu/geometry/coordinate.rb +15 -15
  25. data/lib/vedeu/geometry/dimension.rb +2 -2
  26. data/lib/vedeu/geometry/geometry.rb +30 -27
  27. data/lib/vedeu/geometry/null.rb +17 -11
  28. data/lib/vedeu/interfaces/clear.rb +5 -12
  29. data/lib/vedeu/output/viewport.rb +13 -13
  30. data/lib/vedeu/plugins/plugin.rb +1 -1
  31. data/lib/vedeu/repositories/repository.rb +1 -3
  32. data/lib/vedeu/version.rb +1 -1
  33. data/test/lib/vedeu/borders/border_test.rb +4 -230
  34. data/test/lib/vedeu/borders/caption_test.rb +15 -0
  35. data/test/lib/vedeu/borders/dsl_test.rb +4 -4
  36. data/test/lib/vedeu/borders/null_test.rb +3 -39
  37. data/test/lib/vedeu/buffers/view_test.rb +2 -0
  38. data/test/lib/vedeu/colours/repository_test.rb +0 -19
  39. data/test/lib/vedeu/cursors/reposition_test.rb +17 -4
  40. data/test/lib/vedeu/dsl/shared_test.rb +34 -0
  41. data/test/lib/vedeu/geometry/area_test.rb +196 -3
  42. data/test/lib/vedeu/geometry/dimension_test.rb +79 -79
  43. data/test/lib/vedeu/geometry/geometry_test.rb +4 -0
  44. data/test/lib/vedeu/groups/refresh_test.rb +1 -1
  45. data/test/lib/vedeu/logging/clock_time_test.rb +14 -0
  46. data/test/lib/vedeu/logging/ips_test.rb +43 -0
  47. data/test/lib/vedeu/output/presentation/colour_test.rb +4 -0
  48. data/test/lib/vedeu/repositories/repositories_test.rb +7 -1
  49. data/test/lib/vedeu/terminal/buffer_test.rb +10 -0
  50. data/test/support/examples/material_colours_app.rb +306 -47
  51. data/test/test_helper.rb +5 -5
  52. metadata +7 -4
  53. data/test/support/examples/borders_app.rb +0 -330
@@ -0,0 +1,15 @@
1
+ require 'test_helper'
2
+
3
+ module Vedeu
4
+
5
+ module Borders
6
+
7
+ describe Caption do
8
+
9
+ # @todo Add more tests.
10
+
11
+ end # Caption
12
+
13
+ end # Borders
14
+
15
+ end # Vedeu
@@ -173,8 +173,8 @@ module Vedeu
173
173
 
174
174
  subject { instance.title(_value) }
175
175
 
176
- it { subject.must_be_instance_of(Vedeu::Borders::Title) }
177
- it { subject.title.must_equal('Some title') }
176
+ it { subject.must_be_instance_of(String) }
177
+ it { subject.must_equal('Some title') }
178
178
  it { instance.must_respond_to(:title=) }
179
179
  end
180
180
 
@@ -183,8 +183,8 @@ module Vedeu
183
183
 
184
184
  subject { instance.caption(_value) }
185
185
 
186
- it { subject.must_be_instance_of(Vedeu::Borders::Caption) }
187
- it { subject.caption.must_equal('Some caption') }
186
+ it { subject.must_be_instance_of(String) }
187
+ it { subject.must_equal('Some caption') }
188
188
  it { instance.must_respond_to(:caption=) }
189
189
  end
190
190
 
@@ -32,39 +32,10 @@ module Vedeu
32
32
  it { instance.must_respond_to(:name) }
33
33
  end
34
34
 
35
- describe '#bx' do
36
- subject { instance.bx }
35
+ describe '#enabled' do
36
+ subject { instance.enabled? }
37
37
 
38
- it { subject.must_be_instance_of(Fixnum) }
39
- it { subject.must_equal(4) }
40
- end
41
-
42
- describe '#by' do
43
- subject { instance.by }
44
-
45
- it { subject.must_be_instance_of(Fixnum) }
46
- it { subject.must_equal(6) }
47
- end
48
-
49
- describe '#bxn' do
50
- subject { instance.bxn }
51
-
52
- it { subject.must_be_instance_of(Fixnum) }
53
- it { subject.must_equal(10) }
54
- end
55
-
56
- describe '#byn' do
57
- subject { instance.byn }
58
-
59
- it { subject.must_be_instance_of(Fixnum) }
60
- it { subject.must_equal(12) }
61
- end
62
-
63
- describe '#height' do
64
- subject { instance.height }
65
-
66
- it { subject.must_be_instance_of(Fixnum) }
67
- it { subject.must_equal(7) }
38
+ it { subject.must_equal(false) }
68
39
  end
69
40
 
70
41
  describe '#render' do
@@ -74,13 +45,6 @@ module Vedeu
74
45
  it { subject.must_equal([]) }
75
46
  end
76
47
 
77
- describe '#width' do
78
- subject { instance.width }
79
-
80
- it { subject.must_be_instance_of(Fixnum) }
81
- it { subject.must_equal(7) }
82
- end
83
-
84
48
  end # Null
85
49
 
86
50
  end # Borders
@@ -29,6 +29,8 @@ module Vedeu
29
29
  end
30
30
  end
31
31
 
32
+ # @todo Add more tests.
33
+
32
34
  end # View
33
35
 
34
36
  end # Buffers
@@ -72,25 +72,6 @@ module Vedeu
72
72
  end
73
73
  end
74
74
 
75
- describe '#retrieve_or_register' do
76
- let(:colour) { '#cc0000' }
77
- let(:escape_sequence) { 'escape_sequence' }
78
-
79
- subject { instance.retrieve_or_register(colour, escape_sequence) }
80
-
81
- context 'when the colour is registered' do
82
- let(:colour) { '#cc0000' }
83
-
84
- before { instance.register(colour, 'fake_escape_sequence') }
85
-
86
- it { subject.must_equal('fake_escape_sequence') }
87
- end
88
-
89
- context 'when the colour is not registered' do
90
- it { subject.must_equal('escape_sequence') }
91
- end
92
- end
93
-
94
75
  end # Repository
95
76
 
96
77
  end # Colours
@@ -43,12 +43,25 @@ module Vedeu
43
43
  end
44
44
 
45
45
  describe '#reposition' do
46
+ # let(:new_attributes) {
47
+ # {
48
+ # name: :reposition_test,
49
+ # ox: 0,
50
+ # oy: 0,
51
+ # repository: Vedeu.cursors,
52
+ # visible: false,
53
+ # x: 4,
54
+ # y: 4,
55
+ # }
56
+ # }
57
+
46
58
  subject { instance.reposition }
47
59
 
48
- it {
49
- Vedeu.expects(:trigger).with(:_refresh_cursor_, _name)
50
- subject
51
- }
60
+ # it {
61
+ # subject
62
+ # Vedeu::Cursors::Cursor.expects(:store).with(new_attributes)
63
+ # Vedeu.expects(:trigger).with(:_refresh_cursor_, _name)
64
+ # }
52
65
 
53
66
  it { subject.must_be_instance_of(Vedeu::Cursors::Cursor) }
54
67
 
@@ -15,6 +15,26 @@ module Vedeu
15
15
 
16
16
  it { proc { subject }.must_raise(Vedeu::Error::RequiresBlock) }
17
17
  end
18
+
19
+ context 'when the block is given' do
20
+ subject { instance.border { } }
21
+
22
+ context 'when the name is not given' do
23
+ it 'uses the name of the model' do
24
+ # @todo Add more tests.
25
+ end
26
+ end
27
+
28
+ context 'when the name is given' do
29
+ # @todo Add more tests.
30
+ end
31
+ end
32
+ end
33
+
34
+ describe '#border!' do
35
+ subject { instance.border! }
36
+
37
+ # @todo Add more tests.
18
38
  end
19
39
 
20
40
  describe '#geometry' do
@@ -23,6 +43,20 @@ module Vedeu
23
43
 
24
44
  it { proc { subject }.must_raise(Vedeu::Error::RequiresBlock) }
25
45
  end
46
+
47
+ context 'when the block is given' do
48
+ subject { instance.geometry { } }
49
+
50
+ context 'when the name is not given' do
51
+ it 'uses the name of the model' do
52
+ # @todo Add more tests.
53
+ end
54
+ end
55
+
56
+ context 'when the name is given' do
57
+ # @todo Add more tests.
58
+ end
59
+ end
26
60
  end
27
61
 
28
62
  end # Shared
@@ -7,13 +7,46 @@ module Vedeu
7
7
  describe Area do
8
8
 
9
9
  let(:described) { Vedeu::Geometry::Area }
10
- let(:instance) { described.new(y: y, yn: yn, x: x, xn: xn) }
10
+ let(:instance) { described.new(name: _name, y: y, yn: yn, x: x, xn: xn) }
11
+ let(:_name) { 'Vedeu::Geometry::Area' }
11
12
  let(:y) { 4 }
12
13
  let(:yn) { 9 }
13
14
  let(:x) { 6 }
14
15
  let(:xn) { 21 }
15
16
  let(:offset) { 1 }
16
17
 
18
+ let(:border_attributes) {
19
+ {
20
+ bottom_left: 'C',
21
+ bottom_right: 'D',
22
+ enabled: enabled,
23
+ horizontal: 'H',
24
+ name: _name,
25
+ show_top: top,
26
+ show_bottom: bottom,
27
+ show_left: left,
28
+ show_right: right,
29
+ top_left: 'A',
30
+ top_right: 'B',
31
+ vertical: 'V'
32
+ }
33
+ }
34
+ let(:enabled) { false }
35
+ let(:top) { false }
36
+ let(:bottom) { false }
37
+ let(:left) { false }
38
+ let(:right) { false }
39
+ let(:border) { Vedeu::Borders::Border.new(border_attributes) }
40
+ let(:border_attributes) {
41
+ {
42
+ enabled: enabled
43
+ }
44
+ }
45
+
46
+ before do
47
+ Vedeu.borders.stubs(:by_name).returns(border)
48
+ end
49
+
17
50
  describe 'accessors' do
18
51
  it {
19
52
  instance.must_respond_to(:y)
@@ -29,6 +62,7 @@ module Vedeu
29
62
 
30
63
  describe '#initialize' do
31
64
  it { instance.must_be_instance_of(described) }
65
+ it { instance.instance_variable_get('@name').must_equal(_name) }
32
66
  it { instance.instance_variable_get('@y').must_equal(y) }
33
67
  it { instance.instance_variable_get('@yn').must_equal(yn) }
34
68
  it { instance.instance_variable_get('@x').must_equal(x) }
@@ -47,6 +81,7 @@ module Vedeu
47
81
  x_xn: x_xn,
48
82
  x_default: x_default,
49
83
  maximised: maximised,
84
+ name: _name,
50
85
  horizontal_alignment: horizontal_alignment,
51
86
  vertical_alignment: vertical_alignment,
52
87
  }
@@ -68,15 +103,173 @@ module Vedeu
68
103
  it { subject.must_be_instance_of(described) }
69
104
  end
70
105
 
106
+ describe '#bordered_width' do
107
+ subject { instance.bordered_width }
108
+
109
+ context 'when the border is not enabled' do
110
+ let(:enabled) { false }
111
+
112
+ it 'returns the interface width' do
113
+ subject.must_equal(16)
114
+ end
115
+ end
116
+
117
+ context 'when the border is enabled' do
118
+ context 'when both left and right borders are shown' do
119
+ let(:border_attributes) {
120
+ {
121
+ enabled: true,
122
+ name: _name,
123
+ }
124
+ }
125
+
126
+ it { subject.must_equal(14) }
127
+ end
128
+
129
+ context 'when either the left or right border is shown' do
130
+ let(:border_attributes) {
131
+ {
132
+ enabled: true,
133
+ name: _name,
134
+ show_left: false
135
+ }
136
+ }
137
+
138
+ it { subject.must_equal(15) }
139
+ end
140
+
141
+ context 'when neither left nor right borders are shown' do
142
+ let(:border_attributes) {
143
+ {
144
+ enabled: true,
145
+ name: _name,
146
+ show_left: false,
147
+ show_right: false
148
+ }
149
+ }
150
+
151
+ it { subject.must_equal(16) }
152
+ end
153
+ end
154
+ end
155
+
156
+ describe '#bordered_height' do
157
+ subject { instance.bordered_height }
158
+
159
+ context 'when the border is not enabled' do
160
+ it 'returns the interface height' do
161
+ subject.must_equal(6)
162
+ end
163
+ end
164
+
165
+ context 'when the border is enabled' do
166
+ context 'when both top and bottom borders are shown' do
167
+ let(:border_attributes) {
168
+ {
169
+ enabled: true,
170
+ name: _name,
171
+ }
172
+ }
173
+
174
+ it { subject.must_equal(4) }
175
+ end
176
+
177
+ context 'when either the top or bottom border is shown' do
178
+ let(:border_attributes) {
179
+ {
180
+ enabled: true,
181
+ name: _name,
182
+ show_top: false
183
+ }
184
+ }
185
+
186
+ it { subject.must_equal(5) }
187
+ end
188
+
189
+ context 'when neither top nor bottom borders are shown' do
190
+ let(:border_attributes) {
191
+ {
192
+ enabled: true,
193
+ name: _name,
194
+ show_top: false,
195
+ show_bottom: false
196
+ }
197
+ }
198
+
199
+ it { subject.must_equal(6) }
200
+ end
201
+ end
202
+ end
203
+
204
+ describe '#bx' do
205
+ subject { instance.bx }
206
+
207
+ context 'when enabled' do
208
+ let(:enabled) { true }
209
+ let(:left) { true }
210
+
211
+ it { subject.must_equal(7) }
212
+ end
213
+
214
+ context 'when not enabled or without left' do
215
+ it { subject.must_equal(6) }
216
+ end
217
+ end
218
+
219
+ describe '#bxn' do
220
+ subject { instance.bxn }
221
+
222
+ context 'when enabled' do
223
+ let(:enabled) { true }
224
+ let(:right) { true }
225
+
226
+ it { subject.must_equal(20) }
227
+ end
228
+
229
+ context 'when not enabled or without right' do
230
+ it { subject.must_equal(21) }
231
+ end
232
+ end
233
+
234
+ describe '#by' do
235
+ subject { instance.by }
236
+
237
+ context 'when enabled' do
238
+ let(:enabled) { true }
239
+ let(:top) { true }
240
+
241
+ it { subject.must_equal(5) }
242
+ end
243
+
244
+ context 'when not enabled or without top' do
245
+ it { subject.must_equal(4) }
246
+ end
247
+ end
248
+
249
+ describe '#byn' do
250
+ subject { instance.byn }
251
+
252
+ context 'when enabled' do
253
+ let(:enabled) { true }
254
+ let(:bottom) { true }
255
+
256
+ it { subject.must_equal(8) }
257
+ end
258
+
259
+ context 'when not enabled or without bottom' do
260
+ it { subject.must_equal(9) }
261
+ end
262
+ end
263
+
71
264
  describe '#eql?' do
72
- let(:other) { described.new(y: 4, yn: 9, x: 6, xn: 21) }
265
+ let(:other) { described.new(name: _name, y: 4, yn: 9, x: 6, xn: 21) }
73
266
 
74
267
  subject { instance.eql?(other) }
75
268
 
76
269
  it { subject.must_equal(true) }
77
270
 
78
271
  context 'when different to other' do
79
- let(:other) { described.new(y: 1, yn: 25, x: 1, xn: 40) }
272
+ let(:other) { described.new(name: _name, y: 1, yn: 25, x: 1, xn: 40) }
80
273
 
81
274
  it { subject.must_equal(false) }
82
275
  end