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
@@ -2,208 +2,333 @@ require 'test_helper'
2
2
 
3
3
  module Vedeu
4
4
 
5
- describe Geometry do
6
-
7
- let(:described) { Vedeu::Geometry }
8
- let(:instance) { described.new(attributes) }
9
- let(:attributes) {
10
- {
11
- centred: centred,
12
- height: height,
13
- maximised: maximised,
14
- name: _name,
15
- repository: Vedeu.geometries,
16
- width: width,
17
- x: x,
18
- xn: xn,
19
- y: y,
20
- yn: yn,
21
- }
22
- }
23
- let(:centred) { false }
24
- let(:height) {}
25
- let(:maximised) { false }
26
- let(:_name) {}
27
- let(:width) {}
28
- let(:x) {}
29
- let(:xn) {}
30
- let(:y) {}
31
- let(:yn) {}
32
-
33
- describe '#initialize' do
34
- it { instance.must_be_instance_of(described) }
35
- it {
36
- instance.instance_variable_get('@attributes').must_equal(attributes)
37
- }
38
- it { instance.instance_variable_get('@centred').must_equal(centred) }
39
- it { instance.instance_variable_get('@height').must_equal(height) }
40
- it { instance.instance_variable_get('@maximised').must_equal(maximised) }
41
- it { instance.instance_variable_get('@name').must_equal(_name) }
42
- it { instance.instance_variable_get('@width').must_equal(width) }
43
- it { instance.instance_variable_get('@x').must_equal(x) }
44
- it { instance.instance_variable_get('@xn').must_equal(xn) }
45
- it { instance.instance_variable_get('@y').must_equal(y) }
46
- it { instance.instance_variable_get('@yn').must_equal(yn) }
47
- it do
48
- instance.instance_variable_get('@repository').
49
- must_equal(Vedeu.geometries)
50
- end
51
- end
52
-
53
- describe 'accessors' do
54
- it { instance.must_respond_to(:centred) }
55
- it { instance.must_respond_to(:centred=) }
56
- it { instance.must_respond_to(:attributes) }
57
- it { instance.must_respond_to(:name) }
58
- it { instance.must_respond_to(:name=) }
59
- it { instance.must_respond_to(:height=) }
60
- it { instance.must_respond_to(:maximised) }
61
- it { instance.must_respond_to(:maximised?) }
62
- it { instance.must_respond_to(:maximised=) }
63
- it { instance.must_respond_to(:width=) }
64
- it { instance.must_respond_to(:x=) }
65
- it { instance.must_respond_to(:xn=) }
66
- it { instance.must_respond_to(:y=) }
67
- it { instance.must_respond_to(:yn=) }
68
- end
69
-
70
- describe '#maximise' do
5
+ module Geometry
6
+
7
+ describe Geometry do
8
+
9
+ let(:described) { Vedeu::Geometry::Geometry }
10
+ let(:instance) { described.new(attributes) }
71
11
  let(:attributes) {
72
12
  {
73
- height: 6,
74
- maximised: false,
75
- name: 'maximise',
76
- width: 18
13
+ centred: centred,
14
+ height: height,
15
+ maximised: maximised,
16
+ name: _name,
17
+ repository: Vedeu.geometries,
18
+ width: width,
19
+ x: x,
20
+ xn: xn,
21
+ y: y,
22
+ yn: yn,
77
23
  }
78
24
  }
25
+ let(:centred) { false }
26
+ let(:height) {}
27
+ let(:maximised) { false }
28
+ let(:_name) { 'vedeu_geometry_geometry' }
29
+ let(:width) {}
30
+ let(:x) {}
31
+ let(:xn) {}
32
+ let(:y) {}
33
+ let(:yn) {}
34
+
35
+ describe '#initialize' do
36
+ it { instance.must_be_instance_of(described) }
37
+ it {
38
+ instance.instance_variable_get('@attributes').must_equal(attributes)
39
+ }
40
+ it { instance.instance_variable_get('@centred').must_equal(centred) }
41
+ it { instance.instance_variable_get('@height').must_equal(height) }
42
+ it { instance.instance_variable_get('@maximised').must_equal(maximised) }
43
+ it { instance.instance_variable_get('@name').must_equal(_name) }
44
+ it { instance.instance_variable_get('@width').must_equal(width) }
45
+ it { instance.instance_variable_get('@x').must_equal(x) }
46
+ it { instance.instance_variable_get('@xn').must_equal(xn) }
47
+ it { instance.instance_variable_get('@y').must_equal(y) }
48
+ it { instance.instance_variable_get('@yn').must_equal(yn) }
49
+ it do
50
+ instance.instance_variable_get('@repository').
51
+ must_equal(Vedeu.geometries)
52
+ end
53
+ end
79
54
 
