vedeu 0.8.4 → 0.8.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (156) hide show
  1. checksums.yaml +4 -4
  2. data/TODO.md +4 -0
  3. data/docs/dsl.md +1 -11
  4. data/docs/dsl/by_method/geometry/align.md +1 -0
  5. data/docs/dsl/by_method/geometry/align_bottom.md +40 -0
  6. data/docs/dsl/by_method/geometry/align_centre.md +40 -0
  7. data/docs/dsl/by_method/geometry/align_left.md +40 -0
  8. data/docs/dsl/by_method/geometry/align_middle.md +40 -0
  9. data/docs/dsl/by_method/geometry/align_right.md +40 -0
  10. data/docs/dsl/by_method/geometry/align_top.md +40 -0
  11. data/docs/dsl/by_method/geometry/columns.md +1 -0
  12. data/docs/dsl/by_method/geometry/height.md +0 -0
  13. data/docs/dsl/by_method/geometry/horizontal_alignment.md +1 -0
  14. data/docs/dsl/by_method/geometry/rows.md +1 -0
  15. data/docs/dsl/by_method/geometry/vertical_alignment.md +1 -0
  16. data/docs/dsl/by_method/geometry/width.md +0 -0
  17. data/docs/dsl/by_method/geometry/x.md +1 -0
  18. data/docs/dsl/by_method/geometry/xn.md +1 -0
  19. data/docs/dsl/by_method/geometry/y.md +1 -0
  20. data/docs/dsl/by_method/geometry/yn.md +1 -0
  21. data/docs/dsl/by_method/render.md +5 -1
  22. data/docs/dsl/by_method/renders.md +31 -1
  23. data/docs/dsl/by_method/view.md +26 -0
  24. data/docs/dsl/by_method/view/stream.md +18 -0
  25. data/docs/dsl/by_method/views.md +32 -1
  26. data/docs/events/by_name/set_border_caption.md +2 -4
  27. data/docs/events/by_name/set_border_title.md +2 -4
  28. data/examples/views/empty_template.rb +0 -4
  29. data/examples/views/full_screen.rb +30 -5
  30. data/examples/views/misc_view.rb +464 -0
  31. data/examples/views/wordwrap.rb +72 -0
  32. data/examples/views/wordwrap.txt +8 -0
  33. data/integrations/dsl_app_021.rb +127 -0
  34. data/integrations/dsl_app_022.rb +133 -0
  35. data/integrations/expected/342_streams.out +1 -1
  36. data/integrations/expected/dsl_app_001.out +1 -1
  37. data/integrations/expected/dsl_app_002.out +1 -1
  38. data/integrations/expected/dsl_app_003.out +1 -1
  39. data/integrations/expected/dsl_app_004.out +1 -1
  40. data/integrations/expected/dsl_app_005.out +1 -1
  41. data/integrations/expected/dsl_app_006.out +1 -1
  42. data/integrations/expected/dsl_app_007.out +1 -1
  43. data/integrations/expected/dsl_app_008.out +1 -1
  44. data/integrations/expected/dsl_app_009.out +1 -1
  45. data/integrations/expected/dsl_app_010.out +1 -1
  46. data/integrations/expected/dsl_app_011.out +1 -1
  47. data/integrations/expected/dsl_app_012.out +1 -1
  48. data/integrations/expected/dsl_app_013.out +1 -1
  49. data/integrations/expected/dsl_app_014.out +1 -1
  50. data/integrations/expected/dsl_app_015.out +1 -1
  51. data/integrations/expected/dsl_app_016.out +1 -1
  52. data/integrations/expected/dsl_app_021.out +1 -0
  53. data/integrations/expected/dsl_app_022.out +1 -0
  54. data/integrations/support/test_interface_021.rb +7 -0
  55. data/integrations/support/test_interface_022.rb +15 -0
  56. data/lib/vedeu/all.rb +4 -2
  57. data/lib/vedeu/borders/border.rb +22 -6
  58. data/lib/vedeu/borders/repository.rb +4 -8
  59. data/lib/vedeu/buffers/buffer.rb +9 -6
  60. data/lib/vedeu/buffers/empty.rb +26 -23
  61. data/lib/vedeu/buffers/view.rb +44 -41
  62. data/lib/vedeu/cells/cursor.rb +0 -2
  63. data/lib/vedeu/cells/empty.rb +0 -1
  64. data/lib/vedeu/cells/escape.rb +0 -2
  65. data/lib/vedeu/coercers/alignment.rb +58 -8
  66. data/lib/vedeu/coercers/horizontal_alignment.rb +13 -9
  67. data/lib/vedeu/coercers/vertical_alignment.rb +13 -8
  68. data/lib/vedeu/common.rb +1 -1
  69. data/lib/vedeu/configuration/configuration.rb +41 -3
  70. data/lib/vedeu/cursors/coordinate.rb +1 -3
  71. data/lib/vedeu/cursors/cursor.rb +2 -6
  72. data/lib/vedeu/dsl/all.rb +1 -2
  73. data/lib/vedeu/dsl/border.rb +6 -6
  74. data/lib/vedeu/dsl/elements.rb +2 -2
  75. data/lib/vedeu/dsl/geometry.rb +7 -7
  76. data/lib/vedeu/dsl/{string → helpers}/align.rb +0 -0
  77. data/lib/vedeu/dsl/helpers/all.rb +17 -0
  78. data/lib/vedeu/dsl/{attributes.rb → helpers/attributes.rb} +0 -0
  79. data/lib/vedeu/dsl/{string → helpers}/text.rb +0 -0
  80. data/lib/vedeu/dsl/{string → helpers}/truncate.rb +0 -0
  81. data/lib/vedeu/dsl/{string → helpers}/wordwrap.rb +0 -0
  82. data/lib/vedeu/dsl/view.rb +11 -19
  83. data/lib/vedeu/dsl/views.rb +16 -106
  84. data/lib/vedeu/geometries/all.rb +0 -1
  85. data/lib/vedeu/geometries/area/area.rb +6 -12
  86. data/lib/vedeu/geometries/area/dimension.rb +21 -44
  87. data/lib/vedeu/geometries/dsl/all.rb +0 -1
  88. data/lib/vedeu/geometries/dsl/dsl.rb +22 -31
  89. data/lib/vedeu/geometries/geometry.rb +6 -0
  90. data/lib/vedeu/geometries/position.rb +6 -3
  91. data/lib/vedeu/geometries/repository.rb +1 -1
  92. data/lib/vedeu/input/mouse.rb +1 -0
  93. data/lib/vedeu/logging/log.rb +3 -6
  94. data/lib/vedeu/menus/dsl.rb +4 -5
  95. data/lib/vedeu/output/compressor.rb +11 -1
  96. data/lib/vedeu/output/viewport.rb +59 -59
  97. data/lib/vedeu/presentation/all.rb +1 -2
  98. data/lib/vedeu/presentation/colour.rb +75 -3
  99. data/lib/vedeu/{geometries/positionable.rb → presentation/position.rb} +4 -4
  100. data/lib/vedeu/presentation/presentation.rb +1 -3
  101. data/lib/vedeu/presentation/styles.rb +16 -1
  102. data/lib/vedeu/repositories/all.rb +0 -1
  103. data/lib/vedeu/sentence.rb +91 -0
  104. data/lib/vedeu/support/point.rb +72 -0
  105. data/lib/vedeu/terminal/terminal.rb +11 -53
  106. data/lib/vedeu/version.rb +1 -1
  107. data/lib/vedeu/views/composition.rb +11 -1
  108. data/lib/vedeu/views/default_attributes.rb +2 -0
  109. data/lib/vedeu/views/line.rb +16 -1
  110. data/lib/vedeu/views/stream.rb +16 -1
  111. data/lib/vedeu/views/view.rb +25 -17
  112. data/test/lib/vedeu/borders/border_test.rb +20 -2
  113. data/test/lib/vedeu/buffers/buffer_test.rb +15 -2
  114. data/test/lib/vedeu/buffers/empty_test.rb +51 -18
  115. data/test/lib/vedeu/buffers/view_test.rb +2 -2
  116. data/test/lib/vedeu/coercers/alignment_test.rb +32 -0
  117. data/test/lib/vedeu/coercers/horizontal_alignment_test.rb +16 -0
  118. data/test/lib/vedeu/coercers/vertical_alignment_test.rb +16 -0
  119. data/test/lib/vedeu/cursors/cursor_test.rb +4 -4
  120. data/test/lib/vedeu/cursors/dsl_test.rb +35 -21
  121. data/test/lib/vedeu/dsl/elements_test.rb +94 -2
  122. data/test/lib/vedeu/dsl/{string → helpers}/align_test.rb +0 -0
  123. data/test/lib/vedeu/dsl/{attributes_test.rb → helpers/attributes_test.rb} +0 -0
  124. data/test/lib/vedeu/dsl/{string → helpers}/text_test.rb +0 -0
  125. data/test/lib/vedeu/dsl/{string → helpers}/truncate_test.rb +0 -0
  126. data/test/lib/vedeu/dsl/{string → helpers}/wordwrap_test.rb +0 -0
  127. data/test/lib/vedeu/dsl/view_test.rb +22 -4
  128. data/test/lib/vedeu/dsl/views_test.rb +8 -5
  129. data/test/lib/vedeu/geometries/dsl/dsl_test.rb +2 -159
  130. data/test/lib/vedeu/geometries/position_test.rb +118 -60
  131. data/test/lib/vedeu/input/mouse_test.rb +1 -6
  132. data/test/lib/vedeu/logging/log_test.rb +14 -3
  133. data/test/lib/vedeu/presentation/colour_test.rb +77 -0
  134. data/test/lib/vedeu/{geometries/positionable_test.rb → presentation/position_test.rb} +4 -4
  135. data/test/lib/vedeu/sentence_test.rb +49 -0
  136. data/test/lib/vedeu/support/point_test.rb +139 -0
  137. data/test/lib/vedeu/terminal/terminal_test.rb +3 -44
  138. data/test/lib/vedeu/views/composition_test.rb +24 -4
  139. data/test/lib/vedeu/views/default_attributes_test.rb +10 -2
  140. data/test/lib/vedeu/views/view_test.rb +8 -15
  141. data/test/support/examples/material_colours_app.rb +0 -6
  142. data/vedeu.gemspec +1 -1
  143. metadata +58 -38
  144. data/examples/views/lines_line_stream.rb +0 -95
  145. data/examples/views/lines_line_streams.rb +0 -75
  146. data/examples/views/lines_line_streams_stream.rb +0 -78
  147. data/examples/views/lines_line_streams_stream_stream.rb +0 -50
  148. data/examples/views/lines_streams.rb +0 -93
  149. data/lib/vedeu/dsl/string/all.rb +0 -16
  150. data/lib/vedeu/geometries/dsl/validator.rb +0 -62
  151. data/lib/vedeu/presentation/background.rb +0 -54
  152. data/lib/vedeu/presentation/foreground.rb +0 -54
  153. data/lib/vedeu/repositories/parent.rb +0 -34
  154. data/test/lib/vedeu/geometries/dsl/validator_test.rb +0 -85
  155. data/test/lib/vedeu/presentation/background_test.rb +0 -74
  156. data/test/lib/vedeu/presentation/foreground_test.rb +0 -75
