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
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Vedeu
|
4
|
+
|
5
|
+
module Cursors
|
6
|
+
|
7
|
+
describe Repository do
|
8
|
+
|
9
|
+
let(:described) { Vedeu::Cursors::Repository }
|
10
|
+
|
11
|
+
it { described.must_respond_to(:cursors) }
|
12
|
+
|
13
|
+
describe '.cursor' do
|
14
|
+
subject { Vedeu.cursor }
|
15
|
+
|
16
|
+
context 'when there are cursors are defined' do
|
17
|
+
before do
|
18
|
+
Vedeu::Focus.reset
|
19
|
+
Vedeu.cursors.reset
|
20
|
+
Vedeu::Focus.add('Vedeu.cursor')
|
21
|
+
Vedeu::Cursors::Cursor.new(name: 'Vedeu.cursor').store
|
22
|
+
end
|
23
|
+
|
24
|
+
it { subject.must_be_instance_of(Vedeu::Cursors::Cursor) }
|
25
|
+
end
|
26
|
+
|
27
|
+
context 'when there are no cursors defined' do
|
28
|
+
before do
|
29
|
+
Vedeu::Focus.reset
|
30
|
+
Vedeu.cursors.reset
|
31
|
+
end
|
32
|
+
|
33
|
+
it { subject.must_be_instance_of(NilClass) }
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
end # Repository
|
38
|
+
|
39
|
+
end # Cursors
|
40
|
+
|
41
|
+
end # Vedeu
|
@@ -24,7 +24,7 @@ module Vedeu
|
|
24
24
|
after { Vedeu.interfaces.reset }
|
25
25
|
|
26
26
|
subject {
|
27
|
-
described.interface('
|
27
|
+
described.interface('fluorine') do
|
28
28
|
# ...
|
29
29
|
end
|
30
30
|
}
|
@@ -32,7 +32,7 @@ module Vedeu
|
|
32
32
|
it { subject.must_be_instance_of(Vedeu::Interface) }
|
33
33
|
|
34
34
|
context 'when the block is not given' do
|
35
|
-
subject { described.interface('
|
35
|
+
subject { described.interface('fluorine') }
|
36
36
|
|
37
37
|
it { proc { subject }.must_raise(Vedeu::Error::InvalidSyntax) }
|
38
38
|
end
|
@@ -60,7 +60,7 @@ module Vedeu
|
|
60
60
|
context 'when the block is given' do
|
61
61
|
subject { instance.border { } }
|
62
62
|
|
63
|
-
it { subject.must_be_instance_of(Vedeu::Border) }
|
63
|
+
it { subject.must_be_instance_of(Vedeu::Borders::Border) }
|
64
64
|
|
65
65
|
context 'when the name is not given' do
|
66
66
|
it 'uses the interface name for storing the border' do
|
@@ -83,7 +83,7 @@ module Vedeu
|
|
83
83
|
|
84
84
|
subject { instance.border! }
|
85
85
|
|
86
|
-
it { subject.must_be_instance_of(Vedeu::Border) }
|
86
|
+
it { subject.must_be_instance_of(Vedeu::Borders::Border) }
|
87
87
|
end
|
88
88
|
|
89
89
|
describe '#cursor' do
|
@@ -188,7 +188,7 @@ module Vedeu
|
|
188
188
|
context 'when the block is given' do
|
189
189
|
subject { instance.geometry { } }
|
190
190
|
|
191
|
-
it { subject.must_be_instance_of(Vedeu::Geometry) }
|
191
|
+
it { subject.must_be_instance_of(Vedeu::Geometry::Geometry) }
|
192
192
|
|
193
193
|
context 'when the name is not given' do
|
194
194
|
it 'uses the interface name for storing the geometry' do
|
File without changes
|
@@ -2,189 +2,193 @@ require 'test_helper'
|
|
2
2
|
|
3
3
|
module Vedeu
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
it { instance.must_be_instance_of(described) }
|
28
|
-
it { instance.instance_variable_get('@y').must_equal(y) }
|
29
|
-
it { instance.instance_variable_get('@yn').must_equal(yn) }
|
30
|
-
it { instance.instance_variable_get('@x').must_equal(x) }
|
31
|
-
it { instance.instance_variable_get('@xn').must_equal(xn) }
|
32
|
-
end
|
33
|
-
|
34
|
-
describe '.from_attributes' do
|
35
|
-
let(:attributes) {
|
36
|
-
{
|
37
|
-
y: y,
|
38
|
-
yn: yn,
|
39
|
-
y_yn: y_yn,
|
40
|
-
y_default: y_default,
|
41
|
-
x: x,
|
42
|
-
xn: xn,
|
43
|
-
x_xn: x_xn,
|
44
|
-
x_default: x_default,
|
45
|
-
maximised: maximised,
|
46
|
-
centred: centred,
|
47
|
-
}
|
48
|
-
}
|
49
|
-
let(:y) {}
|
50
|
-
let(:yn) {}
|
51
|
-
let(:y_yn) {}
|
52
|
-
let(:y_default) {}
|
53
|
-
let(:x) {}
|
54
|
-
let(:xn) {}
|
55
|
-
let(:x_xn) {}
|
56
|
-
let(:x_default) {}
|
57
|
-
let(:maximised) {}
|
58
|
-
let(:centred) {}
|
5
|
+
module Geometry
|
6
|
+
|
7
|
+
describe Area do
|
8
|
+
|
9
|
+
let(:described) { Vedeu::Geometry::Area }
|
10
|
+
let(:instance) { described.new(y: y, yn: yn, x: x, xn: xn) }
|
11
|
+
let(:y) { 4 }
|
12
|
+
let(:yn) { 9 }
|
13
|
+
let(:x) { 6 }
|
14
|
+
let(:xn) { 21 }
|
15
|
+
let(:offset) { 1 }
|
16
|
+
|
17
|
+
describe 'accessors' do
|
18
|
+
it { instance.must_respond_to(:y) }
|
19
|
+
it { instance.must_respond_to(:yn) }
|
20
|
+
it { instance.must_respond_to(:x) }
|
21
|
+
it { instance.must_respond_to(:xn) }
|
22
|
+
it { instance.must_respond_to(:top) }
|
23
|
+
it { instance.must_respond_to(:bottom) }
|
24
|
+
it { instance.must_respond_to(:left) }
|
25
|
+
it { instance.must_respond_to(:right) }
|
26
|
+
end
|
59
27
|
|
60
|
-
|
28
|
+
describe '#initialize' do
|
29
|
+
it { instance.must_be_instance_of(described) }
|
30
|
+
it { instance.instance_variable_get('@y').must_equal(y) }
|
31
|
+
it { instance.instance_variable_get('@yn').must_equal(yn) }
|
32
|
+
it { instance.instance_variable_get('@x').must_equal(x) }
|
33
|
+
it { instance.instance_variable_get('@xn').must_equal(xn) }
|
34
|
+
end
|
61
35
|
|
62
|
-
|
63
|
-
|
36
|
+
describe '.from_attributes' do
|
37
|
+
let(:attributes) {
|
38
|
+
{
|
39
|
+
y: y,
|
40
|
+
yn: yn,
|
41
|
+
y_yn: y_yn,
|
42
|
+
y_default: y_default,
|
43
|
+
x: x,
|
44
|
+
xn: xn,
|
45
|
+
x_xn: x_xn,
|
46
|
+
x_default: x_default,
|
47
|
+
maximised: maximised,
|
48
|
+
centred: centred,
|
49
|
+
}
|
50
|
+
}
|
51
|
+
let(:y) {}
|
52
|
+
let(:yn) {}
|
53
|
+
let(:y_yn) {}
|
54
|
+
let(:y_default) {}
|
55
|
+
let(:x) {}
|
56
|
+
let(:xn) {}
|
57
|
+
let(:x_xn) {}
|
58
|
+
let(:x_default) {}
|
59
|
+
let(:maximised) {}
|
60
|
+
let(:centred) {}
|
61
|
+
|
62
|
+
subject { described.from_attributes(attributes) }
|
63
|
+
|
64
|
+
it { subject.must_be_instance_of(described) }
|
65
|
+
end
|
64
66
|
|
65
|
-
|
66
|
-
|
67
|
+
describe '#eql?' do
|
68
|
+
let(:other) { described.new(y: 4, yn: 9, x: 6, xn: 21) }
|
67
69
|
|
68
|
-
|
70
|
+
subject { instance.eql?(other) }
|
69
71
|
|
70
|
-
|
72
|
+
it { subject.must_equal(true) }
|
71
73
|
|
72
|
-
|
73
|
-
|
74
|
+
context 'when different to other' do
|
75
|
+
let(:other) { described.new(y: 1, yn: 25, x: 1, xn: 40) }
|
74
76
|
|
75
|
-
|
77
|
+
it { subject.must_equal(false) }
|
78
|
+
end
|
76
79
|
end
|
77
|
-
end
|
78
80
|
|
79
|
-
|
80
|
-
|
81
|
+
describe '#centre' do
|
82
|
+
subject { instance.centre }
|
81
83
|
|
82
|
-
|
83
|
-
|
84
|
-
|
84
|
+
it { subject.must_be_instance_of(Array) }
|
85
|
+
it { subject.must_equal([7, 14]) }
|
86
|
+
end
|
85
87
|
|
86
|
-
|
87
|
-
|
88
|
+
describe '#centre_y' do
|
89
|
+
subject { instance.centre_y }
|
88
90
|
|
89
|
-
|
90
|
-
|
91
|
-
|
91
|
+
it { subject.must_be_instance_of(Fixnum) }
|
92
|
+
it { subject.must_equal(7) }
|
93
|
+
end
|
92
94
|
|
93
|
-
|
94
|
-
|
95
|
+
describe '#centre_x' do
|
96
|
+
subject { instance.centre_x }
|
95
97
|
|
96
|
-
|
97
|
-
|
98
|
-
|
98
|
+
it { subject.must_be_instance_of(Fixnum) }
|
99
|
+
it { subject.must_equal(14) }
|
100
|
+
end
|
99
101
|
|
100
|
-
|
101
|
-
|
102
|
+
describe '#north' do
|
103
|
+
subject { instance.north(offset) }
|
102
104
|
|
103
|
-
|
105
|
+
it { subject.must_be_instance_of(Fixnum) }
|
104
106
|
|
105
|
-
|
106
|
-
|
107
|
-
|
107
|
+
context 'with the default offset' do
|
108
|
+
it { subject.must_equal(3) }
|
109
|
+
end
|
108
110
|
|
109
|
-
|
110
|
-
|
111
|
+
context 'with a negative offset' do
|
112
|
+
let(:offset) { -2 }
|
111
113
|
|
112
|
-
|
113
|
-
|
114
|
+
it { subject.must_equal(6) }
|
115
|
+
end
|
114
116
|
|
115
|
-
|
116
|
-
|
117
|
+
context 'with a positive offset' do
|
118
|
+
let(:offset) { 2 }
|
117
119
|
|
118
|
-
|
120
|
+
it { subject.must_equal(2) }
|
121
|
+
end
|
119
122
|
end
|
120
|
-
end
|
121
123
|
|
122
|
-
|
123
|
-
|
124
|
+
describe '#east' do
|
125
|
+
subject { instance.east(offset) }
|
124
126
|
|
125
|
-
|
127
|
+
it { subject.must_be_instance_of(Fixnum) }
|
126
128
|
|
127
|
-
|
128
|
-
|
129
|
-
|
129
|
+
context 'with the default offset' do
|
130
|
+
it { subject.must_equal(22) }
|
131
|
+
end
|
130
132
|
|
131
|
-
|
132
|
-
|
133
|
+
context 'with a negative offset' do
|
134
|
+
let(:offset) { -2 }
|
133
135
|
|
134
|
-
|
135
|
-
|
136
|
+
it { subject.must_equal(19) }
|
137
|
+
end
|
136
138
|
|
137
|
-
|
138
|
-
|
139
|
+
context 'with a positive offset' do
|
140
|
+
let(:offset) { 2 }
|
139
141
|
|
140
|
-
|
142
|
+
it { subject.must_equal(23) }
|
143
|
+
end
|
141
144
|
end
|
142
|
-
end
|
143
145
|
|
144
|
-
|
145
|
-
|
146
|
+
describe '#south' do
|
147
|
+
subject { instance.south(offset) }
|
146
148
|
|
147
|
-
|
149
|
+
it { subject.must_be_instance_of(Fixnum) }
|
148
150
|
|
149
|
-
|
150
|
-
|
151
|
-
|
151
|
+
context 'with the default offset' do
|
152
|
+
it { subject.must_equal(10) }
|
153
|
+
end
|
152
154
|
|
153
|
-
|
154
|
-
|
155
|
+
context 'with a negative offset' do
|
156
|
+
let(:offset) { -2 }
|
155
157
|
|
156
|
-
|
157
|
-
|
158
|
+
it { subject.must_equal(7) }
|
159
|
+
end
|
158
160
|
|
159
|
-
|
160
|
-
|
161
|
+
context 'with a positive offset' do
|
162
|
+
let(:offset) { 2 }
|
161
163
|
|
162
|
-
|
164
|
+
it { subject.must_equal(11) }
|
165
|
+
end
|
163
166
|
end
|
164
|
-
end
|
165
167
|
|
166
|
-
|
167
|
-
|
168
|
+
describe '#west' do
|
169
|
+
subject { instance.west(offset) }
|
168
170
|
|
169
|
-
|
171
|
+
it { subject.must_be_instance_of(Fixnum) }
|
170
172
|
|
171
|
-
|
172
|
-
|
173
|
-
|
173
|
+
context 'with the default offset' do
|
174
|
+
it { subject.must_equal(5) }
|
175
|
+
end
|
174
176
|
|
175
|
-
|
176
|
-
|
177
|
+
context 'with a negative offset' do
|
178
|
+
let(:offset) { -2 }
|
177
179
|
|
178
|
-
|
179
|
-
|
180
|
+
it { subject.must_equal(8) }
|
181
|
+
end
|
180
182
|
|
181
|
-
|
182
|
-
|
183
|
+
context 'with a positive offset' do
|
184
|
+
let(:offset) { 2 }
|
183
185
|
|
184
|
-
|
186
|
+
it { subject.must_equal(4) }
|
187
|
+
end
|
185
188
|
end
|
186
|
-
end
|
187
189
|
|
188
|
-
|
190
|
+
end # Area
|
191
|
+
|
192
|
+
end # Geometry
|
189
193
|
|
190
194
|
end # Vedeu
|
@@ -2,130 +2,134 @@ require 'test_helper'
|
|
2
2
|
|
3
3
|
module Vedeu
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
Vedeu::
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
describe '#initialize' do
|
31
|
-
it { instance.must_be_instance_of(described) }
|
32
|
-
it { instance.instance_variable_get('@name').must_equal(_name) }
|
33
|
-
it { instance.instance_variable_get('@oy').must_equal(oy) }
|
34
|
-
it { instance.instance_variable_get('@ox').must_equal(ox) }
|
35
|
-
end
|
36
|
-
|
37
|
-
describe '#yn' do
|
38
|
-
subject { instance.yn }
|
39
|
-
|
40
|
-
context 'when the height is <= to 0' do
|
41
|
-
let(:height) { 0 }
|
42
|
-
|
43
|
-
it { subject.must_equal(0) }
|
5
|
+
module Geometry
|
6
|
+
|
7
|
+
describe Coordinate do
|
8
|
+
|
9
|
+
let(:described) { Vedeu::Geometry::Coordinate }
|
10
|
+
let(:instance) { described.new(_name, oy, ox) }
|
11
|
+
let(:_name) { 'coordinate' }
|
12
|
+
let(:oy) { 0 }
|
13
|
+
let(:ox) { 0 }
|
14
|
+
let(:height) { 6 }
|
15
|
+
let(:width) { 6 }
|
16
|
+
let(:x) { 7 }
|
17
|
+
let(:y) { 5 }
|
18
|
+
let(:border) { Vedeu::Borders::Border.new(name: _name, enabled: true) }
|
19
|
+
let(:geometry) {
|
20
|
+
Vedeu::Geometry::Geometry.new(name: _name,
|
21
|
+
height: height,
|
22
|
+
width: width,
|
23
|
+
x: x,
|
24
|
+
y: y)
|
25
|
+
}
|
26
|
+
|
27
|
+
before do
|
28
|
+
Vedeu.borders.stubs(:by_name).returns(border)
|
29
|
+
Vedeu.geometries.stubs(:by_name).returns(geometry)
|
44
30
|
end
|
45
31
|
|
46
|
-
|
47
|
-
it {
|
32
|
+
describe '#initialize' do
|
33
|
+
it { instance.must_be_instance_of(described) }
|
34
|
+
it { instance.instance_variable_get('@name').must_equal(_name) }
|
35
|
+
it { instance.instance_variable_get('@oy').must_equal(oy) }
|
36
|
+
it { instance.instance_variable_get('@ox').must_equal(ox) }
|
48
37
|
end
|
49
|
-
end
|
50
38
|
|
51
|
-
|
52
|
-
|
39
|
+
describe '#yn' do
|
40
|
+
subject { instance.yn }
|
53
41
|
|
54
|
-
|
55
|
-
|
42
|
+
context 'when the height is <= to 0' do
|
43
|
+
let(:height) { 0 }
|
56
44
|
|
57
|
-
|
45
|
+
it { subject.must_equal(0) }
|
46
|
+
end
|
47
|
+
|
48
|
+
context 'when the height is > 0' do
|
49
|
+
it { subject.must_equal(9) }
|
50
|
+
end
|
58
51
|
end
|
59
52
|
|
60
|
-
|
61
|
-
|
53
|
+
describe '#xn' do
|
54
|
+
subject { instance.xn }
|
55
|
+
|
56
|
+
context 'when the width is <= to 0' do
|
57
|
+
let(:width) { 0 }
|
58
|
+
|
59
|
+
it { subject.must_equal(0) }
|
60
|
+
end
|
61
|
+
|
62
|
+
context 'when the width is > 0' do
|
63
|
+
it { subject.must_equal(11) }
|
64
|
+
end
|
62
65
|
end
|
63
|
-
end
|
64
66
|
|
65
|
-
|
66
|
-
|
67
|
+
describe '#y_position' do
|
68
|
+
let(:oy) { 0 }
|
67
69
|
|
68
|
-
|
70
|
+
subject { instance.y_position }
|
69
71
|
|
70
|
-
|
72
|
+
it { subject.must_be_instance_of(Fixnum) }
|
71
73
|
|
72
|
-
|
73
|
-
|
74
|
+
context 'with a negative index' do
|
75
|
+
let(:oy) { -3 }
|
74
76
|
|
75
|
-
|
76
|
-
|
77
|
+
it { subject.must_equal(6) }
|
78
|
+
end
|
77
79
|
|
78
|
-
|
79
|
-
|
80
|
+
context 'with an index greater than the maximum index for y' do
|
81
|
+
let(:oy) { 9 }
|
80
82
|
|
81
|
-
|
83
|
+
it { subject.must_equal(9) }
|
82
84
|
|
83
|
-
|
84
|
-
|
85
|
+
context 'but the height is negative' do
|
86
|
+
let(:height) { -2 }
|
85
87
|
|
86
|
-
|
88
|
+
it { subject.must_equal(1) }
|
89
|
+
end
|
87
90
|
end
|
88
|
-
end
|
89
91
|
|
90
|
-
|
91
|
-
|
92
|
+
context 'with an index within range' do
|
93
|
+
let(:oy) { 3 }
|
92
94
|
|
93
|
-
|
95
|
+
it { subject.must_equal(8) }
|
96
|
+
end
|
94
97
|
end
|
95
|
-
end
|
96
98
|
|
97
|
-
|
98
|
-
|
99
|
+
describe '#x_position' do
|
100
|
+
let(:ox) { 0 }
|
99
101
|
|
100
|
-
|
102
|
+
subject { instance.x_position }
|
101
103
|
|
102
|
-
|
104
|
+
it { subject.must_be_instance_of(Fixnum) }
|
103
105
|
|
104
|
-
|
105
|
-
|
106
|
+
context 'with a negative index' do
|
107
|
+
let(:ox) { -3 }
|
106
108
|
|
107
|
-
|
108
|
-
|
109
|
+
it { subject.must_equal(8) }
|
110
|
+
end
|
109
111
|
|
110
|
-
|
111
|
-
|
112
|
+
context 'with an index greater than the maximum index for x' do
|
113
|
+
let(:ox) { 9 }
|
112
114
|
|
113
|
-
|
115
|
+
it { subject.must_equal(11) }
|
114
116
|
|
115
|
-
|
116
|
-
|
117
|
+
context 'but the width is negative' do
|
118
|
+
let(:width) { -2 }
|
117
119
|
|
118
|
-
|
120
|
+
it { subject.must_equal(3) }
|
121
|
+
end
|
119
122
|
end
|
120
|
-
end
|
121
123
|
|
122
|
-
|
123
|
-
|
124
|
+
context 'with an index within range' do
|
125
|
+
let(:ox) { 3 }
|
124
126
|
|
125
|
-
|
127
|
+
it { subject.must_equal(10) }
|
128
|
+
end
|
126
129
|
end
|
127
|
-
end
|
128
130
|
|
129
|
-
|
131
|
+
end # Coordinate
|
132
|
+
|
133
|
+
end # Geometry
|
130
134
|
|
131
135
|
end # Vedeu
|