vedeu 0.4.17 → 0.4.18

Sign up to get free protection for your applications and to get access to all the features.
Files changed (127) hide show
  1. checksums.yaml +4 -4
  2. data/docs/dsl.md +54 -0
  3. data/docs/views.md +25 -25
  4. data/examples/cursor_app.rb +1 -1
  5. data/examples/material_colours_app.rb +1 -1
  6. data/lib/vedeu/all.rb +1 -0
  7. data/lib/vedeu/bindings.rb +2 -15
  8. data/lib/vedeu/buffers/buffer.rb +30 -7
  9. data/lib/vedeu/buffers/display_buffer.rb +1 -1
  10. data/lib/vedeu/configuration/configuration.rb +1 -1
  11. data/lib/vedeu/cursor/refresh_cursor.rb +4 -0
  12. data/lib/vedeu/dsl/components/border.rb +6 -1
  13. data/lib/vedeu/geometry/all.rb +0 -1
  14. data/lib/vedeu/geometry/area.rb +0 -20
  15. data/lib/vedeu/geometry/coordinate.rb +0 -50
  16. data/lib/vedeu/geometry/geometry.rb +1 -5
  17. data/lib/vedeu/geometry/position.rb +9 -0
  18. data/lib/vedeu/geometry/position_index.rb +19 -14
  19. data/lib/vedeu/geometry/position_validator.rb +3 -0
  20. data/lib/vedeu/models/all.rb +0 -3
  21. data/lib/vedeu/models/interface.rb +2 -4
  22. data/lib/vedeu/null/all.rb +5 -0
  23. data/lib/vedeu/null/border.rb +79 -0
  24. data/lib/vedeu/null/buffer.rb +44 -0
  25. data/lib/vedeu/null/generic.rb +52 -0
  26. data/lib/vedeu/null/geometry.rb +70 -0
  27. data/lib/vedeu/null/interface.rb +23 -0
  28. data/lib/vedeu/output/all.rb +0 -1
  29. data/lib/vedeu/output/border.rb +9 -9
  30. data/lib/vedeu/output/clear.rb +2 -1
  31. data/lib/vedeu/output/output.rb +1 -1
  32. data/lib/vedeu/output/refresh.rb +1 -1
  33. data/lib/vedeu/output/renderers/all.rb +7 -7
  34. data/lib/vedeu/output/renderers/escape_sequence.rb +47 -0
  35. data/lib/vedeu/output/renderers/{file_renderer.rb → file.rb} +11 -6
  36. data/lib/vedeu/output/renderers/{html_renderer.rb → html.rb} +4 -4
  37. data/lib/vedeu/output/renderers/{json_renderer.rb → json.rb} +4 -4
  38. data/lib/vedeu/output/renderers/{null_renderer.rb → null.rb} +2 -2
  39. data/lib/vedeu/output/renderers/{terminal_renderer.rb → terminal.rb} +4 -4
  40. data/lib/vedeu/output/renderers/{text_renderer.rb → text.rb} +4 -4
  41. data/lib/vedeu/output/text.rb +2 -2
  42. data/lib/vedeu/output/virtual_terminal.rb +2 -2
  43. data/lib/vedeu/repositories/all.rb +2 -0
  44. data/lib/vedeu/repositories/repositories/borders.rb +4 -2
  45. data/lib/vedeu/repositories/repositories/buffers.rb +11 -9
  46. data/lib/vedeu/repositories/repositories/cursors.rb +2 -0
  47. data/lib/vedeu/repositories/repositories/events_repository.rb +2 -0
  48. data/lib/vedeu/repositories/repositories/geometries.rb +4 -2
  49. data/lib/vedeu/repositories/repositories/groups.rb +2 -0
  50. data/lib/vedeu/repositories/repositories/interfaces_repository.rb +4 -2
  51. data/lib/vedeu/repositories/repositories/keymaps.rb +2 -0
  52. data/lib/vedeu/repositories/repositories/menus.rb +2 -0
  53. data/test/lib/vedeu/cursor/cursor_test.rb +1 -1
  54. data/test/lib/vedeu/cursor/move_test.rb +21 -33
  55. data/test/lib/vedeu/cursor/refresh_cursor_test.rb +16 -1
  56. data/test/lib/vedeu/distributed/test_application_test.rb +1 -1
  57. data/test/lib/vedeu/dsl/components/border_test.rb +1 -1
  58. data/test/lib/vedeu/dsl/components/geometry_test.rb +5 -5
  59. data/test/lib/vedeu/dsl/components/menu_test.rb +1 -1
  60. data/test/lib/vedeu/dsl/composition_test.rb +1 -1
  61. data/test/lib/vedeu/dsl/group_test.rb +1 -1
  62. data/test/lib/vedeu/dsl/interface_test.rb +1 -1
  63. data/test/lib/vedeu/dsl/stream_test.rb +1 -1
  64. data/test/lib/vedeu/events/event_test.rb +8 -8
  65. data/test/lib/vedeu/events/trigger_test.rb +1 -1
  66. data/test/lib/vedeu/geometry/area_test.rb +4 -36
  67. data/test/lib/vedeu/geometry/canvas_test.rb +2 -2
  68. data/test/lib/vedeu/geometry/coordinate_test.rb +0 -56
  69. data/test/lib/vedeu/geometry/dimension_test.rb +1 -1
  70. data/test/lib/vedeu/geometry/geometry_test.rb +1 -1
  71. data/test/lib/vedeu/geometry/grid_test.rb +1 -1
  72. data/test/lib/vedeu/geometry/position_index_test.rb +21 -23
  73. data/test/lib/vedeu/geometry/position_validator_test.rb +121 -3
  74. data/test/lib/vedeu/input/input_test.rb +1 -1
  75. data/test/lib/vedeu/input/key_test.rb +1 -1
  76. data/test/lib/vedeu/input/keymap_test.rb +1 -1
  77. data/test/lib/vedeu/models/interface_test.rb +14 -0
  78. data/test/lib/vedeu/null/border_test.rb +76 -0
  79. data/test/lib/vedeu/null/generic_test.rb +69 -0
  80. data/test/lib/vedeu/null/geometry_test.rb +63 -0
  81. data/test/lib/vedeu/null/interface_test.rb +13 -0
  82. data/test/lib/vedeu/output/clear_test.rb +1 -1
  83. data/test/lib/vedeu/output/compressor_test.rb +1 -1
  84. data/test/lib/vedeu/output/html_char_test.rb +1 -1
  85. data/test/lib/vedeu/output/output_test.rb +1 -1
  86. data/test/lib/vedeu/output/refresh_test.rb +17 -5
  87. data/test/lib/vedeu/output/renderers/escape_sequence_renderer_test.rb +4 -4
  88. data/test/lib/vedeu/output/renderers/{file_renderer_test.rb → file_test.rb} +4 -4
  89. data/test/lib/vedeu/output/renderers/{html_renderer_test.rb → html_test.rb} +4 -4
  90. data/test/lib/vedeu/output/renderers/{json_renderer_test.rb → json_test.rb} +4 -4
  91. data/test/lib/vedeu/output/renderers/{null_renderer_test.rb → null_test.rb} +3 -3
  92. data/test/lib/vedeu/output/renderers/{terminal_renderer_test.rb → terminal_test.rb} +4 -4
  93. data/test/lib/vedeu/output/renderers/{text_renderer_test.rb → text_test.rb} +4 -4
  94. data/test/lib/vedeu/output/style_test.rb +1 -1
  95. data/test/lib/vedeu/output/translator_test.rb +1 -1
  96. data/test/lib/vedeu/output/viewport_test.rb +1 -1
  97. data/test/lib/vedeu/output/virtual_terminal_test.rb +3 -3
  98. data/test/lib/vedeu/repositories/collection_test.rb +2 -2
  99. data/test/lib/vedeu/repositories/collections/chars_test.rb +1 -1
  100. data/test/lib/vedeu/repositories/collections/events_test.rb +1 -1
  101. data/test/lib/vedeu/repositories/collections/interfaces_test.rb +1 -1
  102. data/test/lib/vedeu/repositories/collections/keys_test.rb +1 -1
  103. data/test/lib/vedeu/repositories/collections/lines_test.rb +1 -1
  104. data/test/lib/vedeu/repositories/collections/streams_test.rb +1 -1
  105. data/test/lib/vedeu/repositories/repositories/borders_test.rb +1 -1
  106. data/test/lib/vedeu/repositories/repositories/buffers_test.rb +11 -23
  107. data/test/lib/vedeu/repositories/repositories/colours_test.rb +1 -1
  108. data/test/lib/vedeu/repositories/repositories/geometries_test.rb +1 -1
  109. data/test/lib/vedeu/repositories/repository_test.rb +1 -1
  110. data/test/lib/vedeu/storage/associative_store_test.rb +1 -1
  111. data/test/lib/vedeu/storage/conveyor_store_test.rb +1 -1
  112. data/test/lib/vedeu/storage/fifo_store_test.rb +1 -1
  113. data/test/lib/vedeu/support/template_test.rb +1 -1
  114. data/test/lib/vedeu/support/trace_test.rb +1 -1
  115. data/test/lib/vedeu/support/visibility_test.rb +2 -2
  116. data/test/test_helper.rb +1 -1
  117. data/vedeu.gemspec +1 -1
  118. metadata +36 -33
  119. data/lib/vedeu/geometry/null_geometry.rb +0 -70
  120. data/lib/vedeu/models/null.rb +0 -48
  121. data/lib/vedeu/models/null_interface.rb +0 -20
  122. data/lib/vedeu/output/null_border.rb +0 -75
  123. data/lib/vedeu/output/renderers/escape_sequence_renderer.rb +0 -43
  124. data/test/lib/vedeu/geometry/null_geometry_test.rb +0 -59
  125. data/test/lib/vedeu/models/null_interface_test.rb +0 -9
  126. data/test/lib/vedeu/models/null_test.rb +0 -66
  127. data/test/lib/vedeu/output/null_border_test.rb +0 -72