@@ -39,129 +39,6 @@ module Vedeu
39
39
  end
40
40
  end
41
41
 
42
- describe '#align' do
43
- let(:vertical) { :top }
44
- let(:horizontal) { :left }
45
- let(:width) { 20 }
46
- let(:height) { 20 }
47
-
48
- subject { instance.align(vertical, horizontal, width, height) }
49
-
50
- context 'when the vertical argument is not given' do
51
- let(:vertical) {}
52
-
53
- it { proc { subject }.must_raise(Vedeu::Error::InvalidSyntax).
54
- message.must_match(/No vertical alignment/)
55
- }
56
- end
57
-
58
- context 'when the vertical argument is given' do
59
- context 'when the height is not given' do
60
- let(:height) {}
61
-
62
- it { proc { subject }.must_raise(Vedeu::Error::InvalidSyntax).
63
- message.must_equal('No height given.')
64
- }
65
- end
66
-
67
- context 'when the height is given' do
68
- it { subject.must_be_instance_of(Vedeu::Geometries::Geometry) }
69
- it { subject.vertical_alignment.
70
- must_be_instance_of(Vedeu::Coercers::VerticalAlignment) }
71
- it { subject.horizontal_alignment.
72
- must_be_instance_of(Vedeu::Coercers::HorizontalAlignment) }
73
- it { subject.height.must_equal(20) }
74
- it { subject.width.must_equal(20) }
75
- end
76
- end
77
-
78
- context 'when the horizontal argument is not given' do
79
- let(:horizontal) {}
80
-
81
- it { proc { subject }.must_raise(Vedeu::Error::InvalidSyntax).
82
- message.must_match(/No horizontal alignment/)
83
- }
84
- end
85
-
86
- context 'when the horizontal argument is given' do
87
- context 'when the width is not given' do
88
- let(:width) {}
89
-
90
- it { proc { subject }.must_raise(Vedeu::Error::InvalidSyntax).
91
- message.must_equal('No width given.')
92
- }
93
- end
94
-
95
- context 'when the width is given' do
96
- it { subject.must_be_instance_of(Vedeu::Geometries::Geometry) }
97
- it { subject.vertical_alignment.
98
- must_be_instance_of(Vedeu::Coercers::VerticalAlignment) }
99
- it { subject.horizontal_alignment.
100
- must_be_instance_of(Vedeu::Coercers::HorizontalAlignment) }
101
- it { subject.height.must_equal(20) }
102
- it { subject.width.must_equal(20) }
103
- end
104
- end
105
- end
106
-
107
- describe '#horizontal_alignment' do
108
- let(:_value) {}
109
- let(:width) {}
110
-
111
- subject { instance.horizontal_alignment(_value, width) }
112
-
113
- context 'when the value is not given' do
114
- it { proc { subject }.must_raise(Vedeu::Error::InvalidSyntax).
115
- message.must_match(/No horizontal alignment/)
116
- }
117
- end
118
-
119
- context 'when the value is given' do
120
- let(:_value) { :right }
121
-
122
- context 'when a width is not given' do
123
- it { proc { subject }.must_raise(Vedeu::Error::InvalidSyntax).
124
- message.must_equal('No width given.')
125
- }
126
- end
127
-
128
- context 'when a width is given' do
129
- let(:width) { 20 }
130
-
131
- it { subject.must_be_instance_of(Vedeu::Geometries::Geometry) }
132
- end
133
- end
134
- end
135
-
136
- describe '#vertical_alignment' do
137
- let(:_value) {}
138
- let(:height) {}
139
-
140
- subject { instance.vertical_alignment(_value, height) }
141
-
142
- context 'when the value is not given' do
143
- it { proc { subject }.must_raise(Vedeu::Error::InvalidSyntax).
144
- message.must_match(/No vertical alignment/)
145
- }
146
- end
147
-
148
- context 'when the value is given' do
149
- let(:_value) { :bottom }
150
-
151
- context 'when a height is not given' do
152
- it { proc { subject }.must_raise(Vedeu::Error::InvalidSyntax).
153
- message.must_equal('No height given.')
154
- }
155
- end
156
-
157
- context 'when a height is given' do
158
- let(:height) { 20 }
159
-
160
- it { subject.must_be_instance_of(Vedeu::Geometries::Geometry) }
161
- end
162
- end
163
- end
164
-
165
42
  describe '#align_bottom' do
