vedeu 0.6.8 → 0.6.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.yardopts +9 -0
- data/README.md +1 -1
- data/docs/api.md +60 -67
- data/docs/configuration.md +8 -5
- data/docs/events.md +31 -15
- data/docs/events/application.md +12 -0
- data/docs/events/document.md +57 -0
- data/docs/events/drb.md +43 -0
- data/docs/events/focus.md +24 -0
- data/docs/events/menu.md +57 -0
- data/docs/events/movement.md +57 -0
- data/docs/events/refresh.md +25 -0
- data/docs/events/system.md +90 -0
- data/docs/events/visibility.md +68 -0
- data/lib/vedeu.rb +2 -2
- data/lib/vedeu/all.rb +3 -2
- data/lib/vedeu/api.rb +18 -18
- data/lib/vedeu/application/controller.rb +1 -1
- data/lib/vedeu/application/helper.rb +1 -1
- data/lib/vedeu/application/view.rb +1 -1
- data/lib/vedeu/bindings/application.rb +1 -12
- data/lib/vedeu/bindings/bindings.rb +3 -1
- data/lib/vedeu/bindings/document.rb +9 -62
- data/lib/vedeu/bindings/drb.rb +12 -56
- data/lib/vedeu/bindings/focus.rb +3 -28
- data/lib/vedeu/bindings/menus.rb +10 -66
- data/lib/vedeu/bindings/movement.rb +4 -69
- data/lib/vedeu/bindings/refresh.rb +3 -33
- data/lib/vedeu/bindings/system.rb +14 -100
- data/lib/vedeu/bindings/visibility.rb +20 -71
- data/lib/vedeu/borders/all.rb +4 -3
- data/lib/vedeu/borders/border.rb +39 -33
- data/lib/vedeu/borders/dsl.rb +40 -33
- data/lib/vedeu/borders/null.rb +2 -2
- data/lib/vedeu/borders/render.rb +29 -24
- data/lib/vedeu/borders/repository.rb +2 -2
- data/lib/vedeu/buffers/all.rb +8 -7
- data/lib/vedeu/buffers/buffer.rb +47 -39
- data/lib/vedeu/buffers/null.rb +2 -2
- data/lib/vedeu/buffers/refresh.rb +4 -3
- data/lib/vedeu/buffers/virtual_buffer.rb +122 -118
- data/lib/vedeu/buffers/virtual_buffers.rb +62 -56
- data/lib/vedeu/colours/background.rb +2 -1
- data/lib/vedeu/colours/colour.rb +21 -19
- data/lib/vedeu/colours/foreground.rb +2 -1
- data/lib/vedeu/colours/repository.rb +6 -5
- data/lib/vedeu/colours/translator.rb +39 -35
- data/lib/vedeu/configuration/api.rb +59 -51
- data/lib/vedeu/configuration/cli.rb +9 -7
- data/lib/vedeu/configuration/configuration.rb +41 -32
- data/lib/vedeu/cursors/cursor.rb +1 -1
- data/lib/vedeu/cursors/refresh.rb +20 -16
- data/lib/vedeu/distributed/server.rb +8 -6
- data/lib/vedeu/distributed/subprocess.rb +90 -86
- data/lib/vedeu/distributed/uri.rb +4 -3
- data/lib/vedeu/dsl/composition.rb +2 -2
- data/lib/vedeu/dsl/group.rb +4 -4
- data/lib/vedeu/dsl/interface.rb +5 -5
- data/lib/vedeu/dsl/presentation.rb +2 -2
- data/lib/vedeu/dsl/text.rb +1 -1
- data/lib/vedeu/editor/cropper.rb +4 -4
- data/lib/vedeu/editor/cursor.rb +6 -4
- data/lib/vedeu/editor/document.rb +20 -18
- data/lib/vedeu/editor/editor.rb +2 -2
- data/lib/vedeu/editor/line.rb +10 -5
- data/lib/vedeu/editor/lines.rb +2 -2
- data/lib/vedeu/internal_api.rb +4 -4
- data/lib/vedeu/models/focus.rb +197 -191
- data/lib/vedeu/models/group.rb +171 -159
- data/lib/vedeu/models/groups.rb +14 -10
- data/lib/vedeu/models/interface.rb +116 -110
- data/lib/vedeu/models/interfaces.rb +24 -20
- data/lib/vedeu/models/toggleable.rb +4 -4
- data/lib/vedeu/models/views/char.rb +1 -1
- data/lib/vedeu/models/views/composition.rb +1 -1
- data/lib/vedeu/models/views/line.rb +1 -1
- data/lib/vedeu/models/views/stream.rb +1 -1
- data/lib/vedeu/models/views/view.rb +1 -1
- data/lib/vedeu/null/interface.rb +1 -1
- data/lib/vedeu/null/view.rb +1 -1
- data/lib/vedeu/output/clear/named_interface.rb +1 -1
- data/lib/vedeu/output/compressor.rb +78 -73
- data/lib/vedeu/output/direct.rb +61 -57
- data/lib/vedeu/output/output.rb +34 -29
- data/lib/vedeu/output/{presentation.rb → presentation/presentation.rb} +2 -1
- data/lib/vedeu/output/presentation/style.rb +64 -18
- data/lib/vedeu/output/presentation/styles.rb +39 -0
- data/lib/vedeu/output/renderers/html.rb +2 -2
- data/lib/vedeu/output/renderers/json.rb +2 -1
- data/lib/vedeu/output/renderers/terminal.rb +3 -3
- data/lib/vedeu/output/renderers/text.rb +3 -3
- data/lib/vedeu/output/text.rb +186 -180
- data/lib/vedeu/output/wordwrap.rb +142 -138
- data/lib/vedeu/refresh/refresh.rb +2 -2
- data/lib/vedeu/templating/helpers.rb +11 -6
- data/lib/vedeu/templating/view_template.rb +1 -1
- data/lib/vedeu/terminal/terminal.rb +2 -2
- data/lib/vedeu/version.rb +1 -1
- data/test/lib/vedeu/borders/render_test.rb +1 -1
- data/test/lib/vedeu/buffers/buffer_test.rb +16 -14
- data/test/lib/vedeu/buffers/virtual_buffer_test.rb +105 -101
- data/test/lib/vedeu/buffers/virtual_buffers_test.rb +43 -39
- data/test/lib/vedeu/colours/colour_test.rb +4 -4
- data/test/lib/vedeu/cursors/cursor_test.rb +2 -2
- data/test/lib/vedeu/cursors/repository_test.rb +3 -3
- data/test/lib/vedeu/distributed/subprocess_test.rb +33 -29
- data/test/lib/vedeu/dsl/group_test.rb +3 -3
- data/test/lib/vedeu/dsl/interface_test.rb +6 -5
- data/test/lib/vedeu/dsl/line_test.rb +4 -2
- data/test/lib/vedeu/dsl/presentation_test.rb +2 -2
- data/test/lib/vedeu/dsl/text_test.rb +8 -8
- data/test/lib/vedeu/editor/document_test.rb +10 -6
- data/test/lib/vedeu/input/keymap_test.rb +1 -10
- data/test/lib/vedeu/models/focus_test.rb +177 -170
- data/test/lib/vedeu/models/group_test.rb +99 -95
- data/test/lib/vedeu/models/groups_test.rb +13 -9
- data/test/lib/vedeu/models/interface_test.rb +93 -87
- data/test/lib/vedeu/models/interfaces_test.rb +24 -20
- data/test/lib/vedeu/models/views/char_test.rb +2 -2
- data/test/lib/vedeu/models/views/line_test.rb +11 -7
- data/test/lib/vedeu/models/views/stream_test.rb +1 -1
- data/test/lib/vedeu/models/views/view_test.rb +1 -1
- data/test/lib/vedeu/output/clear/named_group_test.rb +1 -1
- data/test/lib/vedeu/output/clear/named_interface_test.rb +3 -1
- data/test/lib/vedeu/output/compressor_test.rb +126 -122
- data/test/lib/vedeu/output/direct_test.rb +49 -43
- data/test/lib/vedeu/output/output_test.rb +35 -31
- data/test/lib/vedeu/output/{presentation_test.rb → presentation/presentation_test.rb} +11 -7
- data/test/lib/vedeu/output/presentation/style_test.rb +88 -48
- data/test/lib/vedeu/output/presentation/styles_test.rb +84 -0
- data/test/lib/vedeu/output/text_test.rb +109 -105
- data/test/lib/vedeu/output/viewport_test.rb +3 -1
- data/test/lib/vedeu/output/wordwrap_test.rb +209 -205
- data/test/lib/vedeu/refresh/refresh_test.rb +3 -1
- data/test/lib/vedeu/templating/helpers_test.rb +6 -6
- data/test/lib/vedeu/templating/view_template_test.rb +1 -1
- metadata +17 -8
- data/lib/vedeu/output/style.rb +0 -76
- data/test/lib/vedeu/output/style_test.rb +0 -120
@@ -2,33 +2,37 @@ require 'test_helper'
|
|
2
2
|
|
3
3
|
module Vedeu
|
4
4
|
|
5
|
-
|
5
|
+
module Models
|
6
6
|
|
7
|
-
|
7
|
+
describe Interfaces do
|
8
8
|
|
9
|
-
|
9
|
+
let(:described) { Vedeu::Models::Interfaces }
|
10
10
|
|
11
|
-
|
12
|
-
before do
|
13
|
-
Vedeu.interfaces.reset
|
11
|
+
it { described.must_respond_to(:interfaces) }
|
14
12
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
13
|
+
describe '#zindexed' do
|
14
|
+
before do
|
15
|
+
Vedeu.interfaces.reset
|
16
|
+
|
17
|
+
@hydrogen = Vedeu.interface('hydrogen') do
|
18
|
+
zindex 2
|
19
|
+
end
|
20
|
+
@helium = Vedeu.interface('helium') do
|
21
|
+
zindex 3
|
22
|
+
end
|
23
|
+
@lithium = Vedeu.interface('lithium') do
|
24
|
+
zindex 1
|
25
|
+
end
|
23
26
|
end
|
24
|
-
|
25
|
-
|
27
|
+
after { Vedeu.interfaces.reset }
|
28
|
+
|
29
|
+
subject { Vedeu.interfaces.zindexed }
|
26
30
|
|
27
|
-
|
31
|
+
it { subject.must_equal([@lithium, @hydrogen, @helium]) }
|
32
|
+
end
|
28
33
|
|
29
|
-
|
30
|
-
end
|
34
|
+
end # Interfaces
|
31
35
|
|
32
|
-
end #
|
36
|
+
end # Models
|
33
37
|
|
34
38
|
end # Vedeu
|
@@ -158,10 +158,10 @@ module Vedeu
|
|
158
158
|
end
|
159
159
|
|
160
160
|
context 'when a style is specified' do
|
161
|
-
let(:style) { Vedeu::Style.new('underline') }
|
161
|
+
let(:style) { Vedeu::Presentation::Style.new('underline') }
|
162
162
|
|
163
163
|
context 'when a parent style is specified' do
|
164
|
-
let(:parent_style) { Vedeu::Style.new('bold') }
|
164
|
+
let(:parent_style) { Vedeu::Presentation::Style.new('bold') }
|
165
165
|
|
166
166
|
it { subject.must_equal("\e[4ma") }
|
167
167
|
end
|
@@ -20,18 +20,22 @@ module Vedeu
|
|
20
20
|
[
|
21
21
|
Vedeu::Views::Stream.new(value: 'Something interesting ',
|
22
22
|
parent: streams_parent,
|
23
|
-
colour:
|
24
|
-
style:
|
23
|
+
colour: yellow,
|
24
|
+
style: normal_style),
|
25
25
|
Vedeu::Views::Stream.new(value: 'on this line ',
|
26
26
|
parent: streams_parent,
|
27
|
-
colour:
|
28
|
-
style:
|
27
|
+
colour: green,
|
28
|
+
style: normal_style),
|
29
29
|
Vedeu::Views::Stream.new(value: 'would be cool, eh?',
|
30
30
|
parent: streams_parent,
|
31
|
-
colour:
|
32
|
-
style:
|
31
|
+
colour: blue,
|
32
|
+
style: normal_style)
|
33
33
|
]
|
34
34
|
}
|
35
|
+
let(:yellow) { Vedeu::Colours::Colour.new(foreground: '#ffff00') }
|
36
|
+
let(:green) { Vedeu::Colours::Colour.new(foreground: '#00ff00') }
|
37
|
+
let(:blue) { Vedeu::Colours::Colour.new(foreground: '#0000ff') }
|
38
|
+
let(:normal_style) { Vedeu::Presentation::Style.new('normal') }
|
35
39
|
|
36
40
|
let(:streams_parent) {
|
37
41
|
Vedeu::Views::Line.new(value: nil,
|
@@ -41,10 +45,10 @@ module Vedeu
|
|
41
45
|
}
|
42
46
|
|
43
47
|
let(:parent) { Vedeu::Views::View.new(name: 'Vedeu::Line') }
|
48
|
+
let(:style) { Vedeu::Presentation::Style.new('normal') }
|
44
49
|
let(:colour) {
|
45
50
|
Vedeu::Colours::Colour.new(foreground: '#ff0000', background: '#000000')
|
46
51
|
}
|
47
|
-
let(:style) { Vedeu::Style.new('normal') }
|
48
52
|
|
49
53
|
describe '#initialize' do
|
50
54
|
it { instance.must_be_instance_of(described) }
|
@@ -29,7 +29,7 @@ module Vedeu
|
|
29
29
|
let(:colour) {
|
30
30
|
Vedeu::Colours::Colour.new(background: '#ff0000', foreground: '#000000')
|
31
31
|
}
|
32
|
-
let(:style) { Vedeu::Style.new('normal') }
|
32
|
+
let(:style) { Vedeu::Presentation::Style.new('normal') }
|
33
33
|
let(:line_parent) { Vedeu::Views::View.new(name: 'Vedeu::Views::Stream') }
|
34
34
|
|
35
35
|
describe '#initialize' do
|
@@ -86,7 +86,7 @@ module Vedeu
|
|
86
86
|
subject { instance.visible? }
|
87
87
|
|
88
88
|
context 'when the interface is visible' do
|
89
|
-
let(:interface) { Vedeu::Interface.new(visible: true) }
|
89
|
+
let(:interface) { Vedeu::Models::Interface.new(visible: true) }
|
90
90
|
|
91
91
|
before do
|
92
92
|
Vedeu.interfaces.stubs(:by_name).with(_name).returns(interface)
|
@@ -22,7 +22,9 @@ module Vedeu
|
|
22
22
|
end
|
23
23
|
|
24
24
|
describe '#render' do
|
25
|
-
let(:interface) {
|
25
|
+
let(:interface) {
|
26
|
+
Vedeu::Models::Interface.new(name: _name, visible: visible)
|
27
|
+
}
|
26
28
|
let(:visible) { true }
|
27
29
|
let(:geometry) {
|
28
30
|
Vedeu::Geometry::Geometry.new(name: _name, x: 1, y: 1, xn: 2, yn: 2)
|
@@ -2,143 +2,147 @@ require 'test_helper'
|
|
2
2
|
|
3
3
|
module Vedeu
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
5
|
+
module Output
|
6
|
+
|
7
|
+
describe Compressor do
|
8
|
+
|
9
|
+
let(:described) { Vedeu::Output::Compressor }
|
10
|
+
let(:instance) { described.new(output) }
|
11
|
+
let(:output) {}
|
12
|
+
|
13
|
+
describe '#initialize' do
|
14
|
+
it { instance.must_be_instance_of(described) }
|
15
|
+
it { instance.instance_variable_get('@output').must_equal(output) }
|
16
|
+
it { instance.instance_variable_get('@colour').must_equal('') }
|
17
|
+
it { instance.instance_variable_get('@style').must_equal('') }
|
18
|
+
end
|
19
|
+
|
20
|
+
describe '.render' do
|
21
|
+
subject { described.render(output) }
|
22
|
+
|
23
|
+
it { subject.must_be_instance_of(String) }
|
24
|
+
|
25
|
+
context 'when compression is enabled' do
|
26
|
+
before { Vedeu.configure { compression(true) } }
|
27
|
+
|
28
|
+
context 'when the output is all Vedeu::Views::Char elements' do
|
29
|
+
let(:output) {
|
30
|
+
[
|
31
|
+
Vedeu::Views::Char.new(value: 'Y',
|
32
|
+
colour: { foreground: '#ff0000' }),
|
33
|
+
Vedeu::Views::Char.new(value: 'e',
|
34
|
+
colour: { foreground: '#ff0000' }),
|
35
|
+
Vedeu::Views::Char.new(value: 's',
|
36
|
+
colour: { foreground: '#ff0000' }),
|
37
|
+
]
|
38
|
+
}
|
39
|
+
it 'converts the non-Vedeu::Views::Char elements into String ' \
|
40
|
+
'elements' do
|
41
|
+
subject.must_equal("\e[38;2;255;0;0mYes")
|
42
|
+
end
|
40
43
|
end
|
41
|
-
end
|
42
44
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
45
|
+
context 'when the output is all Vedeu::Views::Char elements' do
|
46
|
+
let(:output) {
|
47
|
+
[
|
48
|
+
Vedeu::Views::Char.new(value: 'a',
|
49
|
+
colour: { foreground: '#ff0000' }),
|
50
|
+
Vedeu::Views::Char.new(value: 'b',
|
51
|
+
colour: { foreground: '#ff0000' }),
|
52
|
+
Vedeu::Views::Char.new(value: 'c',
|
53
|
+
colour: { foreground: '#0000ff' }),
|
54
|
+
Vedeu::Views::Char.new(value: 'd',
|
55
|
+
colour: { foreground: '#0000ff' }),
|
56
|
+
]
|
57
|
+
}
|
58
|
+
it 'compresses multiple colours and styles where possible' do
|
59
|
+
subject.must_equal("\e[38;2;255;0;0mab\e[38;2;0;0;255mcd")
|
60
|
+
end
|
58
61
|
end
|
59
|
-
end
|
60
62
|
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
63
|
+
context 'when the output is not all Vedeu::Views::Char ' \
|
64
|
+
'elements' do
|
65
|
+
let(:output) {
|
66
|
+
[
|
67
|
+
Vedeu::Views::Char.new(value: 'N'),
|
68
|
+
Vedeu::Models::Escape.new(value: "\e[?25l"),
|
69
|
+
Vedeu::Views::Char.new(value: 't'),
|
70
|
+
]
|
71
|
+
}
|
72
|
+
it 'converts the non-Vedeu::Views::Char elements into String ' \
|
73
|
+
'elements' do
|
74
|
+
subject.must_equal("N\e[1;1H\e[?25lt")
|
75
|
+
end
|
73
76
|
end
|
74
77
|
end
|
75
|
-
end
|
76
78
|
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
79
|
+
context 'when compression is not enabled' do
|
80
|
+
before { Vedeu.configure { compression(false) } }
|
81
|
+
|
82
|
+
context 'when the output is all Vedeu::Views::Char elements' do
|
83
|
+
let(:output) {
|
84
|
+
[
|
85
|
+
Vedeu::Views::Char.new(value: 'Y',
|
86
|
+
colour: { foreground: '#ff0000' }),
|
87
|
+
Vedeu::Views::Char.new(value: 'e',
|
88
|
+
colour: { foreground: '#ff0000' }),
|
89
|
+
Vedeu::Views::Char.new(value: 's',
|
90
|
+
colour: { foreground: '#ff0000' }),
|
91
|
+
]
|
92
|
+
}
|
93
|
+
it 'converts the non-Vedeu::Views::Char elements into String ' \
|
94
|
+
'elements' do
|
95
|
+
subject.must_equal(
|
96
|
+
"\e[38;2;255;0;0mY\e[38;2;255;0;0me\e[38;2;255;0;0ms"
|
97
|
+
)
|
98
|
+
end
|
96
99
|
end
|
97
|
-
end
|
98
100
|
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
101
|
+
context 'when the output is all Vedeu::Views::Char elements' do
|
102
|
+
let(:output) {
|
103
|
+
[
|
104
|
+
Vedeu::Views::Char.new(value: 'a',
|
105
|
+
colour: { foreground: '#ff0000' }),
|
106
|
+
Vedeu::Views::Char.new(value: 'b',
|
107
|
+
colour: { foreground: '#ff0000' }),
|
108
|
+
Vedeu::Views::Char.new(value: 'c',
|
109
|
+
colour: { foreground: '#0000ff' }),
|
110
|
+
Vedeu::Views::Char.new(value: 'd',
|
111
|
+
colour: { foreground: '#0000ff' }),
|
112
|
+
]
|
113
|
+
}
|
114
|
+
it 'compresses multiple colours and styles where possible' do
|
115
|
+
subject.must_equal(
|
116
|
+
"\e[38;2;255;0;0ma" \
|
117
|
+
"\e[38;2;255;0;0mb" \
|
118
|
+
"\e[38;2;0;0;255mc" \
|
119
|
+
"\e[38;2;0;0;255md"
|
120
|
+
)
|
121
|
+
end
|
119
122
|
end
|
120
|
-
end
|
121
123
|
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
124
|
+
context 'when the output is not all Vedeu::Views::Char elements' do
|
125
|
+
let(:output) {
|
126
|
+
[
|
127
|
+
Vedeu::Views::Char.new(value: 'N'),
|
128
|
+
Vedeu::Models::Escape.new(value: "\e[?25l"),
|
129
|
+
Vedeu::Views::Char.new(value: 't'),
|
130
|
+
]
|
131
|
+
}
|
132
|
+
it 'converts the non-Vedeu::Views::Char elements into String ' \
|
133
|
+
'elements' do
|
134
|
+
subject.must_equal("N\e[1;1H\e[?25lt")
|
135
|
+
end
|
133
136
|
end
|
134
137
|
end
|
135
138
|
end
|
136
|
-
end
|
137
139
|
|
138
|
-
|
139
|
-
|
140
|
-
|
140
|
+
describe '#render' do
|
141
|
+
it { instance.must_respond_to(:render) }
|
142
|
+
end
|
143
|
+
|
144
|
+
end # Compressor
|
141
145
|
|
142
|
-
end #
|
146
|
+
end # Output
|
143
147
|
|
144
148
|
end # Vedeu
|
@@ -2,69 +2,75 @@ require 'test_helper'
|
|
2
2
|
|
3
3
|
module Vedeu
|
4
4
|
|
5
|
-
|
5
|
+
module Output
|
6
6
|
|
7
|
-
|
8
|
-
let(:instance) { described.new(value: _value, x: x, y: y) }
|
9
|
-
let(:_value) {}
|
10
|
-
let(:x) {}
|
11
|
-
let(:y) {}
|
7
|
+
describe Direct do
|
12
8
|
|
13
|
-
|
14
|
-
|
9
|
+
let(:described) { Vedeu::Output::Direct }
|
10
|
+
let(:instance) { described.new(value: _value, x: x, y: y) }
|
11
|
+
let(:_value) {}
|
12
|
+
let(:x) {}
|
13
|
+
let(:y) {}
|
15
14
|
|
16
|
-
|
17
|
-
it { instance.
|
18
|
-
end
|
15
|
+
describe '#initialize' do
|
16
|
+
it { instance.must_be_instance_of(described) }
|
19
17
|
|
20
|
-
|
21
|
-
|
18
|
+
context 'when no value is given' do
|
19
|
+
it { instance.instance_variable_get('@value').must_equal('') }
|
20
|
+
end
|
22
21
|
|
23
|
-
|
24
|
-
|
22
|
+
context 'when a value is given' do
|
23
|
+
let(:_value) { 'some value' }
|
25
24
|
|
26
|
-
|
27
|
-
|
28
|
-
|
25
|
+
it {
|
26
|
+
instance.instance_variable_get('@value').must_equal('some value')
|
27
|
+
}
|
28
|
+
end
|
29
29
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
end
|
30
|
+
context 'when no x is given' do
|
31
|
+
it { instance.instance_variable_get('@x').must_equal(1) }
|
32
|
+
end
|
34
33
|
|
35
|
-
|
36
|
-
|
37
|
-
|
34
|
+
context 'when an x is given' do
|
35
|
+
let(:x) { 6 }
|
36
|
+
it { instance.instance_variable_get('@x').must_equal(6) }
|
37
|
+
end
|
38
|
+
|
39
|
+
context 'when no y is given' do
|
40
|
+
it { instance.instance_variable_get('@y').must_equal(1) }
|
41
|
+
end
|
38
42
|
|
39
|
-
|
40
|
-
|
43
|
+
context 'when a y is given' do
|
44
|
+
let(:y) { 3 }
|
41
45
|
|
42
|
-
|
46
|
+
it { instance.instance_variable_get('@y').must_equal(3) }
|
47
|
+
end
|
43
48
|
end
|
44
|
-
end
|
45
49
|
|
46
|
-
|
47
|
-
|
50
|
+
describe '.write' do
|
51
|
+
before { Vedeu::Terminal.stubs(:output) }
|
52
|
+
|
53
|
+
subject { described.write(value: _value, x: x, y: y) }
|
48
54
|
|
49
|
-
|
55
|
+
it { subject.must_be_instance_of(String) }
|
50
56
|
|
51
|
-
|
57
|
+
context 'when a value is given' do
|
58
|
+
let(:_value) { 'some value' }
|
52
59
|
|
53
|
-
|
54
|
-
|
60
|
+
it { subject.must_equal("\e[1;1Hsome value") }
|
61
|
+
end
|
55
62
|
|
56
|
-
|
63
|
+
context 'when a value is not given' do
|
64
|
+
it { subject.must_equal("\e[1;1H") }
|
65
|
+
end
|
57
66
|
end
|
58
67
|
|
59
|
-
|
60
|
-
it {
|
68
|
+
describe '#write' do
|
69
|
+
it { instance.must_respond_to(:write) }
|
61
70
|
end
|
62
|
-
end
|
63
71
|
|
64
|
-
|
65
|
-
it { instance.must_respond_to(:write) }
|
66
|
-
end
|
72
|
+
end # Direct
|
67
73
|
|
68
|
-
end #
|
74
|
+
end # Output
|
69
75
|
|
70
76
|
end # Vedeu
|