80
- before { Vedeu.stubs(:trigger) }
55
+ describe 'accessors' do
56
+ it { instance.must_respond_to(:centred) }
57
+ it { instance.must_respond_to(:centred=) }
58
+ it { instance.must_respond_to(:attributes) }
59
+ it { instance.must_respond_to(:name) }
60
+ it { instance.must_respond_to(:name=) }
61
+ it { instance.must_respond_to(:height=) }
62
+ it { instance.must_respond_to(:maximised) }
63
+ it { instance.must_respond_to(:maximised?) }
64
+ it { instance.must_respond_to(:maximised=) }
65
+ it { instance.must_respond_to(:width=) }
66
+ it { instance.must_respond_to(:x=) }
67
+ it { instance.must_respond_to(:xn=) }
68
+ it { instance.must_respond_to(:y=) }
69
+ it { instance.must_respond_to(:yn=) }
70
+ end
81
71
 
82
- subject { instance.maximise }
72
+ describe '#maximise' do
73
+ let(:attributes) {
74
+ {
75
+ height: 6,
76
+ maximised: false,
77
+ name: 'maximise',
78
+ width: 18
79
+ }
80
+ }
83
81
 
84
- it { subject.must_be_instance_of(described) }
85
- it { subject.maximised.must_equal(true) }
86
- end
82
+ before { Vedeu.stubs(:trigger) }
87
83
 
88
- describe '#unmaximise' do
89
- let(:attributes) {
90
- {
91
- height: 6,
92
- maximised: true,
93
- name: 'unmaximise',
94
- width: 18
95
- }
96
- }
84
+ subject { instance.maximise }
85
+
86
+ it { subject.must_be_instance_of(described) }
87
+ it { subject.maximised.must_equal(true) }
88
+ end
97
89
 
98
- before { Vedeu.stubs(:trigger) }
90
+ describe '#move_down' do
91
+ let(:x) { 15 }
92
+ let(:xn) { 25 }
93
+ let(:y) { 4 }
94
+ let(:yn) { 8 }
99
95
 
100
- subject { instance.unmaximise }
96
+ before { Terminal.stubs(:size).returns([12, 40]) }
101
97
 
102
- it { subject.must_be_instance_of(described) }
103
- it { subject.maximised.must_equal(false) }
104
- end
98
+ subject { instance.move_down }
105
99
 
106
- describe '#top, #right, #bottom, #left' do
107
- before { Terminal.stubs(:size).returns([12, 40]) }
100
+ it { subject.must_be_instance_of(described) }
108
101
 
109
- context 'maximised is true' do
110
- let(:attributes) { { maximised: true } }
102
+ it { subject.y.must_equal(5) }
103
+ it { subject.yn.must_equal(9) }
111
104
 
112
- it { instance.top.must_equal(1) }
113
- it { instance.right.must_equal(40) }
114
- it { instance.bottom.must_equal(12) }
115
- it { instance.left.must_equal(1) }
105
+ context 'when the move will make the geometry out of bounds' do
106
+ let(:x) { 15 }
107
+ let(:xn) { 25 }
108
+ let(:y) { 8 }
109
+ let(:yn) { 12 }
110
+
111
+ it { subject.y.must_equal(8) }
112
+ it { subject.yn.must_equal(12) }
113
+ end
116
114
  end
117
115
 
118
- context 'centred is true' do
119
- let(:attributes) { { height: 6, width: 18, centred: true } }
116
+ describe '#move_left' do
117
+ let(:x) { 15 }
118
+ let(:xn) { 25 }
119
+ let(:y) { 4 }
120
+ let(:yn) { 8 }
120
121
 
121
- it { instance.top.must_equal(3) }
122
- it { instance.right.must_equal(29) }
123
- it { instance.bottom.must_equal(9) }
124
- it { instance.left.must_equal(11) }
125
- end
122
+ before { Terminal.stubs(:size).returns([12, 40]) }
123
+
124
+ subject { instance.move_left }
125
+
126
+ it { subject.must_be_instance_of(described) }
127
+
128
+ it { subject.x.must_equal(14) }
129
+ it { subject.xn.must_equal(24) }
126
130
 
127
- context 'centred is true and y is set, y is ignored' do
128
- let(:attributes) { { height: 6, width: 18, centred: true, y: 4 } }
131
+ context 'when the move will make the geometry out of bounds' do
132
+ let(:x) { 1 }
133
+ let(:xn) { 11 }
134
+ let(:y) { 4 }
135
+ let(:yn) { 8 }
129
136
 