166
43
  let(:height) { 20 }
167
44
 
@@ -170,12 +47,6 @@ module Vedeu
170
47
  context 'when a height is given' do
171
48
  it { subject.must_be_instance_of(Vedeu::Geometries::Geometry) }
172
49
  end
173
-
174
- context 'when a height is not given' do
175
- let(:height) {}
176
-
177
- it { proc { subject }.must_raise(Vedeu::Error::InvalidSyntax) }
178
- end
179
50
  end
180
51
 
181
52
  describe '#align_centre' do
@@ -186,12 +57,6 @@ module Vedeu
186
57
  context 'when a width is given' do
187
58
  it { subject.must_be_instance_of(Vedeu::Geometries::Geometry) }
188
59
  end
189
-
190
- context 'when a width is not given' do
191
- let(:width) {}
192
-
193
- it { proc { subject }.must_raise(Vedeu::Error::InvalidSyntax) }
194
- end
195
60
  end
196
61
 
197
62
  describe '#align_center' do
@@ -204,12 +69,7 @@ module Vedeu
204
69
  subject { instance.align_left(width) }
205
70
 
206
71
  context 'when a width is given' do
207
- end
208
-
209
- context 'when a width is not given' do
210
- let(:width) {}
211
-
212
- it { proc { subject }.must_raise(Vedeu::Error::InvalidSyntax) }
72
+ it { subject.must_be_instance_of(Vedeu::Geometries::Geometry) }
213
73
  end
