vedeu 0.6.4 → 0.6.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (118) hide show
  1. checksums.yaml +4 -4
  2. data/.codeclimate.yml +40 -0
  3. data/README.md +1 -0
  4. data/docs/dsl.md +24 -24
  5. data/lib/vedeu/all.rb +21 -44
  6. data/lib/vedeu/api.rb +13 -13
  7. data/lib/vedeu/application/application_controller.rb +2 -0
  8. data/lib/vedeu/bindings/movement.rb +53 -18
  9. data/lib/vedeu/bindings/refresh.rb +1 -1
  10. data/lib/vedeu/bindings/system.rb +2 -2
  11. data/lib/vedeu/bindings/visibility.rb +3 -3
  12. data/lib/vedeu/borders/all.rb +13 -0
  13. data/lib/vedeu/borders/border.rb +209 -202
  14. data/lib/vedeu/{dsl/border.rb → borders/dsl.rb} +15 -15
  15. data/lib/vedeu/{null/border.rb → borders/null.rb} +9 -9
  16. data/lib/vedeu/borders/render.rb +347 -0
  17. data/lib/vedeu/borders/repository.rb +19 -0
  18. data/lib/vedeu/buffers/all.rb +13 -0
  19. data/lib/vedeu/buffers/buffer.rb +182 -176
  20. data/lib/vedeu/{null/buffer.rb → buffers/null.rb} +8 -8
  21. data/lib/vedeu/buffers/repository.rb +24 -0
  22. data/lib/vedeu/buffers/virtual_buffer.rb +2 -2
  23. data/lib/vedeu/cursors/all.rb +11 -0
  24. data/lib/vedeu/cursors/cursor.rb +276 -0
  25. data/lib/vedeu/cursors/refresh.rb +84 -0
  26. data/lib/vedeu/cursors/repository.rb +34 -0
  27. data/lib/vedeu/dsl/interface.rb +9 -9
  28. data/lib/vedeu/dsl/shared.rb +11 -11
  29. data/lib/vedeu/{exceptions.rb → error.rb} +2 -2
  30. data/lib/vedeu/esc/esc.rb +1 -1
  31. data/lib/vedeu/geometry/all.rb +18 -0
  32. data/lib/vedeu/geometry/area.rb +170 -160
  33. data/lib/vedeu/geometry/coordinate.rb +61 -39
  34. data/lib/vedeu/geometry/dimension.rb +139 -132
  35. data/lib/vedeu/{dsl/geometry.rb → geometry/dsl.rb} +11 -11
  36. data/lib/vedeu/geometry/generic_coordinate.rb +159 -153
  37. data/lib/vedeu/geometry/geometry.rb +310 -212
  38. data/lib/vedeu/geometry/grid.rb +73 -69
  39. data/lib/vedeu/{null/geometry.rb → geometry/null.rb} +10 -10
  40. data/lib/vedeu/geometry/position.rb +124 -120
  41. data/lib/vedeu/geometry/repository.rb +19 -0
  42. data/lib/vedeu/input/editor/document.rb +2 -2
  43. data/lib/vedeu/internal_api.rb +8 -8
  44. data/lib/vedeu/models/escape.rb +2 -2
  45. data/lib/vedeu/models/interface.rb +1 -1
  46. data/lib/vedeu/models/page.rb +89 -0
  47. data/lib/vedeu/models/row.rb +66 -0
  48. data/lib/vedeu/models/toggleable.rb +1 -1
  49. data/lib/vedeu/models/views/char.rb +7 -6
  50. data/lib/vedeu/models/views/line.rb +1 -1
  51. data/lib/vedeu/models/views/view.rb +2 -2
  52. data/lib/vedeu/options.rb +19 -0
  53. data/lib/vedeu/output/clear/named_interface.rb +1 -1
  54. data/lib/vedeu/output/direct.rb +1 -1
  55. data/lib/vedeu/output/presentation.rb +2 -1
  56. data/lib/vedeu/output/viewport.rb +3 -3
  57. data/lib/vedeu/repositories/model.rb +9 -1
  58. data/lib/vedeu/repositories/repository.rb +5 -0
  59. data/lib/vedeu/terminal/terminal.rb +3 -3
  60. data/lib/vedeu/version.rb +1 -1
  61. data/test/lib/vedeu/borders/border_test.rb +299 -291
  62. data/test/lib/vedeu/{dsl/border_test.rb → borders/dsl_test.rb} +6 -6
  63. data/test/lib/vedeu/{null/border_test.rb → borders/null_test.rb} +6 -6
  64. data/test/lib/vedeu/borders/render_test.rb +125 -0
  65. data/test/lib/vedeu/borders/repository_test.rb +17 -0
  66. data/test/lib/vedeu/buffers/buffer_test.rb +116 -112
  67. data/test/lib/vedeu/{null/buffer_test.rb → buffers/null_test.rb} +5 -5
  68. data/test/lib/vedeu/buffers/repository_test.rb +18 -0
  69. data/test/lib/vedeu/cursors/cursor_test.rb +370 -0
  70. data/test/lib/vedeu/cursors/refresh_test.rb +69 -0
  71. data/test/lib/vedeu/cursors/repository_test.rb +41 -0
  72. data/test/lib/vedeu/dsl/interface_test.rb +5 -5
  73. data/test/lib/vedeu/{exceptions_test.rb → error_test.rb} +0 -0
  74. data/test/lib/vedeu/geometry/area_test.rb +141 -137
  75. data/test/lib/vedeu/geometry/coordinate_test.rb +93 -89
  76. data/test/lib/vedeu/geometry/dimension_test.rb +137 -133
  77. data/test/lib/vedeu/{dsl/geometry_test.rb → geometry/dsl_test.rb} +17 -17
  78. data/test/lib/vedeu/geometry/generic_coordinate_test.rb +32 -28
  79. data/test/lib/vedeu/geometry/geometry_test.rb +282 -157
  80. data/test/lib/vedeu/geometry/grid_test.rb +35 -31
  81. data/test/lib/vedeu/{null/geometry_test.rb → geometry/null_test.rb} +5 -5
  82. data/test/lib/vedeu/geometry/position_test.rb +146 -142
  83. data/test/lib/vedeu/geometry/repository_test.rb +19 -0
  84. data/test/lib/vedeu/input/editor/document_test.rb +1 -1
  85. data/test/lib/vedeu/models/escape_test.rb +1 -1
  86. data/test/lib/vedeu/models/interface_test.rb +2 -2
  87. data/test/lib/vedeu/models/page_test.rb +235 -0
  88. data/test/lib/vedeu/models/row_test.rb +111 -0
  89. data/test/lib/vedeu/models/views/char_test.rb +3 -3
  90. data/test/lib/vedeu/options_test.rb +57 -0
  91. data/test/lib/vedeu/output/clear/named_interface_test.rb +1 -1
  92. data/test/lib/vedeu/output/renderers/json_test.rb +1 -1
  93. data/test/lib/vedeu/output/viewport_test.rb +15 -9
  94. data/test/lib/vedeu/refresh/refresh_buffer_test.rb +12 -12
  95. data/test/lib/vedeu/repositories/repositories_test.rb +1 -1
  96. data/test/lib/vedeu/repositories/repository_test.rb +7 -0
  97. data/test/lib/vedeu/terminal/terminal_test.rb +1 -1
  98. data/test/test_helper.rb +1 -1
  99. data/vedeu.gemspec +2 -2
  100. metadata +57 -63
  101. data/lib/vedeu/borders/borders.rb +0 -15
  102. data/lib/vedeu/borders/render_border.rb +0 -331
  103. data/lib/vedeu/buffers/buffers.rb +0 -20
  104. data/lib/vedeu/cursor/cursor.rb +0 -174
  105. data/lib/vedeu/cursor/cursors.rb +0 -30
  106. data/lib/vedeu/cursor/move.rb +0 -239
  107. data/lib/vedeu/cursor/reposition.rb +0 -78
  108. data/lib/vedeu/geometry/geometries.rb +0 -15
  109. data/lib/vedeu/refresh/refresh_cursor.rb +0 -92
  110. data/test/lib/vedeu/borders/borders_test.rb +0 -13
  111. data/test/lib/vedeu/borders/render_border_test.rb +0 -121
  112. data/test/lib/vedeu/buffers/buffers_test.rb +0 -14
  113. data/test/lib/vedeu/cursor/cursor_test.rb +0 -246
  114. data/test/lib/vedeu/cursor/cursors_test.rb +0 -37
  115. data/test/lib/vedeu/cursor/move_test.rb +0 -301
  116. data/test/lib/vedeu/cursor/reposition_test.rb +0 -63
  117. data/test/lib/vedeu/geometry/geometries_test.rb +0 -15
  118. 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('flourine') do
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('flourine') }
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
@@ -2,189 +2,193 @@ require 'test_helper'
2
2
 
