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,19 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Vedeu
|
4
|
+
|
5
|
+
module Geometry
|
6
|
+
|
7
|
+
describe Repository do
|
8
|
+
|
9
|
+
let(:described) { Vedeu::Geometry::Repository }
|
10
|
+
|
11
|
+
after { Vedeu.geometries.reset }
|
12
|
+
|
13
|
+
it { described.must_respond_to(:geometries) }
|
14
|
+
|
15
|
+
end # Repository
|
16
|
+
|
17
|
+
end # Geometry
|
18
|
+
|
19
|
+
end # Vedeu
|
@@ -52,7 +52,7 @@ module Vedeu
|
|
52
52
|
}
|
53
53
|
|
54
54
|
before do
|
55
|
-
Vedeu::Geometry.new(name: _name, x: 1, y: 1, xn: 5, yn: 5).store
|
55
|
+
Vedeu::Geometry::Geometry.new(name: _name, x: 1, y: 1, xn: 5, yn: 5).store
|
56
56
|
Vedeu::Terminal.stubs(:output)
|
57
57
|
Vedeu::Direct.stubs(:write).returns(expected)
|
58
58
|
end
|
@@ -64,7 +64,7 @@ module Vedeu
|
|
64
64
|
end
|
65
65
|
|
66
66
|
describe '#hide' do
|
67
|
-
let(:buffer) { Vedeu::Buffer.new }
|
67
|
+
let(:buffer) { Vedeu::Buffers::Buffer.new }
|
68
68
|
|
69
69
|
before { Vedeu.buffers.stubs(:by_name).returns(buffer) }
|
70
70
|
|
@@ -77,7 +77,7 @@ module Vedeu
|
|
77
77
|
end
|
78
78
|
|
79
79
|
describe '#show' do
|
80
|
-
let(:buffer) { Vedeu::Buffer.new }
|
80
|
+
let(:buffer) { Vedeu::Buffers::Buffer.new }
|
81
81
|
|
82
82
|
before { Vedeu.buffers.stubs(:by_name).returns(buffer) }
|
83
83
|
|
@@ -0,0 +1,235 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Vedeu
|
4
|
+
|
5
|
+
describe Page do
|
6
|
+
|
7
|
+
let(:described) { Vedeu::Page }
|
8
|
+
let(:instance) { described.new(rows) }
|
9
|
+
let(:rows) {
|
10
|
+
[
|
11
|
+
[:hydrogen, :helium, :lithium],
|
12
|
+
[:beryllium, :boron, :carbon],
|
13
|
+
[:nitrogen, :oxygen, :fluorine],
|
14
|
+
]
|
15
|
+
}
|
16
|
+
|
17
|
+
describe '#initialize' do
|
18
|
+
it { instance.must_be_instance_of(described) }
|
19
|
+
|
20
|
+
context 'when there are no rows' do
|
21
|
+
let(:rows) {}
|
22
|
+
|
23
|
+
it { instance.instance_variable_get('@rows').must_equal([]) }
|
24
|
+
end
|
25
|
+
|
26
|
+
context 'when there are rows' do
|
27
|
+
it { instance.instance_variable_get('@rows').must_equal(rows) }
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe '.coerce' do
|
32
|
+
let(:_value) {}
|
33
|
+
|
34
|
+
subject { described.coerce(_value) }
|
35
|
+
|
36
|
+
it { proc { subject }.must_raise(Vedeu::Error::InvalidSyntax) }
|
37
|
+
|
38
|
+
context 'when the value is a Vedeu::Page' do
|
39
|
+
let(:_value) { Vedeu::Page.new }
|
40
|
+
|
41
|
+
it { subject.must_equal(_value) }
|
42
|
+
end
|
43
|
+
|
44
|
+
context 'when the value is a Vedeu::Row' do
|
45
|
+
let(:_value) { Vedeu::Row.new }
|
46
|
+
let(:expected) { Vedeu::Page.new([_value]) }
|
47
|
+
|
48
|
+
it { subject.must_equal(expected) }
|
49
|
+
end
|
50
|
+
|
51
|
+
context 'when the value is an Array' do
|
52
|
+
context 'and the value is empty' do
|
53
|
+
let(:_value) { [] }
|
54
|
+
let(:expected) { Vedeu::Page.coerce(Vedeu::Row.coerce(_value)) }
|
55
|
+
|
56
|
+
it { subject.must_be_instance_of(Vedeu::Page) }
|
57
|
+
it { subject.must_equal(expected) }
|
58
|
+
end
|
59
|
+
|
60
|
+
context 'and the value is not empty, the content is' do
|
61
|
+
context 'is an empty Array' do
|
62
|
+
let(:_value) { [[]] }
|
63
|
+
let(:expected) { Vedeu::Page.coerce(Vedeu::Row.coerce([])) }
|
64
|
+
|
65
|
+
it { subject.must_be_instance_of(Vedeu::Page) }
|
66
|
+
it { subject.must_equal(expected) }
|
67
|
+
end
|
68
|
+
|
69
|
+
context 'an array of Vedeu::Row objects' do
|
70
|
+
let(:_value) {
|
71
|
+
[
|
72
|
+
Vedeu::Row.new([:hydrogen, :helium]),
|
73
|
+
Vedeu::Row.new([:lithium, :beryllium]),
|
74
|
+
]
|
75
|
+
}
|
76
|
+
let(:expected) { Vedeu::Page.new(_value) }
|
77
|
+
|
78
|
+
it { subject.must_equal(expected) }
|
79
|
+
end
|
80
|
+
|
81
|
+
context 'a mix of Vedeu::Row objects and other objects' do
|
82
|
+
let(:_value) {
|
83
|
+
[
|
84
|
+
Vedeu::Row.new([:hydrogen, :helium]),
|
85
|
+
[:lithium],
|
86
|
+
Vedeu::Row.new([:beryllium, :boron]),
|
87
|
+
]
|
88
|
+
}
|
89
|
+
let(:expected) {
|
90
|
+
Vedeu::Page.new([
|
91
|
+
Vedeu::Row.new([:hydrogen, :helium]),
|
92
|
+
Vedeu::Row.new([:lithium]),
|
93
|
+
Vedeu::Row.new([:beryllium, :boron]),
|
94
|
+
])
|
95
|
+
}
|
96
|
+
|
97
|
+
it { subject.must_equal(expected) }
|
98
|
+
end
|
99
|
+
|
100
|
+
context 'a mix of Vedeu::Row objects, other objects and nils' do
|
101
|
+
let(:_value) {
|
102
|
+
[
|
103
|
+
Vedeu::Row.new([:hydrogen, :helium]),
|
104
|
+
nil,
|
105
|
+
[:lithium],
|
106
|
+
Vedeu::Row.new([:beryllium, :boron]),
|
107
|
+
[nil, :carbon],
|
108
|
+
]
|
109
|
+
}
|
110
|
+
let(:expected) {
|
111
|
+
Vedeu::Page.new([
|
112
|
+
Vedeu::Row.new([:hydrogen, :helium]),
|
113
|
+
Vedeu::Row.new([]),
|
114
|
+
Vedeu::Row.new([:lithium]),
|
115
|
+
Vedeu::Row.new([:beryllium, :boron]),
|
116
|
+
Vedeu::Row.new([:carbon]),
|
117
|
+
])
|
118
|
+
}
|
119
|
+
|
120
|
+
it { subject.must_equal(expected) }
|
121
|
+
end
|
122
|
+
|
123
|
+
end
|
124
|
+
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
describe '#each' do
|
129
|
+
subject { instance.each }
|
130
|
+
|
131
|
+
it { subject.must_be_instance_of(Enumerator) }
|
132
|
+
end
|
133
|
+
|
134
|
+
describe '#eql?' do
|
135
|
+
let(:other) { instance }
|
136
|
+
|
137
|
+
subject { instance.eql?(other) }
|
138
|
+
|
139
|
+
it { subject.must_equal(true) }
|
140
|
+
|
141
|
+
context 'when different to other' do
|
142
|
+
let(:other) { described.new([:hydrogen]) }
|
143
|
+
|
144
|
+
it { subject.must_equal(false) }
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
148
|
+
describe '#row' do
|
149
|
+
let(:index) {}
|
150
|
+
|
151
|
+
subject { instance.row(index) }
|
152
|
+
|
153
|
+
context 'when the index is nil' do
|
154
|
+
it { subject.must_equal(nil) }
|
155
|
+
end
|
156
|
+
|
157
|
+
context 'when the index is not nil' do
|
158
|
+
context 'and the index is in range' do
|
159
|
+
let(:index) { 1 }
|
160
|
+
|
161
|
+
it { subject.must_equal([:beryllium, :boron, :carbon]) }
|
162
|
+
end
|
163
|
+
|
164
|
+
context 'and the index is out of range' do
|
165
|
+
let(:index) { 4 }
|
166
|
+
|
167
|
+
it { subject.must_equal(nil) }
|
168
|
+
end
|
169
|
+
|
170
|
+
context 'and the index is out of range' do
|
171
|
+
let(:index) { -4 }
|
172
|
+
|
173
|
+
it { subject.must_equal(nil) }
|
174
|
+
end
|
175
|
+
end
|
176
|
+
end
|
177
|
+
|
178
|
+
describe '#cell' do
|
179
|
+
let(:row_index) {}
|
180
|
+
let(:cell_index) {}
|
181
|
+
|
182
|
+
subject { instance.cell(row_index, cell_index) }
|
183
|
+
|
184
|
+
context 'when the row_index is nil' do
|
185
|
+
it { subject.must_equal(nil) }
|
186
|
+
end
|
187
|
+
|
188
|
+
context 'when the row_index is not nil' do
|
189
|
+
let(:row_index) { 1 }
|
190
|
+
|
191
|
+
context 'and the row_index is in range' do
|
192
|
+
let(:row_index) { 1 }
|
193
|
+
|
194
|
+
context 'when the cell_index is nil' do
|
195
|
+
it { subject.must_equal(nil) }
|
196
|
+
end
|
197
|
+
|
198
|
+
context 'when the cell_index is not nil' do
|
199
|
+
context 'and the cell_index is in range' do
|
200
|
+
let(:cell_index) { 2 }
|
201
|
+
|
202
|
+
it { subject.must_equal(:carbon) }
|
203
|
+
end
|
204
|
+
|
205
|
+
context 'and the cell_index is out of range' do
|
206
|
+
let(:cell_index) { 4 }
|
207
|
+
|
208
|
+
it { subject.must_equal(nil) }
|
209
|
+
end
|
210
|
+
|
211
|
+
context 'and the cell_index is out of range' do
|
212
|
+
let(:cell_index) { -4 }
|
213
|
+
|
214
|
+
it { subject.must_equal(nil) }
|
215
|
+
end
|
216
|
+
end
|
217
|
+
end
|
218
|
+
|
219
|
+
context 'and the row_index is out of range' do
|
220
|
+
let(:row_index) { 4 }
|
221
|
+
|
222
|
+
it { subject.must_equal(nil) }
|
223
|
+
end
|
224
|
+
|
225
|
+
context 'and the row_index is out of range' do
|
226
|
+
let(:row_index) { -4 }
|
227
|
+
|
228
|
+
it { subject.must_equal(nil) }
|
229
|
+
end
|
230
|
+
end
|
231
|
+
end
|
232
|
+
|
233
|
+
end # Page
|
234
|
+
|
235
|
+
end # Vedeu
|
@@ -0,0 +1,111 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Vedeu
|
4
|
+
|
5
|
+
describe Row do
|
6
|
+
|
7
|
+
let(:described) { Vedeu::Row }
|
8
|
+
let(:instance) { described.new(cells) }
|
9
|
+
let(:cells) { [:hydrogen, :helium, :lithium] }
|
10
|
+
|
11
|
+
describe '#initialize' do
|
12
|
+
it { instance.must_be_instance_of(described) }
|
13
|
+
|
14
|
+
context 'when there are no cells' do
|
15
|
+
let(:cells) {}
|
16
|
+
|
17
|
+
it { instance.instance_variable_get('@cells').must_equal([]) }
|
18
|
+
end
|
19
|
+
|
20
|
+
context 'when there are cells' do
|
21
|
+
it { instance.instance_variable_get('@cells').must_equal(cells) }
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
describe '.coerce' do
|
26
|
+
subject { described.coerce(_value) }
|
27
|
+
|
28
|
+
context 'when the value is a Vedeu::Row' do
|
29
|
+
let(:_value) { Vedeu::Row.new }
|
30
|
+
|
31
|
+
it { subject.must_equal(_value) }
|
32
|
+
end
|
33
|
+
|
34
|
+
context 'when the value is an Array' do
|
35
|
+
let(:_value) { [:hydrogen, :helium, :lithium] }
|
36
|
+
|
37
|
+
it { subject.must_equal(Vedeu::Row.new(_value)) }
|
38
|
+
end
|
39
|
+
|
40
|
+
context 'when the value is an Array containing nil objects' do
|
41
|
+
let(:_value) { [:hydrogen, nil, :lithium] }
|
42
|
+
|
43
|
+
it { subject.must_equal(Vedeu::Row.new([:hydrogen, :lithium])) }
|
44
|
+
end
|
45
|
+
|
46
|
+
context 'when the value is nil' do
|
47
|
+
let(:_value) {}
|
48
|
+
|
49
|
+
it { subject.must_equal(Vedeu::Row.new) }
|
50
|
+
end
|
51
|
+
|
52
|
+
context 'when the value is anything else' do
|
53
|
+
let(:_value) { :beryllium }
|
54
|
+
|
55
|
+
it { subject.must_equal(Vedeu::Row.new([_value])) }
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
describe '#each' do
|
60
|
+
subject { instance.each }
|
61
|
+
|
62
|
+
it { subject.must_be_instance_of(Enumerator) }
|
63
|
+
end
|
64
|
+
|
65
|
+
describe '#eql?' do
|
66
|
+
let(:other) { instance }
|
67
|
+
|
68
|
+
subject { instance.eql?(other) }
|
69
|
+
|
70
|
+
it { subject.must_equal(true) }
|
71
|
+
|
72
|
+
context 'when different to other' do
|
73
|
+
let(:other) { described.new([:hydrogen]) }
|
74
|
+
|
75
|
+
it { subject.must_equal(false) }
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
describe '#cell' do
|
80
|
+
let(:index) {}
|
81
|
+
|
82
|
+
subject { instance.cell(index) }
|
83
|
+
|
84
|
+
context 'when the index is nil' do
|
85
|
+
it { subject.must_equal(nil) }
|
86
|
+
end
|
87
|
+
|
88
|
+
context 'when the index is not nil' do
|
89
|
+
context 'and the index is in range' do
|
90
|
+
let(:index) { 1 }
|
91
|
+
|
92
|
+
it { subject.must_equal(:helium) }
|
93
|
+
end
|
94
|
+
|
95
|
+
context 'and the index is out of range' do
|
96
|
+
let(:index) { 4 }
|
97
|
+
|
98
|
+
it { subject.must_equal(nil) }
|
99
|
+
end
|
100
|
+
|
101
|
+
context 'and the index is out of range' do
|
102
|
+
let(:index) { -4 }
|
103
|
+
|
104
|
+
it { subject.must_equal(nil) }
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
end # Row
|
110
|
+
|
111
|
+
end # Vedeu
|
@@ -118,7 +118,7 @@ module Vedeu
|
|
118
118
|
it { subject.must_be_instance_of(String) }
|
119
119
|
|
120
120
|
context 'when a position is specified' do
|
121
|
-
let(:position) { Vedeu::Position[17, 2] }
|
121
|
+
let(:position) { Vedeu::Geometry::Position[17, 2] }
|
122
122
|
|
123
123
|
it { subject.must_equal("\e[17;2Ha") }
|
124
124
|
end
|
@@ -204,7 +204,7 @@ module Vedeu
|
|
204
204
|
end
|
205
205
|
|
206
206
|
describe '#x' do
|
207
|
-
let(:position) { Vedeu::Position[17, 2] }
|
207
|
+
let(:position) { Vedeu::Geometry::Position[17, 2] }
|
208
208
|
|
209
209
|
subject { instance.x }
|
210
210
|
|
@@ -220,7 +220,7 @@ module Vedeu
|
|
220
220
|
end
|
221
221
|
|
222
222
|
describe '#y' do
|
223
|
-
let(:position) { Vedeu::Position[17, 2] }
|
223
|
+
let(:position) { Vedeu::Geometry::Position[17, 2] }
|
224
224
|
|
225
225
|
subject { instance.y }
|
226
226
|
|
@@ -0,0 +1,57 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Vedeu
|
4
|
+
|
5
|
+
describe Options do
|
6
|
+
|
7
|
+
let(:described) { Vedeu::Options }
|
8
|
+
let(:instance) { described.new(options, defaults) }
|
9
|
+
let(:options) {}
|
10
|
+
let(:defaults) {}
|
11
|
+
|
12
|
+
describe '#initialize' do
|
13
|
+
subject { instance }
|
14
|
+
|
15
|
+
it { instance.must_be_instance_of(described) }
|
16
|
+
|
17
|
+
context 'when the options are nil and defaults are nil' do
|
18
|
+
it { instance.instance_variable_get('@options').must_equal({}) }
|
19
|
+
it { instance.instance_variable_get('@defaults').must_equal({}) }
|
20
|
+
end
|
21
|
+
|
22
|
+
context 'when the options are empty and the defaults are empty' do
|
23
|
+
let(:options) { {} }
|
24
|
+
let(:defaults) { {} }
|
25
|
+
|
26
|
+
it { instance.instance_variable_get('@options').must_equal({}) }
|
27
|
+
it { instance.instance_variable_get('@defaults').must_equal({}) }
|
28
|
+
end
|
29
|
+
|
30
|
+
context 'when an option is set but no default is set' do
|
31
|
+
let(:options) { { element: :hydrogen } }
|
32
|
+
let(:defaults) { {} }
|
33
|
+
|
34
|
+
it { (instance.methods - Object.methods).must_equal([:element]) }
|
35
|
+
it { instance.element.must_equal(:hydrogen) }
|
36
|
+
end
|
37
|
+
|
38
|
+
context 'when an option is set but a default is set' do
|
39
|
+
let(:options) { { element: :lithium } }
|
40
|
+
let(:defaults) { { element: :helium } }
|
41
|
+
|
42
|
+
it { (instance.methods - Object.methods).must_equal([:element]) }
|
43
|
+
it { instance.element.must_equal(:lithium) }
|
44
|
+
end
|
45
|
+
|
46
|
+
context 'when no option is set but a default is set' do
|
47
|
+
let(:options) { {} }
|
48
|
+
let(:defaults) { { element: :beryllium } }
|
49
|
+
|
50
|
+
it { (instance.methods - Object.methods).must_equal([:element]) }
|
51
|
+
it { instance.element.must_equal(:beryllium) }
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
end # Options
|
56
|
+
|
57
|
+
end # Vedeu
|