vedeu 0.6.4 → 0.6.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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
data/lib/vedeu/version.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  module Vedeu
2
2
 
3
3
  # The current version of Vedeu.
4
- VERSION = '0.6.4'
4
+ VERSION = '0.6.5'
5
5
 
6
6
  end
@@ -2,273 +2,322 @@ require 'test_helper'
2
2
 
3
3
  module Vedeu
4
4
 
5
- describe Border do
6
-
7
- let(:described) { Vedeu::Border }
8
- let(:instance) { described.new(attributes) }
9
- let(:attributes) {
10
- {
11
- bottom_left: 'm',
12
- bottom_right: 'j',
13
- caption: '',
14
- client: nil,
15
- colour: nil,
16
- enabled: false,
17
- horizontal: 'q',
18
- name: 'borders',
19
- repository: Vedeu.borders,
20
- show_bottom: true,
21
- show_left: true,
22
- show_right: true,
23
- show_top: true,
24
- style: nil,
25
- title: '',
26
- top_left: 'l',
27
- top_right: 'k',
28
- vertical: 'x',
29
- }
30
- }
31
- let(:geometry) {}
5
+ module Borders
32
6
 
33
- before { Vedeu.geometries.stubs(:by_name).returns(geometry) }
7
+ describe Border do
34
8
 