@@ -12,6 +12,8 @@ module Vedeu
12
12
  end
13
13
  alias_method :repository, :interfaces
14
14
 
15
+ # Remove all stored models from the repository.
16
+ #
15
17
  # @return [Vedeu::InterfacesRepository]
16
18
  def reset!
17
19
  @interfaces = Vedeu::InterfacesRepository.
@@ -21,13 +23,13 @@ module Vedeu
21
23
  end
22
24
 
23
25
  # @param name [String]
24
- # @return [Vedeu::Interface|Vedeu::NullInterface]
26
+ # @return [Vedeu::Interface|Vedeu::Null::Interface]
25
27
  def by_name(name)
26
28
  if registered?(name)
27
29
  find(name)
28
30
 
29
31
  else
30
- Vedeu::NullInterface.new(name: name)
32
+ Vedeu::Null::Interface.new(name: name)
31
33
 
32
34
  end
33
35
  end
@@ -12,6 +12,8 @@ module Vedeu
12
12
  end
13
13
  alias_method :repository, :keymaps
14
14
 
15
+ # Remove all stored models from the repository.
16
+ #
15
17
  # @return [Vedeu::Keymaps]
16
18
  def reset!
17
19
  @keymaps = Vedeu::Keymaps.register_repository(Vedeu::Keymap)
