vedeu 0.8.2 → 0.8.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/examples/views/_interfaces.rb +127 -0
- data/examples/views/empty_template.rb +10 -0
- data/examples/views/expected/vedeu_full_screen.html +140 -0
- data/examples/views/expected/vedeu_full_screen.json +96050 -0
- data/examples/views/expected/vedeu_full_screen.out +1 -0
- data/examples/views/expected/vedeu_full_screen.txt +50 -0
- data/examples/views/expected/vedeu_line.html +140 -0
- data/examples/views/expected/vedeu_line.json +96050 -0
- data/examples/views/expected/vedeu_line.out +1 -0
- data/examples/views/expected/vedeu_line.txt +58 -0
- data/examples/views/expected/vedeu_lines.html +140 -0
- data/examples/views/expected/vedeu_lines.json +96050 -0
- data/examples/views/expected/{lines.out → vedeu_lines.out} +1 -1
- data/examples/views/expected/vedeu_lines_alignment.html +80 -0
- data/examples/views/expected/vedeu_lines_alignment.json +46370 -0
- data/examples/views/expected/vedeu_lines_alignment.out +1 -0
- data/examples/views/full_screen.rb +10 -0
- data/examples/views/line.rb +11 -106
- data/examples/views/lines.rb +8 -127
- data/examples/views/lines_alignment.rb +17 -125
- data/examples/views/runner.sh +65 -19
- data/lib/vedeu/borders/border.rb +6 -6
- data/lib/vedeu/borders/refresh.rb +4 -6
- data/lib/vedeu/buffers/buffer.rb +1 -1
- data/lib/vedeu/buffers/terminal.rb +4 -4
- data/lib/vedeu/buffers/view.rb +2 -2
- data/lib/vedeu/cells/all.rb +2 -2
- data/lib/vedeu/cells/border.rb +5 -0
- data/lib/vedeu/cells/borders/all.rb +2 -8
- data/lib/vedeu/cells/borders/edges/all.rb +6 -0
- data/lib/vedeu/cells/borders/{bottom_horizontal.rb → edges/bottom_horizontal.rb} +0 -0
- data/lib/vedeu/cells/borders/{left_vertical.rb → edges/left_vertical.rb} +0 -0
- data/lib/vedeu/cells/borders/{right_vertical.rb → edges/right_vertical.rb} +0 -0
- data/lib/vedeu/cells/borders/{top_horizontal.rb → edges/top_horizontal.rb} +0 -0
- data/lib/vedeu/cells/borders/horizontal.rb +5 -0
- data/lib/vedeu/cells/borders/vertical.rb +5 -0
- data/lib/vedeu/cells/borders/vertices/all.rb +6 -0
- data/lib/vedeu/cells/borders/{bottom_left.rb → vertices/bottom_left.rb} +5 -0
- data/lib/vedeu/cells/borders/{bottom_right.rb → vertices/bottom_right.rb} +5 -0
- data/lib/vedeu/cells/borders/{top_left.rb → vertices/top_left.rb} +5 -0
- data/lib/vedeu/cells/borders/{top_right.rb → vertices/top_right.rb} +5 -0
- data/lib/vedeu/cells/char.rb +16 -0
- data/lib/vedeu/cells/clear.rb +5 -0
- data/lib/vedeu/cells/cursor.rb +70 -0
- data/lib/vedeu/cells/empty.rb +24 -14
- data/lib/vedeu/cells/escape.rb +8 -7
- data/lib/vedeu/cells/support/all.rb +3 -0
- data/lib/vedeu/cells/support/html.rb +98 -0
- data/lib/vedeu/colours/background.rb +21 -1
- data/lib/vedeu/colours/colour.rb +10 -2
- data/lib/vedeu/colours/foreground.rb +21 -1
- data/lib/vedeu/colours/translator.rb +17 -24
- data/lib/vedeu/colours/validator.rb +9 -9
- data/lib/vedeu/configuration/api.rb +1 -1
- data/lib/vedeu/cursors/cursor.rb +5 -5
- data/lib/vedeu/dsl/elements.rb +22 -79
- data/lib/vedeu/dsl/string/text.rb +3 -3
- data/lib/vedeu/editor/cropper.rb +2 -2
- data/lib/vedeu/editor/cursor.rb +1 -1
- data/lib/vedeu/editor/document.rb +1 -1
- data/lib/vedeu/geometries/area/dimension.rb +1 -1
- data/lib/vedeu/geometries/position.rb +5 -2
- data/lib/vedeu/interfaces/clear.rb +5 -5
- data/lib/vedeu/models/row.rb +4 -3
- data/lib/vedeu/output/compressor.rb +7 -7
- data/lib/vedeu/output/output.rb +8 -13
- data/lib/vedeu/output/viewport.rb +1 -1
- data/lib/vedeu/presentation/background.rb +2 -2
- data/lib/vedeu/presentation/colour.rb +0 -4
- data/lib/vedeu/presentation/foreground.rb +2 -2
- data/lib/vedeu/presentation/style.rb +1 -1
- data/lib/vedeu/presentation/styles.rb +0 -3
- data/lib/vedeu/renderers/file.rb +10 -68
- data/lib/vedeu/renderers/html.rb +28 -96
- data/lib/vedeu/renderers/json.rb +15 -31
- data/lib/vedeu/renderers/options.rb +160 -14
- data/lib/vedeu/renderers/templates/html_renderer.vedeu +1 -0
- data/lib/vedeu/renderers/terminal.rb +16 -17
- data/lib/vedeu/renderers/text.rb +32 -41
- data/lib/vedeu/version.rb +1 -1
- data/lib/vedeu/views/all.rb +0 -2
- data/lib/vedeu/views/chars.rb +6 -3
- data/lib/vedeu/views/stream.rb +3 -2
- data/test/lib/vedeu/borders/caption_test.rb +17 -17
- data/test/lib/vedeu/borders/title_test.rb +12 -12
- data/test/lib/vedeu/cells/border_test.rb +6 -0
- data/test/lib/vedeu/cells/borders/{bottom_horizontal_test.rb → edges/bottom_horizontal_test.rb} +0 -0
- data/test/lib/vedeu/cells/borders/{left_vertical_test.rb → edges/left_vertical_test.rb} +0 -0
- data/test/lib/vedeu/cells/borders/{right_vertical_test.rb → edges/right_vertical_test.rb} +0 -0
- data/test/lib/vedeu/cells/borders/{top_horizontal_test.rb → edges/top_horizontal_test.rb} +0 -0
- data/test/lib/vedeu/cells/borders/horizontal_test.rb +6 -0
- data/test/lib/vedeu/cells/borders/vertical_test.rb +6 -0
- data/test/lib/vedeu/cells/borders/{bottom_left_test.rb → vertices/bottom_left_test.rb} +6 -0
- data/test/lib/vedeu/cells/borders/{bottom_right_test.rb → vertices/bottom_right_test.rb} +6 -0
- data/test/lib/vedeu/cells/borders/{top_left_test.rb → vertices/top_left_test.rb} +6 -0
- data/test/lib/vedeu/cells/borders/{top_right_test.rb → vertices/top_right_test.rb} +6 -0
- data/test/lib/vedeu/cells/char_test.rb +18 -0
- data/test/lib/vedeu/cells/clear_test.rb +6 -0
- data/test/lib/vedeu/cells/cursor_test.rb +113 -0
- data/test/lib/vedeu/cells/empty_test.rb +100 -7
- data/test/lib/vedeu/cells/escape_test.rb +29 -13
- data/test/lib/vedeu/cells/support/html_test.rb +100 -0
- data/test/lib/vedeu/colours/background_test.rb +35 -3
- data/test/lib/vedeu/colours/colour_test.rb +66 -0
- data/test/lib/vedeu/colours/foreground_test.rb +35 -3
- data/test/lib/vedeu/colours/translator_test.rb +0 -34
- data/test/lib/vedeu/colours/validator_test.rb +84 -6
- data/test/lib/vedeu/cursors/cursor_test.rb +4 -4
- data/test/lib/vedeu/cursors/refresh_test.rb +4 -1
- data/test/lib/vedeu/dsl/string/text_test.rb +36 -36
- data/test/lib/vedeu/editor/cropper_test.rb +15 -15
- data/test/lib/vedeu/geometries/position_test.rb +14 -1
- data/test/lib/vedeu/models/page_test.rb +10 -10
- data/test/lib/vedeu/models/row_test.rb +7 -7
- data/test/lib/vedeu/output/compressor_test.rb +63 -50
- data/test/lib/vedeu/renderers/file_test.rb +64 -35
- data/test/lib/vedeu/renderers/html_test.rb +15 -12
- data/test/lib/vedeu/renderers/json_test.rb +79 -56
- data/test/lib/vedeu/renderers/options_test.rb +74 -26
- data/test/lib/vedeu/renderers/terminal_test.rb +34 -4
- data/test/lib/vedeu/renderers/text_test.rb +35 -3
- data/test/lib/vedeu/views/chars_test.rb +6 -0
- metadata +50 -41
- data/examples/views/expected/line.out +0 -1
- data/examples/views/expected/lines_alignment.out +0 -1
- data/lib/vedeu/cells/html.rb +0 -21
- data/lib/vedeu/cells/json.rb +0 -21
- data/lib/vedeu/views/char.rb +0 -180
- data/lib/vedeu/views/html_char.rb +0 -133
- data/test/lib/vedeu/cells/html_test.rb +0 -15
- data/test/lib/vedeu/cells/json_test.rb +0 -15
- data/test/lib/vedeu/views/char_test.rb +0 -283
- data/test/lib/vedeu/views/html_char_test.rb +0 -125
@@ -11,6 +11,12 @@ module Vedeu
|
|
11
11
|
let(:described) { Vedeu::Cells::TopRight }
|
12
12
|
let(:instance) { described.new }
|
13
13
|
|
14
|
+
describe '#as_html' do
|
15
|
+
subject { instance.as_html }
|
16
|
+
|
17
|
+
it { subject.must_equal('┐') }
|
18
|
+
end
|
19
|
+
|
14
20
|
describe '#type' do
|
15
21
|
subject { instance.type }
|
16
22
|
|
@@ -11,6 +11,18 @@ module Vedeu
|
|
11
11
|
let(:described) { Vedeu::Cells::Char }
|
12
12
|
let(:instance) { described.new }
|
13
13
|
|
14
|
+
describe '#as_html' do
|
15
|
+
subject { instance.as_html }
|
16
|
+
|
17
|
+
context 'when the value is present' do
|
18
|
+
# it { subject.must_equal(' ') }
|
19
|
+
end
|
20
|
+
|
21
|
+
context 'when the value is not present' do
|
22
|
+
it { subject.must_equal(' ') }
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
14
26
|
describe '#cell?' do
|
15
27
|
subject { instance.cell? }
|
16
28
|
|
@@ -23,6 +35,12 @@ module Vedeu
|
|
23
35
|
it { subject.must_equal('') }
|
24
36
|
end
|
25
37
|
|
38
|
+
describe '#type' do
|
39
|
+
subject { instance.type }
|
40
|
+
|
41
|
+
it { subject.must_equal(:char) }
|
42
|
+
end
|
43
|
+
|
26
44
|
end # Char
|
27
45
|
|
28
46
|
end # Cells
|
@@ -0,0 +1,113 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'test_helper'
|
4
|
+
|
5
|
+
module Vedeu
|
6
|
+
|
7
|
+
module Cells
|
8
|
+
|
9
|
+
describe Cursor do
|
10
|
+
|
11
|
+
let(:described) { Vedeu::Cells::Cursor }
|
12
|
+
let(:instance) { described.new(attributes) }
|
13
|
+
let(:attributes) {
|
14
|
+
{
|
15
|
+
position: position,
|
16
|
+
value: _value,
|
17
|
+
}
|
18
|
+
}
|
19
|
+
let(:position) { [2, 6] }
|
20
|
+
let(:_value) { "\e[?25h" }
|
21
|
+
|
22
|
+
describe '#initialize' do
|
23
|
+
it { instance.must_be_instance_of(described) }
|
24
|
+
it { instance.instance_variable_get('@position').must_equal(position) }
|
25
|
+
it { instance.instance_variable_get('@value').must_equal(_value) }
|
26
|
+
end
|
27
|
+
|
28
|
+
describe '#cell?' do
|
29
|
+
it { instance.cell?.must_equal(false) }
|
30
|
+
end
|
31
|
+
|
32
|
+
describe '#null' do
|
33
|
+
it { instance.null.must_equal(nil) }
|
34
|
+
it { instance.background.must_equal(nil) }
|
35
|
+
it { instance.colour.must_equal(nil) }
|
36
|
+
it { instance.foreground.must_equal(nil) }
|
37
|
+
it { instance.style.must_equal(nil) }
|
38
|
+
end
|
39
|
+
|
40
|
+
describe '#eql?' do
|
41
|
+
let(:other) { instance }
|
42
|
+
|
43
|
+
subject { instance.eql?(other) }
|
44
|
+
|
45
|
+
it { subject.must_equal(true) }
|
46
|
+
|
47
|
+
context 'when different to other' do
|
48
|
+
let(:other) { described.new(value: 'b') }
|
49
|
+
|
50
|
+
it { subject.must_equal(false) }
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
describe '#==' do
|
55
|
+
it { instance.must_respond_to(:==) }
|
56
|
+
end
|
57
|
+
|
58
|
+
describe '#value' do
|
59
|
+
subject { instance.value }
|
60
|
+
|
61
|
+
it { subject.must_be_instance_of(String) }
|
62
|
+
it { subject.must_equal("\e[?25h") }
|
63
|
+
end
|
64
|
+
|
65
|
+
describe '#to_h' do
|
66
|
+
let(:expected) {
|
67
|
+
{
|
68
|
+
position: {
|
69
|
+
y: 2,
|
70
|
+
x: 6,
|
71
|
+
},
|
72
|
+
value: "\e[?25h",
|
73
|
+
}
|
74
|
+
}
|
75
|
+
subject { instance.to_h }
|
76
|
+
|
77
|
+
it { subject.must_be_instance_of(Hash) }
|
78
|
+
it { subject.must_equal(expected) }
|
79
|
+
end
|
80
|
+
|
81
|
+
describe '#to_hash' do
|
82
|
+
it { instance.must_respond_to(:to_hash) }
|
83
|
+
end
|
84
|
+
|
85
|
+
describe '#to_html' do
|
86
|
+
subject { instance.to_html }
|
87
|
+
|
88
|
+
it { subject.must_be_instance_of(String) }
|
89
|
+
it { subject.must_equal('') }
|
90
|
+
end
|
91
|
+
|
92
|
+
describe '#to_s' do
|
93
|
+
subject { instance.to_s }
|
94
|
+
|
95
|
+
it { subject.must_be_instance_of(String) }
|
96
|
+
it { subject.must_equal("\e[2;6H\e[?25h") }
|
97
|
+
end
|
98
|
+
|
99
|
+
describe '#to_str' do
|
100
|
+
it { instance.must_respond_to(:to_str) }
|
101
|
+
end
|
102
|
+
|
103
|
+
describe '#type' do
|
104
|
+
subject { instance.type }
|
105
|
+
|
106
|
+
it { subject.must_equal(:cursor) }
|
107
|
+
end
|
108
|
+
|
109
|
+
end # Cursor
|
110
|
+
|
111
|
+
end # Cells
|
112
|
+
|
113
|
+
end # Vedeu
|
@@ -25,6 +25,12 @@ module Vedeu
|
|
25
25
|
let(:style) { '' }
|
26
26
|
let(:_value) { '' }
|
27
27
|
|
28
|
+
describe '#as_html' do
|
29
|
+
subject { instance.as_html }
|
30
|
+
|
31
|
+
it { subject.must_equal(' ') }
|
32
|
+
end
|
33
|
+
|
28
34
|
describe '#name' do
|
29
35
|
it { instance.must_respond_to(:name) }
|
30
36
|
end
|
@@ -63,42 +69,129 @@ module Vedeu
|
|
63
69
|
it { subject.must_equal(' ') }
|
64
70
|
end
|
65
71
|
|
66
|
-
describe '#
|
67
|
-
let(:position) {
|
72
|
+
describe '#to_h' do
|
73
|
+
let(:position) { Vedeu::Geometries::Position.new(1, 1) }
|
68
74
|
let(:colour) { Vedeu::Colours::Colour.new(background: '#000000') }
|
69
75
|
let(:expected) {
|
70
76
|
{
|
71
|
-
|
77
|
+
name: '',
|
72
78
|
style: '',
|
79
|
+
type: :empty,
|
73
80
|
value: '',
|
74
|
-
|
81
|
+
colour: {
|
82
|
+
background: '#000000',
|
83
|
+
foreground: '',
|
84
|
+
},
|
85
|
+
position: {
|
86
|
+
y: 1,
|
87
|
+
x: 1,
|
88
|
+
},
|
75
89
|
}
|
76
90
|
}
|
77
91
|
|
78
|
-
subject { instance.
|
92
|
+
subject { instance.to_h }
|
79
93
|
|
80
94
|
it { subject.must_be_instance_of(Hash) }
|
81
95
|
it { subject.must_equal(expected) }
|
82
96
|
end
|
83
97
|
|
98
|
+
describe '#to_hash' do
|
99
|
+
it { instance.must_respond_to(:to_hash) }
|
100
|
+
end
|
101
|
+
|
84
102
|
describe '#to_html' do
|
85
103
|
subject { instance.to_html }
|
86
104
|
|
87
105
|
it { subject.must_be_instance_of(String) }
|
88
|
-
it { subject.must_equal('') }
|
106
|
+
it { subject.must_equal('<td> </td>') }
|
89
107
|
end
|
90
108
|
|
91
109
|
describe '#to_s' do
|
110
|
+
let(:_value) { 'a' }
|
111
|
+
|
92
112
|
subject { instance.to_s }
|
93
113
|
|
94
114
|
it { subject.must_be_instance_of(String) }
|
95
|
-
|
115
|
+
|
116
|
+
context 'when a position is specified' do
|
117
|
+
let(:position) { Vedeu::Geometries::Position.coerce([17, 2]) }
|
118
|
+
|
119
|
+
it { subject.must_equal("\e[17;2Ha") }
|
120
|
+
end
|
121
|
+
|
122
|
+
context 'when a position is not specified' do
|
123
|
+
let(:position) {}
|
124
|
+
|
125
|
+
it { subject.must_equal('a') }
|
126
|
+
end
|
127
|
+
|
128
|
+
context 'when a colour is specified' do
|
129
|
+
let(:colour) {
|
130
|
+
Vedeu::Colours::Colour.new(foreground: '#00ff00',
|
131
|
+
background: '#005500')
|
132
|
+
}
|
133
|
+
|
134
|
+
context 'and a parent colour is specified' do
|
135
|
+
let(:parent_colour) {
|
136
|
+
Vedeu::Colours::Colour.new(foreground: '#ff0000',
|
137
|
+
background: '#550000')
|
138
|
+
}
|
139
|
+
|
140
|
+
it { subject.must_equal("\e[38;2;0;255;0m\e[48;2;0;85;0ma") }
|
141
|
+
end
|
142
|
+
|
143
|
+
context 'and a parent colour is not specified' do
|
144
|
+
let(:parent_colour) {}
|
145
|
+
|
146
|
+
it { subject.must_equal("\e[38;2;0;255;0m\e[48;2;0;85;0ma") }
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
150
|
+
context 'when a colour is not specified' do
|
151
|
+
let(:colour) {}
|
152
|
+
|
153
|
+
it { subject.must_equal('a') }
|
154
|
+
end
|
155
|
+
|
156
|
+
context 'when a style is specified' do
|
157
|
+
let(:style) { Vedeu::Presentation::Style.new('underline') }
|
158
|
+
|
159
|
+
context 'when a parent style is specified' do
|
160
|
+
let(:parent_style) { Vedeu::Presentation::Style.new('bold') }
|
161
|
+
|
162
|
+
it { subject.must_equal("\e[4ma") }
|
163
|
+
end
|
164
|
+
|
165
|
+
context 'when a parent style is not specified' do
|
166
|
+
let(:parent_style) {}
|
167
|
+
|
168
|
+
it { subject.must_equal("\e[4ma") }
|
169
|
+
end
|
170
|
+
end
|
171
|
+
|
172
|
+
context 'when a style is not specified' do
|
173
|
+
let(:style) {}
|
174
|
+
|
175
|
+
it { subject.must_equal('a') }
|
176
|
+
end
|
177
|
+
|
178
|
+
context 'when the value is nil' do
|
179
|
+
let(:_value) {}
|
180
|
+
|
181
|
+
it { subject.must_equal('') }
|
182
|
+
end
|
96
183
|
end
|
97
184
|
|
98
185
|
describe '#to_str' do
|
99
186
|
it { instance.must_respond_to(:to_str) }
|
100
187
|
end
|
101
188
|
|
189
|
+
describe '#type' do
|
190
|
+
subject { instance.type }
|
191
|
+
|
192
|
+
it { subject.must_equal(:empty) }
|
193
|
+
end
|
194
|
+
|
102
195
|
end # Empty
|
103
196
|
|
104
197
|
end # Cells
|
@@ -37,19 +37,19 @@ module Vedeu
|
|
37
37
|
it { instance.style.must_equal(nil) }
|
38
38
|
end
|
39
39
|
|
40
|
-
|
41
|
-
|
40
|
+
describe '#eql?' do
|
41
|
+
let(:other) { instance }
|
42
42
|
|
43
|
-
|
43
|
+
subject { instance.eql?(other) }
|
44
44
|
|
45
|
-
|
45
|
+
it { subject.must_equal(true) }
|
46
46
|
|
47
|
-
|
48
|
-
|
47
|
+
context 'when different to other' do
|
48
|
+
let(:other) { described.new(value: 'b') }
|
49
49
|
|
50
|
-
|
51
|
-
|
52
|
-
|
50
|
+
it { subject.must_equal(false) }
|
51
|
+
end
|
52
|
+
end
|
53
53
|
|
54
54
|
describe '#==' do
|
55
55
|
it { instance.must_respond_to(:==) }
|
@@ -62,11 +62,21 @@ module Vedeu
|
|
62
62
|
it { subject.must_equal("\e[?25h") }
|
63
63
|
end
|
64
64
|
|
65
|
-
describe '#
|
66
|
-
|
65
|
+
describe '#to_h' do
|
66
|
+
let(:expected) {
|
67
|
+
{
|
68
|
+
type: :escape,
|
69
|
+
value: "\e[?25h",
|
70
|
+
}
|
71
|
+
}
|
72
|
+
subject { instance.to_h }
|
67
73
|
|
68
74
|
it { subject.must_be_instance_of(Hash) }
|
69
|
-
it { subject.must_equal(
|
75
|
+
it { subject.must_equal(expected) }
|
76
|
+
end
|
77
|
+
|
78
|
+
describe '#to_hash' do
|
79
|
+
it { instance.must_respond_to(:to_hash) }
|
70
80
|
end
|
71
81
|
|
72
82
|
describe '#to_html' do
|
@@ -80,13 +90,19 @@ module Vedeu
|
|
80
90
|
subject { instance.to_s }
|
81
91
|
|
82
92
|
it { subject.must_be_instance_of(String) }
|
83
|
-
it { subject.must_equal("\e[
|
93
|
+
it { subject.must_equal("\e[?25h") }
|
84
94
|
end
|
85
95
|
|
86
96
|
describe '#to_str' do
|
87
97
|
it { instance.must_respond_to(:to_str) }
|
88
98
|
end
|
89
99
|
|
100
|
+
describe '#type' do
|
101
|
+
subject { instance.type }
|
102
|
+
|
103
|
+
it { subject.must_equal(:escape) }
|
104
|
+
end
|
105
|
+
|
90
106
|
end # Escape
|
91
107
|
|
92
108
|
end # Cells
|
@@ -0,0 +1,100 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Vedeu
|
4
|
+
|
5
|
+
module Cells
|
6
|
+
|
7
|
+
describe HTML do
|
8
|
+
|
9
|
+
let(:described) { Vedeu::Cells::HTML }
|
10
|
+
let(:instance) { described.new(cell, options) }
|
11
|
+
let(:cell) {
|
12
|
+
Vedeu::Cells::Char.new(colour: {
|
13
|
+
background: background,
|
14
|
+
foreground: foreground,
|
15
|
+
},
|
16
|
+
value: _value)
|
17
|
+
}
|
18
|
+
let(:options) {
|
19
|
+
{
|
20
|
+
start_tag: start_tag,
|
21
|
+
end_tag: end_tag,
|
22
|
+
}
|
23
|
+
}
|
24
|
+
let(:start_tag) { '<td' }
|
25
|
+
let(:end_tag) { '</td>' }
|
26
|
+
let(:background) { '#220022' }
|
27
|
+
let(:foreground) { '#0066ff' }
|
28
|
+
let(:_value) { 'A' }
|
29
|
+
|
30
|
+
describe '#initialize' do
|
31
|
+
it { instance.must_be_instance_of(described) }
|
32
|
+
it { instance.instance_variable_get('@cell').must_equal(cell) }
|
33
|
+
it { instance.instance_variable_get('@options').must_equal(options) }
|
34
|
+
end
|
35
|
+
|
36
|
+
describe '#to_html' do
|
37
|
+
subject { instance.to_html }
|
38
|
+
|
39
|
+
it { subject.must_be_instance_of(String) }
|
40
|
+
|
41
|
+
context 'with a custom :start_tag and :end_tag' do
|
42
|
+
let(:start_tag) { '<div' }
|
43
|
+
let(:end_tag) { '</div>' }
|
44
|
+
let(:expected) {
|
45
|
+
"<div style='background-color:#220022;color:#0066ff;'>A</div>"
|
46
|
+
}
|
47
|
+
|
48
|
+
it { subject.must_equal(expected) }
|
49
|
+
end
|
50
|
+
|
51
|
+
context 'with the default :start_tag and :end_tag' do
|
52
|
+
let(:expected) {
|
53
|
+
"<td style='background-color:#220022;color:#0066ff;'>A</td>"
|
54
|
+
}
|
55
|
+
|
56
|
+
it { subject.must_equal(expected) }
|
57
|
+
end
|
58
|
+
|
59
|
+
context 'when the cell has only a background colour' do
|
60
|
+
let(:foreground) {}
|
61
|
+
let(:expected) {
|
62
|
+
"<td style='background-color:#220022;'>A</td>"
|
63
|
+
}
|
64
|
+
|
65
|
+
it { subject.must_equal(expected) }
|
66
|
+
end
|
67
|
+
|
68
|
+
context 'when the cell has only a foreground colour' do
|
69
|
+
let(:background) {}
|
70
|
+
let(:expected) {
|
71
|
+
"<td style='color:#0066ff;'>A</td>"
|
72
|
+
}
|
73
|
+
|
74
|
+
it { subject.must_equal(expected) }
|
75
|
+
end
|
76
|
+
|
77
|
+
context 'when the cell has neither background or foreground colours' do
|
78
|
+
let(:background) {}
|
79
|
+
let(:foreground) {}
|
80
|
+
let(:expected) { '<td>A</td>' }
|
81
|
+
|
82
|
+
it { subject.must_equal(expected) }
|
83
|
+
end
|
84
|
+
|
85
|
+
context 'when the cell does not have a value or does not respond to ' \
|
86
|
+
':as_html' do
|
87
|
+
let(:_value) { '' }
|
88
|
+
let(:expected) {
|
89
|
+
"<td style='background-color:#220022;color:#0066ff;'> </td>"
|
90
|
+
}
|
91
|
+
|
92
|
+
it { subject.must_equal(expected) }
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
end # HTML
|
97
|
+
|
98
|
+
end # Cells
|
99
|
+
|
100
|
+
end # Vedeu
|