35
- describe '.build' do
36
- subject {
37
- described.build(attributes) do
38
- horizontal '~'
39
- end
9
+ let(:described) { Vedeu::Borders::Border }
10
+ let(:instance) { described.new(attributes) }
11
+ let(:attributes) {
12
+ {
13
+ bottom_left: 'm',
14
+ bottom_right: 'j',
15
+ caption: '',
16
+ client: nil,
17
+ colour: nil,
18
+ enabled: false,
19
+ horizontal: 'q',
20
+ name: 'borders',
21
+ repository: Vedeu.borders,
22
+ show_bottom: true,
23
+ show_left: true,
24
+ show_right: true,
25
+ show_top: true,
26
+ style: nil,
27
+ title: '',
28
+ top_left: 'l',
29
+ top_right: 'k',
30
+ vertical: 'x',
31
+ }
40
32
  }
33
+ let(:geometry) {}
41
34
 
42
- it { subject.must_be_instance_of(described) }
43
- end
35
+ before { Vedeu.geometries.stubs(:by_name).returns(geometry) }
44
36
 
45
- describe '#initialize' do
46
- it { instance.must_be_instance_of(described) }
47
- it do
48
- instance.instance_variable_get('@attributes').
49
- must_equal(attributes)
37
+ describe '.build' do
38
+ subject {
39
+ described.build(attributes) do
40
+ horizontal '~'
41
+ end
42
+ }
43
+
44
+ it { subject.must_be_instance_of(described) }
50
45
  end
51
- end
52
-
53
- describe 'accessors' do
54
- it { instance.must_respond_to(:attributes) }
55
- it { instance.must_respond_to(:attributes=) }
56
- it { instance.must_respond_to(:bottom_left) }
57
- it { instance.must_respond_to(:bottom_left=) }
58
- it { instance.must_respond_to(:bottom_right) }
59
- it { instance.must_respond_to(:bottom_right=) }
60
- it { instance.must_respond_to(:caption) }
61
- it { instance.must_respond_to(:caption=) }
62
- it { instance.must_respond_to(:horizontal) }
63
- it { instance.must_respond_to(:horizontal=) }
64
- it { instance.must_respond_to(:show_bottom) }
65
- it { instance.must_respond_to(:bottom?) }
66
- it { instance.must_respond_to(:show_bottom=) }
67
- it { instance.must_respond_to(:show_left) }
68
- it { instance.must_respond_to(:left?) }
69
- it { instance.must_respond_to(:show_left=) }
70
- it { instance.must_respond_to(:show_right) }
71
- it { instance.must_respond_to(:right?) }
72
- it { instance.must_respond_to(:show_right=) }
73
- it { instance.must_respond_to(:show_top) }
74
- it { instance.must_respond_to(:top?) }
75
- it { instance.must_respond_to(:show_top=) }
76
- it { instance.must_respond_to(:title) }
77
- it { instance.must_respond_to(:title=) }
78
- it { instance.must_respond_to(:top_left) }
79
- it { instance.must_respond_to(:top_left=) }
80
- it { instance.must_respond_to(:top_right) }
81
- it { instance.must_respond_to(:top_right=) }
82
- it { instance.must_respond_to(:vertical) }
83
- it { instance.must_respond_to(:vertical=) }
84
- it { instance.must_respond_to(:name) }
85
- it { instance.must_respond_to(:enabled) }
86
- it { instance.must_respond_to(:enabled=) }
87
- it { instance.must_respond_to(:enabled?) }
88
- end
89
-
90
- describe 'border offset methods; bx, bxn, by, byn' do
91
- let(:attributes) {
92
- {
93
- bottom_left: 'C',
94
- bottom_right: 'D',
95
- enabled: enabled,
96
- horizontal: 'H',
97
- name: 'Border#bxbxnbybyn',
98
- show_top: top,
99
- show_bottom: bottom,
100
- show_left: left,
101
- show_right: right,
102
- top_left: 'A',
103
- top_right: 'B',
104
- vertical: 'V'
46
+
47
+ describe '#initialize' do
48
+ it { instance.must_be_instance_of(described) }
49
+ it do
50
+ instance.instance_variable_get('@attributes').
51
+ must_equal(attributes)
52
+ end
53
+ end
54
+
55
+ describe 'accessors' do
56
+ it { instance.must_respond_to(:attributes) }
57
+ it { instance.must_respond_to(:attributes=) }
58
+ it { instance.must_respond_to(:bottom_left) }
59
+ it { instance.must_respond_to(:bottom_left=) }
60
+ it { instance.must_respond_to(:bottom_right) }
61
+ it { instance.must_respond_to(:bottom_right=) }
62
+ it { instance.must_respond_to(:caption) }
63
+ it { instance.must_respond_to(:caption=) }
64
+ it { instance.must_respond_to(:horizontal) }
65
+ it { instance.must_respond_to(:horizontal=) }
66
+ it { instance.must_respond_to(:show_bottom) }
67
+ it { instance.must_respond_to(:bottom?) }
68
+ it { instance.must_respond_to(:show_bottom=) }
69
+ it { instance.must_respond_to(:show_left) }
70
+ it { instance.must_respond_to(:left?) }
71
+ it { instance.must_respond_to(:show_left=) }
72
+ it { instance.must_respond_to(:show_right) }
73
+ it { instance.must_respond_to(:right?) }
74
+ it { instance.must_respond_to(:show_right=) }
75
+ it { instance.must_respond_to(:show_top) }
76
+ it { instance.must_respond_to(:top?) }
77
+ it { instance.must_respond_to(:show_top=) }
78
+ it { instance.must_respond_to(:title) }
79
+ it { instance.must_respond_to(:title=) }
80
+ it { instance.must_respond_to(:top_left) }
81
+ it { instance.must_respond_to(:top_left=) }
82
+ it { instance.must_respond_to(:top_right) }
83
+ it { instance.must_respond_to(:top_right=) }
84
+ it { instance.must_respond_to(:vertical) }
85
+ it { instance.must_respond_to(:vertical=) }
86
+ it { instance.must_respond_to(:name) }
87
+ it { instance.must_respond_to(:enabled) }
88
+ it { instance.must_respond_to(:enabled=) }
89
+ it { instance.must_respond_to(:enabled?) }
90
+ end
91
+
92
+ describe 'border offset methods; bx, bxn, by, byn' do
93
+ let(:attributes) {
94
+ {
95
+ bottom_left: 'C',
96
+ bottom_right: 'D',
97
+ enabled: enabled,
98
+ horizontal: 'H',
99
+ name: 'Border#bxbxnbybyn',
100
+ show_top: top,
101
+ show_bottom: bottom,
102
+ show_left: left,
103
+ show_right: right,
104
+ top_left: 'A',
105
+ top_right: 'B',
106
+ vertical: 'V'
107
+ }
108
+ }
109
+ let(:enabled) { false }
110
+ let(:top) { false }
111
+ let(:bottom) { false }
112
+ let(:left) { false }
113
+ let(:right) { false }
114
+ let(:geometry) {
115
+ Vedeu::Geometry::Geometry.new(name: 'Border#bxbxnbybyn',
116
+ x: 2,
117
+ xn: 6,
118
+ y: 2,
119
+ yn: 6)
105
120
  }
106
- }
107
- let(:enabled) { false }
108
- let(:top) { false }
109
- let(:bottom) { false }
110
- let(:left) { false }
111
- let(:right) { false }
112
- let(:geometry) {
113
- Vedeu::Geometry.new(name: 'Border#bxbxnbybyn', x: 2, xn: 6, y: 2, yn: 6)
114
- }
115
121
 
116
- describe '#bx' do
117
- subject { instance.bx }
122
+ describe '#bx' do
123
+ subject { instance.bx }
118
124
 
119
- context 'when enabled' do
120
- let(:enabled) { true }
125
+ context 'when enabled' do
126
+ let(:enabled) { true }
121
127
 
122
- context 'with left' do
123
- let(:left) { true }
128
+ context 'with left' do
129
+ let(:left) { true }
124
130
 
125
- it { subject.must_equal(3) }
131
+ it { subject.must_equal(3) }
132
+ end
133
+
134
+ context 'without left' do
135
+ it { subject.must_equal(2) }
136
+ end
126
137
  end
127
138
 
128
- context 'without left' do
139
+ context 'when not enabled' do
129
140
  it { subject.must_equal(2) }
130
141
  end
131
142
  end
132
143
 
133
- context 'when not enabled' do
134
- it { subject.must_equal(2) }
135
- end
136
- end
144
+ describe '#bxn' do
145
+ subject { instance.bxn }
137
146
 
138
- describe '#bxn' do
139
- subject { instance.bxn }
147
+ context 'when enabled' do
148
+ let(:enabled) { true }
140
149
 
141
- context 'when enabled' do
142
- let(:enabled) { true }
150
+ context 'with right' do
151
+ let(:right) { true }
143
152
 
144
- context 'with right' do
145
- let(:right) { true }
153
+ it { subject.must_equal(5) }
154
+ end
146
155
 
147
- it { subject.must_equal(5) }
156
+ context 'without right' do
157
+ it { subject.must_equal(6) }
158
+ end
148
159
  end
149
160
 
150
- context 'without right' do
161
+ context 'when not enabled' do
151
162
  it { subject.must_equal(6) }
152
163
  end
153
164
  end
154
165
 
155
- context 'when not enabled' do
156
- it { subject.must_equal(6) }
157
- end
158
- end
166
+ describe '#by' do
167
+ subject { instance.by }
159
168
 
160
- describe '#by' do
161
- subject { instance.by }
169
+ context 'when enabled' do
170
+ let(:enabled) { true }
162
171
 
163
- context 'when enabled' do
164
- let(:enabled) { true }
172
+ context 'with top' do
173
+ let(:top) { true }
165
174
 
166
- context 'with top' do
167
- let(:top) { true }
175
+ it { subject.must_equal(3) }
176
+ end
168
177
 
169
- it { subject.must_equal(3) }
178
+ context 'without top' do
179
+ it { subject.must_equal(2) }
180
+ end
170
181
  end
171
182
 
172
- context 'without top' do
183
+ context 'when not enabled' do
173
184
  it { subject.must_equal(2) }
174
185
  end
175
186
  end
176
187
 
177
- context 'when not enabled' do
178
- it { subject.must_equal(2) }
179
- end
180
- end
188
+ describe '#byn' do
189
+ subject { instance.byn }
181
190
 
182
- describe '#byn' do
183
- subject { instance.byn }
191
+ context 'when enabled' do
192
+ let(:enabled) { true }
184
193
 
185
- context 'when enabled' do
186
- let(:enabled) { true }
194
+ context 'with bottom' do
195
+ let(:bottom) { true }
187
196
 
188
- context 'with bottom' do
189
- let(:bottom) { true }
197
+ it { subject.must_equal(5) }
198
+ end
190
199
 
191
- it { subject.must_equal(5) }
200
+ context 'without bottom' do
201
+ it { subject.must_equal(6) }
202
+ end
192
203
  end
193
204
 
194
- context 'without bottom' do
205
+ context 'when not enabled' do
195
206
  it { subject.must_equal(6) }
196
207
  end
197
208
  end
198
-
199
- context 'when not enabled' do
200
- it { subject.must_equal(6) }
201
- end
202
209
  end
203
- end
204
210
 
205
- describe '#width' do
206
- let(:geometry) {
207
- Vedeu::Geometry.new(name: 'borders', width: 8)
208
- }
211
+ describe '#width' do
212
+ let(:geometry) {
213
+ Vedeu::Geometry::Geometry.new(name: 'borders', width: 8)
214
+ }
209
215
 
210
- subject { instance.width }
216
+ subject { instance.width }
211
217
 
212
- context 'when the border is not enabled' do
213
- it 'returns the interface width' do
214
- subject.must_equal(8)
218
+ context 'when the border is not enabled' do
219
+ it 'returns the interface width' do
220
+ subject.must_equal(8)
221
+ end
215
222
  end
216
- end
217
223
 
218
- context 'when the border is enabled' do
219
- context 'when both left and right borders are shown' do
220
- let(:attributes) {
221
- {
222
- enabled: true,
223
- name: 'borders',
224
+ context 'when the border is enabled' do
225
+ context 'when both left and right borders are shown' do
226
+ let(:attributes) {
227
+ {
228
+ enabled: true,
229
+ name: 'borders',
230
+ }
224
231
  }
225
- }
226
232
 
227
- it { subject.must_equal(6) }
228
- end
233
+ it { subject.must_equal(6) }
234
+ end
229
235
 
230
- context 'when either the left or right border is shown' do
231
- let(:attributes) {
232
- {
233
- enabled: true,
234
- name: 'borders',
235
- show_left: false
236
+ context 'when either the left or right border is shown' do
237
+ let(:attributes) {
238
+ {
239
+ enabled: true,
240
+ name: 'borders',
241
+ show_left: false
242
+ }
236
243
  }
237
- }
238
244
 
239
- it { subject.must_equal(7) }
240
- end
245
+ it { subject.must_equal(7) }
246
+ end
241
247
 
242
- context 'when neither left nor right borders are shown' do
243
- let(:attributes) {
244
- {
245
- enabled: true,
246
- name: 'borders',
247
- show_left: false,
248
- show_right: false
248
+ context 'when neither left nor right borders are shown' do
249
+ let(:attributes) {
250
+ {
251
+ enabled: true,
252
+ name: 'borders',
253
+ show_left: false,
254
+ show_right: false
255
+ }
249
256
  }
250
- }
251
257
 
252
- it { subject.must_equal(8) }
258
+ it { subject.must_equal(8) }
259
+ end
253
260
  end
254
261
  end
255
- end
256
262
 
257
- describe '#height' do
258
- let(:geometry) {
259
- Vedeu::Geometry.new(name: 'borders', height: 5)
260
- }
263
+ describe '#height' do
264
+ let(:geometry) {
265
+ Vedeu::Geometry::Geometry.new(name: 'borders', height: 5)
266
+ }
261
267
 
262
- subject { instance.height }
268
+ subject { instance.height }
263
269
 
264
- context 'when the border is not enabled' do
265
- it 'returns the interface height' do
266
- subject.must_equal(5)
270
+ context 'when the border is not enabled' do
271
+ it 'returns the interface height' do
272
+ subject.must_equal(5)
273
+ end
274
+ end
275
+
276
+ context 'when the border is enabled' do
277
+ context 'when both top and bottom borders are shown' do
278
+ let(:attributes) {
279
+ {
280
+ enabled: true,
281
+ name: 'borders',
282
+ }
283
+ }
284
+
285
+ it { subject.must_equal(3) }
286
+ end
287
+
288
+ context 'when either the top or bottom border is shown' do
289
+ let(:attributes) {
290
+ {
291
+ enabled: true,
292
+ name: 'borders',
293
+ show_top: false
294
+ }
295
+ }
296
+
297
+ it { subject.must_equal(4) }
298
+ end
299
+
300
+ context 'when neither top nor bottom borders are shown' do
301
+ let(:attributes) {
302
+ {
303
+ enabled: true,
304
+ name: 'borders',
305
+ show_top: false,
306
+ show_bottom: false
307
+ }
308
+ }
309
+
310
+ it { subject.must_equal(5) }
311
+ end
267
312
  end
268
313
  end
269
314
 
270
- context 'when the border is enabled' do
271
- context 'when both top and bottom borders are shown' do
315
+ describe '#enabled?' do
316
+ subject { instance.enabled? }
317
+
318
+ it { subject.must_be_instance_of(FalseClass) }
319
+
320
+ context 'when true' do
272
321
  let(:attributes) {
273
322
  {
274
323
  enabled: true,
@@ -276,136 +325,95 @@ module Vedeu
276
325
  }
277
326
  }
278
327
 
279
- it { subject.must_equal(3) }
328
+ it { subject.must_be_instance_of(TrueClass) }
280
329
  end
330
+ end
281
331
 
282
- context 'when either the top or bottom border is shown' do
283
- let(:attributes) {
284
- {
285
- enabled: true,
286
- name: 'borders',
287
- show_top: false
288
- }
289
- }
332
+ describe '#bottom?' do
333
+ subject { instance.bottom? }
290
334
 
291
- it { subject.must_equal(4) }
292
- end
335
+ it { subject.must_be_instance_of(TrueClass) }
293
336
 
294
- context 'when neither top nor bottom borders are shown' do
337
+ context 'when false' do
295
338
  let(:attributes) {
296
339
  {
297
340
  enabled: true,
298
341
  name: 'borders',
299
- show_top: false,
300
- show_bottom: false
342
+ show_bottom: false,
301
343
  }
302
344
  }
303
345
 
304
- it { subject.must_equal(5) }
346
+ it { subject.must_be_instance_of(FalseClass) }
305
347
  end
306
348
  end
307
- end
308
-
309
- describe '#enabled?' do
310
- subject { instance.enabled? }
311
349
 
312
- it { subject.must_be_instance_of(FalseClass) }
313
-
314
- context 'when true' do
315
- let(:attributes) {
316
- {
317
- enabled: true,
318
- name: 'borders',
319
- }
320
- }
350
+ describe '#left?' do
351
+ subject { instance.left? }
321
352
 
322
353
  it { subject.must_be_instance_of(TrueClass) }
323
- end
324
- end
325
354
 
326
- describe '#bottom?' do
327
- subject { instance.bottom? }
328
-
329
- it { subject.must_be_instance_of(TrueClass) }
330
-
331
- context 'when false' do
332
- let(:attributes) {
333
- {
334
- enabled: true,
335
- name: 'borders',
336
- show_bottom: false,
355
+ context 'when false' do
356
+ let(:attributes) {
357
+ {
358
+ enabled: true,
359
+ name: 'borders',
360
+ show_left: false,
361
+ }
337
362
  }
338
- }
339
363
 
340
- it { subject.must_be_instance_of(FalseClass) }
364
+ it { subject.must_be_instance_of(FalseClass) }
365
+ end
341
366
  end
342
- end
343
367
 
344
- describe '#left?' do
345
- subject { instance.left? }
368
+ describe '#right?' do
369
+ subject { instance.right? }
346
370
 
347
- it { subject.must_be_instance_of(TrueClass) }
371
+ it { subject.must_be_instance_of(TrueClass) }
348
372
 
349
- context 'when false' do
350
- let(:attributes) {
351
- {
352
- enabled: true,
353
- name: 'borders',
354
- show_left: false,
373
+ context 'when false' do
374
+ let(:attributes) {
375
+ {
376
+ enabled: true,
377
+ name: 'borders',
378
+ show_right: false,
379
+ }
355
380
  }
356
- }
357
381
 
358
- it { subject.must_be_instance_of(FalseClass) }
382
+ it { subject.must_be_instance_of(FalseClass) }
383
+ end
359
384
  end
360
- end
361
385
 
362
- describe '#right?' do
363
- subject { instance.right? }
386
+ describe '#top?' do
387
+ subject { instance.top? }
364
388
 
365
- it { subject.must_be_instance_of(TrueClass) }
389
+ it { subject.must_be_instance_of(TrueClass) }
366
390
 
367
- context 'when false' do
368
- let(:attributes) {
369
- {
370
- enabled: true,
371
- name: 'borders',
372
- show_right: false,
391
+ context 'when false' do
392
+ let(:attributes) {
393
+ {
394
+ enabled: true,
395
+ name: 'borders',
396
+ show_top: false,
397
+ }
373
398
  }
374
- }
375
399
 
376
- it { subject.must_be_instance_of(FalseClass) }
400
+ it { subject.must_be_instance_of(FalseClass) }
401
+ end
377
402
  end
378
- end
379
403
 
380
- describe '#top?' do
381
- subject { instance.top? }
404
+ describe '#render' do
405
+ before { Vedeu::Borders::Render.stubs(:with) }
382
406
 
383
- it { subject.must_be_instance_of(TrueClass) }
407
+ subject { instance.render }
384
408
 
385
- context 'when false' do
386
- let(:attributes) {
387
- {
388
- enabled: true,
389
- name: 'borders',
390
- show_top: false,
391
- }
409
+ it {
410
+ Vedeu::Borders::Render.expects(:with).with(instance)
411
+ subject
392
412
  }
393
-
394
- it { subject.must_be_instance_of(FalseClass) }
395
413
  end
396
- end
397
-
398
- describe '#render' do
399
- before { Vedeu::RenderBorder.stubs(:with) }
400
414
 
401
- subject { instance.render }
402
-
403
- it {
404
- Vedeu::RenderBorder.expects(:with).with(instance)
405
- subject
406
- }
407
- end
415
+ end # Border
408
416
 
409
- end # Border
417
+ end # Borders
410
418
 
411
419
  end # Vedeu