@@ -12,6 +12,8 @@ module Vedeu
12
12
  end
13
13
  alias_method :repository, :menus
14
14
 
15
+ # Remove all stored models from the repository.
16
+ #
15
17
  # @return [Vedeu::Menus]
16
18
  def reset!
17
19
  @menus = Vedeu::Menus.register_repository(Vedeu::Menu)
@@ -29,7 +29,7 @@ module Vedeu
29
29
  describe '#initialize' do
30
30
  subject { instance }
31
31
 
32
- it { subject.must_be_instance_of(Cursor) }
32
+ it { subject.must_be_instance_of(described) }
33
33
  it { subject.instance_variable_get('@name').must_equal('silver') }
34
34
  it { subject.instance_variable_get('@ox').must_equal(3) }
35
35
  it { subject.instance_variable_get('@oy').must_equal(2) }
@@ -18,8 +18,6 @@ module Vedeu
18
18
  Vedeu.borders.reset
19
19
  Vedeu.cursors.reset
20
20
  Vedeu.geometries.reset
21
- Vedeu.interfaces.reset
22
-
23
21
  Vedeu::Cursor.new(name: 'move_with_border',
24
22
  ox: ox,
25
23
  oy: oy,
@@ -32,24 +30,20 @@ module Vedeu
32
30
  visible: true,
33
31
  x: x,
34
32
  y: y).store