214
74
  end
215
75
 
@@ -221,12 +81,6 @@ module Vedeu
221
81
  context 'when a height is given' do
222
82
  it { subject.must_be_instance_of(Vedeu::Geometries::Geometry) }
223
83
  end
224
-
225
- context 'when a height is not given' do
226
- let(:height) {}
227
-
228
- it { proc { subject }.must_raise(Vedeu::Error::InvalidSyntax) }
229
- end
230
84
  end
231
85
 
232
86
  describe '#align_right' do
@@ -235,12 +89,7 @@ module Vedeu
235
89
  subject { instance.align_right(width) }
236
90
 
237
91
  context 'when a width is given' do
238
- end
239
-
240
- context 'when a width is not given' do
241
- let(:width) {}
242
-
243
- it { proc { subject }.must_raise(Vedeu::Error::InvalidSyntax) }
92
+ it { subject.must_be_instance_of(Vedeu::Geometries::Geometry) }
244
93
  end
245
94
  end
246
95
 
@@ -252,12 +101,6 @@ module Vedeu
252
101
  context 'when a height is given' do
253
102
  it { subject.must_be_instance_of(Vedeu::Geometries::Geometry) }
254
103
  end
255
-
256
- context 'when a height is not given' do
257
- let(:height) {}
258
-
259
- it { proc { subject }.must_raise(Vedeu::Error::InvalidSyntax) }
260
- end
261
104
  end
