vedeu 0.6.8 → 0.6.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (140) hide show
  1. checksums.yaml +4 -4
  2. data/.yardopts +9 -0
  3. data/README.md +1 -1
  4. data/docs/api.md +60 -67
  5. data/docs/configuration.md +8 -5
  6. data/docs/events.md +31 -15
  7. data/docs/events/application.md +12 -0
  8. data/docs/events/document.md +57 -0
  9. data/docs/events/drb.md +43 -0
  10. data/docs/events/focus.md +24 -0
  11. data/docs/events/menu.md +57 -0
  12. data/docs/events/movement.md +57 -0
  13. data/docs/events/refresh.md +25 -0
  14. data/docs/events/system.md +90 -0
  15. data/docs/events/visibility.md +68 -0
  16. data/lib/vedeu.rb +2 -2
  17. data/lib/vedeu/all.rb +3 -2
  18. data/lib/vedeu/api.rb +18 -18
  19. data/lib/vedeu/application/controller.rb +1 -1
  20. data/lib/vedeu/application/helper.rb +1 -1
  21. data/lib/vedeu/application/view.rb +1 -1
  22. data/lib/vedeu/bindings/application.rb +1 -12
  23. data/lib/vedeu/bindings/bindings.rb +3 -1
  24. data/lib/vedeu/bindings/document.rb +9 -62
  25. data/lib/vedeu/bindings/drb.rb +12 -56
  26. data/lib/vedeu/bindings/focus.rb +3 -28
  27. data/lib/vedeu/bindings/menus.rb +10 -66
  28. data/lib/vedeu/bindings/movement.rb +4 -69
  29. data/lib/vedeu/bindings/refresh.rb +3 -33
  30. data/lib/vedeu/bindings/system.rb +14 -100
  31. data/lib/vedeu/bindings/visibility.rb +20 -71
  32. data/lib/vedeu/borders/all.rb +4 -3
  33. data/lib/vedeu/borders/border.rb +39 -33
  34. data/lib/vedeu/borders/dsl.rb +40 -33
  35. data/lib/vedeu/borders/null.rb +2 -2
  36. data/lib/vedeu/borders/render.rb +29 -24
  37. data/lib/vedeu/borders/repository.rb +2 -2
  38. data/lib/vedeu/buffers/all.rb +8 -7
  39. data/lib/vedeu/buffers/buffer.rb +47 -39
  40. data/lib/vedeu/buffers/null.rb +2 -2
  41. data/lib/vedeu/buffers/refresh.rb +4 -3
  42. data/lib/vedeu/buffers/virtual_buffer.rb +122 -118
  43. data/lib/vedeu/buffers/virtual_buffers.rb +62 -56
  44. data/lib/vedeu/colours/background.rb +2 -1
  45. data/lib/vedeu/colours/colour.rb +21 -19
  46. data/lib/vedeu/colours/foreground.rb +2 -1
  47. data/lib/vedeu/colours/repository.rb +6 -5
  48. data/lib/vedeu/colours/translator.rb +39 -35
  49. data/lib/vedeu/configuration/api.rb +59 -51
  50. data/lib/vedeu/configuration/cli.rb +9 -7
  51. data/lib/vedeu/configuration/configuration.rb +41 -32
  52. data/lib/vedeu/cursors/cursor.rb +1 -1
  53. data/lib/vedeu/cursors/refresh.rb +20 -16
  54. data/lib/vedeu/distributed/server.rb +8 -6
  55. data/lib/vedeu/distributed/subprocess.rb +90 -86
  56. data/lib/vedeu/distributed/uri.rb +4 -3
  57. data/lib/vedeu/dsl/composition.rb +2 -2
  58. data/lib/vedeu/dsl/group.rb +4 -4
  59. data/lib/vedeu/dsl/interface.rb +5 -5
  60. data/lib/vedeu/dsl/presentation.rb +2 -2
  61. data/lib/vedeu/dsl/text.rb +1 -1
  62. data/lib/vedeu/editor/cropper.rb +4 -4
  63. data/lib/vedeu/editor/cursor.rb +6 -4
  64. data/lib/vedeu/editor/document.rb +20 -18
  65. data/lib/vedeu/editor/editor.rb +2 -2
  66. data/lib/vedeu/editor/line.rb +10 -5
  67. data/lib/vedeu/editor/lines.rb +2 -2
  68. data/lib/vedeu/internal_api.rb +4 -4
  69. data/lib/vedeu/models/focus.rb +197 -191
  70. data/lib/vedeu/models/group.rb +171 -159
  71. data/lib/vedeu/models/groups.rb +14 -10
  72. data/lib/vedeu/models/interface.rb +116 -110
  73. data/lib/vedeu/models/interfaces.rb +24 -20
  74. data/lib/vedeu/models/toggleable.rb +4 -4
  75. data/lib/vedeu/models/views/char.rb +1 -1
  76. data/lib/vedeu/models/views/composition.rb +1 -1
  77. data/lib/vedeu/models/views/line.rb +1 -1
  78. data/lib/vedeu/models/views/stream.rb +1 -1
  79. data/lib/vedeu/models/views/view.rb +1 -1
  80. data/lib/vedeu/null/interface.rb +1 -1
  81. data/lib/vedeu/null/view.rb +1 -1
  82. data/lib/vedeu/output/clear/named_interface.rb +1 -1
  83. data/lib/vedeu/output/compressor.rb +78 -73
  84. data/lib/vedeu/output/direct.rb +61 -57
  85. data/lib/vedeu/output/output.rb +34 -29
  86. data/lib/vedeu/output/{presentation.rb → presentation/presentation.rb} +2 -1
  87. data/lib/vedeu/output/presentation/style.rb +64 -18
  88. data/lib/vedeu/output/presentation/styles.rb +39 -0
  89. data/lib/vedeu/output/renderers/html.rb +2 -2
  90. data/lib/vedeu/output/renderers/json.rb +2 -1
  91. data/lib/vedeu/output/renderers/terminal.rb +3 -3
  92. data/lib/vedeu/output/renderers/text.rb +3 -3
  93. data/lib/vedeu/output/text.rb +186 -180
  94. data/lib/vedeu/output/wordwrap.rb +142 -138
  95. data/lib/vedeu/refresh/refresh.rb +2 -2
  96. data/lib/vedeu/templating/helpers.rb +11 -6
  97. data/lib/vedeu/templating/view_template.rb +1 -1
  98. data/lib/vedeu/terminal/terminal.rb +2 -2
  99. data/lib/vedeu/version.rb +1 -1
  100. data/test/lib/vedeu/borders/render_test.rb +1 -1
  101. data/test/lib/vedeu/buffers/buffer_test.rb +16 -14
  102. data/test/lib/vedeu/buffers/virtual_buffer_test.rb +105 -101
  103. data/test/lib/vedeu/buffers/virtual_buffers_test.rb +43 -39
  104. data/test/lib/vedeu/colours/colour_test.rb +4 -4
  105. data/test/lib/vedeu/cursors/cursor_test.rb +2 -2
  106. data/test/lib/vedeu/cursors/repository_test.rb +3 -3
  107. data/test/lib/vedeu/distributed/subprocess_test.rb +33 -29
  108. data/test/lib/vedeu/dsl/group_test.rb +3 -3
  109. data/test/lib/vedeu/dsl/interface_test.rb +6 -5
  110. data/test/lib/vedeu/dsl/line_test.rb +4 -2
  111. data/test/lib/vedeu/dsl/presentation_test.rb +2 -2
  112. data/test/lib/vedeu/dsl/text_test.rb +8 -8
  113. data/test/lib/vedeu/editor/document_test.rb +10 -6
  114. data/test/lib/vedeu/input/keymap_test.rb +1 -10
  115. data/test/lib/vedeu/models/focus_test.rb +177 -170
  116. data/test/lib/vedeu/models/group_test.rb +99 -95
  117. data/test/lib/vedeu/models/groups_test.rb +13 -9
  118. data/test/lib/vedeu/models/interface_test.rb +93 -87
  119. data/test/lib/vedeu/models/interfaces_test.rb +24 -20
  120. data/test/lib/vedeu/models/views/char_test.rb +2 -2
  121. data/test/lib/vedeu/models/views/line_test.rb +11 -7
  122. data/test/lib/vedeu/models/views/stream_test.rb +1 -1
  123. data/test/lib/vedeu/models/views/view_test.rb +1 -1
  124. data/test/lib/vedeu/output/clear/named_group_test.rb +1 -1
  125. data/test/lib/vedeu/output/clear/named_interface_test.rb +3 -1
  126. data/test/lib/vedeu/output/compressor_test.rb +126 -122
  127. data/test/lib/vedeu/output/direct_test.rb +49 -43
  128. data/test/lib/vedeu/output/output_test.rb +35 -31
  129. data/test/lib/vedeu/output/{presentation_test.rb → presentation/presentation_test.rb} +11 -7
  130. data/test/lib/vedeu/output/presentation/style_test.rb +88 -48
  131. data/test/lib/vedeu/output/presentation/styles_test.rb +84 -0
  132. data/test/lib/vedeu/output/text_test.rb +109 -105
  133. data/test/lib/vedeu/output/viewport_test.rb +3 -1
  134. data/test/lib/vedeu/output/wordwrap_test.rb +209 -205
  135. data/test/lib/vedeu/refresh/refresh_test.rb +3 -1
  136. data/test/lib/vedeu/templating/helpers_test.rb +6 -6
  137. data/test/lib/vedeu/templating/view_template_test.rb +1 -1
  138. metadata +17 -8
  139. data/lib/vedeu/output/style.rb +0 -76
  140. 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