35
- Vedeu.interface 'move_with_border' do
36
- border do
37
- # ...
38
- end
39
- geometry do
40
- x 5
41
- xn 10
42
- y 5
43
- yn 10
44
- end
33
+ Vedeu.border 'move_with_border' do
34
+ # ...
45
35
  end
46
- Vedeu.interface 'move_without_border' do
47
- geometry do
48
- x 5
49
- xn 10
50
- y 5
51
- yn 10
52
- end
36
+ Vedeu.geometry 'move_with_border' do
37
+ x 5
38
+ xn 10
39
+ y 5
40
+ yn 10
41
+ end
42
+ Vedeu.geometry 'move_without_border' do
43
+ x 5
44
+ xn 10
45
+ y 5
46
+ yn 10
53
47
  end
54
48
  IO.console.stubs(:winsize).returns([25, 80])
55
49
  IO.console.stubs(:print)
@@ -58,11 +52,10 @@ module Vedeu
58
52
  Vedeu.borders.reset
59
53
  Vedeu.cursors.reset
60
54
  Vedeu.geometries.reset
61
- Vedeu.interfaces.reset
62
55
  end
63
56
 
64
57
  describe '#initialize' do
65
- it { instance.must_be_instance_of(Vedeu::Move) }
58
+ it { instance.must_be_instance_of(described) }
66
59
  it { instance.instance_variable_get('@name').must_equal(_name) }
67
60
  it { instance.instance_variable_get('@dy').must_equal(dy) }
68
61
  it { instance.instance_variable_get('@dx').must_equal(dx) }
@@ -76,7 +69,7 @@ module Vedeu
76
69
  Vedeu::Cursor.new(name: 'manganese', oy: 2, ox: 3, x: 8, y: 7).store
77
70
  end
78
71
 
79
- subject { Move.by_name(direction, _name) }
72
+ subject { described.by_name(direction, _name) }
80
73
 
81
74
  it { subject.must_be_instance_of(Vedeu::Cursor) }
82
75
 
@@ -108,18 +101,13 @@ module Vedeu
108
101
 
109
102
  it { subject.oy.must_equal(1) }
110
103
  end
111
-
112
- context 'but the interface does not exist' do
113
- before { Vedeu.interfaces.stubs(:find).with(_name).returns(nil) }
114
-
115
- end
116
104
  end
117
105
  end
118
106
 
119
107
  describe '.down' do
120
108
  let(:_name) { 'move_down' }
121
109
 
122
- subject { Move.down(_name) }
110
+ subject { described.down(_name) }
123
111
 
124
112
  it { subject.must_be_instance_of(Vedeu::Cursor) }
125
113
 
@@ -147,7 +135,7 @@ module Vedeu
147
135
  describe '.left' do
148
136
  let(:_name) { 'move_left' }
149
137
 
150
- subject { Move.left(_name) }
138
+ subject { described.left(_name) }
151
139
 
152
140
  it { subject.must_be_instance_of(Vedeu::Cursor) }
153
141
 
@@ -173,7 +161,7 @@ module Vedeu
173
161
  describe '.right' do
174
162
  let(:_name) { 'move_right' }
175
163
 
176
- subject { Move.right(_name) }
164
+ subject { described.right(_name) }
177
165
 
178
166
  it { subject.must_be_instance_of(Vedeu::Cursor) }
179
167
 
@@ -201,7 +189,7 @@ module Vedeu
201
189
  describe '.up' do
202
190
  let(:_name) { 'move_up' }
203
191
 
204
- subject { Move.up(_name) }
192
+ subject { described.up(_name) }
205
193
 
206
194
  it { subject.must_be_instance_of(Vedeu::Cursor) }
207
195
 
@@ -227,7 +215,7 @@ module Vedeu
227
215
  describe '#origin' do
228
216
  let(:_name) { 'move_origin' }
229
217
 