130
- it { instance.top.must_equal(3) }
131
- it { instance.right.must_equal(29) }
132
- it { instance.bottom.must_equal(9) }
133
- it { instance.left.must_equal(11) }
137
+ it { subject.x.must_equal(1) }
138
+ it { subject.xn.must_equal(11) }
139
+ end
134
140
  end
135
141
 
136
- context 'centred is true and x is set, x is ignored' do
137
- let(:attributes) { { height: 6, width: 18, centred: true, x: 4 } }
142
+ describe '#move_origin' do
143
+ let(:x) { 15 }
144
+ let(:xn) { 25 }
145
+ let(:y) { 4 }
146
+ let(:yn) { 8 }
138
147
 
139
- it { instance.top.must_equal(3) }
140
- it { instance.right.must_equal(29) }
141
- it { instance.bottom.must_equal(9) }
142
- it { instance.left.must_equal(11) }
148
+ before { Terminal.stubs(:size).returns([12, 40]) }
149
+
150
+ subject { instance.move_origin }
151
+
152
+ it { subject.must_be_instance_of(described) }
153
+ it { subject.x.must_equal(1) }
154
+ it { subject.xn.must_equal(11) }
155
+ it { subject.y.must_equal(1) }
156
+ it { subject.yn.must_equal(5) }
143
157
  end
144
158
 
145
- context 'centred is false' do
146
- let(:attributes) { { height: 6, width: 18 } }
159
+ describe '#move_right' do
160
+ let(:x) { 15 }
161
+ let(:xn) { 25 }
162
+ let(:y) { 4 }
163
+ let(:yn) { 8 }
147
164
 
148
- it { instance.top.must_equal(1) }
149
- it { instance.right.must_equal(18) }
150
- it { instance.bottom.must_equal(6) }
151
- it { instance.left.must_equal(1) }
165
+ before { Terminal.stubs(:size).returns([12, 40]) }
166
+
167
+ subject { instance.move_right }
168
+
169
+ it { subject.must_be_instance_of(described) }
170
+
171
+ it { subject.x.must_equal(16) }
172
+ it { subject.xn.must_equal(26) }
173
+
174
+ context 'when the move will make the geometry out of bounds' do
175
+ let(:x) { 30 }
176
+ let(:xn) { 40 }
177
+ let(:y) { 4 }
178
+ let(:yn) { 8 }
179
+
180
+ it { subject.x.must_equal(30) }
181
+ it { subject.xn.must_equal(40) }
182
+ end
152
183
  end
153
184
 
154
- context 'centred is false and y is set' do
155
- let(:attributes) { { height: 6, width: 18, y: 4 } }
185
+ describe '#move_up' do
186
+ let(:x) { 15 }
187
+ let(:xn) { 25 }
188
+ let(:y) { 4 }
189
+ let(:yn) { 8 }
156
190
 
157
- it { instance.top.must_equal(4) }
158
- it { instance.right.must_equal(18) }
159
- it { instance.bottom.must_equal(9) }
160
- it { instance.left.must_equal(1) }
191
+ before { Terminal.stubs(:size).returns([12, 40]) }
192
+
193
+ subject { instance.move_up }
194
+
195
+ it { subject.must_be_instance_of(described) }
196
+
197
+ it { subject.y.must_equal(3) }
198
+ it { subject.yn.must_equal(7) }
199
+
200
+ context 'when the move will make the geometry out of bounds' do
201
+ let(:x) { 15 }
202
+ let(:xn) { 25 }
203
+ let(:y) { 1 }
204
+ let(:yn) { 5 }
205
+
206
+ it { subject.y.must_equal(1) }
207
+ it { subject.yn.must_equal(5) }
208
+ end
161
209
  end
162
210
 
163
- context 'centred is false and x is set' do
164
- let(:attributes) { { height: 6, width: 18, x: 4 } }
211
+ describe '#unmaximise' do
212
+ let(:attributes) {
213
+ {
214
+ height: 6,
215
+ maximised: true,
216
+ name: 'unmaximise',
217
+ width: 18
218
+ }
219
+ }
165
220
 