262
105
 
263
106
  describe '#columns' do
@@ -13,26 +13,48 @@ module Vedeu
13
13
  let(:y) { 12 }
14
14
  let(:x) { 19 }
15
15
 
16
- describe '#y' do
17
- it { instance.must_respond_to(:y) }
18
- end
19
-
20
- describe '#first' do
21
- it { instance.must_respond_to(:first) }
22
- end
16
+ let(:term_height) { 15 }
17
+ let(:term_width) { 20 }
23
18
 
24
- describe '#x' do
25
- it { instance.must_respond_to(:x) }
26
- end
27
-
28
- describe '#last' do
29
- it { instance.must_respond_to(:last) }
19
+ before do
20
+ Vedeu.stubs(:height).returns(term_height)
21
+ Vedeu.stubs(:width).returns(term_width)
30
22
  end
31
23
 
32
24
  describe '#initialize' do
33
25
  it { instance.must_be_instance_of(described) }
34
- it { instance.instance_variable_get('@y').must_equal(y) }
35
- it { instance.instance_variable_get('@x').must_equal(x) }
26
+
27
+ context 'when y < 1' do
28
+ let(:y) { -3 }
29
+
30
+ it { instance.instance_variable_get('@y').must_equal(1) }
31
+ end
32
+
33
+ context 'when y > Vedeu.height' do
34
+ let(:y) { 17 }
35
+
36
+ it { instance.instance_variable_get('@y').must_equal(term_height) }
37
+ end
38
+
39
+ context 'when y >= 1 and y <= Vedeu.height' do
40
+ it { instance.instance_variable_get('@y').must_equal(y) }
41
+ end
42
+
43
+ context 'when x < 1' do
44
+ let(:x) { -2 }
45
+
46
+ it { instance.instance_variable_get('@x').must_equal(1) }
47
+ end
48
+
49
+ context 'when x > Vedeu.width' do
50
+ let(:x) { 23 }
51
+
52
+ it { instance.instance_variable_get('@x').must_equal(term_width) }
53
+ end
54
+
55
+ context 'when x >= 1 and x <= Vedeu.height' do
56
+ it { instance.instance_variable_get('@x').must_equal(x) }
57
+ end
36
58
  end
