vedeu 0.3.3 → 0.3.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/vedeu_drb_client +6 -0
- data/lib/vedeu/all.rb +1 -0
- data/lib/vedeu/application.rb +24 -1
- data/lib/vedeu/configuration/api.rb +107 -0
- data/lib/vedeu/configuration/cli.rb +34 -0
- data/lib/vedeu/configuration/configuration.rb +75 -4
- data/lib/vedeu/distributed/all.rb +8 -0
- data/lib/vedeu/distributed/application.rb +91 -0
- data/lib/vedeu/distributed/client.rb +58 -0
- data/lib/vedeu/distributed/subprocess.rb +111 -0
- data/lib/vedeu/distributed/templates/default_application.vedeu +34 -0
- data/lib/vedeu/distributed/templates/default_borders.vedeu +19 -0
- data/lib/vedeu/distributed/templates/default_configuration.vedeu +31 -0
- data/lib/vedeu/distributed/templates/default_events.vedeu +1 -0
- data/lib/vedeu/distributed/templates/default_geometries.vedeu +7 -0
- data/lib/vedeu/distributed/templates/default_interfaces.vedeu +4 -0
- data/lib/vedeu/distributed/templates/default_keymaps.vedeu +6 -0
- data/lib/vedeu/distributed/templates/default_menus.vedeu +3 -0
- data/lib/vedeu/distributed/templates/default_views.vedeu +14 -0
- data/lib/vedeu/distributed/test_application.rb +99 -0
- data/lib/vedeu/distributed/uri.rb +38 -0
- data/lib/vedeu/input/mapper.rb +10 -0
- data/lib/vedeu/launcher.rb +4 -0
- data/lib/vedeu/models/geometry.rb +16 -31
- data/lib/vedeu/models/view/char.rb +5 -5
- data/lib/vedeu/models/view/interface.rb +2 -1
- data/lib/vedeu/output/all.rb +2 -0
- data/lib/vedeu/output/output.rb +40 -0
- data/lib/vedeu/output/position_index.rb +24 -0
- data/lib/vedeu/output/virtual_terminal.rb +87 -0
- data/lib/vedeu/support/all.rb +1 -0
- data/lib/vedeu/support/limit.rb +33 -0
- data/lib/vedeu/support/position.rb +29 -0
- data/lib/vedeu/support/terminal.rb +14 -2
- data/test/integration/distributed_test.rb +14 -0
- data/test/lib/vedeu/application_test.rb +7 -6
- data/test/lib/vedeu/buffers/buffer_test.rb +6 -8
- data/test/lib/vedeu/configuration/api_test.rb +50 -0
- data/test/lib/vedeu/configuration/cli_test.rb +21 -0
- data/test/lib/vedeu/configuration/configuration_test.rb +24 -0
- data/test/lib/vedeu/cursor/move_cursor_test.rb +5 -7
- data/test/lib/vedeu/distributed/application_test.rb +24 -0
- data/test/lib/vedeu/distributed/client_test.rb +36 -0
- data/test/lib/vedeu/distributed/subprocess_test.rb +20 -0
- data/test/lib/vedeu/distributed/test_application_test.rb +26 -0
- data/test/lib/vedeu/distributed/uri_test.rb +73 -0
- data/test/lib/vedeu/dsl/components/border_test.rb +3 -5
- data/test/lib/vedeu/dsl/components/keymap_test.rb +2 -4
- data/test/lib/vedeu/dsl/components/menu_test.rb +2 -4
- data/test/lib/vedeu/dsl/composition_test.rb +3 -5
- data/test/lib/vedeu/dsl/interface_test.rb +3 -5
- data/test/lib/vedeu/dsl/line_test.rb +3 -5
- data/test/lib/vedeu/dsl/stream_test.rb +3 -5
- data/test/lib/vedeu/events/event_test.rb +8 -10
- data/test/lib/vedeu/events/trigger_test.rb +4 -6
- data/test/lib/vedeu/input/input_test.rb +2 -4
- data/test/lib/vedeu/input/key_test.rb +0 -2
- data/test/lib/vedeu/input/keymap_test.rb +4 -6
- data/test/lib/vedeu/input/mapper_test.rb +5 -7
- data/test/lib/vedeu/launcher_test.rb +7 -9
- data/test/lib/vedeu/models/collection_test.rb +4 -6
- data/test/lib/vedeu/models/geometry_test.rb +40 -13
- data/test/lib/vedeu/models/group_test.rb +4 -6
- data/test/lib/vedeu/models/menu_test.rb +6 -9
- data/test/lib/vedeu/models/view/char_test.rb +7 -9
- data/test/lib/vedeu/models/view/chars_test.rb +1 -3
- data/test/lib/vedeu/models/view/composition_test.rb +4 -6
- data/test/lib/vedeu/models/view/interface_test.rb +10 -12
- data/test/lib/vedeu/models/view/interfaces_test.rb +1 -3
- data/test/lib/vedeu/models/view/line_test.rb +5 -7
- data/test/lib/vedeu/models/view/lines_test.rb +1 -3
- data/test/lib/vedeu/models/view/stream_test.rb +6 -8
- data/test/lib/vedeu/models/view/streams_test.rb +1 -3
- data/test/lib/vedeu/output/border_test.rb +6 -8
- data/test/lib/vedeu/output/compositor_test.rb +2 -4
- data/test/lib/vedeu/output/output_test.rb +5 -4
- data/test/lib/vedeu/output/position_index_test.rb +72 -0
- data/test/lib/vedeu/output/viewport_test.rb +2 -4
- data/test/lib/vedeu/output/virtual_terminal_test.rb +120 -0
- data/test/lib/vedeu/output/wordwrap_test.rb +3 -5
- data/test/lib/vedeu/presentation/colour_test.rb +0 -2
- data/test/lib/vedeu/presentation/style_test.rb +2 -4
- data/test/lib/vedeu/presentation/translator_test.rb +2 -4
- data/test/lib/vedeu/repositories/repository_test.rb +3 -5
- data/test/lib/vedeu/support/console_test.rb +5 -7
- data/test/lib/vedeu/support/content_geometry_test.rb +2 -4
- data/test/lib/vedeu/support/coordinate_test.rb +5 -7
- data/test/lib/vedeu/support/grid_test.rb +2 -4
- data/test/lib/vedeu/support/limit_test.rb +30 -0
- data/test/lib/vedeu/support/position_test.rb +8 -4
- data/test/lib/vedeu/support/position_validator_test.rb +4 -6
- data/test/lib/vedeu/support/read_test.rb +3 -5
- data/test/lib/vedeu/support/sentence_test.rb +3 -4
- data/test/lib/vedeu/support/trace_test.rb +2 -4
- data/test/lib/vedeu/support/visible_test.rb +6 -8
- data/test/lib/vedeu/support/write_test.rb +3 -5
- data/test/test_helper.rb +6 -2
- data/vedeu.gemspec +1 -1
- metadata +40 -2
@@ -13,12 +13,10 @@ module Vedeu
|
|
13
13
|
end
|
14
14
|
|
15
15
|
describe '#initialize' do
|
16
|
-
|
17
|
-
|
18
|
-
it { subject.must_be_instance_of(Geometry) }
|
16
|
+
it { instance.must_be_instance_of(Geometry) }
|
19
17
|
|
20
18
|
context 'with default attributes' do
|
21
|
-
it {
|
19
|
+
it { instance.instance_variable_get('@attributes').must_equal({
|
22
20
|
centred: false,
|
23
21
|
client: nil,
|
24
22
|
height: 25,
|
@@ -30,15 +28,15 @@ module Vedeu
|
|
30
28
|
yn: 25,
|
31
29
|
})
|
32
30
|
}
|
33
|
-
it {
|
34
|
-
it {
|
35
|
-
it {
|
36
|
-
it {
|
37
|
-
it {
|
38
|
-
it {
|
39
|
-
it {
|
40
|
-
it {
|
41
|
-
it {
|
31
|
+
it { instance.instance_variable_get('@centred').must_equal(false) }
|
32
|
+
it { instance.instance_variable_get('@height').must_equal(25) }
|
33
|
+
it { instance.instance_variable_get('@name').must_equal('') }
|
34
|
+
it { instance.instance_variable_get('@width').must_equal(80) }
|
35
|
+
it { instance.instance_variable_get('@x').must_equal(1) }
|
36
|
+
it { instance.instance_variable_get('@xn').must_equal(80) }
|
37
|
+
it { instance.instance_variable_get('@y').must_equal(1) }
|
38
|
+
it { instance.instance_variable_get('@yn').must_equal(25) }
|
39
|
+
it { instance.instance_variable_get('@repository').must_equal(Vedeu.geometries) }
|
42
40
|
end
|
43
41
|
end
|
44
42
|
|
@@ -171,6 +169,35 @@ module Vedeu
|
|
171
169
|
end
|
172
170
|
end
|
173
171
|
|
172
|
+
describe '#raw_origin' do
|
173
|
+
it 'returns the origin for the interface' do
|
174
|
+
geometry = Geometry.new({ width: 5, height: 5 })
|
175
|
+
geometry.raw_origin.must_equal([1, 1])
|
176
|
+
end
|
177
|
+
|
178
|
+
it 'returns the origin for the interface' do
|
179
|
+
geometry = Geometry.new({ width: 5, height: 5, centred: true })
|
180
|
+
geometry.raw_origin.must_equal([10, 38])
|
181
|
+
end
|
182
|
+
|
183
|
+
it 'returns the line position relative to the origin' do
|
184
|
+
geometry = Geometry.new({ width: 5, height: 5 })
|
185
|
+
geometry.raw_origin(3).must_equal([4, 1])
|
186
|
+
end
|
187
|
+
|
188
|
+
it 'returns the origin for the interface when the interface' \
|
189
|
+
' is at a custom position' do
|
190
|
+
geometry = Geometry.new({ width: 5, height: 5, x: 3, y: 6 })
|
191
|
+
geometry.raw_origin.must_equal([6, 3])
|
192
|
+
end
|
193
|
+
|
194
|
+
it 'returns the line position relative to the origin when the' \
|
195
|
+
' interface is at a custom position' do
|
196
|
+
geometry = Geometry.new({ width: 5, height: 5, x: 3, y: 6 })
|
197
|
+
geometry.raw_origin(3).must_equal([9, 3])
|
198
|
+
end
|
199
|
+
end
|
200
|
+
|
174
201
|
describe '#top' do
|
175
202
|
it 'centred is true' do
|
176
203
|
console = IO.console
|
@@ -10,12 +10,10 @@ module Vedeu
|
|
10
10
|
let(:members) { ['carbon', 'nitrogen', 'oxygen'] }
|
11
11
|
|
12
12
|
describe '#initialize' do
|
13
|
-
|
14
|
-
|
15
|
-
it {
|
16
|
-
it {
|
17
|
-
it { subject.instance_variable_get('@name').must_equal(_name) }
|
18
|
-
it { subject.instance_variable_get('@repository').must_equal(Vedeu.groups) }
|
13
|
+
it { instance.must_be_instance_of(Group) }
|
14
|
+
it { instance.instance_variable_get('@members').must_equal(members) }
|
15
|
+
it { instance.instance_variable_get('@name').must_equal(_name) }
|
16
|
+
it { instance.instance_variable_get('@repository').must_equal(Vedeu.groups) }
|
19
17
|
end
|
20
18
|
|
21
19
|
describe '#add' do
|
@@ -38,15 +38,12 @@ module Vedeu
|
|
38
38
|
end
|
39
39
|
|
40
40
|
describe '#initialize' do
|
41
|
-
|
42
|
-
|
43
|
-
it {
|
44
|
-
|
45
|
-
it {
|
46
|
-
it {
|
47
|
-
it { subject.instance_variable_get('@current').must_equal(0) }
|
48
|
-
it { subject.instance_variable_get('@selected').must_equal(nil) }
|
49
|
-
it { subject.instance_variable_get('@repository').must_equal(Vedeu.menus) }
|
41
|
+
it { instance.must_be_instance_of(described) }
|
42
|
+
it { instance.instance_variable_get('@collection').must_equal(collection) }
|
43
|
+
it { instance.instance_variable_get('@name').must_equal('elements') }
|
44
|
+
it { instance.instance_variable_get('@current').must_equal(0) }
|
45
|
+
it { instance.instance_variable_get('@selected').must_equal(nil) }
|
46
|
+
it { instance.instance_variable_get('@repository').must_equal(Vedeu.menus) }
|
50
47
|
end
|
51
48
|
|
52
49
|
describe '#current' do
|
@@ -59,20 +59,18 @@ module Vedeu
|
|
59
59
|
end
|
60
60
|
|
61
61
|
describe '#initialize' do
|
62
|
-
|
63
|
-
|
64
|
-
it {
|
65
|
-
it {
|
66
|
-
it {
|
67
|
-
it {
|
68
|
-
it { subject.instance_variable_get('@value').must_equal(value) }
|
69
|
-
it { subject.instance_variable_get('@position').must_equal(position) }
|
62
|
+
it { instance.must_be_instance_of(Char) }
|
63
|
+
it { instance.instance_variable_get('@colour').must_be_instance_of(Vedeu::Colour) }
|
64
|
+
it { instance.instance_variable_get('@parent').must_equal(parent) }
|
65
|
+
it { instance.instance_variable_get('@style').must_equal(style) }
|
66
|
+
it { instance.instance_variable_get('@value').must_equal(value) }
|
67
|
+
it { instance.instance_variable_get('@position').must_equal(position) }
|
70
68
|
end
|
71
69
|
|
72
70
|
describe '#inspect' do
|
73
71
|
subject { instance.inspect }
|
74
72
|
|
75
|
-
it { subject.must_equal(
|
73
|
+
it { subject.must_equal("<Vedeu::Char (value:'a')>") }
|
76
74
|
end
|
77
75
|
|
78
76
|
describe '#value' do
|
@@ -28,12 +28,10 @@ module Vedeu
|
|
28
28
|
end
|
29
29
|
|
30
30
|
describe '#initialize' do
|
31
|
-
|
32
|
-
|
33
|
-
it {
|
34
|
-
it {
|
35
|
-
it { subject.instance_variable_get('@colour').must_be_instance_of(Vedeu::Colour) }
|
36
|
-
it { subject.instance_variable_get('@style').must_be_instance_of(Vedeu::Style) }
|
31
|
+
it { instance.must_be_instance_of(described) }
|
32
|
+
it { instance.instance_variable_get('@interfaces').must_equal(interfaces) }
|
33
|
+
it { instance.instance_variable_get('@colour').must_be_instance_of(Vedeu::Colour) }
|
34
|
+
it { instance.instance_variable_get('@style').must_be_instance_of(Vedeu::Style) }
|
37
35
|
end
|
38
36
|
|
39
37
|
describe '#inspect' do
|
@@ -22,18 +22,16 @@ module Vedeu
|
|
22
22
|
let(:style) {}
|
23
23
|
|
24
24
|
describe '#initialize' do
|
25
|
-
|
26
|
-
|
27
|
-
it {
|
28
|
-
it {
|
29
|
-
it {
|
30
|
-
it {
|
31
|
-
it {
|
32
|
-
it {
|
33
|
-
it {
|
34
|
-
it {
|
35
|
-
it { subject.instance_variable_get('@group').must_equal('') }
|
36
|
-
it { subject.instance_variable_get('@repository').must_equal(Vedeu.interfaces) }
|
25
|
+
it { instance.instance_variable_get('@name').must_equal(_name) }
|
26
|
+
it { instance.instance_variable_get('@lines').must_equal(lines) }
|
27
|
+
it { instance.instance_variable_get('@parent').must_equal(parent) }
|
28
|
+
it { instance.instance_variable_get('@colour').must_be_instance_of(Vedeu::Colour) }
|
29
|
+
it { instance.instance_variable_get('@style').must_be_instance_of(Vedeu::Style) }
|
30
|
+
it { instance.instance_variable_get('@border').must_equal(nil) }
|
31
|
+
it { instance.instance_variable_get('@delay').must_equal(0.0) }
|
32
|
+
it { instance.instance_variable_get('@geometry').must_equal(nil) }
|
33
|
+
it { instance.instance_variable_get('@group').must_equal('') }
|
34
|
+
it { instance.instance_variable_get('@repository').must_equal(Vedeu.interfaces) }
|
37
35
|
end
|
38
36
|
|
39
37
|
describe '#border?' do
|
@@ -43,13 +43,11 @@ module Vedeu
|
|
43
43
|
end
|
44
44
|
|
45
45
|
describe '#initialize' do
|
46
|
-
|
47
|
-
|
48
|
-
it {
|
49
|
-
it {
|
50
|
-
it {
|
51
|
-
it { subject.instance_variable_get('@colour').must_equal(colour) }
|
52
|
-
it { subject.instance_variable_get('@style').must_equal(style) }
|
46
|
+
it { instance.must_be_instance_of(described) }
|
47
|
+
it { instance.instance_variable_get('@streams').must_equal(streams) }
|
48
|
+
it { instance.instance_variable_get('@parent').must_equal(parent) }
|
49
|
+
it { instance.instance_variable_get('@colour').must_equal(colour) }
|
50
|
+
it { instance.instance_variable_get('@style').must_equal(style) }
|
53
51
|
end
|
54
52
|
|
55
53
|
describe '#chars' do
|
@@ -28,14 +28,12 @@ module Vedeu
|
|
28
28
|
let(:line_parent) { mock('Vedeu::Interface') }
|
29
29
|
|
30
30
|
describe '#initialize' do
|
31
|
-
|
32
|
-
|
33
|
-
it {
|
34
|
-
|
35
|
-
it {
|
36
|
-
it {
|
37
|
-
it { subject.instance_variable_get('@colour').must_equal(colour) }
|
38
|
-
it { subject.instance_variable_get('@style').must_equal(style) }
|
31
|
+
it { instance.must_be_instance_of(described) }
|
32
|
+
# it { instance.instance_variable_get('@attributes').must_equal(attributes) }
|
33
|
+
it { instance.instance_variable_get('@value').must_equal(value) }
|
34
|
+
it { instance.instance_variable_get('@parent').must_equal(parent) }
|
35
|
+
it { instance.instance_variable_get('@colour').must_equal(colour) }
|
36
|
+
it { instance.instance_variable_get('@style').must_equal(style) }
|
39
37
|
end
|
40
38
|
|
41
39
|
describe '#add' do
|
@@ -41,10 +41,8 @@ module Vedeu
|
|
41
41
|
end
|
42
42
|
|
43
43
|
describe '#initialize' do
|
44
|
-
|
45
|
-
|
46
|
-
it { subject.must_be_instance_of(described) }
|
47
|
-
it { subject.instance_variable_get('@attributes').must_equal(
|
44
|
+
it { instance.must_be_instance_of(described) }
|
45
|
+
it { instance.instance_variable_get('@attributes').must_equal(
|
48
46
|
{
|
49
47
|
bottom_left: 'm',
|
50
48
|
bottom_right: 'j',
|
@@ -63,10 +61,10 @@ module Vedeu
|
|
63
61
|
vertical: 'x',
|
64
62
|
})
|
65
63
|
}
|
66
|
-
it {
|
67
|
-
it {
|
68
|
-
it {
|
69
|
-
it {
|
64
|
+
it { instance.instance_variable_get('@colour').must_be_instance_of(Vedeu::Colour) }
|
65
|
+
it { instance.instance_variable_get('@name').must_equal('borders') }
|
66
|
+
it { instance.instance_variable_get('@repository').must_be_instance_of(Vedeu::Borders) }
|
67
|
+
it { instance.instance_variable_get('@style').must_be_instance_of(Vedeu::Style) }
|
70
68
|
end
|
71
69
|
|
72
70
|
describe '#width' do
|
@@ -31,10 +31,8 @@ module Vedeu
|
|
31
31
|
end
|
32
32
|
|
33
33
|
describe '#initialize' do
|
34
|
-
|
35
|
-
|
36
|
-
it { subject.must_be_instance_of(Compositor) }
|
37
|
-
it { subject.instance_variable_get('@name').must_equal(_name) }
|
34
|
+
it { instance.must_be_instance_of(Compositor) }
|
35
|
+
it { instance.instance_variable_get('@name').must_equal(_name) }
|
38
36
|
end
|
39
37
|
|
40
38
|
describe '.compose' do
|
@@ -4,7 +4,8 @@ module Vedeu
|
|
4
4
|
|
5
5
|
describe Output do
|
6
6
|
|
7
|
-
let(:described) { Output
|
7
|
+
let(:described) { Vedeu::Output }
|
8
|
+
let(:instance) { described.new(interface) }
|
8
9
|
let(:interface) {
|
9
10
|
Vedeu.interface 'flourine' do
|
10
11
|
geometry do
|
@@ -28,12 +29,12 @@ module Vedeu
|
|
28
29
|
end
|
29
30
|
|
30
31
|
describe '#initialize' do
|
31
|
-
it {
|
32
|
-
it {
|
32
|
+
it { instance.must_be_instance_of(described) }
|
33
|
+
it { instance.instance_variable_get('@interface').must_equal(interface) }
|
33
34
|
end
|
34
35
|
|
35
36
|
describe '.render' do
|
36
|
-
subject {
|
37
|
+
subject { described.render(interface) }
|
37
38
|
|
38
39
|
it { subject.must_be_instance_of(Array) }
|
39
40
|
|
@@ -0,0 +1,72 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Vedeu
|
4
|
+
|
5
|
+
describe PositionIndex do
|
6
|
+
|
7
|
+
let(:described) { Vedeu::PositionIndex }
|
8
|
+
let(:instance) { described.new(y, x) }
|
9
|
+
let(:y) { 6 }
|
10
|
+
let(:x) { 17 }
|
11
|
+
|
12
|
+
describe '#initialize' do
|
13
|
+
it { instance.must_be_instance_of(described) }
|
14
|
+
it { instance.instance_variable_get('@y').must_equal(5) }
|
15
|
+
it { instance.instance_variable_get('@x').must_equal(16) }
|
16
|
+
|
17
|
+
context 'when y is less than 1' do
|
18
|
+
let(:y) { -3 }
|
19
|
+
|
20
|
+
it { instance.instance_variable_get('@y').must_equal(1) }
|
21
|
+
end
|
22
|
+
|
23
|
+
context 'when x is less than 1' do
|
24
|
+
let(:x) { -9 }
|
25
|
+
|
26
|
+
it { instance.instance_variable_get('@x').must_equal(1) }
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe '.[]' do
|
31
|
+
subject { described[y, x] }
|
32
|
+
|
33
|
+
it { subject.must_be_instance_of(Array) }
|
34
|
+
it { subject.must_equal([5, 16]) }
|
35
|
+
end
|
36
|
+
|
37
|
+
describe '#[]' do
|
38
|
+
subject { instance.[] }
|
39
|
+
|
40
|
+
it { subject.must_be_instance_of(Array) }
|
41
|
+
it { subject.must_equal([5, 16]) }
|
42
|
+
end
|
43
|
+
|
44
|
+
describe 'attr_reader' do
|
45
|
+
context '#y' do
|
46
|
+
subject { instance.y }
|
47
|
+
|
48
|
+
it { subject.must_equal(5) }
|
49
|
+
|
50
|
+
context 'alias method: first' do
|
51
|
+
subject { instance.first }
|
52
|
+
|
53
|
+
it { subject.must_equal(5) }
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
context '#x' do
|
58
|
+
subject { instance.x }
|
59
|
+
|
60
|
+
it { subject.must_equal(16) }
|
61
|
+
|
62
|
+
context 'alias method: last' do
|
63
|
+
subject { instance.last }
|
64
|
+
|
65
|
+
it { subject.must_equal(16) }
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
end # PositionIndex
|
71
|
+
|
72
|
+
end # Vedeu
|
@@ -24,10 +24,8 @@ module Vedeu
|
|
24
24
|
}
|
25
25
|
|
26
26
|
describe '#initialize' do
|
27
|
-
|
28
|
-
|
29
|
-
it { subject.must_be_instance_of(Viewport) }
|
30
|
-
it { subject.instance_variable_get('@interface').must_equal(interface) }
|
27
|
+
it { instance.must_be_instance_of(Viewport) }
|
28
|
+
it { instance.instance_variable_get('@interface').must_equal(interface) }
|
31
29
|
end
|
32
30
|
|
33
31
|
describe '#render' do
|
@@ -0,0 +1,120 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Vedeu
|
4
|
+
|
5
|
+
describe VirtualTerminal do
|
6
|
+
|
7
|
+
let(:described) { Vedeu::VirtualTerminal }
|
8
|
+
let(:instance) { described.new(height, width) }
|
9
|
+
let(:height) { 5 }
|
10
|
+
let(:width) { 10 }
|
11
|
+
|
12
|
+
describe '#initialize' do
|
13
|
+
it { instance.must_be_instance_of(Vedeu::VirtualTerminal) }
|
14
|
+
it { instance.instance_variable_get('@cell_height').must_equal(4) }
|
15
|
+
it { instance.instance_variable_get('@cell_width').must_equal(9) }
|
16
|
+
it { instance.instance_variable_get('@height').must_equal(5) }
|
17
|
+
it { instance.instance_variable_get('@width').must_equal(10) }
|
18
|
+
end
|
19
|
+
|
20
|
+
describe 'attr_reader' do
|
21
|
+
context '#cell_height' do
|
22
|
+
subject { instance.cell_height }
|
23
|
+
|
24
|
+
it { subject.must_equal(4) }
|
25
|
+
end
|
26
|
+
|
27
|
+
context '#cell_width' do
|
28
|
+
subject { instance.cell_width }
|
29
|
+
|
30
|
+
it { subject.must_equal(9) }
|
31
|
+
end
|
32
|
+
|
33
|
+
context '#height' do
|
34
|
+
subject { instance.height }
|
35
|
+
|
36
|
+
it { subject.must_equal(5) }
|
37
|
+
end
|
38
|
+
|
39
|
+
context '#width' do
|
40
|
+
subject { instance.width }
|
41
|
+
|
42
|
+
it { subject.must_equal(10) }
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
describe '#cells' do
|
47
|
+
subject { instance.cells }
|
48
|
+
|
49
|
+
it { subject.must_be_instance_of(Array) }
|
50
|
+
end
|
51
|
+
|
52
|
+
describe '#read' do
|
53
|
+
subject { instance.read(y, x) }
|
54
|
+
|
55
|
+
context 'when x is out of bounds' do
|
56
|
+
let(:y) { 3 }
|
57
|
+
let(:x) { 15 }
|
58
|
+
|
59
|
+
it { subject.must_equal([]) }
|
60
|
+
end
|
61
|
+
|
62
|
+
context 'when y is out of bounds' do
|
63
|
+
let(:y) { 15 }
|
64
|
+
let(:x) { 5 }
|
65
|
+
|
66
|
+
it { subject.must_equal([]) }
|
67
|
+
end
|
68
|
+
|
69
|
+
context 'when both x and y are out of bounds' do
|
70
|
+
let(:y) { 15 }
|
71
|
+
let(:x) { 15 }
|
72
|
+
|
73
|
+
it { subject.must_equal([]) }
|
74
|
+
end
|
75
|
+
|
76
|
+
context 'when x and y are in bounds' do
|
77
|
+
let(:y) { 3 }
|
78
|
+
let(:x) { 5 }
|
79
|
+
|
80
|
+
it { subject.must_be_instance_of(Vedeu::Char) }
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
describe '#write' do
|
85
|
+
let(:data) { Vedeu::Char.new('a') }
|
86
|
+
|
87
|
+
subject { instance.write(y, x, data) }
|
88
|
+
|
89
|
+
context 'when x is out of bounds' do
|
90
|
+
let(:y) { 3 }
|
91
|
+
let(:x) { 15 }
|
92
|
+
|
93
|
+
it { subject.must_equal(false) }
|
94
|
+
end
|
95
|
+
|
96
|
+
context 'when y is out of bounds' do
|
97
|
+
let(:y) { 15 }
|
98
|
+
let(:x) { 5 }
|
99
|
+
|
100
|
+
it { subject.must_equal(false) }
|
101
|
+
end
|
102
|
+
|
103
|
+
context 'when both x and y are out of bounds' do
|
104
|
+
let(:y) { 15 }
|
105
|
+
let(:x) { 15 }
|
106
|
+
|
107
|
+
it { subject.must_equal(false) }
|
108
|
+
end
|
109
|
+
|
110
|
+
context 'when x and y are in bounds' do
|
111
|
+
let(:y) { 3 }
|
112
|
+
let(:x) { 5 }
|
113
|
+
|
114
|
+
it { subject.must_equal(true) }
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
end # VirtualTerminal
|
119
|
+
|
120
|
+
end # Vedeu
|
@@ -45,11 +45,9 @@ module Vedeu
|
|
45
45
|
}
|
46
46
|
|
47
47
|
describe '#initialize' do
|
48
|
-
|
49
|
-
|
50
|
-
it {
|
51
|
-
it { subject.instance_variable_get('@text').must_equal(text) }
|
52
|
-
it { subject.instance_variable_get('@options').must_equal(options) }
|
48
|
+
it { instance.must_be_instance_of(described) }
|
49
|
+
it { instance.instance_variable_get('@text').must_equal(text) }
|
50
|
+
it { instance.instance_variable_get('@options').must_equal(options) }
|
53
51
|
end
|
54
52
|
|
55
53
|
describe '#prune' do
|
@@ -9,10 +9,8 @@ module Vedeu
|
|
9
9
|
let(:value) { 'bold' }
|
10
10
|
|
11
11
|
describe '#initialize' do
|
12
|
-
|
13
|
-
|
14
|
-
it { subject.must_be_instance_of(described) }
|
15
|
-
it { subject.instance_variable_get('@value').must_equal('bold') }
|
12
|
+
it { instance.must_be_instance_of(described) }
|
13
|
+
it { instance.instance_variable_get('@value').must_equal('bold') }
|
16
14
|
end
|
17
15
|
|
18
16
|
describe '#attributes' do
|
@@ -9,10 +9,8 @@ module Vedeu
|
|
9
9
|
let(:colour) { '#ff0000' }
|
10
10
|
|
11
11
|
describe '#initialize' do
|
12
|
-
|
13
|
-
|
14
|
-
it { subject.must_be_instance_of(Translator) }
|
15
|
-
it { subject.instance_variable_get('@colour').must_equal(colour) }
|
12
|
+
it { instance.must_be_instance_of(Translator) }
|
13
|
+
it { instance.instance_variable_get('@colour').must_equal(colour) }
|
16
14
|
end
|
17
15
|
|
18
16
|
describe '#escape_sequence' do
|
@@ -26,11 +26,9 @@ module Vedeu
|
|
26
26
|
let(:storage) { {} }
|
27
27
|
|
28
28
|
describe '#initialize' do
|
29
|
-
|
30
|
-
|
31
|
-
it {
|
32
|
-
it { subject.instance_variable_get('@model').must_equal(model) }
|
33
|
-
it { subject.instance_variable_get('@storage').must_equal(storage) }
|
29
|
+
it { instance.must_be_instance_of(Vedeu::Repository) }
|
30
|
+
it { instance.instance_variable_get('@model').must_equal(model) }
|
31
|
+
it { instance.instance_variable_get('@storage').must_equal(storage) }
|
34
32
|
end
|
35
33
|
|
36
34
|
describe '#inspect' do
|
@@ -10,22 +10,20 @@ module Vedeu
|
|
10
10
|
let(:width) { 32 }
|
11
11
|
|
12
12
|
describe '#initialize' do
|
13
|
-
|
14
|
-
|
15
|
-
it {
|
16
|
-
it { subject.instance_variable_get('@height').must_equal(height) }
|
17
|
-
it { subject.instance_variable_get('@width').must_equal(width) }
|
13
|
+
it { instance.must_be_instance_of(described) }
|
14
|
+
it { instance.instance_variable_get('@height').must_equal(height) }
|
15
|
+
it { instance.instance_variable_get('@width').must_equal(width) }
|
18
16
|
|
19
17
|
context 'when the height is not given' do
|
20
18
|
let(:height) {}
|
21
19
|
|
22
|
-
it {
|
20
|
+
it { instance.instance_variable_get('@height').must_equal(25) }
|
23
21
|
end
|
24
22
|
|
25
23
|
context 'when the width is not given' do
|
26
24
|
let(:width) {}
|
27
25
|
|
28
|
-
it {
|
26
|
+
it { instance.instance_variable_get('@width').must_equal(80) }
|
29
27
|
end
|
30
28
|
end
|
31
29
|
|