3
3
  module Vedeu
4
4
 
5
- describe Area do
6
-
7
- let(:described) { Vedeu::Area }
8
- let(:instance) { described.new(y: y, yn: yn, x: x, xn: xn) }
9
- let(:y) { 4 }
10
- let(:yn) { 9 }
11
- let(:x) { 6 }
12
- let(:xn) { 21 }
13
- let(:offset) { 1 }
14
-
15
- describe 'accessors' do
16
- it { instance.must_respond_to(:y) }
17
- it { instance.must_respond_to(:yn) }
18
- it { instance.must_respond_to(:x) }
19
- it { instance.must_respond_to(:xn) }
20
- it { instance.must_respond_to(:top) }
21
- it { instance.must_respond_to(:bottom) }
22
- it { instance.must_respond_to(:left) }
23
- it { instance.must_respond_to(:right) }
24
- end
25
-
26
- describe '#initialize' do
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
- subject { described.from_attributes(attributes) }
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
- it { subject.must_be_instance_of(described) }
63
- end
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
- describe '#eql?' do
66
- let(:other) { described.new(y: 4, yn: 9, x: 6, xn: 21) }
67
+ describe '#eql?' do
68
+ let(:other) { described.new(y: 4, yn: 9, x: 6, xn: 21) }
67
69
 