37
59
 
38
60
  describe '.[]' do
@@ -68,30 +90,6 @@ module Vedeu
68
90
  end
69
91
  end
70
92
 
71
- describe '#<=>' do
72
- subject { instance.<=>(other) }
73
-
74
- context 'when y is the same as other.y' do
75
- context 'when x is the same as other.x' do
76
- let(:other) { described.new(12, 19) }
77
-
78
- it { subject.must_equal(0) }
79
- end
80
-
81
- context 'when x is different to other.x' do
82
- let(:other) { described.new(12, 21) }
83
-
84
- it { subject.must_equal(-1) }
85
- end
86
- end
87
-
88
- context 'when y is different to other.y' do
89
- let(:other) { described.new(14, 19) }
90
-
91
- it { subject.must_equal(-1) }
92
- end
93
- end
94
-
95
93
  describe '.coerce' do
96
94
  let(:_value) {}
97
95
 
@@ -127,6 +125,12 @@ module Vedeu
127
125
  it { subject.x.must_equal(9) }
128
126
  end
129
127
 
128
+ context 'when the value is a NilClass' do
129
+ let(:_value) {}
130
+
131
+ it { subject.must_be_instance_of(NilClass) }
132
+ end
133
+
130
134
  context 'when the value is something unhandled' do
131
135
  let(:_value) { :invalid }
132
136
 
@@ -134,6 +138,30 @@ module Vedeu
134
138
  end
135
139
  end
136
140
 
141
+ describe '#<=>' do
142
+ subject { instance.<=>(other) }
143
+
144
+ context 'when y is the same as other.y' do
145
+ context 'when x is the same as other.x' do
146
+ let(:other) { described.new(12, 19) }
147
+
148
+ it { subject.must_equal(0) }
149
+ end
150
+
151
+ context 'when x is different to other.x' do
152
+ let(:other) { described.new(12, 21) }
153
+
154
+ it { subject.must_equal(-1) }
155
+ end
156
+ end
157
+
158
+ context 'when y is different to other.y' do
159
+ let(:other) { described.new(14, 19) }
160
+
161
+ it { subject.must_equal(-1) }
162
+ end
163
+ end
164
+
137
165
  describe '#eql?' do
138
166
  let(:other) { described.new(12, 19) }
139
167
 
@@ -148,6 +176,14 @@ module Vedeu
148
176
  end
149
177
  end
150
178
 
179
+ describe '#first' do
180
+ it { instance.must_respond_to(:first) }
181
+ end
182
+
183
+ describe '#last' do
184
+ it { instance.must_respond_to(:last) }
185
+ end
186
+
151
187
  describe '#to_a' do
