vedeu 0.2.10 → 0.2.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/docs/events.md +6 -0
- data/examples/{cursor_app/cursor_app.rb → cursor_app.rb} +1 -1
- data/examples/{lines_app/lines_app.rb → lines_app.rb} +1 -1
- data/lib/vedeu.rb +48 -28
- data/lib/vedeu/api/api.rb +8 -95
- data/lib/vedeu/application.rb +6 -2
- data/lib/vedeu/{models → colours}/background.rb +1 -1
- data/lib/vedeu/{models → colours}/colour.rb +0 -0
- data/lib/vedeu/{models → colours}/foreground.rb +2 -2
- data/lib/vedeu/{support/colour_translator.rb → colours/translator.rb} +7 -7
- data/lib/vedeu/input/input.rb +13 -5
- data/lib/vedeu/models/geometry.rb +30 -2
- data/lib/vedeu/models/key.rb +39 -0
- data/lib/vedeu/output/compositor.rb +30 -76
- data/lib/vedeu/output/output.rb +74 -0
- data/lib/vedeu/output/viewport.rb +36 -44
- data/lib/vedeu/repositories/buffers.rb +5 -18
- data/lib/vedeu/repositories/cursors.rb +16 -8
- data/lib/vedeu/repositories/events.rb +96 -9
- data/lib/vedeu/repositories/focus.rb +21 -20
- data/lib/vedeu/repositories/groups.rb +3 -11
- data/lib/vedeu/repositories/interfaces.rb +6 -9
- data/lib/vedeu/repositories/keymaps.rb +8 -3
- data/lib/vedeu/repositories/menus.rb +6 -21
- data/lib/vedeu/{models → repositories/models}/buffer.rb +62 -28
- data/lib/vedeu/{models → repositories/models}/cursor.rb +8 -2
- data/lib/vedeu/{models → repositories/models}/event.rb +7 -0
- data/lib/vedeu/repositories/models/group.rb +56 -0
- data/lib/vedeu/{models → repositories/models}/interface.rb +6 -0
- data/lib/vedeu/{models → repositories/models}/keymap.rb +7 -1
- data/lib/vedeu/{models → repositories/models}/menu.rb +9 -0
- data/lib/vedeu/{models → repositories/models}/offset.rb +8 -1
- data/lib/vedeu/repositories/offsets.rb +17 -12
- data/lib/vedeu/support/bounding_area.rb +127 -0
- data/lib/vedeu/support/common.rb +8 -0
- data/lib/vedeu/support/exceptions.rb +2 -12
- data/lib/vedeu/support/model.rb +14 -0
- data/lib/vedeu/support/refresh.rb +8 -7
- data/lib/vedeu/support/registrar.rb +7 -1
- data/lib/vedeu/support/repository.rb +31 -10
- data/lib/vedeu/support/sentence.rb +67 -0
- data/lib/vedeu/support/terminal.rb +19 -0
- data/lib/vedeu/support/trace.rb +2 -5
- data/test/integration/api/api_test.rb +97 -0
- data/test/integration/api_dsl/dsl_api_test.rb +4 -0
- data/test/integration/api_dsl/dsl_composition_test.rb +4 -0
- data/test/integration/api_dsl/dsl_defined_test.rb +4 -0
- data/test/integration/api_dsl/dsl_helpers_test.rb +4 -0
- data/test/integration/api_dsl/dsl_interface_test.rb +4 -0
- data/test/integration/api_dsl/dsl_keymap.rb +4 -0
- data/test/integration/api_dsl/dsl_line_test.rb +4 -0
- data/test/integration/api_dsl/dsl_menu_test.rb +4 -0
- data/test/integration/api_dsl/dsl_stream_test.rb +138 -0
- data/test/lib/vedeu/api/api_test.rb +1 -25
- data/test/lib/vedeu/api/helpers_test.rb +0 -10
- data/test/lib/vedeu/{models → colours}/background_test.rb +0 -0
- data/test/lib/vedeu/{models → colours}/colour_test.rb +0 -0
- data/test/lib/vedeu/{models → colours}/foreground_test.rb +0 -0
- data/test/lib/vedeu/{support/colour_translator_test.rb → colours/translator_test.rb} +3 -3
- data/test/lib/vedeu/input/input_test.rb +16 -47
- data/test/lib/vedeu/models/geometry_test.rb +46 -0
- data/test/lib/vedeu/models/group_test.rb +99 -0
- data/test/lib/vedeu/models/key_test.rb +41 -0
- data/test/lib/vedeu/output/compositor_test.rb +25 -101
- data/test/lib/vedeu/output/output_test.rb +108 -0
- data/test/lib/vedeu/repositories/buffers_test.rb +0 -8
- data/test/lib/vedeu/repositories/cursors_test.rb +34 -0
- data/test/lib/vedeu/repositories/focus_test.rb +37 -28
- data/test/lib/vedeu/repositories/interfaces_test.rb +1 -1
- data/test/lib/vedeu/repositories/keymaps_test.rb +6 -20
- data/test/lib/vedeu/repositories/menus_test.rb +0 -6
- data/test/lib/vedeu/{models → repositories/models}/buffer_test.rb +24 -27
- data/test/lib/vedeu/{models → repositories/models}/cursor_test.rb +0 -0
- data/test/lib/vedeu/{models → repositories/models}/event_test.rb +0 -0
- data/test/lib/vedeu/{models → repositories/models}/interface_test.rb +0 -0
- data/test/lib/vedeu/{models → repositories/models}/keymap_test.rb +0 -0
- data/test/lib/vedeu/{models → repositories/models}/menu_test.rb +0 -0
- data/test/lib/vedeu/{models → repositories/models}/offset_test.rb +0 -0
- data/test/lib/vedeu/support/bounding_area_test.rb +139 -0
- data/test/lib/vedeu/support/coercions_test.rb +6 -17
- data/test/lib/vedeu/support/grid_test.rb +1 -1
- data/test/lib/vedeu/support/model_test.rb +23 -0
- data/test/lib/vedeu/support/presentation_test.rb +0 -10
- data/test/lib/vedeu/support/refresh_test.rb +2 -2
- data/test/lib/vedeu/support/repository_test.rb +63 -64
- data/test/lib/vedeu/support/sentence_test.rb +48 -0
- data/test/lib/vedeu/support/terminal_test.rb +86 -6
- data/test/support/test_classes/all.rb +5 -0
- data/test/support/test_classes/coercions.rb +16 -0
- data/test/support/test_classes/helpers.rb +19 -0
- data/test/support/test_classes/model.rb +23 -0
- data/test/support/test_classes/presentation.rb +16 -0
- data/test/support/test_classes/repositories.rb +26 -0
- data/test/support/test_modules/all.rb +1 -0
- data/test/support/test_modules/repository.rb +16 -0
- data/test/test_helper.rb +4 -0
- data/vedeu.gemspec +3 -3
- metadata +95 -50
- data/lib/vedeu/output/clear.rb +0 -88
- data/lib/vedeu/output/render.rb +0 -50
- data/lib/vedeu/repositories/positional.rb +0 -23
- data/test/lib/vedeu/output/clear_test.rb +0 -56
- data/test/lib/vedeu/output/render_test.rb +0 -100
- data/test/lib/vedeu/repositories/positional_test.rb +0 -50
@@ -25,13 +25,13 @@ module Vedeu
|
|
25
25
|
it 'raises an exception when the group cannot be found' do
|
26
26
|
Groups.reset
|
27
27
|
|
28
|
-
proc { Refresh.by_group('') }.must_raise(
|
28
|
+
proc { Refresh.by_group('') }.must_raise(ModelNotFound)
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
32
32
|
describe '.by_name' do
|
33
33
|
it 'raises an exception when the buffer cannot be found' do
|
34
|
-
proc { Refresh.by_name('') }.must_raise(
|
34
|
+
proc { Refresh.by_name('') }.must_raise(ModelNotFound)
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
@@ -1,76 +1,60 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
3
|
module Vedeu
|
4
|
-
EntityNotFound = Class.new(StandardError)
|
5
|
-
|
6
|
-
class RepositoryTestClass
|
7
|
-
include Repository
|
8
|
-
|
9
|
-
def initialize(storage = {})
|
10
|
-
@storage = storage
|
11
|
-
end
|
12
|
-
|
13
|
-
def add(entity)
|
14
|
-
if storage.is_a?(Hash)
|
15
|
-
@storage = in_memory.merge!(entity)
|
16
|
-
|
17
|
-
else
|
18
|
-
@storage << entity
|
19
|
-
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
attr_accessor :storage
|
24
|
-
alias_method :in_memory, :storage
|
25
|
-
|
26
|
-
def not_found(name)
|
27
|
-
fail EntityNotFound
|
28
|
-
end
|
29
|
-
end # RepositoryTestClass
|
30
4
|
|
31
5
|
describe Repository do
|
32
6
|
|
33
7
|
describe '#all' do
|
34
8
|
it 'returns a Hash' do
|
35
|
-
|
9
|
+
RepositoriesTestClass.new.all.must_be_instance_of(Hash)
|
36
10
|
end
|
37
11
|
|
38
12
|
it 'returns the whole repository' do
|
39
|
-
|
13
|
+
RepositoriesTestClass.new.all.must_equal({})
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
describe '#empty?' do
|
18
|
+
it 'returns true when the storage is empty' do
|
19
|
+
RepositoriesTestClass.new.empty?.must_equal(true)
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'returns false when the storage is not empty' do
|
23
|
+
RepositoriesTestClass.new({ key: :value }).empty?.must_equal(false)
|
40
24
|
end
|
41
25
|
end
|
42
26
|
|
43
27
|
describe '#find' do
|
44
|
-
it 'raises an exception when the
|
28
|
+
it 'raises an exception when the model cannot be found' do
|
45
29
|
proc {
|
46
|
-
|
47
|
-
}.must_raise(
|
30
|
+
RepositoriesTestClass.new.find('terbium')
|
31
|
+
}.must_raise(ModelNotFound)
|
48
32
|
end
|
49
33
|
|
50
|
-
context 'when the
|
51
|
-
it 'returns the stored
|
52
|
-
|
53
|
-
repo =
|
54
|
-
repo.add({ 'terbium' =>
|
34
|
+
context 'when the model is found' do
|
35
|
+
it 'returns the stored model' do
|
36
|
+
model = { key: :value }
|
37
|
+
repo = RepositoriesTestClass.new
|
38
|
+
repo.add({ 'terbium' => model })
|
55
39
|
|
56
|
-
repo.find('terbium').must_equal(
|
40
|
+
repo.find('terbium').must_equal(model)
|
57
41
|
end
|
58
42
|
end
|
59
43
|
end
|
60
44
|
|
61
45
|
describe '#find_or_create' do
|
62
|
-
context 'when the
|
63
|
-
it 'returns the storage
|
46
|
+
context 'when the model is found by name' do
|
47
|
+
it 'returns the storage model' do
|
64
48
|
skip
|
65
49
|
end
|
66
50
|
end
|
67
51
|
|
68
|
-
context 'when the
|
69
|
-
it 'stores the newly created
|
52
|
+
context 'when the model is not found by name' do
|
53
|
+
it 'stores the newly created model' do
|
70
54
|
skip
|
71
55
|
end
|
72
56
|
|
73
|
-
it 'returns the newly created
|
57
|
+
it 'returns the newly created model' do
|
74
58
|
skip
|
75
59
|
end
|
76
60
|
end
|
@@ -78,12 +62,12 @@ module Vedeu
|
|
78
62
|
|
79
63
|
describe '#registered' do
|
80
64
|
it 'returns an Array' do
|
81
|
-
|
65
|
+
RepositoriesTestClass.new.registered.must_be_instance_of(Array)
|
82
66
|
end
|
83
67
|
|
84
68
|
context 'when the storage is a Hash' do
|
85
69
|
it 'returns a collection of the names of all the registered entities' do
|
86
|
-
repo =
|
70
|
+
repo = RepositoriesTestClass.new
|
87
71
|
repo.add({ 'rutherfordium' => { name: 'rutherfordium' } })
|
88
72
|
|
89
73
|
repo.registered.must_equal(['rutherfordium'])
|
@@ -92,7 +76,7 @@ module Vedeu
|
|
92
76
|
|
93
77
|
context 'when the storage is an Array' do
|
94
78
|
it 'returns the registered entities' do
|
95
|
-
repo =
|
79
|
+
repo = RepositoriesTestClass.new([])
|
96
80
|
repo.add('rutherfordium')
|
97
81
|
|
98
82
|
repo.registered.must_equal(['rutherfordium'])
|
@@ -101,7 +85,7 @@ module Vedeu
|
|
101
85
|
|
102
86
|
context 'when the storage is a Set' do
|
103
87
|
it 'returns the registered entities' do
|
104
|
-
repo =
|
88
|
+
repo = RepositoriesTestClass.new(Set.new)
|
105
89
|
repo.add('rutherfordium')
|
106
90
|
|
107
91
|
repo.registered.must_equal(['rutherfordium'])
|
@@ -109,26 +93,26 @@ module Vedeu
|
|
109
93
|
end
|
110
94
|
|
111
95
|
it 'returns an empty collection when the storage is empty' do
|
112
|
-
|
96
|
+
RepositoriesTestClass.new.registered.must_equal([])
|
113
97
|
end
|
114
98
|
end
|
115
99
|
|
116
100
|
describe '#registered?' do
|
117
101
|
it 'returns false when the storage is empty' do
|
118
|
-
|
102
|
+
RepositoriesTestClass.new.registered?('terbium').must_equal(false)
|
119
103
|
end
|
120
104
|
|
121
|
-
it 'returns false when the
|
122
|
-
repo =
|
105
|
+
it 'returns false when the model is not registered' do
|
106
|
+
repo = RepositoriesTestClass.new
|
123
107
|
repo.add({ name: 'samarium' })
|
124
108
|
|
125
109
|
repo.registered?('terbium').must_equal(false)
|
126
110
|
end
|
127
111
|
|
128
|
-
it 'returns true when the
|
112
|
+
it 'returns true when the model is registered' do
|
129
113
|
skip
|
130
114
|
|
131
|
-
repo =
|
115
|
+
repo = RepositoriesTestClass.new
|
132
116
|
repo.add({ name: 'samarium' })
|
133
117
|
|
134
118
|
repo.registered?('samarium').must_equal(true)
|
@@ -138,14 +122,14 @@ module Vedeu
|
|
138
122
|
describe '#remove' do
|
139
123
|
context 'when the storage is empty' do
|
140
124
|
it 'returns false' do
|
141
|
-
test_repo =
|
125
|
+
test_repo = RepositoriesTestClass.new
|
142
126
|
test_repo.remove('francium').must_equal(false)
|
143
127
|
end
|
144
128
|
end
|
145
129
|
|
146
|
-
context 'when the
|
130
|
+
context 'when the model is not registered' do
|
147
131
|
it 'returns false' do
|
148
|
-
test_repo =
|
132
|
+
test_repo = RepositoriesTestClass.new
|
149
133
|
test_repo.add({
|
150
134
|
'gadolinium' => 'rare-earth metal',
|
151
135
|
'samarium' => 'a hard silvery metal'
|
@@ -154,9 +138,9 @@ module Vedeu
|
|
154
138
|
end
|
155
139
|
end
|
156
140
|
|
157
|
-
context 'when the
|
158
|
-
it 'returns the storage with the
|
159
|
-
test_repo =
|
141
|
+
context 'when the model is registered' do
|
142
|
+
it 'returns the storage with the model removed' do
|
143
|
+
test_repo = RepositoriesTestClass.new
|
160
144
|
test_repo.add({
|
161
145
|
'gadolinium' => 'rare-earth metal',
|
162
146
|
'samarium' => 'a hard silvery metal'
|
@@ -168,8 +152,8 @@ module Vedeu
|
|
168
152
|
end
|
169
153
|
|
170
154
|
context 'alias method: #destroy' do
|
171
|
-
it 'returns the storage with the
|
172
|
-
test_repo =
|
155
|
+
it 'returns the storage with the model removed' do
|
156
|
+
test_repo = RepositoriesTestClass.new
|
173
157
|
test_repo.add({
|
174
158
|
'gadolinium' => 'rare-earth metal',
|
175
159
|
'samarium' => 'a hard silvery metal'
|
@@ -181,8 +165,8 @@ module Vedeu
|
|
181
165
|
end
|
182
166
|
|
183
167
|
context 'alias method; #delete' do
|
184
|
-
it 'returns the storage with the
|
185
|
-
test_repo =
|
168
|
+
it 'returns the storage with the model removed' do
|
169
|
+
test_repo = RepositoriesTestClass.new
|
186
170
|
test_repo.add({
|
187
171
|
'gadolinium' => 'rare-earth metal',
|
188
172
|
'samarium' => 'a hard silvery metal'
|
@@ -196,11 +180,26 @@ module Vedeu
|
|
196
180
|
|
197
181
|
describe '#reset' do
|
198
182
|
it 'returns a Hash' do
|
199
|
-
|
183
|
+
RepositoriesTestClass.new.reset.must_be_instance_of(Hash)
|
200
184
|
end
|
201
185
|
|
202
186
|
it 'resets the repository' do
|
203
|
-
|
187
|
+
RepositoriesTestClass.new.reset.must_equal({})
|
188
|
+
end
|
189
|
+
end
|
190
|
+
|
191
|
+
describe '#store' do
|
192
|
+
let(:attributes) {
|
193
|
+
{
|
194
|
+
name: 'hydrogen'
|
195
|
+
}
|
196
|
+
}
|
197
|
+
let(:model) { ModelTestClass.new(attributes) }
|
198
|
+
|
199
|
+
subject { RepositoriesTestClass.new.store(model) }
|
200
|
+
|
201
|
+
it 'returns the model' do
|
202
|
+
subject.must_be_instance_of(model.class)
|
204
203
|
end
|
205
204
|
end
|
206
205
|
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Vedeu
|
4
|
+
|
5
|
+
describe Sentence do
|
6
|
+
|
7
|
+
let(:elements) { ['Hydrogen'] }
|
8
|
+
let(:label) { 'elements' }
|
9
|
+
|
10
|
+
describe '.construct' do
|
11
|
+
subject { Sentence.construct(elements, label) }
|
12
|
+
|
13
|
+
context 'when there is one element' do
|
14
|
+
let(:elements) { ['Hydrogen'] }
|
15
|
+
|
16
|
+
it 'returns the element as a string' do
|
17
|
+
subject.must_equal('Hydrogen')
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
context 'when there are two elements' do
|
22
|
+
let(:elements) { %w(Hydrogen Helium) }
|
23
|
+
|
24
|
+
it "returns the elements joined with 'and'" do
|
25
|
+
subject.must_equal('Hydrogen and Helium')
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
context 'when there are more than two elements' do
|
30
|
+
let(:elements) { %w(Hydrogen Helium Lithium) }
|
31
|
+
|
32
|
+
it 'returns the elements as a sentence list' do
|
33
|
+
subject.must_equal('Hydrogen, Helium and Lithium')
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
context 'when there are no elements' do
|
38
|
+
let(:elements) { [] }
|
39
|
+
|
40
|
+
it 'returns a polite message' do
|
41
|
+
subject.must_equal('No elements have been assigned.')
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
end # Sentence
|
47
|
+
|
48
|
+
end # Vedeu
|
@@ -92,13 +92,19 @@ module Vedeu
|
|
92
92
|
end
|
93
93
|
|
94
94
|
describe '.switch_mode!' do
|
95
|
+
it 'returns a Symbol' do
|
96
|
+
Terminal.switch_mode!.must_be_instance_of(Symbol)
|
97
|
+
end
|
98
|
+
|
95
99
|
it 'returns :cooked if previously :raw' do
|
96
100
|
Terminal.raw_mode!
|
101
|
+
|
97
102
|
Terminal.switch_mode!.must_equal(:cooked)
|
98
103
|
end
|
99
104
|
|
100
105
|
it 'returns :raw if previously :cooked' do
|
101
106
|
Terminal.cooked_mode!
|
107
|
+
|
102
108
|
Terminal.switch_mode!.must_equal(:raw)
|
103
109
|
end
|
104
110
|
end
|
@@ -110,6 +116,8 @@ module Vedeu
|
|
110
116
|
end
|
111
117
|
|
112
118
|
it 'returns the configured terminal mode' do
|
119
|
+
Terminal.mode.must_be_instance_of(Symbol)
|
120
|
+
|
113
121
|
Terminal.mode.must_equal(:raw)
|
114
122
|
end
|
115
123
|
end
|
@@ -117,6 +125,8 @@ module Vedeu
|
|
117
125
|
describe '.centre' do
|
118
126
|
it 'returns the centre point on the terminal' do
|
119
127
|
console.stub :winsize, [25, 80] do
|
128
|
+
Terminal.centre.must_be_instance_of(Array)
|
129
|
+
|
120
130
|
Terminal.centre.must_equal([12, 40])
|
121
131
|
end
|
122
132
|
end
|
@@ -125,6 +135,8 @@ module Vedeu
|
|
125
135
|
describe '.centre_y' do
|
126
136
|
it 'returns the centre `y` point on the terminal' do
|
127
137
|
console.stub :winsize, [25, 80] do
|
138
|
+
Terminal.centre_y.must_be_instance_of(Fixnum)
|
139
|
+
|
128
140
|
Terminal.centre_y.must_equal(12)
|
129
141
|
end
|
130
142
|
end
|
@@ -133,23 +145,89 @@ module Vedeu
|
|
133
145
|
describe '.centre_x' do
|
134
146
|
it 'returns the centre `x` point on the terminal' do
|
135
147
|
console.stub :winsize, [25, 80] do
|
148
|
+
Terminal.centre_x.must_be_instance_of(Fixnum)
|
149
|
+
|
136
150
|
Terminal.centre_x.must_equal(40)
|
137
151
|
end
|
138
152
|
end
|
139
153
|
end
|
140
154
|
|
141
|
-
describe '.
|
142
|
-
it 'returns
|
155
|
+
describe '.origin' do
|
156
|
+
it 'returns 1' do
|
143
157
|
console.stub :winsize, [25, 80] do
|
144
|
-
Terminal.
|
158
|
+
Terminal.origin.must_be_instance_of(Fixnum)
|
159
|
+
|
160
|
+
Terminal.origin.must_equal(1)
|
161
|
+
end
|
162
|
+
end
|
163
|
+
|
164
|
+
context 'alias_methods' do
|
165
|
+
it 'returns 1' do
|
166
|
+
console.stub :winsize, [25, 80] do
|
167
|
+
Terminal.x.must_equal(1)
|
168
|
+
end
|
169
|
+
end
|
170
|
+
|
171
|
+
it 'returns 1' do
|
172
|
+
console.stub :winsize, [25, 80] do
|
173
|
+
Terminal.y.must_equal(1)
|
174
|
+
end
|
175
|
+
end
|
176
|
+
end
|
177
|
+
end
|
178
|
+
|
179
|
+
describe '.width' do
|
180
|
+
context 'via method' do
|
181
|
+
it 'returns the width of the terminal' do
|
182
|
+
console.stub :winsize, [25, 80] do
|
183
|
+
Terminal.width.must_be_instance_of(Fixnum)
|
184
|
+
|
185
|
+
Terminal.width.must_equal(80)
|
186
|
+
end
|
187
|
+
end
|
188
|
+
end
|
189
|
+
|
190
|
+
context 'via API' do
|
191
|
+
it 'returns the width of the terminal' do
|
192
|
+
console.stub :winsize, [24, 40] do
|
193
|
+
Vedeu.width.must_equal(40)
|
194
|
+
end
|
195
|
+
end
|
196
|
+
end
|
197
|
+
|
198
|
+
context 'alias_methods' do
|
199
|
+
it 'returns the xn coordinate of the terminal' do
|
200
|
+
console.stub :winsize, [25, 80] do
|
201
|
+
Terminal.xn.must_equal(80)
|
202
|
+
end
|
145
203
|
end
|
146
204
|
end
|
147
205
|
end
|
148
206
|
|
149
207
|
describe '.height' do
|
150
|
-
|
151
|
-
|
152
|
-
|
208
|
+
context 'via method' do
|
209
|
+
it 'returns the height of the terminal' do
|
210
|
+
console.stub :winsize, [25, 80] do
|
211
|
+
Terminal.height.must_be_instance_of(Fixnum)
|
212
|
+
|
213
|
+
Terminal.height.must_equal(25)
|
214
|
+
end
|
215
|
+
end
|
216
|
+
end
|
217
|
+
|
218
|
+
context 'via API' do
|
219
|
+
it 'returns the height of the terminal' do
|
220
|
+
console.stub :winsize, [24, 40] do
|
221
|
+
Vedeu.height.must_equal(24)
|
222
|
+
end
|
223
|
+
end
|
224
|
+
end
|
225
|
+
|
226
|
+
context 'alias_methods' do
|
227
|
+
it 'returns the yn coordinate of the terminal' do
|
228
|
+
console.stub :winsize, [25, 80] do
|
229
|
+
Terminal.yn.must_equal(25)
|
230
|
+
end
|
153
231
|
end
|
154
232
|
end
|
155
233
|
end
|
@@ -157,6 +235,8 @@ module Vedeu
|
|
157
235
|
describe '.size' do
|
158
236
|
it 'returns the width and height of the terminal' do
|
159
237
|
console.stub :winsize, [25, 80] do
|
238
|
+
Terminal.size.must_be_instance_of(Array)
|
239
|
+
|
160
240
|
Terminal.size.must_equal([25, 80])
|
161
241
|
end
|
162
242
|
end
|