vedeu 0.3.3 → 0.3.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (100) hide show
  1. checksums.yaml +4 -4
  2. data/bin/vedeu_drb_client +6 -0
  3. data/lib/vedeu/all.rb +1 -0
  4. data/lib/vedeu/application.rb +24 -1
  5. data/lib/vedeu/configuration/api.rb +107 -0
  6. data/lib/vedeu/configuration/cli.rb +34 -0
  7. data/lib/vedeu/configuration/configuration.rb +75 -4
  8. data/lib/vedeu/distributed/all.rb +8 -0
  9. data/lib/vedeu/distributed/application.rb +91 -0
  10. data/lib/vedeu/distributed/client.rb +58 -0
  11. data/lib/vedeu/distributed/subprocess.rb +111 -0
  12. data/lib/vedeu/distributed/templates/default_application.vedeu +34 -0
  13. data/lib/vedeu/distributed/templates/default_borders.vedeu +19 -0
  14. data/lib/vedeu/distributed/templates/default_configuration.vedeu +31 -0
  15. data/lib/vedeu/distributed/templates/default_events.vedeu +1 -0
  16. data/lib/vedeu/distributed/templates/default_geometries.vedeu +7 -0
  17. data/lib/vedeu/distributed/templates/default_interfaces.vedeu +4 -0
  18. data/lib/vedeu/distributed/templates/default_keymaps.vedeu +6 -0
  19. data/lib/vedeu/distributed/templates/default_menus.vedeu +3 -0
  20. data/lib/vedeu/distributed/templates/default_views.vedeu +14 -0
  21. data/lib/vedeu/distributed/test_application.rb +99 -0
  22. data/lib/vedeu/distributed/uri.rb +38 -0
  23. data/lib/vedeu/input/mapper.rb +10 -0
  24. data/lib/vedeu/launcher.rb +4 -0
  25. data/lib/vedeu/models/geometry.rb +16 -31
  26. data/lib/vedeu/models/view/char.rb +5 -5
  27. data/lib/vedeu/models/view/interface.rb +2 -1
  28. data/lib/vedeu/output/all.rb +2 -0
  29. data/lib/vedeu/output/output.rb +40 -0
  30. data/lib/vedeu/output/position_index.rb +24 -0
  31. data/lib/vedeu/output/virtual_terminal.rb +87 -0
  32. data/lib/vedeu/support/all.rb +1 -0
  33. data/lib/vedeu/support/limit.rb +33 -0
  34. data/lib/vedeu/support/position.rb +29 -0
  35. data/lib/vedeu/support/terminal.rb +14 -2
  36. data/test/integration/distributed_test.rb +14 -0
  37. data/test/lib/vedeu/application_test.rb +7 -6
  38. data/test/lib/vedeu/buffers/buffer_test.rb +6 -8
  39. data/test/lib/vedeu/configuration/api_test.rb +50 -0
  40. data/test/lib/vedeu/configuration/cli_test.rb +21 -0
  41. data/test/lib/vedeu/configuration/configuration_test.rb +24 -0
  42. data/test/lib/vedeu/cursor/move_cursor_test.rb +5 -7
  43. data/test/lib/vedeu/distributed/application_test.rb +24 -0
  44. data/test/lib/vedeu/distributed/client_test.rb +36 -0
  45. data/test/lib/vedeu/distributed/subprocess_test.rb +20 -0
  46. data/test/lib/vedeu/distributed/test_application_test.rb +26 -0
  47. data/test/lib/vedeu/distributed/uri_test.rb +73 -0
  48. data/test/lib/vedeu/dsl/components/border_test.rb +3 -5
  49. data/test/lib/vedeu/dsl/components/keymap_test.rb +2 -4
  50. data/test/lib/vedeu/dsl/components/menu_test.rb +2 -4
  51. data/test/lib/vedeu/dsl/composition_test.rb +3 -5
  52. data/test/lib/vedeu/dsl/interface_test.rb +3 -5
  53. data/test/lib/vedeu/dsl/line_test.rb +3 -5
  54. data/test/lib/vedeu/dsl/stream_test.rb +3 -5
  55. data/test/lib/vedeu/events/event_test.rb +8 -10
  56. data/test/lib/vedeu/events/trigger_test.rb +4 -6
  57. data/test/lib/vedeu/input/input_test.rb +2 -4
  58. data/test/lib/vedeu/input/key_test.rb +0 -2
  59. data/test/lib/vedeu/input/keymap_test.rb +4 -6
  60. data/test/lib/vedeu/input/mapper_test.rb +5 -7
  61. data/test/lib/vedeu/launcher_test.rb +7 -9
  62. data/test/lib/vedeu/models/collection_test.rb +4 -6
  63. data/test/lib/vedeu/models/geometry_test.rb +40 -13
  64. data/test/lib/vedeu/models/group_test.rb +4 -6
  65. data/test/lib/vedeu/models/menu_test.rb +6 -9
  66. data/test/lib/vedeu/models/view/char_test.rb +7 -9
  67. data/test/lib/vedeu/models/view/chars_test.rb +1 -3
  68. data/test/lib/vedeu/models/view/composition_test.rb +4 -6
  69. data/test/lib/vedeu/models/view/interface_test.rb +10 -12
  70. data/test/lib/vedeu/models/view/interfaces_test.rb +1 -3
  71. data/test/lib/vedeu/models/view/line_test.rb +5 -7
  72. data/test/lib/vedeu/models/view/lines_test.rb +1 -3
  73. data/test/lib/vedeu/models/view/stream_test.rb +6 -8
  74. data/test/lib/vedeu/models/view/streams_test.rb +1 -3
  75. data/test/lib/vedeu/output/border_test.rb +6 -8
  76. data/test/lib/vedeu/output/compositor_test.rb +2 -4
  77. data/test/lib/vedeu/output/output_test.rb +5 -4
  78. data/test/lib/vedeu/output/position_index_test.rb +72 -0
  79. data/test/lib/vedeu/output/viewport_test.rb +2 -4
  80. data/test/lib/vedeu/output/virtual_terminal_test.rb +120 -0
  81. data/test/lib/vedeu/output/wordwrap_test.rb +3 -5
  82. data/test/lib/vedeu/presentation/colour_test.rb +0 -2
  83. data/test/lib/vedeu/presentation/style_test.rb +2 -4
  84. data/test/lib/vedeu/presentation/translator_test.rb +2 -4
  85. data/test/lib/vedeu/repositories/repository_test.rb +3 -5
  86. data/test/lib/vedeu/support/console_test.rb +5 -7
  87. data/test/lib/vedeu/support/content_geometry_test.rb +2 -4
  88. data/test/lib/vedeu/support/coordinate_test.rb +5 -7
  89. data/test/lib/vedeu/support/grid_test.rb +2 -4
  90. data/test/lib/vedeu/support/limit_test.rb +30 -0
  91. data/test/lib/vedeu/support/position_test.rb +8 -4
  92. data/test/lib/vedeu/support/position_validator_test.rb +4 -6
  93. data/test/lib/vedeu/support/read_test.rb +3 -5
  94. data/test/lib/vedeu/support/sentence_test.rb +3 -4
  95. data/test/lib/vedeu/support/trace_test.rb +2 -4
  96. data/test/lib/vedeu/support/visible_test.rb +6 -8
  97. data/test/lib/vedeu/support/write_test.rb +3 -5
  98. data/test/test_helper.rb +6 -2
  99. data/vedeu.gemspec +1 -1
  100. metadata +40 -2