- describe Output do
5
+ module Output
6
6
 
7
- let(:described) { Vedeu::Output }
8
- let(:instance) { described.new(output) }
9
- let(:output) {}
10
- let(:drb) { false }
7
+ describe Output do
11
8
 
12
- before { Vedeu::Configuration.stubs(:drb?).returns(drb) }
9
+ let(:described) { Vedeu::Output::Output }
10
+ let(:instance) { described.new(output) }
11
+ let(:output) {}
12
+ let(:drb) { false }
13
13
 
14
- describe '#initialize' do
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
- describe '.render' do
20
- before { Vedeu.renderers.stubs(:render) }
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
- subject { described.render(output) }
21
+ describe '.render' do
22
+ before { Vedeu.renderers.stubs(:render) }
23
23
 
24
- context 'when DRb is enabled' do
25
- let(:drb) { true }
26
- let(:virtual_buffer) { [] }
24
+ subject { described.render(output) }
27
25
 
28
- before do
29
- Vedeu::Configuration.stubs(:drb?).returns(drb)
30
- # Vedeu::Renderers::HTML.stubs(:to_file)
31
- # Vedeu::VirtualBuffers.stubs(:retrieve).returns(virtual_buffer)
32
- end
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
- it {
35
- Vedeu.expects(:trigger).with(:_drb_store_output_, output)
36
- subject
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
- # it 'writes the virtual buffer to a file' do
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
- it { Vedeu.renderers.expects(:render).with(output); subject }
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: Vedeu::Colours::Colour.new(foreground: '#00ff00',
52
- background: '#000000'),
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: Vedeu::Colours::Colour.new(foreground: '#ff0000',
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
- class ParentPresentationStyleTestClass
5
+ module Presentation
6
6
 
7
- include Vedeu::Presentation
7
+ describe Style do
8
8
 
9
- attr_reader :attributes
10
- attr_reader :parent
9
+ let(:described) { Vedeu::Presentation::Style }
10
+ let(:instance) { described.new(_value) }
11
+ let(:_value) { 'bold' }
11
12
 
12
- def attributes
13
- {
14
- style: ['underline']
15
- }
16
- end
13
+ describe 'alias methods' do
14
+ it { instance.must_respond_to(:escape_sequences) }
15
+ end
17
16
 
18
- end
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
- class PresentationStyleTestClass
22
+ describe 'accessors' do
23
+ it { instance.must_respond_to(:value) }
24
+ it { instance.must_respond_to(:value=) }
25
+ end
21
26
 
22
- include Vedeu::Presentation
27
+ describe '.coerce' do
28
+ let(:_value) { 'bold' }
23
29
 
24
- attr_reader :attributes
25
- attr_reader :parent
30
+ subject { described.coerce(_value) }
26
31
 
27
- def initialize(attributes = {})
28
- @attributes = attributes
29
- @parent = @attributes[:parent]
30
- end
32
+ it { subject.must_be_instance_of(described) }
31
33
 
32
- end # PresentationTestClass
34
+ context 'when the value is nil' do
35
+ let(:_value) { nil }
33
36
 
34
- module Presentation
37
+ it { subject.must_be_instance_of(described) }
38
+ end
35
39
 
36
- describe Style do
40
+ context 'when the value is a Style already' do
41
+ let(:_value) { Vedeu::Presentation::Style.new('bold') }
37
42
 
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'] }
43
+ it 'returns the value' do
44
+ subject.must_equal(_value)
45
+ end
46
+ end
47
47
 
48
- describe '#style' do
49
- subject { includer.style }
48
+ context 'when the value is an Array' do
49
+ let(:_value) { [:bold, :blink] }
50
50
 
51
- it { subject.must_be_instance_of(Vedeu::Style) }
51
+ it { subject.value.must_equal([:bold, :blink]) }
52
+ end
53
+ end
52
54
 
53
- context 'when the attribute is not set' do
54
- let(:style) {}
55
+ describe '#attributes' do
56
+ subject { instance.attributes }
55
57
 
56
- context 'when a parent is available' do
57
- it { subject.value.must_equal(['underline']) }
58
- end
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
- context 'when a parent is not available' do
61
- let(:parent) {}
68
+ subject { instance.eql?(other) }
62
69
 
63
- it { subject.value.must_equal(nil) }
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
- context 'when the attribute is set' do
68
- it { subject.value.must_equal(['bold']) }
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
- describe '#style=' do
73
- let(:style) { Vedeu::Style.new('normal') }
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
- subject { includer.style = (style) }
111
+ describe 'for an empty or nil' do
112
+ let(:_value) { '' }
76
113
 
77
- it { subject.must_be_instance_of(Vedeu::Style) }
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
- describe Text do
6
-
7
- let(:described) { Vedeu::Text }
8
- let(:_value) { 'Testing the Text class with various options' }
9
- let(:options) {
10
- {
11
- anchor: anchor,
12
- background: background,
13
- colour: colour,
14
- foreground: foreground,
15
- model: model,
16
- pad: pad,
17
- width: width,
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
- let(:anchor) { :left }
21
- let(:background) { nil }
22
- let(:colour) { nil }
23
- let(:foreground) { nil }
24
- let(:model) { nil }
25
- let(:pad) { ' ' }
26
- let(:width) { nil }
27
-
28
- describe '.with' do
29
- subject { described.with(_value, options) }
30
-
31
- context 'when a width is provided' do
32
- context 'when value longer than the width' do
33
- let(:width) { 23 }
34
-
35
- it 'returns the value truncated' do
36
- subject.must_equal('Testing the Text class ')
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
- context 'when value is shorter or equal to the width' do
41
- let(:width) { 48 }
42
+ context 'when value is shorter or equal to the width' do
43
+ let(:width) { 48 }
42
44
 
43
- context 'and an anchor is not set' do
44
- it 'returns the value left aligned' do
45
- subject
46
- .must_equal('Testing the Text class with various options ')
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
- context 'and the anchor is set to :left' do
51
- it 'returns the value left aligned' do
52
- subject
53
- .must_equal('Testing the Text class with various options ')
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
- context 'and the anchor is set to :align' do
58
- let(:anchor) { :align }
59
+ context 'and the anchor is set to :align' do
60
+ let(:anchor) { :align }
59
61
 
60
- it 'returns the value left aligned' do
61
- subject
62
- .must_equal('Testing the Text class with various options ')
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
- context 'and the anchor is set to centre' do
67
- let(:anchor) { :centre }
68
+ context 'and the anchor is set to centre' do
69
+ let(:anchor) { :centre }
68
70
 
69
- it 'returns the value centre aligned' do
70
- subject
71
- .must_equal(' Testing the Text class with various options ')
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
- context 'and the anchor is set to right' do
76
- let(:anchor) { :right }
77
+ context 'and the anchor is set to right' do
78
+ let(:anchor) { :right }
77
79
 
78
- it 'returns the value right aligned' do
79
- subject
80
- .must_equal(' Testing the Text class with various options')
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
- context 'and the anchor is invalid' do
85
- let(:anchor) { :invalid }
86
+ context 'and the anchor is invalid' do
87
+ let(:anchor) { :invalid }
86
88
 
87
- it 'returns the value left aligned' do
88
- subject
89
- .must_equal('Testing the Text class with various options ')
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
- context 'when a width is not provided' do
96
- let(:width) {}
97
- let(:_value) { 'some value' }
97
+ context 'when a width is not provided' do
98
+ let(:width) {}
99
+ let(:_value) { 'some value' }
98
100
 
99
- it 'returns the value as a string' do
100
- subject.must_equal('some value')
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
- describe '.add' do
106
- subject { described.add(value, options) }
107
+ describe '.add' do
108
+ subject { described.add(value, options) }
107
109
 
108
- context 'when the model is a Vedeu::Views::View' do
109
- let(:model) { Vedeu::Views::View.new }
110
+ context 'when the model is a Vedeu::Views::View' do
111
+ let(:model) { Vedeu::Views::View.new }
110
112
 
111
- it { subject.must_be_instance_of(Vedeu::Views::Lines) }
112
- end
113
+ it { subject.must_be_instance_of(Vedeu::Views::Lines) }
114
+ end
113
115
 
114
- context 'when the model is a Vedeu::Views::Line' do
115
- let(:model) { Vedeu::Views::Line.new }
116
+ context 'when the model is a Vedeu::Views::Line' do
117
+ let(:model) { Vedeu::Views::Line.new }
116
118
 
117
- it { subject.must_be_instance_of(Vedeu::Views::Streams) }
118
- end
119
+ it { subject.must_be_instance_of(Vedeu::Views::Streams) }
120
+ end
119
121
 
120
- context 'when the model is a Vedeu::Views::Stream' do
121
- let(:parent) { Vedeu::Views::Line.new }
122
- let(:model) { Vedeu::Views::Stream.new(parent: parent) }
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
- it { subject.must_be_instance_of(Vedeu::Views::Streams) }
125
- end
126
+ it { subject.must_be_instance_of(Vedeu::Views::Streams) }
127
+ end
126
128
 
127
- context 'when the model is not given' do
128
- let(:model) {}
129
+ context 'when the model is not given' do
130
+ let(:model) {}
129
131
 
130
- it { subject.must_be_instance_of(NilClass) }
131
- end
132
+ it { subject.must_be_instance_of(NilClass) }
133
+ end
132
134
 
133
- context 'when the colour option is given' do
134
- let(:colour) { { background: '#33ff33', foreground: '#ffaa00' } }
135
+ context 'when the colour option is given' do
136
+ let(:colour) { { background: '#33ff33', foreground: '#ffaa00' } }
135
137
 
136
- # @todo Add more tests.
137
- # it { skip }
138
- end
138
+ # @todo Add more tests.
139
+ # it { skip }
140
+ end
139
141
 
140
- context 'when the background and/or foreground options are given' do
141
- let(:background) { '#111111' }
142
- let(:foreground) { '#aadd00' }
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 # Text
154
+ end # Output
151
155
 
152
156
  end # Vedeu