152
188
  subject { instance.to_a }
153
189
 
@@ -226,6 +262,14 @@ module Vedeu
226
262
  end
227
263
  end
228
264
 
265
+ describe '#x' do
266
+ it { instance.must_respond_to(:x) }
267
+ end
268
+
269
+ describe '#y' do
270
+ it { instance.must_respond_to(:y) }
271
+ end
272
+
229
273
  describe '#as_indices' do
230
274
  subject { instance.as_indices }
231
275
 
@@ -247,27 +291,33 @@ module Vedeu
247
291
  describe '#down' do
248
292
  subject { instance.down }
249
293
 
250
- it { subject.must_be_instance_of(described) }
251
- it { subject.y.must_equal(13) }
252
- it { subject.x.must_equal(19) }
294
+ context 'when moving down is inside the terminal boundary' do
295
+ it { subject.must_be_instance_of(described) }
296
+ it { subject.wont_equal(instance) }
297
+ it { subject.y.must_equal(13) }
298
+ end
253
299
 
254
- context 'when y is 0' do
255
- let(:y) { 0 }
300
+ context 'when moving down is not inside the terminal boundary' do
301
+ let(:y) { 15 }
256
302
 
257
- it { subject.y.must_equal(2) }
303
+ it { subject.must_equal(instance) }
304
+ it { subject.y.must_equal(15) }
258
305
  end
259
306
  end
260
307
 
261
308
  describe '#left' do
262
309
  subject { instance.left }
263
310
 
264
- it { subject.must_be_instance_of(described) }
265
- it { subject.y.must_equal(12) }
266
- it { subject.x.must_equal(18) }
311
+ context 'when moving left is inside the terminal boundary' do
312
+ it { subject.must_be_instance_of(described) }
313
+ it { subject.wont_equal(instance) }
314
+ it { subject.x.must_equal(18) }
315
+ end
267
316
 
268
- context 'when x is 0' do
269
- let(:x) { 0 }
317
+ context 'when moving left is not inside the terminal boundary' do
318
+ let(:x) { 1 }
270
319
 
320
+ it { subject.must_equal(instance) }
271
321
  it { subject.x.must_equal(1) }
272
322
  end
273
323
  end
@@ -275,27 +325,35 @@ module Vedeu
275
325
  describe '#right' do
276
326
  subject { instance.right }
277
327
 
278
- it { subject.must_be_instance_of(described) }
279
- it { subject.y.must_equal(12) }
280
328
  it { subject.x.must_equal(20) }
281
329
 
282
- context 'when x is 0' do
283
- let(:x) { 0 }
330
+ context 'when moving right is inside the terminal boundary' do
331
+ it { subject.must_be_instance_of(described) }
332
+ it { subject.wont_equal(instance) }
333
+ it { subject.x.must_equal(20) }
334
+ end
284
335
 
285
- it { subject.x.must_equal(2) }
336
+ context 'when moving right is not inside the terminal boundary' do
337
+ let(:x) { 20 }
338
+
339
+ it { subject.must_equal(instance) }
340
+ it { subject.x.must_equal(20) }
286
341
  end
287
342
  end
288
343
 
289
344
  describe '#up' do
290
345
  subject { instance.up }
291
346
 
292
- it { subject.must_be_instance_of(described) }
293
- it { subject.y.must_equal(11) }
294
- it { subject.x.must_equal(19) }
347
+ context 'when moving up is inside the terminal boundary' do
348
+ it { subject.must_be_instance_of(described) }
349
+ it { subject.wont_equal(instance) }
350
+ it { subject.y.must_equal(11) }
351
+ end
295
352
 
296
- context 'when y is 0' do
297
- let(:y) { 0 }
353
+ context 'when moving up is not inside the terminal boundary' do
354
+ let(:y) { 1 }
298
355
 
356
+ it { subject.must_equal(instance) }
299
357
  it { subject.y.must_equal(1) }
300
358
  end
301
359
  end