68
- subject { instance.eql?(other) }
70
+ subject { instance.eql?(other) }
69
71
 
70
- it { subject.must_equal(true) }
72
+ it { subject.must_equal(true) }
71
73
 
72
- context 'when different to other' do
73
- let(:other) { described.new(y: 1, yn: 25, x: 1, xn: 40) }
74
+ context 'when different to other' do
75
+ let(:other) { described.new(y: 1, yn: 25, x: 1, xn: 40) }
74
76
 
75
- it { subject.must_equal(false) }
77
+ it { subject.must_equal(false) }
78
+ end
76
79
  end
77
- end
78
80
 
79
- describe '#centre' do
80
- subject { instance.centre }
81
+ describe '#centre' do
82
+ subject { instance.centre }
81
83
 
82
- it { subject.must_be_instance_of(Array) }
83
- it { subject.must_equal([7, 14]) }
84
- end
84
+ it { subject.must_be_instance_of(Array) }
85
+ it { subject.must_equal([7, 14]) }
86
+ end
85
87
 
86
- describe '#centre_y' do
87
- subject { instance.centre_y }
88
+ describe '#centre_y' do
89
+ subject { instance.centre_y }
88
90
 
89
- it { subject.must_be_instance_of(Fixnum) }
90
- it { subject.must_equal(7) }
91
- end
91
+ it { subject.must_be_instance_of(Fixnum) }
92
+ it { subject.must_equal(7) }
93
+ end
92
94
 
93
- describe '#centre_x' do
94
- subject { instance.centre_x }
95
+ describe '#centre_x' do
96
+ subject { instance.centre_x }
95
97
 
96
- it { subject.must_be_instance_of(Fixnum) }
97
- it { subject.must_equal(14) }
98
- end
98
+ it { subject.must_be_instance_of(Fixnum) }
99
+ it { subject.must_equal(14) }
100
+ end
99
101
 
100
- describe '#north' do
101
- subject { instance.north(offset) }
102
+ describe '#north' do
103
+ subject { instance.north(offset) }
102
104
 
103
- it { subject.must_be_instance_of(Fixnum) }
105
+ it { subject.must_be_instance_of(Fixnum) }
104
106
 
105
- context 'with the default offset' do
106
- it { subject.must_equal(3) }
107
- end
107
+ context 'with the default offset' do
108
+ it { subject.must_equal(3) }
109
+ end
108
110
 
109
- context 'with a negative offset' do
110
- let(:offset) { -2 }
111
+ context 'with a negative offset' do
112
+ let(:offset) { -2 }
111
113
 