@@ -13,12 +13,10 @@ module Vedeu
13
13
  end
14
14
 
15
15
  describe '#initialize' do
16
- subject { instance }
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 { subject.instance_variable_get('@attributes').must_equal({
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 { subject.instance_variable_get('@centred').must_equal(false) }
34
- it { subject.instance_variable_get('@height').must_equal(25) }
35
- it { subject.instance_variable_get('@name').must_equal('') }
36
- it { subject.instance_variable_get('@width').must_equal(80) }
37
- it { subject.instance_variable_get('@x').must_equal(1) }
38
- it { subject.instance_variable_get('@xn').must_equal(80) }
39
- it { subject.instance_variable_get('@y').must_equal(1) }
40
- it { subject.instance_variable_get('@yn').must_equal(25) }
41
- it { subject.instance_variable_get('@repository').must_equal(Vedeu.geometries) }
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
- subject { instance }
14
-
15
- it { subject.must_be_instance_of(Group) }
16
- it { subject.instance_variable_get('@members').must_equal(members) }
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
- subject { instance }
42
-
43
- it { subject.must_be_instance_of(described) }
44
-
45
- it { subject.instance_variable_get('@collection').must_equal(collection) }
46
- it { subject.instance_variable_get('@name').must_equal('elements') }
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
- subject { instance }
63
-
64
- it { subject.must_be_instance_of(Char) }
65
- it { subject.instance_variable_get('@colour').must_equal(colour) }
66
- it { subject.instance_variable_get('@parent').must_equal(parent) }
67
- it { subject.instance_variable_get('@style').must_equal(style) }
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('<Vedeu::Char (value:a)>') }
73
+ it { subject.must_equal("<Vedeu::Char (value:'a')>") }
76
74
  end
77
75
 
78
76
  describe '#value' do
@@ -8,9 +8,7 @@ module Vedeu
8
8
  let(:instance) { described.new }
9
9
 
10
10
  describe '#initialize' do
11
- subject { instance }
12
-
13
- it { subject.must_be_instance_of(Vedeu::Chars) }
11
+ it { instance.must_be_instance_of(Vedeu::Chars) }
14
12
  end
15
13
 
16
14
  end # Chars
@@ -28,12 +28,10 @@ module Vedeu
28
28
  end
29
29
 
30
30
  describe '#initialize' do
31
- subject { instance }
32
-
33
- it { subject.must_be_instance_of(described) }
34
- it { subject.instance_variable_get('@interfaces').must_equal(interfaces) }
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
- subject { instance }
26
-
27
- it { subject.instance_variable_get('@name').must_equal(_name) }
28
- it { subject.instance_variable_get('@lines').must_equal(lines) }
29
- it { subject.instance_variable_get('@parent').must_equal(parent) }
30
- it { subject.instance_variable_get('@colour').must_be_instance_of(Vedeu::Colour) }
31
- it { subject.instance_variable_get('@style').must_be_instance_of(Vedeu::Style) }
32
- it { subject.instance_variable_get('@border').must_equal(nil) }
33
- it { subject.instance_variable_get('@delay').must_equal(0.0) }
34
- it { subject.instance_variable_get('@geometry').must_equal(nil) }
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
@@ -8,9 +8,7 @@ module Vedeu
8
8
  let(:instance) { described.new }
9
9
 
10
10
  describe '#initialize' do
11
- subject { instance }
12
-
13
- it { subject.must_be_instance_of(Vedeu::Interfaces) }
11
+ it { instance.must_be_instance_of(Vedeu::Interfaces) }
14
12
  end
15
13
 
16
14
  end # Interfaces
@@ -43,13 +43,11 @@ module Vedeu
43
43
  end
44
44
 
45
45
  describe '#initialize' do
46
- subject { instance }
47
-
48
- it { subject.must_be_instance_of(described) }
49
- it { subject.instance_variable_get('@streams').must_equal(streams) }
50
- it { subject.instance_variable_get('@parent').must_equal(parent) }
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
@@ -8,9 +8,7 @@ module Vedeu
8
8
  let(:instance) { described.new }
9
9
 
10
10
  describe '#initialize' do
11
- subject { instance }
12
-
13
- it { subject.must_be_instance_of(Vedeu::Lines) }
11
+ it { instance.must_be_instance_of(Vedeu::Lines) }
14
12
  end
15
13
 
16
14
  end # Lines
@@ -28,14 +28,12 @@ module Vedeu
28
28
  let(:line_parent) { mock('Vedeu::Interface') }
29
29
 
30
30
  describe '#initialize' do
31
- subject { instance }
32
-
33
- it { subject.must_be_instance_of(described) }
34
- # it { subject.instance_variable_get('@attributes').must_equal(attributes) }
35
- it { subject.instance_variable_get('@value').must_equal(value) }
36
- it { subject.instance_variable_get('@parent').must_equal(parent) }
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
@@ -8,9 +8,7 @@ module Vedeu
8
8
  let(:instance) { described.new }
9
9
 
10
10
  describe '#initialize' do
11
- subject { instance }
12
-
13
- it { subject.must_be_instance_of(Vedeu::Streams) }
11
+ it { instance.must_be_instance_of(Vedeu::Streams) }
14
12
  end
15
13
 
16
14
  end # Streams
@@ -41,10 +41,8 @@ module Vedeu
41
41
  end
42
42
 
43
43
  describe '#initialize' do
44
- subject { instance }
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 { subject.instance_variable_get('@colour').must_be_instance_of(Vedeu::Colour) }
67
- it { subject.instance_variable_get('@name').must_equal('borders') }
68
- it { subject.instance_variable_get('@repository').must_be_instance_of(Vedeu::Borders) }
69
- it { subject.instance_variable_get('@style').must_be_instance_of(Vedeu::Style) }
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
- subject { instance }
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.new(interface) }
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 { described.must_be_instance_of(Output) }
32
- it { described.instance_variable_get('@interface').must_equal(interface) }
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 { Output.render(interface) }
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
- subject { instance }
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
- subject { instance }
49
-
50
- it { subject.must_be_instance_of(described) }
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
@@ -14,8 +14,6 @@ module Vedeu
14
14
  }
15
15
 
16
16
  describe '#initialize' do
17
- subject { instance }
18
-
19
17
  it { instance.must_be_instance_of(described) }
20
18
  it { instance.instance_variable_get('@attributes').must_equal(attributes) }
21
19
  end
@@ -9,10 +9,8 @@ module Vedeu
9
9
  let(:value) { 'bold' }
10
10
 
11
11
  describe '#initialize' do
12
- subject { instance }
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
- subject { instance }
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
- subject { instance }
30
-
31
- it { subject.must_be_instance_of(Vedeu::Repository) }
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
- subject { instance }
14
-
15
- it { subject.must_be_instance_of(described) }
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 { subject.instance_variable_get('@height').must_equal(25) }
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 { subject.instance_variable_get('@width').must_equal(80) }
26
+ it { instance.instance_variable_get('@width').must_equal(80) }
29
27
  end
30
28
  end
31
29