166
- it { instance.top.must_equal(1) }
167
- it { instance.right.must_equal(21) }
168
- it { instance.bottom.must_equal(6) }
169
- it { instance.left.must_equal(4) }
221
+ before { Vedeu.stubs(:trigger) }
222
+
223
+ subject { instance.unmaximise }
224
+
225
+ it { subject.must_be_instance_of(described) }
226
+ it { subject.maximised.must_equal(false) }
227
+ end
228
+
229
+ describe '#top, #right, #bottom, #left' do
230
+ before { Terminal.stubs(:size).returns([12, 40]) }
231
+
232
+ context 'maximised is true' do
233
+ let(:attributes) { { maximised: true } }
234
+
235
+ it { instance.top.must_equal(1) }
236
+ it { instance.right.must_equal(40) }
237
+ it { instance.bottom.must_equal(12) }
238
+ it { instance.left.must_equal(1) }
239
+ end
240
+
241
+ context 'centred is true' do
242
+ let(:attributes) { { height: 6, width: 18, centred: true } }
243
+
244
+ it { instance.top.must_equal(3) }
245
+ it { instance.right.must_equal(29) }
246
+ it { instance.bottom.must_equal(9) }
247
+ it { instance.left.must_equal(11) }
248
+ end
249
+
250
+ context 'centred is true and y is set, y is ignored' do
251
+ let(:attributes) { { height: 6, width: 18, centred: true, y: 4 } }
252
+
253
+ it { instance.top.must_equal(3) }
254
+ it { instance.right.must_equal(29) }
255
+ it { instance.bottom.must_equal(9) }
256
+ it { instance.left.must_equal(11) }
257
+ end
258
+
259
+ context 'centred is true and x is set, x is ignored' do
260
+ let(:attributes) { { height: 6, width: 18, centred: true, x: 4 } }
261
+
262
+ it { instance.top.must_equal(3) }
263
+ it { instance.right.must_equal(29) }
264
+ it { instance.bottom.must_equal(9) }
265
+ it { instance.left.must_equal(11) }
266
+ end
267
+
268
+ context 'centred is false' do
269
+ let(:attributes) { { height: 6, width: 18 } }
270
+
271
+ it { instance.top.must_equal(1) }
272
+ it { instance.right.must_equal(18) }
273
+ it { instance.bottom.must_equal(6) }
274
+ it { instance.left.must_equal(1) }
275
+ end
276
+
277
+ context 'centred is false and y is set' do
278
+ let(:attributes) { { height: 6, width: 18, y: 4 } }
279
+
280
+ it { instance.top.must_equal(4) }
281
+ it { instance.right.must_equal(18) }
282
+ it { instance.bottom.must_equal(9) }
283
+ it { instance.left.must_equal(1) }
284
+ end
285
+
286
+ context 'centred is false and x is set' do
287
+ let(:attributes) { { height: 6, width: 18, x: 4 } }
288
+
289
+ it { instance.top.must_equal(1) }
290
+ it { instance.right.must_equal(21) }
291
+ it { instance.bottom.must_equal(6) }
292
+ it { instance.left.must_equal(4) }
293
+ end
294
+
295
+ context 'maximised' do
296
+ let(:attributes) { { maximised: true } }
297
+
298
+ it { instance.top.must_equal(1) }
299
+ it { instance.right.must_equal(40) }
300
+ it { instance.bottom.must_equal(12) }
301
+ it { instance.left.must_equal(1) }
302
+ end
170
303
  end
171
304
 
172
- context 'maximised' do
305
+ describe '#maximise' do
173
306
  let(:attributes) { { maximised: true } }
174
307
 
308
+ before { Terminal.stubs(:size).returns([12, 40]) }
309
+
310
+ subject { instance.maximise }
311
+
175
312
  it { instance.top.must_equal(1) }
176
313
  it { instance.right.must_equal(40) }
177
314
  it { instance.bottom.must_equal(12) }
178
315
  it { instance.left.must_equal(1) }
179
316
  end
180
- end
181
-
182
- describe '#maximise' do
183
- let(:attributes) { { maximised: true } }
184
317
 
185
- before { Terminal.stubs(:size).returns([12, 40]) }
318
+ describe '#unmaximise' do
319
+ let(:attributes) { { maximised: false } }
186
320
 
187
- subject { instance.maximise }
321
+ before { Terminal.stubs(:size).returns([12, 40]) }
188
322
 
189
- it { instance.top.must_equal(1) }
190
- it { instance.right.must_equal(40) }
191
- it { instance.bottom.must_equal(12) }
192
- it { instance.left.must_equal(1) }
193
- end
323
+ subject { instance.unmaximise }
194
324
 
195
- describe '#unmaximise' do
196
- let(:attributes) { { maximised: false } }
197
-
198
- before { Terminal.stubs(:size).returns([12, 40]) }
199
-
200
- subject { instance.unmaximise }
325
+ it { instance.top.must_equal(1) }
326
+ it { instance.right.must_equal(40) }
327
+ it { instance.bottom.must_equal(12) }
328
+ it { instance.left.must_equal(1) }
329
+ end
201
330
 
202
- it { instance.top.must_equal(1) }
203
- it { instance.right.must_equal(40) }
204
- it { instance.bottom.must_equal(12) }
205
- it { instance.left.must_equal(1) }
206
- end
331
+ end # Geometry
207
332
 
208
333
  end # Geometry
209
334