230
- subject { Move.origin(_name) }
218
+ subject { described.origin(_name) }
231
219
 
232
220
  it { subject.must_be_instance_of(Vedeu::Cursor) }
233
221
 
@@ -254,7 +242,7 @@ module Vedeu
254
242
  describe '#move' do
255
243
  let(:_name) { 'move_move' }
256
244
 
257
- subject { Move.new(_name, dy, dx).move }
245
+ subject { instance.move }
258
246
 
259
247
  it { subject.must_be_instance_of(Vedeu::Cursor) }
260
248
  end
@@ -13,10 +13,25 @@ module Vedeu
13
13
  end
14
14
 
15
15
  describe '#initialize' do
16
- it { instance.must_be_instance_of(Vedeu::RefreshCursor) }
16
+ it { instance.must_be_instance_of(described) }
17
17
  it { instance.instance_variable_get('@name').must_equal(_name) }
18
18
  end
19
19
 
20
+ # describe '.render' do
21
+ # subject { described.render(_name) }
22
+
23
+ # it 'renders the cursor in the terminal' do
24
+ # Vedeu::Terminal.expects(:output).with("\e[1;1H\e[?25l")
25
+ # subject
26
+ # end
27
+
28
+ # context 'when the view should be refreshed' do
29
+ # end
30
+
31
+ # context 'when the view should not be refreshed' do
32
+ # end
33
+ # end
34
+
20
35
  end # RefreshCursor
21
36
 
22
37
  end # Vedeu
@@ -9,7 +9,7 @@ module Vedeu
9
9
  let(:attributes) { {} }
10
10
 
11
11
  describe '#initialize' do
12
- it { instance.must_be_instance_of(Vedeu::TestApplication) }
12
+ it { instance.must_be_instance_of(described) }
13
13
  end
14
14
 
15
15
  describe '.build' do
@@ -36,7 +36,7 @@ module Vedeu
36
36
  end
37
37
 
38
38
  describe '#initialize' do
39
- it { instance.must_be_instance_of(Vedeu::DSL::Border) }
39
+ it { instance.must_be_instance_of(described) }
40
40
  it { instance.instance_variable_get('@model').must_equal(model) }
41
41
  it { instance.instance_variable_get('@client').must_equal(client) }
42
42
  end
@@ -17,7 +17,7 @@ module Vedeu
17
17
  end
18
18
 
19
19
  describe '#initialize' do
20
- it { instance.must_be_instance_of(Vedeu::DSL::Geometry) }
20
+ it { instance.must_be_instance_of(described) }
21
21
  it { instance.instance_variable_get('@model').must_equal(model) }
22
22
  end
23
23
 
@@ -119,14 +119,14 @@ module Vedeu
119
119
  context 'DSL #x' do
120
120
  subject {
121
121
  Vedeu.geometry 'geometry' do
122
- x 7
122
+ x 9
123
123
  end
124
124
  }
125
125
 
126
126
  it { subject.must_be_instance_of(Vedeu::Geometry) }
127
127
 
128
128
  it 'allows the use of x within geometry' do
129
- subject.x.must_equal(7)
129
+ subject.x.must_equal(9)
130
130
  end
131
131
 
132
132
  context 'when no value is given' do
@@ -236,12 +236,12 @@ module Vedeu
236
236
  subject {
237
237
  Vedeu::Geometry.build({}) do
238
238
  yn do
239
- 5 + 3
239
+ 5 + 4
240
240
  end
241
241
  end
242
242
  }
243
243
 
244
- it { subject.yn.must_equal(8) }
244
+ it { subject.yn.must_equal(9) }
245
245
  end
246
246
  end
247
247
 
@@ -19,7 +19,7 @@ module Vedeu
19
19
  let(:menu_name) { 'elements' }
20
20
 
21
21
  describe '#initialize' do
22
- it { instance.must_be_instance_of(Vedeu::DSL::Menu) }
22
+ it { instance.must_be_instance_of(described) }
23
23
  it { instance.instance_variable_get('@model').must_equal(model) }
24
24
  end
25
25
 
@@ -12,7 +12,7 @@ module Vedeu
12
12
  let(:client) {}
13
13
 
14
14
  describe '#initialize' do
