vedeu 0.6.8 → 0.6.9
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/.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,48 +2,52 @@ require 'test_helper'
|
|
2
2
|
|
3
3
|
module Vedeu
|
4
4
|
|
5
|
-
|
5
|
+
module Output
|
6
6
|
|
7
|
-
|
8
|
-
let(:instance) { described.new(output) }
|
9
|
-
let(:output) {}
|
10
|
-
let(:drb) { false }
|
7
|
+
describe Output do
|
11
8
|
|
12
|
-
|
9
|
+
let(:described) { Vedeu::Output::Output }
|
10
|
+
let(:instance) { described.new(output) }
|
11
|
+
let(:output) {}
|
12
|
+
let(:drb) { false }
|
13
13
|
|
14
|
-
|
15
|
-
it { instance.must_be_instance_of(described) }
|
16
|
-
it { instance.instance_variable_get('@output').must_equal(output) }
|
17
|
-
end
|
14
|
+
before { Vedeu::Configuration.stubs(:drb?).returns(drb) }
|
18
15
|
|
19
|
-
|
20
|
-
|
16
|
+
describe '#initialize' do
|
17
|
+
it { instance.must_be_instance_of(described) }
|
18
|
+
it { instance.instance_variable_get('@output').must_equal(output) }
|
19
|
+
end
|
21
20
|
|
22
|
-
|
21
|
+
describe '.render' do
|
22
|
+
before { Vedeu.renderers.stubs(:render) }
|
23
23
|
|
24
|
-
|
25
|
-
let(:drb) { true }
|
26
|
-
let(:virtual_buffer) { [] }
|
24
|
+
subject { described.render(output) }
|
27
25
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
26
|
+
context 'when DRb is enabled' do
|
27
|
+
let(:drb) { true }
|
28
|
+
let(:virtual_buffer) { [] }
|
29
|
+
|
30
|
+
before do
|
31
|
+
Vedeu::Configuration.stubs(:drb?).returns(drb)
|
32
|
+
# Vedeu::Renderers::HTML.stubs(:to_file)
|
33
|
+
# Vedeu::Buffers::VirtualBuffers.stubs(:retrieve).returns(virtual_buffer)
|
34
|
+
end
|
33
35
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
36
|
+
it {
|
37
|
+
Vedeu.expects(:trigger).with(:_drb_store_output_, output)
|
38
|
+
subject
|
39
|
+
}
|
40
|
+
|
41
|
+
# it 'writes the virtual buffer to a file' do
|
42
|
+
# Vedeu::Renderers::HTML.expects(:to_file).with(virtual_buffer)
|
43
|
+
# subject
|
44
|
+
# end
|
45
|
+
end
|
38
46
|
|
39
|
-
|
40
|
-
# Vedeu::Renderers::HTML.expects(:to_file).with(virtual_buffer)
|
41
|
-
# subject
|
42
|
-
# end
|
47
|
+
it { Vedeu.renderers.expects(:render).with(output); subject }
|
43
48
|
end
|
44
49
|
|
45
|
-
|
46
|
-
end
|
50
|
+
end # Output
|
47
51
|
|
48
52
|
end # Output
|
49
53
|
|
@@ -45,22 +45,26 @@ module Vedeu
|
|
45
45
|
let(:foreground) { '#aadd00' }
|
46
46
|
|
47
47
|
describe '#to_s' do
|
48
|
+
let(:red) {
|
49
|
+
Vedeu::Colours::Colour.new(foreground: '#ff0000', background: '#000000')
|
50
|
+
}
|
51
|
+
let(:green) {
|
52
|
+
Vedeu::Colours::Colour.new(foreground: '#00ff00', background: '#000000')
|
53
|
+
}
|
48
54
|
let(:line) {
|
49
55
|
Vedeu::Views::Line.new(value: [],
|
50
|
-
parent: Vedeu::Interface.new,
|
51
|
-
colour:
|
52
|
-
|
53
|
-
style: Vedeu::Style.new('normal'))
|
56
|
+
parent: Vedeu::Models::Interface.new,
|
57
|
+
colour: green,
|
58
|
+
style: Vedeu::Presentation::Style.new('normal'))
|
54
59
|
}
|
55
60
|
let(:stream) {
|
56
61
|
Vedeu::Views::Stream.new(value: stream_value,
|
57
62
|
parent: line,
|
58
|
-
colour:
|
59
|
-
background: '#000000'),
|
63
|
+
colour: red,
|
60
64
|
style: stream_style)
|
61
65
|
}
|
62
66
|
let(:stream_value) { 'Some text' }
|
63
|
-
let(:stream_style) { Vedeu::Style.new(:underline) }
|
67
|
+
let(:stream_style) { Vedeu::Presentation::Style.new(:underline) }
|
64
68
|
|
65
69
|
it { includer.must_respond_to(:to_str) }
|
66
70
|
|
@@ -2,79 +2,119 @@ require 'test_helper'
|
|
2
2
|
|
3
3
|
module Vedeu
|
4
4
|
|
5
|
-
|
5
|
+
module Presentation
|
6
6
|
|
7
|
-
|
7
|
+
describe Style do
|
8
8
|
|
9
|
-
|
10
|
-
|
9
|
+
let(:described) { Vedeu::Presentation::Style }
|
10
|
+
let(:instance) { described.new(_value) }
|
11
|
+
let(:_value) { 'bold' }
|
11
12
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
}
|
16
|
-
end
|
13
|
+
describe 'alias methods' do
|
14
|
+
it { instance.must_respond_to(:escape_sequences) }
|
15
|
+
end
|
17
16
|
|
18
|
-
|
17
|
+
describe '#initialize' do
|
18
|
+
it { instance.must_be_instance_of(described) }
|
19
|
+
it { instance.instance_variable_get('@value').must_equal('bold') }
|
20
|
+
end
|
19
21
|
|
20
|
-
|
22
|
+
describe 'accessors' do
|
23
|
+
it { instance.must_respond_to(:value) }
|
24
|
+
it { instance.must_respond_to(:value=) }
|
25
|
+
end
|
21
26
|
|
22
|
-
|
27
|
+
describe '.coerce' do
|
28
|
+
let(:_value) { 'bold' }
|
23
29
|
|
24
|
-
|
25
|
-
attr_reader :parent
|
30
|
+
subject { described.coerce(_value) }
|
26
31
|
|
27
|
-
|
28
|
-
@attributes = attributes
|
29
|
-
@parent = @attributes[:parent]
|
30
|
-
end
|
32
|
+
it { subject.must_be_instance_of(described) }
|
31
33
|
|
32
|
-
|
34
|
+
context 'when the value is nil' do
|
35
|
+
let(:_value) { nil }
|
33
36
|
|
34
|
-
|
37
|
+
it { subject.must_be_instance_of(described) }
|
38
|
+
end
|
35
39
|
|
36
|
-
|
40
|
+
context 'when the value is a Style already' do
|
41
|
+
let(:_value) { Vedeu::Presentation::Style.new('bold') }
|
37
42
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
style: style,
|
43
|
-
}
|
44
|
-
}
|
45
|
-
let(:parent) { Vedeu::ParentPresentationStyleTestClass.new }
|
46
|
-
let(:style) { ['bold'] }
|
43
|
+
it 'returns the value' do
|
44
|
+
subject.must_equal(_value)
|
45
|
+
end
|
46
|
+
end
|
47
47
|
|
48
|
-
|
49
|
-
|
48
|
+
context 'when the value is an Array' do
|
49
|
+
let(:_value) { [:bold, :blink] }
|
50
50
|
|
51
|
-
|
51
|
+
it { subject.value.must_equal([:bold, :blink]) }
|
52
|
+
end
|
53
|
+
end
|
52
54
|
|
53
|
-
|
54
|
-
|
55
|
+
describe '#attributes' do
|
56
|
+
subject { instance.attributes }
|
55
57
|
|
56
|
-
|
57
|
-
|
58
|
-
|
58
|
+
it { subject.must_be_instance_of(Hash) }
|
59
|
+
|
60
|
+
it 'returns an attributes hash for this instance' do
|
61
|
+
subject.must_equal(style: 'bold')
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
describe '#eql?' do
|
66
|
+
let(:other) { instance }
|
59
67
|
|
60
|
-
|
61
|
-
let(:parent) {}
|
68
|
+
subject { instance.eql?(other) }
|
62
69
|
|
63
|
-
|
70
|
+
it { subject.must_equal(true) }
|
71
|
+
|
72
|
+
context 'when different to other' do
|
73
|
+
let(:other) { described.new('underline') }
|
74
|
+
|
75
|
+
it { subject.must_equal(false) }
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
describe '#to_s' do
|
80
|
+
let(:_value) {}
|
81
|
+
|
82
|
+
subject { instance.to_s }
|
83
|
+
|
84
|
+
it { subject.must_be_instance_of(String) }
|
85
|
+
it { subject.must_equal('') }
|
86
|
+
|
87
|
+
describe 'for a single style' do
|
88
|
+
let(:_value) { 'normal' }
|
89
|
+
|
90
|
+
it 'returns an escape sequence' do
|
91
|
+
subject.must_equal("\e[24m\e[22m\e[27m")
|
64
92
|
end
|
65
93
|
end
|
66
94
|
|
67
|
-
|
68
|
-
|
95
|
+
describe 'for multiple styles' do
|
96
|
+
let(:_value) { ['normal', 'underline'] }
|
97
|
+
|
98
|
+
it 'returns an escape sequence for multiple styles' do
|
99
|
+
subject.must_equal("\e[24m\e[22m\e[27m\e[4m")
|
100
|
+
end
|
69
101
|
end
|
70
|
-
end
|
71
102
|
|
72
|
-
|
73
|
-
|
103
|
+
describe 'for an unknown style' do
|
104
|
+
let(:_value) { 'unknown' }
|
105
|
+
|
106
|
+
it 'returns an empty string for an unknown style' do
|
107
|
+
subject.must_equal('')
|
108
|
+
end
|
109
|
+
end
|
74
110
|
|
75
|
-
|
111
|
+
describe 'for an empty or nil' do
|
112
|
+
let(:_value) { '' }
|
76
113
|
|
77
|
-
|
114
|
+
it 'returns an empty string for empty or nil' do
|
115
|
+
subject.must_equal('')
|
116
|
+
end
|
117
|
+
end
|
78
118
|
end
|
79
119
|
|
80
120
|
end # Style
|
@@ -0,0 +1,84 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Vedeu
|
4
|
+
|
5
|
+
class ParentPresentationStyleTestClass
|
6
|
+
|
7
|
+
include Vedeu::Presentation
|
8
|
+
|
9
|
+
attr_reader :attributes
|
10
|
+
attr_reader :parent
|
11
|
+
|
12
|
+
def attributes
|
13
|
+
{
|
14
|
+
style: ['underline']
|
15
|
+
}
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
|
20
|
+
class PresentationStyleTestClass
|
21
|
+
|
22
|
+
include Vedeu::Presentation
|
23
|
+
|
24
|
+
attr_reader :attributes
|
25
|
+
attr_reader :parent
|
26
|
+
|
27
|
+
def initialize(attributes = {})
|
28
|
+
@attributes = attributes
|
29
|
+
@parent = @attributes[:parent]
|
30
|
+
end
|
31
|
+
|
32
|
+
end # PresentationTestClass
|
33
|
+
|
34
|
+
module Presentation
|
35
|
+
|
36
|
+
describe Styles do
|
37
|
+
|
38
|
+
let(:includer) { Vedeu::PresentationStyleTestClass.new(attributes) }
|
39
|
+
let(:attributes) {
|
40
|
+
{
|
41
|
+
parent: parent,
|
42
|
+
style: style,
|
43
|
+
}
|
44
|
+
}
|
45
|
+
let(:parent) { Vedeu::ParentPresentationStyleTestClass.new }
|
46
|
+
let(:style) { ['bold'] }
|
47
|
+
|
48
|
+
describe '#style' do
|
49
|
+
subject { includer.style }
|
50
|
+
|
51
|
+
it { subject.must_be_instance_of(Vedeu::Presentation::Style) }
|
52
|
+
|
53
|
+
context 'when the attribute is not set' do
|
54
|
+
let(:style) {}
|
55
|
+
|
56
|
+
context 'when a parent is available' do
|
57
|
+
it { subject.value.must_equal(['underline']) }
|
58
|
+
end
|
59
|
+
|
60
|
+
context 'when a parent is not available' do
|
61
|
+
let(:parent) {}
|
62
|
+
|
63
|
+
it { subject.value.must_equal(nil) }
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
context 'when the attribute is set' do
|
68
|
+
it { subject.value.must_equal(['bold']) }
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
describe '#style=' do
|
73
|
+
let(:style) { Vedeu::Presentation::Style.new('normal') }
|
74
|
+
|
75
|
+
subject { includer.style = (style) }
|
76
|
+
|
77
|
+
it { subject.must_be_instance_of(Vedeu::Presentation::Style) }
|
78
|
+
end
|
79
|
+
|
80
|
+
end # Style
|
81
|
+
|
82
|
+
end # Presentation
|
83
|
+
|
84
|
+
end # Vedeu
|
@@ -2,151 +2,155 @@ require 'test_helper'
|
|
2
2
|
|
3
3
|
module Vedeu
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
{
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
5
|
+
module Output
|
6
|
+
|
7
|
+
describe Text do
|
8
|
+
|
9
|
+
let(:described) { Vedeu::Output::Text }
|
10
|
+
let(:_value) { 'Testing the Text class with various options' }
|
11
|
+
let(:options) {
|
12
|
+
{
|
13
|
+
anchor: anchor,
|
14
|
+
background: background,
|
15
|
+
colour: colour,
|
16
|
+
foreground: foreground,
|
17
|
+
model: model,
|
18
|
+
pad: pad,
|
19
|
+
width: width,
|
20
|
+
}
|
18
21
|
}
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
22
|
+
let(:anchor) { :left }
|
23
|
+
let(:background) { nil }
|
24
|
+
let(:colour) { nil }
|
25
|
+
let(:foreground) { nil }
|
26
|
+
let(:model) { nil }
|
27
|
+
let(:pad) { ' ' }
|
28
|
+
let(:width) { nil }
|
29
|
+
|
30
|
+
describe '.with' do
|
31
|
+
subject { described.with(_value, options) }
|
32
|
+
|
33
|
+
context 'when a width is provided' do
|
34
|
+
context 'when value longer than the width' do
|
35
|
+
let(:width) { 23 }
|
36
|
+
|
37
|
+
it 'returns the value truncated' do
|
38
|
+
subject.must_equal('Testing the Text class ')
|
39
|
+
end
|
37
40
|
end
|
38
|
-
end
|
39
41
|
|
40
|
-
|
41
|
-
|
42
|
+
context 'when value is shorter or equal to the width' do
|
43
|
+
let(:width) { 48 }
|
42
44
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
45
|
+
context 'and an anchor is not set' do
|
46
|
+
it 'returns the value left aligned' do
|
47
|
+
subject
|
48
|
+
.must_equal('Testing the Text class with various options ')
|
49
|
+
end
|
47
50
|
end
|
48
|
-
end
|
49
51
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
52
|
+
context 'and the anchor is set to :left' do
|
53
|
+
it 'returns the value left aligned' do
|
54
|
+
subject
|
55
|
+
.must_equal('Testing the Text class with various options ')
|
56
|
+
end
|
54
57
|
end
|
55
|
-
end
|
56
58
|
|
57
|
-
|
58
|
-
|
59
|
+
context 'and the anchor is set to :align' do
|
60
|
+
let(:anchor) { :align }
|
59
61
|
|
60
|
-
|
61
|
-
|
62
|
-
|
62
|
+
it 'returns the value left aligned' do
|
63
|
+
subject
|
64
|
+
.must_equal('Testing the Text class with various options ')
|
65
|
+
end
|
63
66
|
end
|
64
|
-
end
|
65
67
|
|
66
|
-
|
67
|
-
|
68
|
+
context 'and the anchor is set to centre' do
|
69
|
+
let(:anchor) { :centre }
|
68
70
|
|
69
|
-
|
70
|
-
|
71
|
-
|
71
|
+
it 'returns the value centre aligned' do
|
72
|
+
subject
|
73
|
+
.must_equal(' Testing the Text class with various options ')
|
74
|
+
end
|
72
75
|
end
|
73
|
-
end
|
74
76
|
|
75
|
-
|
76
|
-
|
77
|
+
context 'and the anchor is set to right' do
|
78
|
+
let(:anchor) { :right }
|
77
79
|
|
78
|
-
|
79
|
-
|
80
|
-
|
80
|
+
it 'returns the value right aligned' do
|
81
|
+
subject
|
82
|
+
.must_equal(' Testing the Text class with various options')
|
83
|
+
end
|
81
84
|
end
|
82
|
-
end
|
83
85
|
|
84
|
-
|
85
|
-
|
86
|
+
context 'and the anchor is invalid' do
|
87
|
+
let(:anchor) { :invalid }
|
86
88
|
|
87
|
-
|
88
|
-
|
89
|
-
|
89
|
+
it 'returns the value left aligned' do
|
90
|
+
subject
|
91
|
+
.must_equal('Testing the Text class with various options ')
|
92
|
+
end
|
90
93
|
end
|
91
94
|
end
|
92
95
|
end
|
93
|
-
end
|
94
96
|
|
95
|
-
|
96
|
-
|
97
|
-
|
97
|
+
context 'when a width is not provided' do
|
98
|
+
let(:width) {}
|
99
|
+
let(:_value) { 'some value' }
|
98
100
|
|
99
|
-
|
100
|
-
|
101
|
+
it 'returns the value as a string' do
|
102
|
+
subject.must_equal('some value')
|
103
|
+
end
|
101
104
|
end
|
102
105
|
end
|
103
|
-
end
|
104
106
|
|
105
|
-
|
106
|
-
|
107
|
+
describe '.add' do
|
108
|
+
subject { described.add(value, options) }
|
107
109
|
|
108
|
-
|
109
|
-
|
110
|
+
context 'when the model is a Vedeu::Views::View' do
|
111
|
+
let(:model) { Vedeu::Views::View.new }
|
110
112
|
|
111
|
-
|
112
|
-
|
113
|
+
it { subject.must_be_instance_of(Vedeu::Views::Lines) }
|
114
|
+
end
|
113
115
|
|
114
|
-
|
115
|
-
|
116
|
+
context 'when the model is a Vedeu::Views::Line' do
|
117
|
+
let(:model) { Vedeu::Views::Line.new }
|
116
118
|
|
117
|
-
|
118
|
-
|
119
|
+
it { subject.must_be_instance_of(Vedeu::Views::Streams) }
|
120
|
+
end
|
119
121
|
|
120
|
-
|
121
|
-
|
122
|
-
|
122
|
+
context 'when the model is a Vedeu::Views::Stream' do
|
123
|
+
let(:parent) { Vedeu::Views::Line.new }
|
124
|
+
let(:model) { Vedeu::Views::Stream.new(parent: parent) }
|
123
125
|
|
124
|
-
|
125
|
-
|
126
|
+
it { subject.must_be_instance_of(Vedeu::Views::Streams) }
|
127
|
+
end
|
126
128
|
|
127
|
-
|
128
|
-
|
129
|
+
context 'when the model is not given' do
|
130
|
+
let(:model) {}
|
129
131
|
|
130
|
-
|
131
|
-
|
132
|
+
it { subject.must_be_instance_of(NilClass) }
|
133
|
+
end
|
132
134
|
|
133
|
-
|
134
|
-
|
135
|
+
context 'when the colour option is given' do
|
136
|
+
let(:colour) { { background: '#33ff33', foreground: '#ffaa00' } }
|
135
137
|
|
136
|
-
|
137
|
-
|
138
|
-
|
138
|
+
# @todo Add more tests.
|
139
|
+
# it { skip }
|
140
|
+
end
|
139
141
|
|
140
|
-
|
141
|
-
|
142
|
-
|
142
|
+
context 'when the background and/or foreground options are given' do
|
143
|
+
let(:background) { '#111111' }
|
144
|
+
let(:foreground) { '#aadd00' }
|
145
|
+
|
146
|
+
# @todo Add more tests.
|
147
|
+
# it { skip }
|
148
|
+
end
|
143
149
|
|
144
|
-
# @todo Add more tests.
|
145
|
-
# it { skip }
|
146
150
|
end
|
147
151
|
|
148
|
-
end
|
152
|
+
end # Text
|
149
153
|
|
150
|
-
end #
|
154
|
+
end # Output
|
151
155
|
|
152
156
|
end # Vedeu
|