vedeu 0.6.4 → 0.6.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.codeclimate.yml +40 -0
- data/README.md +1 -0
- data/docs/dsl.md +24 -24
- data/lib/vedeu/all.rb +21 -44
- data/lib/vedeu/api.rb +13 -13
- data/lib/vedeu/application/application_controller.rb +2 -0
- data/lib/vedeu/bindings/movement.rb +53 -18
- data/lib/vedeu/bindings/refresh.rb +1 -1
- data/lib/vedeu/bindings/system.rb +2 -2
- data/lib/vedeu/bindings/visibility.rb +3 -3
- data/lib/vedeu/borders/all.rb +13 -0
- data/lib/vedeu/borders/border.rb +209 -202
- data/lib/vedeu/{dsl/border.rb → borders/dsl.rb} +15 -15
- data/lib/vedeu/{null/border.rb → borders/null.rb} +9 -9
- data/lib/vedeu/borders/render.rb +347 -0
- data/lib/vedeu/borders/repository.rb +19 -0
- data/lib/vedeu/buffers/all.rb +13 -0
- data/lib/vedeu/buffers/buffer.rb +182 -176
- data/lib/vedeu/{null/buffer.rb → buffers/null.rb} +8 -8
- data/lib/vedeu/buffers/repository.rb +24 -0
- data/lib/vedeu/buffers/virtual_buffer.rb +2 -2
- data/lib/vedeu/cursors/all.rb +11 -0
- data/lib/vedeu/cursors/cursor.rb +276 -0
- data/lib/vedeu/cursors/refresh.rb +84 -0
- data/lib/vedeu/cursors/repository.rb +34 -0
- data/lib/vedeu/dsl/interface.rb +9 -9
- data/lib/vedeu/dsl/shared.rb +11 -11
- data/lib/vedeu/{exceptions.rb → error.rb} +2 -2
- data/lib/vedeu/esc/esc.rb +1 -1
- data/lib/vedeu/geometry/all.rb +18 -0
- data/lib/vedeu/geometry/area.rb +170 -160
- data/lib/vedeu/geometry/coordinate.rb +61 -39
- data/lib/vedeu/geometry/dimension.rb +139 -132
- data/lib/vedeu/{dsl/geometry.rb → geometry/dsl.rb} +11 -11
- data/lib/vedeu/geometry/generic_coordinate.rb +159 -153
- data/lib/vedeu/geometry/geometry.rb +310 -212
- data/lib/vedeu/geometry/grid.rb +73 -69
- data/lib/vedeu/{null/geometry.rb → geometry/null.rb} +10 -10
- data/lib/vedeu/geometry/position.rb +124 -120
- data/lib/vedeu/geometry/repository.rb +19 -0
- data/lib/vedeu/input/editor/document.rb +2 -2
- data/lib/vedeu/internal_api.rb +8 -8
- data/lib/vedeu/models/escape.rb +2 -2
- data/lib/vedeu/models/interface.rb +1 -1
- data/lib/vedeu/models/page.rb +89 -0
- data/lib/vedeu/models/row.rb +66 -0
- data/lib/vedeu/models/toggleable.rb +1 -1
- data/lib/vedeu/models/views/char.rb +7 -6
- data/lib/vedeu/models/views/line.rb +1 -1
- data/lib/vedeu/models/views/view.rb +2 -2
- data/lib/vedeu/options.rb +19 -0
- data/lib/vedeu/output/clear/named_interface.rb +1 -1
- data/lib/vedeu/output/direct.rb +1 -1
- data/lib/vedeu/output/presentation.rb +2 -1
- data/lib/vedeu/output/viewport.rb +3 -3
- data/lib/vedeu/repositories/model.rb +9 -1
- data/lib/vedeu/repositories/repository.rb +5 -0
- data/lib/vedeu/terminal/terminal.rb +3 -3
- data/lib/vedeu/version.rb +1 -1
- data/test/lib/vedeu/borders/border_test.rb +299 -291
- data/test/lib/vedeu/{dsl/border_test.rb → borders/dsl_test.rb} +6 -6
- data/test/lib/vedeu/{null/border_test.rb → borders/null_test.rb} +6 -6
- data/test/lib/vedeu/borders/render_test.rb +125 -0
- data/test/lib/vedeu/borders/repository_test.rb +17 -0
- data/test/lib/vedeu/buffers/buffer_test.rb +116 -112
- data/test/lib/vedeu/{null/buffer_test.rb → buffers/null_test.rb} +5 -5
- data/test/lib/vedeu/buffers/repository_test.rb +18 -0
- data/test/lib/vedeu/cursors/cursor_test.rb +370 -0
- data/test/lib/vedeu/cursors/refresh_test.rb +69 -0
- data/test/lib/vedeu/cursors/repository_test.rb +41 -0
- data/test/lib/vedeu/dsl/interface_test.rb +5 -5
- data/test/lib/vedeu/{exceptions_test.rb → error_test.rb} +0 -0
- data/test/lib/vedeu/geometry/area_test.rb +141 -137
- data/test/lib/vedeu/geometry/coordinate_test.rb +93 -89
- data/test/lib/vedeu/geometry/dimension_test.rb +137 -133
- data/test/lib/vedeu/{dsl/geometry_test.rb → geometry/dsl_test.rb} +17 -17
- data/test/lib/vedeu/geometry/generic_coordinate_test.rb +32 -28
- data/test/lib/vedeu/geometry/geometry_test.rb +282 -157
- data/test/lib/vedeu/geometry/grid_test.rb +35 -31
- data/test/lib/vedeu/{null/geometry_test.rb → geometry/null_test.rb} +5 -5
- data/test/lib/vedeu/geometry/position_test.rb +146 -142
- data/test/lib/vedeu/geometry/repository_test.rb +19 -0
- data/test/lib/vedeu/input/editor/document_test.rb +1 -1
- data/test/lib/vedeu/models/escape_test.rb +1 -1
- data/test/lib/vedeu/models/interface_test.rb +2 -2
- data/test/lib/vedeu/models/page_test.rb +235 -0
- data/test/lib/vedeu/models/row_test.rb +111 -0
- data/test/lib/vedeu/models/views/char_test.rb +3 -3
- data/test/lib/vedeu/options_test.rb +57 -0
- data/test/lib/vedeu/output/clear/named_interface_test.rb +1 -1
- data/test/lib/vedeu/output/renderers/json_test.rb +1 -1
- data/test/lib/vedeu/output/viewport_test.rb +15 -9
- data/test/lib/vedeu/refresh/refresh_buffer_test.rb +12 -12
- data/test/lib/vedeu/repositories/repositories_test.rb +1 -1
- data/test/lib/vedeu/repositories/repository_test.rb +7 -0
- data/test/lib/vedeu/terminal/terminal_test.rb +1 -1
- data/test/test_helper.rb +1 -1
- data/vedeu.gemspec +2 -2
- metadata +57 -63
- data/lib/vedeu/borders/borders.rb +0 -15
- data/lib/vedeu/borders/render_border.rb +0 -331
- data/lib/vedeu/buffers/buffers.rb +0 -20
- data/lib/vedeu/cursor/cursor.rb +0 -174
- data/lib/vedeu/cursor/cursors.rb +0 -30
- data/lib/vedeu/cursor/move.rb +0 -239
- data/lib/vedeu/cursor/reposition.rb +0 -78
- data/lib/vedeu/geometry/geometries.rb +0 -15
- data/lib/vedeu/refresh/refresh_cursor.rb +0 -92
- data/test/lib/vedeu/borders/borders_test.rb +0 -13
- data/test/lib/vedeu/borders/render_border_test.rb +0 -121
- data/test/lib/vedeu/buffers/buffers_test.rb +0 -14
- data/test/lib/vedeu/cursor/cursor_test.rb +0 -246
- data/test/lib/vedeu/cursor/cursors_test.rb +0 -37
- data/test/lib/vedeu/cursor/move_test.rb +0 -301
- data/test/lib/vedeu/cursor/reposition_test.rb +0 -63
- data/test/lib/vedeu/geometry/geometries_test.rb +0 -15
- 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
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
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
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
85
|
-
it { subject.maximised.must_equal(true) }
|
86
|
-
end
|
82
|
+
before { Vedeu.stubs(:trigger) }
|
87
83
|
|
88
|
-
|
89
|
-
|
90
|
-
{
|
91
|
-
|
92
|
-
|
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
|
-
|
90
|
+
describe '#move_down' do
|
91
|
+
let(:x) { 15 }
|
92
|
+
let(:xn) { 25 }
|
93
|
+
let(:y) { 4 }
|
94
|
+
let(:yn) { 8 }
|
99
95
|
|
100
|
-
|
96
|
+
before { Terminal.stubs(:size).returns([12, 40]) }
|
101
97
|
|
102
|
-
|
103
|
-
it { subject.maximised.must_equal(false) }
|
104
|
-
end
|
98
|
+
subject { instance.move_down }
|
105
99
|
|
106
|
-
|
107
|
-
before { Terminal.stubs(:size).returns([12, 40]) }
|
100
|
+
it { subject.must_be_instance_of(described) }
|
108
101
|
|
109
|
-
|
110
|
-
|
102
|
+
it { subject.y.must_equal(5) }
|
103
|
+
it { subject.yn.must_equal(9) }
|
111
104
|
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
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
|
-
|
119
|
-
let(:
|
116
|
+
describe '#move_left' do
|
117
|
+
let(:x) { 15 }
|
118
|
+
let(:xn) { 25 }
|
119
|
+
let(:y) { 4 }
|
120
|
+
let(:yn) { 8 }
|
120
121
|
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
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
|
-
|
128
|
-
|
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
|
-
|
131
|
-
|
132
|
-
|
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
|
-
|
137
|
-
let(:
|
142
|
+
describe '#move_origin' do
|
143
|
+
let(:x) { 15 }
|
144
|
+
let(:xn) { 25 }
|
145
|
+
let(:y) { 4 }
|
146
|
+
let(:yn) { 8 }
|
138
147
|
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
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
|
-
|
146
|
-
let(:
|
159
|
+
describe '#move_right' do
|
160
|
+
let(:x) { 15 }
|
161
|
+
let(:xn) { 25 }
|
162
|
+
let(:y) { 4 }
|
163
|
+
let(:yn) { 8 }
|
147
164
|
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
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
|
-
|
155
|
-
let(:
|
185
|
+
describe '#move_up' do
|
186
|
+
let(:x) { 15 }
|
187
|
+
let(:xn) { 25 }
|
188
|
+
let(:y) { 4 }
|
189
|
+
let(:yn) { 8 }
|
156
190
|
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
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
|
-
|
164
|
-
let(:attributes) {
|
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
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
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
|
-
|
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
|
-
|
318
|
+
describe '#unmaximise' do
|
319
|
+
let(:attributes) { { maximised: false } }
|
186
320
|
|
187
|
-
|
321
|
+
before { Terminal.stubs(:size).returns([12, 40]) }
|
188
322
|
|
189
|
-
|
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
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
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
|
-
|
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
|
|