15
- it { instance.must_be_instance_of(Vedeu::DSL::Composition) }
15
+ it { instance.must_be_instance_of(described) }
16
16
  it { instance.instance_variable_get('@model').must_equal(model) }
17
17
  it { instance.instance_variable_get('@client').must_equal(client) }
18
18
  end
@@ -13,7 +13,7 @@ module Vedeu
13
13
  let(:group_name) { 'main_screen' }
14
14
 
15
15
  describe '#initialize' do
16
- it { instance.must_be_instance_of(Vedeu::DSL::Group) }
16
+ it { instance.must_be_instance_of(described) }
17
17
  it { instance.instance_variable_get('@model').must_equal(model) }
18
18
  it { instance.instance_variable_get('@client').must_equal(client) }
19
19
  end
@@ -23,7 +23,7 @@ module Vedeu
23
23
  end
24
24
 
25
25
  describe '#initialize' do
26
- it { instance.must_be_instance_of(Vedeu::DSL::Interface) }
26
+ it { instance.must_be_instance_of(described) }
27
27
  it { instance.instance_variable_get('@model').must_equal(model) }
28
28
  it { instance.instance_variable_get('@client').must_equal(client) }
29
29
  end
@@ -13,7 +13,7 @@ module Vedeu
13
13
  let(:parent) { Vedeu::Line.new }
14
14
 
15
15
  describe '#initialize' do
16
- it { instance.must_be_instance_of(Vedeu::DSL::Stream) }
16
+ it { instance.must_be_instance_of(described) }
17
17
  it { instance.instance_variable_get('@model').must_equal(model) }
18
18
  it { instance.instance_variable_get('@client').must_equal(client) }
19
19
  end
@@ -23,7 +23,7 @@ module Vedeu
23
23
  end
24
24
 
25
25
  describe '#initialize' do
26
- it { instance.must_be_instance_of(Event) }
26
+ it { instance.must_be_instance_of(described) }
27
27
  it { instance.instance_variable_get('@name').must_equal(event_name) }
28
28
  it { instance.instance_variable_get('@options').must_equal(options) }
29
29
  it { instance.instance_variable_get('@deadline').must_equal(0) }
@@ -50,22 +50,22 @@ module Vedeu
50
50
 
51
51
  describe '#trigger' do
52
52
  it 'returns the result of calling the closure when debouncing' do
53
- event = Event.new(event_name, { debounce: 0.002 }, closure)
53
+ event = Event.new(event_name, { debounce: 0.001 }, closure)
54
54
  event.trigger.must_equal(nil)
55
- sleep 0.001
55
+ sleep 0.0005
56
56
  event.trigger.must_equal(nil)
57
- sleep 0.0015
57
+ sleep 0.0009
58
58
  event.trigger.must_equal(:event_triggered)
59
- sleep 0.001
59
+ sleep 0.0001
60
60
  event.trigger.must_equal(nil)
61
61
  end
62
62
 
63
63
  it 'returns the result of calling the closure when throttling' do
64
- event = Event.new(event_name, { delay: 0.002 }, closure)
64
+ event = Event.new(event_name, { delay: 0.001 }, closure)
65
65
  event.trigger.must_equal(:event_triggered)
66
- sleep 0.001
66
+ sleep 0.0005
67
67
  event.trigger.must_equal(nil)
68
- sleep 0.001
68
+ sleep 0.0005
69
69
  event.trigger.must_equal(:event_triggered)
70
70
  end
71
71
 
@@ -20,7 +20,7 @@ module Vedeu
20
20
  describe '#initialize' do
21
21
  subject { instance }
22
22
 
23
- it { subject.must_be_instance_of(Vedeu::Trigger) }
23
+ it { subject.must_be_instance_of(described) }
24
24
  it { subject.instance_variable_get('@name').must_equal(event_name) }
25
25
  it { subject.instance_variable_get('@args').must_equal([args]) }
26
26
  it do
@@ -24,7 +24,7 @@ module Vedeu
24
24
  end
25
25
 
26
26
  describe '#initialize' do
27
- it { instance.must_be_instance_of(Vedeu::Area) }
27
+ it { instance.must_be_instance_of(described) }
28
28
  it { instance.instance_variable_get('@y').must_equal(y) }