112
- it { subject.must_equal(6) }
113
- end
114
+ it { subject.must_equal(6) }
115
+ end
114
116
 
115
- context 'with a positive offset' do
116
- let(:offset) { 2 }
117
+ context 'with a positive offset' do
118
+ let(:offset) { 2 }
117
119
 
118
- it { subject.must_equal(2) }
120
+ it { subject.must_equal(2) }
121
+ end
119
122
  end
120
- end
121
123
 
122
- describe '#east' do
123
- subject { instance.east(offset) }
124
+ describe '#east' do
125
+ subject { instance.east(offset) }
124
126
 
125
- it { subject.must_be_instance_of(Fixnum) }
127
+ it { subject.must_be_instance_of(Fixnum) }
126
128
 
127
- context 'with the default offset' do
128
- it { subject.must_equal(22) }
129
- end
129
+ context 'with the default offset' do
130
+ it { subject.must_equal(22) }
131
+ end
130
132
 
131
- context 'with a negative offset' do
132
- let(:offset) { -2 }
133
+ context 'with a negative offset' do
134
+ let(:offset) { -2 }
133
135
 
134
- it { subject.must_equal(19) }
135
- end
136
+ it { subject.must_equal(19) }
137
+ end
136
138
 
137
- context 'with a positive offset' do
138
- let(:offset) { 2 }
139
+ context 'with a positive offset' do
140
+ let(:offset) { 2 }
139
141
 
140
- it { subject.must_equal(23) }
142
+ it { subject.must_equal(23) }
143
+ end
141
144
  end
142
- end
143
145
 
144
- describe '#south' do
145
- subject { instance.south(offset) }
146
+ describe '#south' do
147
+ subject { instance.south(offset) }
146
148
 
147
- it { subject.must_be_instance_of(Fixnum) }
149
+ it { subject.must_be_instance_of(Fixnum) }
148
150
 
149
- context 'with the default offset' do
150
- it { subject.must_equal(10) }
151
- end
151
+ context 'with the default offset' do
152
+ it { subject.must_equal(10) }
153
+ end
152
154
 
153
- context 'with a negative offset' do
154
- let(:offset) { -2 }
155
+ context 'with a negative offset' do
156
+ let(:offset) { -2 }
155
157
 
156
- it { subject.must_equal(7) }
157
- end
158
+ it { subject.must_equal(7) }
159
+ end
158
160
 
159
- context 'with a positive offset' do
160
- let(:offset) { 2 }
161
+ context 'with a positive offset' do
162
+ let(:offset) { 2 }
161
163
 
162
- it { subject.must_equal(11) }
164
+ it { subject.must_equal(11) }
165
+ end
163
166
  end
164
- end
165
167
 
166
- describe '#west' do
167
- subject { instance.west(offset) }
168
+ describe '#west' do
169
+ subject { instance.west(offset) }
168
170
 
169
- it { subject.must_be_instance_of(Fixnum) }
171
+ it { subject.must_be_instance_of(Fixnum) }
170
172
 
171
- context 'with the default offset' do
172
- it { subject.must_equal(5) }
173
- end
173
+ context 'with the default offset' do
174
+ it { subject.must_equal(5) }
175
+ end
174
176
 
175
- context 'with a negative offset' do
176
- let(:offset) { -2 }
177
+ context 'with a negative offset' do
178
+ let(:offset) { -2 }
177
179
 
178
- it { subject.must_equal(8) }
179
- end
180
+ it { subject.must_equal(8) }
181
+ end
180
182
 
181
- context 'with a positive offset' do
182
- let(:offset) { 2 }
183
+ context 'with a positive offset' do
184
+ let(:offset) { 2 }
183
185
 
184
- it { subject.must_equal(4) }
186
+ it { subject.must_equal(4) }
187
+ end
185
188
  end
186
- end
187
189
 