29
29
  it { instance.instance_variable_get('@yn').must_equal(yn) }
30
30
  it { instance.instance_variable_get('@x').must_equal(x) }
@@ -37,7 +37,7 @@ module Vedeu
37
37
 
38
38
  subject { described.from_dimensions(y_yn: y_yn, x_xn: x_xn) }
39
39
 
40
- it { subject.must_be_instance_of(Vedeu::Area) }
40
+ it { subject.must_be_instance_of(described) }
41
41
  it { subject.instance_variable_get('@y').must_equal(5) }
42
42
  it { subject.instance_variable_get('@yn').must_equal(8) }
43
43
  it { subject.instance_variable_get('@x').must_equal(15) }
@@ -50,7 +50,7 @@ module Vedeu
50
50
 
51
51
  subject { described.from_height_and_width(height: height, width: width) }
52
52
 
53
- it { subject.must_be_instance_of(Vedeu::Area) }
53
+ it { subject.must_be_instance_of(described) }
54
54
  it { subject.instance_variable_get('@y').must_equal(1) }
55
55
  it { subject.instance_variable_get('@yn').must_equal(5) }
56
56
  it { subject.instance_variable_get('@x').must_equal(1) }
@@ -60,7 +60,7 @@ module Vedeu
60
60
  describe '.from_points' do
61
61
  subject { described.from_points(y: y, yn: yn, x: x, xn: xn) }
62
62
 
63
- it { subject.must_be_instance_of(Vedeu::Area) }
63
+ it { subject.must_be_instance_of(described) }
64
64
  it { subject.instance_variable_get('@y').must_equal(y) }
65
65
  it { subject.instance_variable_get('@yn').must_equal(yn) }
66
66
  it { subject.instance_variable_get('@x').must_equal(x) }
@@ -182,38 +182,6 @@ module Vedeu
182
182
  end
183
183
  end
184
184
 
185
- describe '#top_left' do
186
- subject { instance.top_left }
187
-
188
- it { subject.must_be_instance_of(Vedeu::Position) }
189
- it { subject.y.must_equal(4) }
190
- it { subject.x.must_equal(6) }
191
- end
192
-
193
- describe '#bottom_left' do
194
- subject { instance.bottom_left }
195
-
196
- it { subject.must_be_instance_of(Vedeu::Position) }
197
- it { subject.y.must_equal(9) }
198
- it { subject.x.must_equal(6) }
199
- end
200
-
201
- describe '#top_right' do
202
- subject { instance.top_right }
203
-
204
- it { subject.must_be_instance_of(Vedeu::Position) }
205
- it { subject.y.must_equal(4) }
206
- it { subject.x.must_equal(21) }
207
- end
208
-
209
- describe '#bottom_right' do
210
- subject { instance.bottom_right }
211
-
212
- it { subject.must_be_instance_of(Vedeu::Position) }
213
- it { subject.y.must_equal(9) }
214
- it { subject.x.must_equal(21) }
215
- end
216
-
217
185
  end # Area
218
186
 
219
187
  end # Vedeu
@@ -12,11 +12,11 @@ module Vedeu
12
12
  before { instance.configure(yn, xn) }
13
13
 
14
14
  describe '.canvas' do
15
- it { instance.must_be_instance_of(Vedeu::Canvas) }
15
+ it { instance.must_be_instance_of(described) }
16
16
  end
17
17
 
18
18
  describe '#configure' do
19
- it { instance.must_be_instance_of(Vedeu::Canvas) }
19
+ it { instance.must_be_instance_of(described) }
20
20
  end
21
21
 
22
22
  describe '#c' do
@@ -47,62 +47,6 @@ module Vedeu
47
47
  end
48
48
  end
49
49
 