188
- end # Area
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
- describe Coordinate do
6
-
7
- let(:described) { Vedeu::Coordinate }
8
- let(:instance) { described.new(_name, oy, ox) }
9
- let(:_name) { 'coordinate' }
10
- let(:oy) { 0 }
11
- let(:ox) { 0 }
12
- let(:height) { 6 }
13
- let(:width) { 6 }
14
- let(:x) { 7 }
15
- let(:y) { 5 }
16
- let(:border) { Vedeu::Border.new(name: _name, enabled: true) }
17
- let(:geometry) {
18
- Vedeu::Geometry.new(name: _name,
19
- height: height,
20
- width: width,
21
- x: x,
22
- y: y)
23
- }
24
-
25
- before do
26
- Vedeu.borders.stubs(:by_name).returns(border)
27
- Vedeu.geometries.stubs(:by_name).returns(geometry)
28
- end
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
- context 'when the height is > 0' do
47
- it { subject.must_equal(9) }
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
- describe '#xn' do
52
- subject { instance.xn }
39
+ describe '#yn' do
40
+ subject { instance.yn }
53
41
 
54
- context 'when the width is <= to 0' do
55
- let(:width) { 0 }
42
+ context 'when the height is <= to 0' do
43
+ let(:height) { 0 }
56
44
 
57
- it { subject.must_equal(0) }
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
- context 'when the width is > 0' do
61
- it { subject.must_equal(11) }
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
- describe '#y_position' do
66
- let(:oy) { 0 }
67
+ describe '#y_position' do
68
+ let(:oy) { 0 }
67
69
 
68
- subject { instance.y_position }
70
+ subject { instance.y_position }
69
71
 
70
- it { subject.must_be_instance_of(Fixnum) }
72
+ it { subject.must_be_instance_of(Fixnum) }
71
73
 
72
- context 'with a negative index' do
73
- let(:oy) { -3 }
74
+ context 'with a negative index' do
75
+ let(:oy) { -3 }
74
76
 
75
- it { subject.must_equal(6) }
76
- end
77
+ it { subject.must_equal(6) }
78
+ end
77
79
 
78
- context 'with an index greater than the maximum index for y' do
79
- let(:oy) { 9 }
80
+ context 'with an index greater than the maximum index for y' do
81
+ let(:oy) { 9 }
80
82
 
81
- it { subject.must_equal(9) }
83
+ it { subject.must_equal(9) }
82
84
 
83
- context 'but the height is negative' do
84
- let(:height) { -2 }
85
+ context 'but the height is negative' do
86
+ let(:height) { -2 }
85
87
 
86
- it { subject.must_equal(1) }
88
+ it { subject.must_equal(1) }
89
+ end
87
90
  end
88
- end
89
91
 
90
- context 'with an index within range' do
91
- let(:oy) { 3 }
92
+ context 'with an index within range' do
93
+ let(:oy) { 3 }
92
94
 
93
- it { subject.must_equal(8) }
95
+ it { subject.must_equal(8) }
96
+ end
94
97
  end
95
- end
96
98
 
97
- describe '#x_position' do
98
- let(:ox) { 0 }
99
+ describe '#x_position' do
100
+ let(:ox) { 0 }
99
101
 
100
- subject { instance.x_position }
102
+ subject { instance.x_position }
101
103
 
102
- it { subject.must_be_instance_of(Fixnum) }
104
+ it { subject.must_be_instance_of(Fixnum) }
103
105
 
104
- context 'with a negative index' do
105
- let(:ox) { -3 }
106
+ context 'with a negative index' do
107
+ let(:ox) { -3 }
106
108
 
107
- it { subject.must_equal(8) }
108
- end
109
+ it { subject.must_equal(8) }
110
+ end
109
111
 
110
- context 'with an index greater than the maximum index for x' do
111
- let(:ox) { 9 }
112
+ context 'with an index greater than the maximum index for x' do
113
+ let(:ox) { 9 }
112
114
 
113
- it { subject.must_equal(11) }
115
+ it { subject.must_equal(11) }
114
116
 
115
- context 'but the width is negative' do
116
- let(:width) { -2 }
117
+ context 'but the width is negative' do
118
+ let(:width) { -2 }
117
119
 
118
- it { subject.must_equal(3) }
120
+ it { subject.must_equal(3) }
121
+ end
119
122
  end
120
- end
121
123
 
122
- context 'with an index within range' do
123
- let(:ox) { 3 }
124
+ context 'with an index within range' do
125
+ let(:ox) { 3 }
124
126
 
125
- it { subject.must_equal(10) }
127
+ it { subject.must_equal(10) }
128
+ end
126
129
  end
127
- end
128
130
 
129
- end # Coordinate
131
+ end # Coordinate
132
+
133
+ end # Geometry
130
134
 
131
135
  end # Vedeu