50
- describe '#y_index' do
51
- subject { instance.y_index(position) }
52
-
53
- context 'when the position is <= 0' do
54
- let(:position) { -2 }
55
-
56
- it { subject.must_equal(0) }
57
- end
58
-
59
- context 'when the position is <= y' do
60
- let(:position) { 4 }
61
-
62
- it { subject.must_equal(0) }
63
- end
64
-
65
- context 'when the position is >= yn' do
66
- let(:position) { 20 }
67
-
68
- it { subject.must_equal(5) }
69
- end
70
-
71
- context 'when the position is > y and < yn' do
72
- let(:position) { 8 }
73
-
74
- it { subject.must_equal(3) }
75
- end
76
- end
77
-
78
- describe '#x_index' do
79
- subject { instance.x_index(position) }
80
-
81
- context 'when the position is <= 0' do
82
- let(:position) { -2 }
83
-
84
- it { subject.must_equal(0) }
85
- end
86
-
87
- context 'when the position is <= x' do
88
- let(:position) { 4 }
89
-
90
- it { subject.must_equal(0) }
91
- end
92
-
93
- context 'when the position is >= xn' do
94
- let(:position) { 20 }
95
-
96
- it { subject.must_equal(5) }
97
- end
98
-
99
- context 'when the position is > x and < xn' do
100
- let(:position) { 8 }
101
-
102
- it { subject.must_equal(1) }
103
- end
104
- end
105
-
106
50
  describe '#y_position' do
107
51
  let(:index) { 0 }
108
52
  let(:height) { 6 }
@@ -22,7 +22,7 @@ module Vedeu
22
22
  let(:options) { {} }
23
23
 
24
24
  describe '#initialize' do
25
- it { instance.must_be_instance_of(Vedeu::Dimension) }
25
+ it { instance.must_be_instance_of(described) }
26
26
  it { instance.instance_variable_get('@d').must_equal(d) }
27
27
  it { instance.instance_variable_get('@dn').must_equal(dn) }
28
28
  it { instance.instance_variable_get('@d_dn').must_equal(d_dn) }
@@ -33,7 +33,7 @@ module Vedeu
33
33
  describe '#initialize' do
34
34
  subject { instance }
35
35
 
36
- it { subject.must_be_instance_of(Geometry) }
36
+ it { subject.must_be_instance_of(described) }
37
37
  it { subject.instance_variable_get('@attributes').must_equal(attributes) }
38
38
  it { subject.instance_variable_get('@centred').must_equal(centred) }
39
39
  it { subject.instance_variable_get('@height').must_equal(height) }
@@ -23,7 +23,7 @@ module Vedeu
23
23
  before { IO.console.stubs(:winsize).returns([25, 80]) }
24
24
 
25
25
  describe '#initialize' do
26
- it { instance.must_be_instance_of(Grid) }
26
+ it { instance.must_be_instance_of(described) }
27
27
  it { instance.instance_variable_get('@value').must_equal(_value) }
28
28
  end
29
29
 
@@ -11,20 +11,8 @@ module Vedeu
11
11
 
12
12
  describe '#initialize' do
13
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(0) }
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(0) }
27
- end
14
+ it { instance.instance_variable_get('@y').must_equal(y) }
15
+ it { instance.instance_variable_get('@x').must_equal(x) }
28
16
  end
29
17
 
30
18
  describe '.[]' do
@@ -61,21 +49,31 @@ module Vedeu
61
49
  it { subject.must_be_instance_of(Vedeu::Position) }
62
50
  end
63
51
 
64
- describe 'attr_reader' do
65
- context '#y' do
66
- subject { instance.y }
52
+ describe '#y' do
53
+ subject { instance.y }
67
54
 
68
- it { subject.must_equal(5) }
55
+ it { subject.must_equal(5) }
69
56
 
70
- it { instance.must_respond_to(:first) }
57
+ it { instance.must_respond_to(:first) }
58
+
59
+ context 'when y is less than 1' do
60
+ let(:y) { -3 }
61
+
62
+ it { subject.must_equal(0) }
71
63
  end
64
+ end
72
65
 
73
- context '#x' do
74
- subject { instance.x }
66
+ describe '#x' do
67
+ subject { instance.x }
75
68
 
76
- it { subject.must_equal(16) }
69
+ it { subject.must_equal(16) }
70
+
71
+ it { instance.must_respond_to(:last) }
72
+
73
+ context 'when x is less than 1' do
74
+ let(:x) { -9 }
77
75
 
78
- it { instance.must_respond_to(:last) }
76
+ it { subject.must_equal(0) }
79
77
  end
80
78
  end
81
79