command_kit 0.4.1 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ChangeLog.md +6 -0
- data/README.md +3 -0
- data/command_kit.gemspec +7 -2
- data/lib/command_kit/completion/install.rb +276 -0
- data/lib/command_kit/env/prefix.rb +41 -0
- data/lib/command_kit/env/shell.rb +58 -0
- data/lib/command_kit/version.rb +1 -1
- metadata +4 -64
- data/spec/arguments/argument_spec.rb +0 -133
- data/spec/arguments/argument_value_spec.rb +0 -66
- data/spec/arguments_spec.rb +0 -279
- data/spec/bug_report_spec.rb +0 -266
- data/spec/colors_spec.rb +0 -771
- data/spec/command_kit_spec.rb +0 -8
- data/spec/command_name_spec.rb +0 -130
- data/spec/command_spec.rb +0 -123
- data/spec/commands/auto_load/subcommand_spec.rb +0 -82
- data/spec/commands/auto_load_spec.rb +0 -159
- data/spec/commands/auto_require_spec.rb +0 -142
- data/spec/commands/fixtures/test_auto_load/cli/commands/test1.rb +0 -10
- data/spec/commands/fixtures/test_auto_load/cli/commands/test2.rb +0 -10
- data/spec/commands/fixtures/test_auto_require/lib/test_auto_require/cli/commands/test1.rb +0 -10
- data/spec/commands/help_spec.rb +0 -66
- data/spec/commands/parent_command_spec.rb +0 -40
- data/spec/commands/subcommand_spec.rb +0 -99
- data/spec/commands_spec.rb +0 -865
- data/spec/description_spec.rb +0 -179
- data/spec/edit_spec.rb +0 -72
- data/spec/env/home_spec.rb +0 -46
- data/spec/env/path_spec.rb +0 -84
- data/spec/env_spec.rb +0 -123
- data/spec/examples_spec.rb +0 -211
- data/spec/exception_handler_spec.rb +0 -103
- data/spec/file_utils_spec.rb +0 -59
- data/spec/fixtures/template.erb +0 -5
- data/spec/help/man_spec.rb +0 -345
- data/spec/help_spec.rb +0 -94
- data/spec/inflector_spec.rb +0 -166
- data/spec/interactive_spec.rb +0 -415
- data/spec/main_spec.rb +0 -179
- data/spec/man_spec.rb +0 -46
- data/spec/open_app_spec.rb +0 -85
- data/spec/options/option_spec.rb +0 -343
- data/spec/options/option_value_spec.rb +0 -171
- data/spec/options/parser_spec.rb +0 -274
- data/spec/options/quiet_spec.rb +0 -51
- data/spec/options/verbose_spec.rb +0 -51
- data/spec/options/version_spec.rb +0 -146
- data/spec/options_spec.rb +0 -465
- data/spec/os/linux_spec.rb +0 -164
- data/spec/os_spec.rb +0 -233
- data/spec/package_manager_spec.rb +0 -806
- data/spec/pager_spec.rb +0 -217
- data/spec/printing/fields_spec.rb +0 -167
- data/spec/printing/indent_spec.rb +0 -132
- data/spec/printing/lists_spec.rb +0 -99
- data/spec/printing/tables/border_style.rb +0 -43
- data/spec/printing/tables/cell_builer_spec.rb +0 -135
- data/spec/printing/tables/row_builder_spec.rb +0 -165
- data/spec/printing/tables/style_spec.rb +0 -377
- data/spec/printing/tables/table_builder_spec.rb +0 -252
- data/spec/printing/tables/table_formatter_spec.rb +0 -1190
- data/spec/printing/tables_spec.rb +0 -1069
- data/spec/printing_spec.rb +0 -106
- data/spec/program_name_spec.rb +0 -70
- data/spec/spec_helper.rb +0 -3
- data/spec/stdio_spec.rb +0 -264
- data/spec/sudo_spec.rb +0 -51
- data/spec/terminal_spec.rb +0 -231
- data/spec/usage_spec.rb +0 -237
- data/spec/xdg_spec.rb +0 -191
@@ -1,1190 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'command_kit/printing/tables/table_formatter'
|
3
|
-
require 'command_kit/printing/tables/table_builder'
|
4
|
-
require 'command_kit/printing/tables/style'
|
5
|
-
|
6
|
-
describe CommandKit::Printing::Tables::TableFormatter do
|
7
|
-
let(:header) { ['A', 'B', 'C'] }
|
8
|
-
let(:rows) do
|
9
|
-
[
|
10
|
-
['AAAA', 'BBBB', 'CCCC'],
|
11
|
-
['DDDD', 'EEEE', 'FFFF'],
|
12
|
-
['GGGG', 'HHHH', 'IIII']
|
13
|
-
]
|
14
|
-
end
|
15
|
-
let(:multiline_rows) do
|
16
|
-
[
|
17
|
-
["AAAA\nAA", "BBBB", "CCCC"],
|
18
|
-
["DDDD", "EEEE\nEE", "FFFF"],
|
19
|
-
["GGGG", "HHHH", "IIII\nII"]
|
20
|
-
]
|
21
|
-
end
|
22
|
-
let(:rows_with_empty_cells) do
|
23
|
-
[
|
24
|
-
[nil, 'BBBB', 'CCCC'],
|
25
|
-
['DDDD', nil, 'FFFF'],
|
26
|
-
['GGGG', 'HHHH', nil ]
|
27
|
-
]
|
28
|
-
end
|
29
|
-
let(:rows_with_diff_row_lengths) do
|
30
|
-
[
|
31
|
-
['AAAA'],
|
32
|
-
['DDDD', 'EEEE'],
|
33
|
-
['GGGG', 'HHHH', 'IIII']
|
34
|
-
]
|
35
|
-
end
|
36
|
-
let(:unjustified_rows) do
|
37
|
-
[
|
38
|
-
['AAAA', 'BBBB', 'CCCC'],
|
39
|
-
['DD', 'EE', 'FF' ],
|
40
|
-
['G', 'H', 'I' ]
|
41
|
-
]
|
42
|
-
end
|
43
|
-
|
44
|
-
let(:table) { CommandKit::Printing::Tables::TableBuilder.new(rows) }
|
45
|
-
let(:style) { CommandKit::Printing::Tables::Style.new }
|
46
|
-
|
47
|
-
subject { described_class.new(table,style) }
|
48
|
-
|
49
|
-
describe "#format" do
|
50
|
-
it "must yield each line of the table with 1 space padding and no borders" do
|
51
|
-
expect { |b|
|
52
|
-
subject.format(&b)
|
53
|
-
}.to yield_successive_args(
|
54
|
-
" AAAA BBBB CCCC ",
|
55
|
-
" DDDD EEEE FFFF ",
|
56
|
-
" GGGG HHHH IIII "
|
57
|
-
)
|
58
|
-
end
|
59
|
-
|
60
|
-
it "must encode the Strings as UTF-8" do
|
61
|
-
yielded_lines = []
|
62
|
-
|
63
|
-
subject.format do |line|
|
64
|
-
yielded_lines << line
|
65
|
-
end
|
66
|
-
|
67
|
-
expect(yielded_lines.map(&:encoding)).to all(be(Encoding::UTF_8))
|
68
|
-
end
|
69
|
-
|
70
|
-
context "but when the table contains multi-line cells" do
|
71
|
-
let(:rows) { multiline_rows }
|
72
|
-
|
73
|
-
it "must yield each line of each row" do
|
74
|
-
expect { |b|
|
75
|
-
subject.format(&b)
|
76
|
-
}.to yield_successive_args(
|
77
|
-
" AAAA BBBB CCCC ",
|
78
|
-
" AA ",
|
79
|
-
" DDDD EEEE FFFF ",
|
80
|
-
" EE ",
|
81
|
-
" GGGG HHHH IIII ",
|
82
|
-
" II "
|
83
|
-
)
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
87
|
-
context "but when the table contains empty cells" do
|
88
|
-
let(:rows) { rows_with_empty_cells }
|
89
|
-
|
90
|
-
it "must replace the empty cells with spaces" do
|
91
|
-
expect { |b|
|
92
|
-
subject.format(&b)
|
93
|
-
}.to yield_successive_args(
|
94
|
-
" BBBB CCCC ",
|
95
|
-
" DDDD FFFF ",
|
96
|
-
" GGGG HHHH "
|
97
|
-
)
|
98
|
-
end
|
99
|
-
end
|
100
|
-
|
101
|
-
context "but when the table contains empty cells" do
|
102
|
-
let(:rows) { rows_with_diff_row_lengths }
|
103
|
-
|
104
|
-
it "must pad the columns with empty cells" do
|
105
|
-
expect { |b|
|
106
|
-
subject.format(&b)
|
107
|
-
}.to yield_successive_args(
|
108
|
-
" AAAA ",
|
109
|
-
" DDDD EEEE ",
|
110
|
-
" GGGG HHHH IIII "
|
111
|
-
)
|
112
|
-
end
|
113
|
-
end
|
114
|
-
|
115
|
-
context "when the #style.separate_rows? is true" do
|
116
|
-
let(:style) do
|
117
|
-
CommandKit::Printing::Tables::Style.new(separate_rows: true)
|
118
|
-
end
|
119
|
-
|
120
|
-
it "must yield the rows with blank lines between each row" do
|
121
|
-
expect { |b|
|
122
|
-
subject.format(&b)
|
123
|
-
}.to yield_successive_args(
|
124
|
-
" AAAA BBBB CCCC ",
|
125
|
-
"",
|
126
|
-
" DDDD EEEE FFFF ",
|
127
|
-
"",
|
128
|
-
" GGGG HHHH IIII "
|
129
|
-
)
|
130
|
-
end
|
131
|
-
end
|
132
|
-
|
133
|
-
context "and when #style.justify is :left" do
|
134
|
-
let(:rows) { unjustified_rows }
|
135
|
-
let(:style) do
|
136
|
-
CommandKit::Printing::Tables::Style.new(justify: :left)
|
137
|
-
end
|
138
|
-
|
139
|
-
it "must left justify each cell" do
|
140
|
-
expect { |b|
|
141
|
-
subject.format(&b)
|
142
|
-
}.to yield_successive_args(
|
143
|
-
" AAAA BBBB CCCC ",
|
144
|
-
" DD EE FF ",
|
145
|
-
" G H I "
|
146
|
-
)
|
147
|
-
end
|
148
|
-
end
|
149
|
-
|
150
|
-
context "and when #style.justify is :right" do
|
151
|
-
let(:rows) { unjustified_rows }
|
152
|
-
let(:style) do
|
153
|
-
CommandKit::Printing::Tables::Style.new(justify: :right)
|
154
|
-
end
|
155
|
-
|
156
|
-
it "must right justify each cell" do
|
157
|
-
expect { |b|
|
158
|
-
subject.format(&b)
|
159
|
-
}.to yield_successive_args(
|
160
|
-
" AAAA BBBB CCCC ",
|
161
|
-
" DD EE FF ",
|
162
|
-
" G H I "
|
163
|
-
)
|
164
|
-
end
|
165
|
-
end
|
166
|
-
|
167
|
-
context "and when #style.justify is :center" do
|
168
|
-
let(:rows) { unjustified_rows }
|
169
|
-
let(:style) do
|
170
|
-
CommandKit::Printing::Tables::Style.new(justify: :center)
|
171
|
-
end
|
172
|
-
|
173
|
-
it "must center justify each cell" do
|
174
|
-
expect { |b|
|
175
|
-
subject.format(&b)
|
176
|
-
}.to yield_successive_args(
|
177
|
-
" AAAA BBBB CCCC ",
|
178
|
-
" DD EE FF ",
|
179
|
-
" G H I "
|
180
|
-
)
|
181
|
-
end
|
182
|
-
end
|
183
|
-
|
184
|
-
context "and when #table.header? is true" do
|
185
|
-
let(:table) do
|
186
|
-
CommandKit::Printing::Tables::TableBuilder.new(rows, header: header)
|
187
|
-
end
|
188
|
-
|
189
|
-
it "must yield the center justified header row, then a blank line, then the rest of the rows" do
|
190
|
-
expect { |b|
|
191
|
-
subject.format(&b)
|
192
|
-
}.to yield_successive_args(
|
193
|
-
" A B C ",
|
194
|
-
"",
|
195
|
-
" AAAA BBBB CCCC ",
|
196
|
-
" DDDD EEEE FFFF ",
|
197
|
-
" GGGG HHHH IIII "
|
198
|
-
)
|
199
|
-
end
|
200
|
-
|
201
|
-
context "and #style.separate_rows? is true" do
|
202
|
-
let(:style) do
|
203
|
-
CommandKit::Printing::Tables::Style.new(separate_rows: true)
|
204
|
-
end
|
205
|
-
|
206
|
-
it "must yield the header, a blank line, then the rows with blaink lines between each row" do
|
207
|
-
expect { |b|
|
208
|
-
subject.format(&b)
|
209
|
-
}.to yield_successive_args(
|
210
|
-
" A B C ",
|
211
|
-
"",
|
212
|
-
" AAAA BBBB CCCC ",
|
213
|
-
"",
|
214
|
-
" DDDD EEEE FFFF ",
|
215
|
-
"",
|
216
|
-
" GGGG HHHH IIII "
|
217
|
-
)
|
218
|
-
end
|
219
|
-
end
|
220
|
-
|
221
|
-
context "and when #style.justify_header is :left" do
|
222
|
-
let(:style) do
|
223
|
-
CommandKit::Printing::Tables::Style.new(justify_header: :left)
|
224
|
-
end
|
225
|
-
|
226
|
-
it "must left justify the header cells" do
|
227
|
-
expect { |b|
|
228
|
-
subject.format(&b)
|
229
|
-
}.to yield_successive_args(
|
230
|
-
" A B C ",
|
231
|
-
"",
|
232
|
-
" AAAA BBBB CCCC ",
|
233
|
-
" DDDD EEEE FFFF ",
|
234
|
-
" GGGG HHHH IIII "
|
235
|
-
)
|
236
|
-
end
|
237
|
-
end
|
238
|
-
|
239
|
-
context "and when #style.justify_header is :right" do
|
240
|
-
let(:style) do
|
241
|
-
CommandKit::Printing::Tables::Style.new(justify_header: :right)
|
242
|
-
end
|
243
|
-
|
244
|
-
it "must right justify the header cells" do
|
245
|
-
expect { |b|
|
246
|
-
subject.format(&b)
|
247
|
-
}.to yield_successive_args(
|
248
|
-
" A B C ",
|
249
|
-
"",
|
250
|
-
" AAAA BBBB CCCC ",
|
251
|
-
" DDDD EEEE FFFF ",
|
252
|
-
" GGGG HHHH IIII "
|
253
|
-
)
|
254
|
-
end
|
255
|
-
end
|
256
|
-
|
257
|
-
context "and when #style.justify_header is :center" do
|
258
|
-
let(:style) do
|
259
|
-
CommandKit::Printing::Tables::Style.new(justify_header: :center)
|
260
|
-
end
|
261
|
-
|
262
|
-
it "must center justify the header cells" do
|
263
|
-
expect { |b|
|
264
|
-
subject.format(&b)
|
265
|
-
}.to yield_successive_args(
|
266
|
-
" A B C ",
|
267
|
-
"",
|
268
|
-
" AAAA BBBB CCCC ",
|
269
|
-
" DDDD EEEE FFFF ",
|
270
|
-
" GGGG HHHH IIII "
|
271
|
-
)
|
272
|
-
end
|
273
|
-
end
|
274
|
-
|
275
|
-
context "and when #style.justify is :left" do
|
276
|
-
let(:rows) { unjustified_rows }
|
277
|
-
let(:style) do
|
278
|
-
CommandKit::Printing::Tables::Style.new(justify: :left)
|
279
|
-
end
|
280
|
-
|
281
|
-
it "must left justify each cell" do
|
282
|
-
expect { |b|
|
283
|
-
subject.format(&b)
|
284
|
-
}.to yield_successive_args(
|
285
|
-
" A B C ",
|
286
|
-
"",
|
287
|
-
" AAAA BBBB CCCC ",
|
288
|
-
" DD EE FF ",
|
289
|
-
" G H I "
|
290
|
-
)
|
291
|
-
end
|
292
|
-
end
|
293
|
-
|
294
|
-
context "and when #style.justify is :right" do
|
295
|
-
let(:rows) { unjustified_rows }
|
296
|
-
let(:style) do
|
297
|
-
CommandKit::Printing::Tables::Style.new(justify: :right)
|
298
|
-
end
|
299
|
-
|
300
|
-
it "must right justify each cell" do
|
301
|
-
expect { |b|
|
302
|
-
subject.format(&b)
|
303
|
-
}.to yield_successive_args(
|
304
|
-
" A B C ",
|
305
|
-
"",
|
306
|
-
" AAAA BBBB CCCC ",
|
307
|
-
" DD EE FF ",
|
308
|
-
" G H I "
|
309
|
-
)
|
310
|
-
end
|
311
|
-
end
|
312
|
-
|
313
|
-
context "and when #style.justify is :center" do
|
314
|
-
let(:rows) { unjustified_rows }
|
315
|
-
let(:style) do
|
316
|
-
CommandKit::Printing::Tables::Style.new(justify: :center)
|
317
|
-
end
|
318
|
-
|
319
|
-
it "must center justify each cell" do
|
320
|
-
expect { |b|
|
321
|
-
subject.format(&b)
|
322
|
-
}.to yield_successive_args(
|
323
|
-
" A B C ",
|
324
|
-
"",
|
325
|
-
" AAAA BBBB CCCC ",
|
326
|
-
" DD EE FF ",
|
327
|
-
" G H I "
|
328
|
-
)
|
329
|
-
end
|
330
|
-
end
|
331
|
-
end
|
332
|
-
|
333
|
-
context "when #style.border is :ascii" do
|
334
|
-
let(:style) do
|
335
|
-
CommandKit::Printing::Tables::Style.new(border: :ascii)
|
336
|
-
end
|
337
|
-
|
338
|
-
it "must yield each row with an ASCII border" do
|
339
|
-
expect { |b|
|
340
|
-
subject.format(&b)
|
341
|
-
}.to yield_successive_args(
|
342
|
-
"+------+------+------+",
|
343
|
-
"| AAAA | BBBB | CCCC |",
|
344
|
-
"| DDDD | EEEE | FFFF |",
|
345
|
-
"| GGGG | HHHH | IIII |",
|
346
|
-
"+------+------+------+"
|
347
|
-
)
|
348
|
-
end
|
349
|
-
|
350
|
-
context "but when the table contains multi-line cells" do
|
351
|
-
let(:rows) { multiline_rows }
|
352
|
-
|
353
|
-
it "must yield each line of each row" do
|
354
|
-
expect { |b|
|
355
|
-
subject.format(&b)
|
356
|
-
}.to yield_successive_args(
|
357
|
-
"+------+------+------+",
|
358
|
-
"| AAAA | BBBB | CCCC |",
|
359
|
-
"| AA | | |",
|
360
|
-
"| DDDD | EEEE | FFFF |",
|
361
|
-
"| | EE | |",
|
362
|
-
"| GGGG | HHHH | IIII |",
|
363
|
-
"| | | II |",
|
364
|
-
"+------+------+------+"
|
365
|
-
)
|
366
|
-
end
|
367
|
-
end
|
368
|
-
|
369
|
-
context "but when the table contains empty cells" do
|
370
|
-
let(:rows) { rows_with_empty_cells }
|
371
|
-
|
372
|
-
it "must replace the empty cells with spaces" do
|
373
|
-
expect { |b|
|
374
|
-
subject.format(&b)
|
375
|
-
}.to yield_successive_args(
|
376
|
-
"+------+------+------+",
|
377
|
-
"| | BBBB | CCCC |",
|
378
|
-
"| DDDD | | FFFF |",
|
379
|
-
"| GGGG | HHHH | |",
|
380
|
-
"+------+------+------+"
|
381
|
-
)
|
382
|
-
end
|
383
|
-
end
|
384
|
-
|
385
|
-
context "but when the table contains empty cells" do
|
386
|
-
let(:rows) { rows_with_diff_row_lengths }
|
387
|
-
|
388
|
-
it "must pad the columns with empty cells" do
|
389
|
-
expect { |b|
|
390
|
-
subject.format(&b)
|
391
|
-
}.to yield_successive_args(
|
392
|
-
"+------+------+------+",
|
393
|
-
"| AAAA | | |",
|
394
|
-
"| DDDD | EEEE | |",
|
395
|
-
"| GGGG | HHHH | IIII |",
|
396
|
-
"+------+------+------+"
|
397
|
-
)
|
398
|
-
end
|
399
|
-
end
|
400
|
-
|
401
|
-
context "and when #style.separate_rows is true" do
|
402
|
-
let(:style) do
|
403
|
-
CommandKit::Printing::Tables::Style.new(
|
404
|
-
border: :ascii,
|
405
|
-
separate_rows: true
|
406
|
-
)
|
407
|
-
end
|
408
|
-
|
409
|
-
it "must yield each row with a separator line between each row" do
|
410
|
-
expect { |b|
|
411
|
-
subject.format(&b)
|
412
|
-
}.to yield_successive_args(
|
413
|
-
"+------+------+------+",
|
414
|
-
"| AAAA | BBBB | CCCC |",
|
415
|
-
"+------+------+------+",
|
416
|
-
"| DDDD | EEEE | FFFF |",
|
417
|
-
"+------+------+------+",
|
418
|
-
"| GGGG | HHHH | IIII |",
|
419
|
-
"+------+------+------+"
|
420
|
-
)
|
421
|
-
end
|
422
|
-
end
|
423
|
-
|
424
|
-
context "and when #style.justify is :left" do
|
425
|
-
let(:rows) { unjustified_rows }
|
426
|
-
|
427
|
-
let(:style) do
|
428
|
-
CommandKit::Printing::Tables::Style.new(
|
429
|
-
border: :ascii,
|
430
|
-
justify: :left
|
431
|
-
)
|
432
|
-
end
|
433
|
-
|
434
|
-
it "must left justify each cell" do
|
435
|
-
expect { |b|
|
436
|
-
subject.format(&b)
|
437
|
-
}.to yield_successive_args(
|
438
|
-
"+------+------+------+",
|
439
|
-
"| AAAA | BBBB | CCCC |",
|
440
|
-
"| DD | EE | FF |",
|
441
|
-
"| G | H | I |",
|
442
|
-
"+------+------+------+"
|
443
|
-
)
|
444
|
-
end
|
445
|
-
end
|
446
|
-
|
447
|
-
context "and when #style.justify is :right" do
|
448
|
-
let(:rows) { unjustified_rows }
|
449
|
-
|
450
|
-
let(:style) do
|
451
|
-
CommandKit::Printing::Tables::Style.new(
|
452
|
-
border: :ascii,
|
453
|
-
justify: :right
|
454
|
-
)
|
455
|
-
end
|
456
|
-
|
457
|
-
it "must right justify each cell" do
|
458
|
-
expect { |b|
|
459
|
-
subject.format(&b)
|
460
|
-
}.to yield_successive_args(
|
461
|
-
"+------+------+------+",
|
462
|
-
"| AAAA | BBBB | CCCC |",
|
463
|
-
"| DD | EE | FF |",
|
464
|
-
"| G | H | I |",
|
465
|
-
"+------+------+------+"
|
466
|
-
)
|
467
|
-
end
|
468
|
-
end
|
469
|
-
|
470
|
-
context "and when #style.justify is :center" do
|
471
|
-
let(:rows) { unjustified_rows }
|
472
|
-
|
473
|
-
let(:style) do
|
474
|
-
CommandKit::Printing::Tables::Style.new(
|
475
|
-
border: :ascii,
|
476
|
-
justify: :center
|
477
|
-
)
|
478
|
-
end
|
479
|
-
|
480
|
-
it "must center justify each cell" do
|
481
|
-
expect { |b|
|
482
|
-
subject.format(&b)
|
483
|
-
}.to yield_successive_args(
|
484
|
-
"+------+------+------+",
|
485
|
-
"| AAAA | BBBB | CCCC |",
|
486
|
-
"| DD | EE | FF |",
|
487
|
-
"| G | H | I |",
|
488
|
-
"+------+------+------+"
|
489
|
-
)
|
490
|
-
end
|
491
|
-
end
|
492
|
-
|
493
|
-
context "and when #table.header? is true" do
|
494
|
-
let(:table) do
|
495
|
-
CommandKit::Printing::Tables::TableBuilder.new(rows, header: header)
|
496
|
-
end
|
497
|
-
|
498
|
-
it "must yield the center justified header row, then a separator line, then the table" do
|
499
|
-
expect { |b|
|
500
|
-
subject.format(&b)
|
501
|
-
}.to yield_successive_args(
|
502
|
-
"+------+------+------+",
|
503
|
-
"| A | B | C |",
|
504
|
-
"+------+------+------+",
|
505
|
-
"| AAAA | BBBB | CCCC |",
|
506
|
-
"| DDDD | EEEE | FFFF |",
|
507
|
-
"| GGGG | HHHH | IIII |",
|
508
|
-
"+------+------+------+"
|
509
|
-
)
|
510
|
-
end
|
511
|
-
|
512
|
-
context "and when #style.separate_rows? is true" do
|
513
|
-
let(:style) do
|
514
|
-
CommandKit::Printing::Tables::Style.new(
|
515
|
-
border: :ascii,
|
516
|
-
separate_rows: true
|
517
|
-
)
|
518
|
-
end
|
519
|
-
|
520
|
-
it "must yield the header and rows with separator lines between each row" do
|
521
|
-
expect { |b|
|
522
|
-
subject.format(&b)
|
523
|
-
}.to yield_successive_args(
|
524
|
-
"+------+------+------+",
|
525
|
-
"| A | B | C |",
|
526
|
-
"+------+------+------+",
|
527
|
-
"| AAAA | BBBB | CCCC |",
|
528
|
-
"+------+------+------+",
|
529
|
-
"| DDDD | EEEE | FFFF |",
|
530
|
-
"+------+------+------+",
|
531
|
-
"| GGGG | HHHH | IIII |",
|
532
|
-
"+------+------+------+"
|
533
|
-
)
|
534
|
-
end
|
535
|
-
end
|
536
|
-
|
537
|
-
context "and when #style.justify_header is :left" do
|
538
|
-
let(:style) do
|
539
|
-
CommandKit::Printing::Tables::Style.new(
|
540
|
-
border: :ascii,
|
541
|
-
justify_header: :left
|
542
|
-
)
|
543
|
-
end
|
544
|
-
|
545
|
-
it "must left justify the header cells" do
|
546
|
-
expect { |b|
|
547
|
-
subject.format(&b)
|
548
|
-
}.to yield_successive_args(
|
549
|
-
"+------+------+------+",
|
550
|
-
"| A | B | C |",
|
551
|
-
"+------+------+------+",
|
552
|
-
"| AAAA | BBBB | CCCC |",
|
553
|
-
"| DDDD | EEEE | FFFF |",
|
554
|
-
"| GGGG | HHHH | IIII |",
|
555
|
-
"+------+------+------+"
|
556
|
-
)
|
557
|
-
end
|
558
|
-
end
|
559
|
-
|
560
|
-
context "and when #style.justify_header is :right" do
|
561
|
-
let(:style) do
|
562
|
-
CommandKit::Printing::Tables::Style.new(
|
563
|
-
border: :ascii,
|
564
|
-
justify_header: :right
|
565
|
-
)
|
566
|
-
end
|
567
|
-
|
568
|
-
it "must right justify the header cells" do
|
569
|
-
expect { |b|
|
570
|
-
subject.format(&b)
|
571
|
-
}.to yield_successive_args(
|
572
|
-
"+------+------+------+",
|
573
|
-
"| A | B | C |",
|
574
|
-
"+------+------+------+",
|
575
|
-
"| AAAA | BBBB | CCCC |",
|
576
|
-
"| DDDD | EEEE | FFFF |",
|
577
|
-
"| GGGG | HHHH | IIII |",
|
578
|
-
"+------+------+------+"
|
579
|
-
)
|
580
|
-
end
|
581
|
-
end
|
582
|
-
|
583
|
-
context "and when #style.justify_header is :center" do
|
584
|
-
let(:style) do
|
585
|
-
CommandKit::Printing::Tables::Style.new(
|
586
|
-
border: :ascii,
|
587
|
-
justify_header: :center
|
588
|
-
)
|
589
|
-
end
|
590
|
-
|
591
|
-
it "must center justify the header cells" do
|
592
|
-
expect { |b|
|
593
|
-
subject.format(&b)
|
594
|
-
}.to yield_successive_args(
|
595
|
-
"+------+------+------+",
|
596
|
-
"| A | B | C |",
|
597
|
-
"+------+------+------+",
|
598
|
-
"| AAAA | BBBB | CCCC |",
|
599
|
-
"| DDDD | EEEE | FFFF |",
|
600
|
-
"| GGGG | HHHH | IIII |",
|
601
|
-
"+------+------+------+"
|
602
|
-
)
|
603
|
-
end
|
604
|
-
end
|
605
|
-
end
|
606
|
-
end
|
607
|
-
|
608
|
-
context "when #style.border is :line" do
|
609
|
-
let(:style) do
|
610
|
-
CommandKit::Printing::Tables::Style.new(border: :line)
|
611
|
-
end
|
612
|
-
|
613
|
-
it "must yield the table with an ANSI line border" do
|
614
|
-
expect { |b|
|
615
|
-
subject.format(&b)
|
616
|
-
}.to yield_successive_args(
|
617
|
-
"┌──────┬──────┬──────┐",
|
618
|
-
"│ AAAA │ BBBB │ CCCC │",
|
619
|
-
"│ DDDD │ EEEE │ FFFF │",
|
620
|
-
"│ GGGG │ HHHH │ IIII │",
|
621
|
-
"└──────┴──────┴──────┘"
|
622
|
-
)
|
623
|
-
end
|
624
|
-
|
625
|
-
context "but when the table contains multi-line cells" do
|
626
|
-
let(:rows) { multiline_rows }
|
627
|
-
|
628
|
-
it "must yield each line of each row" do
|
629
|
-
expect { |b|
|
630
|
-
subject.format(&b)
|
631
|
-
}.to yield_successive_args(
|
632
|
-
"┌──────┬──────┬──────┐",
|
633
|
-
"│ AAAA │ BBBB │ CCCC │",
|
634
|
-
"│ AA │ │ │",
|
635
|
-
"│ DDDD │ EEEE │ FFFF │",
|
636
|
-
"│ │ EE │ │",
|
637
|
-
"│ GGGG │ HHHH │ IIII │",
|
638
|
-
"│ │ │ II │",
|
639
|
-
"└──────┴──────┴──────┘"
|
640
|
-
)
|
641
|
-
end
|
642
|
-
end
|
643
|
-
|
644
|
-
context "but when the table contains empty cells" do
|
645
|
-
let(:rows) { rows_with_empty_cells }
|
646
|
-
|
647
|
-
it "must replace the empty cells with spaces" do
|
648
|
-
expect { |b|
|
649
|
-
subject.format(&b)
|
650
|
-
}.to yield_successive_args(
|
651
|
-
"┌──────┬──────┬──────┐",
|
652
|
-
"│ │ BBBB │ CCCC │",
|
653
|
-
"│ DDDD │ │ FFFF │",
|
654
|
-
"│ GGGG │ HHHH │ │",
|
655
|
-
"└──────┴──────┴──────┘"
|
656
|
-
)
|
657
|
-
end
|
658
|
-
end
|
659
|
-
|
660
|
-
context "but when the table contains empty cells" do
|
661
|
-
let(:rows) { rows_with_diff_row_lengths }
|
662
|
-
|
663
|
-
it "must pad the columns with empty cells" do
|
664
|
-
expect { |b|
|
665
|
-
subject.format(&b)
|
666
|
-
}.to yield_successive_args(
|
667
|
-
"┌──────┬──────┬──────┐",
|
668
|
-
"│ AAAA │ │ │",
|
669
|
-
"│ DDDD │ EEEE │ │",
|
670
|
-
"│ GGGG │ HHHH │ IIII │",
|
671
|
-
"└──────┴──────┴──────┘"
|
672
|
-
)
|
673
|
-
end
|
674
|
-
end
|
675
|
-
|
676
|
-
context "and when #style.separate_rows is true" do
|
677
|
-
let(:style) do
|
678
|
-
CommandKit::Printing::Tables::Style.new(
|
679
|
-
border: :line,
|
680
|
-
separate_rows: true
|
681
|
-
)
|
682
|
-
end
|
683
|
-
|
684
|
-
it "must yield each row with separator lines between each row" do
|
685
|
-
expect { |b|
|
686
|
-
subject.format(&b)
|
687
|
-
}.to yield_successive_args(
|
688
|
-
"┌──────┬──────┬──────┐",
|
689
|
-
"│ AAAA │ BBBB │ CCCC │",
|
690
|
-
"├──────┼──────┼──────┤",
|
691
|
-
"│ DDDD │ EEEE │ FFFF │",
|
692
|
-
"├──────┼──────┼──────┤",
|
693
|
-
"│ GGGG │ HHHH │ IIII │",
|
694
|
-
"└──────┴──────┴──────┘"
|
695
|
-
)
|
696
|
-
end
|
697
|
-
end
|
698
|
-
|
699
|
-
context "and when #style.justify is :left" do
|
700
|
-
let(:rows) { unjustified_rows }
|
701
|
-
|
702
|
-
let(:style) do
|
703
|
-
CommandKit::Printing::Tables::Style.new(
|
704
|
-
border: :line,
|
705
|
-
justify: :left
|
706
|
-
)
|
707
|
-
end
|
708
|
-
|
709
|
-
it "must left justify each cell" do
|
710
|
-
expect { |b|
|
711
|
-
subject.format(&b)
|
712
|
-
}.to yield_successive_args(
|
713
|
-
"┌──────┬──────┬──────┐",
|
714
|
-
"│ AAAA │ BBBB │ CCCC │",
|
715
|
-
"│ DD │ EE │ FF │",
|
716
|
-
"│ G │ H │ I │",
|
717
|
-
"└──────┴──────┴──────┘"
|
718
|
-
)
|
719
|
-
end
|
720
|
-
end
|
721
|
-
|
722
|
-
context "and when #style.justify is :right" do
|
723
|
-
let(:rows) { unjustified_rows }
|
724
|
-
|
725
|
-
let(:style) do
|
726
|
-
CommandKit::Printing::Tables::Style.new(
|
727
|
-
border: :line,
|
728
|
-
justify: :right
|
729
|
-
)
|
730
|
-
end
|
731
|
-
|
732
|
-
it "must right justify each cell" do
|
733
|
-
expect { |b|
|
734
|
-
subject.format(&b)
|
735
|
-
}.to yield_successive_args(
|
736
|
-
"┌──────┬──────┬──────┐",
|
737
|
-
"│ AAAA │ BBBB │ CCCC │",
|
738
|
-
"│ DD │ EE │ FF │",
|
739
|
-
"│ G │ H │ I │",
|
740
|
-
"└──────┴──────┴──────┘"
|
741
|
-
)
|
742
|
-
end
|
743
|
-
end
|
744
|
-
|
745
|
-
context "and when #style.justify is :center" do
|
746
|
-
let(:rows) { unjustified_rows }
|
747
|
-
|
748
|
-
let(:style) do
|
749
|
-
CommandKit::Printing::Tables::Style.new(
|
750
|
-
border: :line,
|
751
|
-
justify: :center
|
752
|
-
)
|
753
|
-
end
|
754
|
-
|
755
|
-
it "must center justify each cell" do
|
756
|
-
expect { |b|
|
757
|
-
subject.format(&b)
|
758
|
-
}.to yield_successive_args(
|
759
|
-
"┌──────┬──────┬──────┐",
|
760
|
-
"│ AAAA │ BBBB │ CCCC │",
|
761
|
-
"│ DD │ EE │ FF │",
|
762
|
-
"│ G │ H │ I │",
|
763
|
-
"└──────┴──────┴──────┘"
|
764
|
-
)
|
765
|
-
end
|
766
|
-
end
|
767
|
-
|
768
|
-
context "and when #style.header is true" do
|
769
|
-
let(:table) do
|
770
|
-
CommandKit::Printing::Tables::TableBuilder.new(rows, header: header)
|
771
|
-
end
|
772
|
-
|
773
|
-
it "must yield the center justified header row, then a separator line, then the rows" do
|
774
|
-
expect { |b|
|
775
|
-
subject.format(&b)
|
776
|
-
}.to yield_successive_args(
|
777
|
-
"┌──────┬──────┬──────┐",
|
778
|
-
"│ A │ B │ C │",
|
779
|
-
"├──────┼──────┼──────┤",
|
780
|
-
"│ AAAA │ BBBB │ CCCC │",
|
781
|
-
"│ DDDD │ EEEE │ FFFF │",
|
782
|
-
"│ GGGG │ HHHH │ IIII │",
|
783
|
-
"└──────┴──────┴──────┘"
|
784
|
-
)
|
785
|
-
end
|
786
|
-
|
787
|
-
context "and when #style.separate_rows is true" do
|
788
|
-
let(:style) do
|
789
|
-
CommandKit::Printing::Tables::Style.new(
|
790
|
-
border: :line,
|
791
|
-
separate_rows: true
|
792
|
-
)
|
793
|
-
end
|
794
|
-
|
795
|
-
it "must yield the header and each row with a separator line between each row" do
|
796
|
-
expect { |b|
|
797
|
-
subject.format(&b)
|
798
|
-
}.to yield_successive_args(
|
799
|
-
"┌──────┬──────┬──────┐",
|
800
|
-
"│ A │ B │ C │",
|
801
|
-
"├──────┼──────┼──────┤",
|
802
|
-
"│ AAAA │ BBBB │ CCCC │",
|
803
|
-
"├──────┼──────┼──────┤",
|
804
|
-
"│ DDDD │ EEEE │ FFFF │",
|
805
|
-
"├──────┼──────┼──────┤",
|
806
|
-
"│ GGGG │ HHHH │ IIII │",
|
807
|
-
"└──────┴──────┴──────┘"
|
808
|
-
)
|
809
|
-
end
|
810
|
-
end
|
811
|
-
|
812
|
-
context "and when #style.justify_header is :left" do
|
813
|
-
let(:style) do
|
814
|
-
CommandKit::Printing::Tables::Style.new(
|
815
|
-
border: :line,
|
816
|
-
justify_header: :left
|
817
|
-
)
|
818
|
-
end
|
819
|
-
|
820
|
-
it "must left justify the header cells" do
|
821
|
-
expect { |b|
|
822
|
-
subject.format(&b)
|
823
|
-
}.to yield_successive_args(
|
824
|
-
"┌──────┬──────┬──────┐",
|
825
|
-
"│ A │ B │ C │",
|
826
|
-
"├──────┼──────┼──────┤",
|
827
|
-
"│ AAAA │ BBBB │ CCCC │",
|
828
|
-
"│ DDDD │ EEEE │ FFFF │",
|
829
|
-
"│ GGGG │ HHHH │ IIII │",
|
830
|
-
"└──────┴──────┴──────┘"
|
831
|
-
)
|
832
|
-
end
|
833
|
-
end
|
834
|
-
|
835
|
-
context "and when #style.justify_header is :right" do
|
836
|
-
let(:style) do
|
837
|
-
CommandKit::Printing::Tables::Style.new(
|
838
|
-
border: :line,
|
839
|
-
justify_header: :right
|
840
|
-
)
|
841
|
-
end
|
842
|
-
|
843
|
-
it "must right justify the header cells" do
|
844
|
-
expect { |b|
|
845
|
-
subject.format(&b)
|
846
|
-
}.to yield_successive_args(
|
847
|
-
"┌──────┬──────┬──────┐",
|
848
|
-
"│ A │ B │ C │",
|
849
|
-
"├──────┼──────┼──────┤",
|
850
|
-
"│ AAAA │ BBBB │ CCCC │",
|
851
|
-
"│ DDDD │ EEEE │ FFFF │",
|
852
|
-
"│ GGGG │ HHHH │ IIII │",
|
853
|
-
"└──────┴──────┴──────┘"
|
854
|
-
)
|
855
|
-
end
|
856
|
-
end
|
857
|
-
|
858
|
-
context "and when #style.justify_header is :center" do
|
859
|
-
let(:style) do
|
860
|
-
CommandKit::Printing::Tables::Style.new(
|
861
|
-
border: :line,
|
862
|
-
justify_header: :center
|
863
|
-
)
|
864
|
-
end
|
865
|
-
|
866
|
-
it "must center justify the header cells" do
|
867
|
-
expect { |b|
|
868
|
-
subject.format(&b)
|
869
|
-
}.to yield_successive_args(
|
870
|
-
"┌──────┬──────┬──────┐",
|
871
|
-
"│ A │ B │ C │",
|
872
|
-
"├──────┼──────┼──────┤",
|
873
|
-
"│ AAAA │ BBBB │ CCCC │",
|
874
|
-
"│ DDDD │ EEEE │ FFFF │",
|
875
|
-
"│ GGGG │ HHHH │ IIII │",
|
876
|
-
"└──────┴──────┴──────┘"
|
877
|
-
)
|
878
|
-
end
|
879
|
-
end
|
880
|
-
end
|
881
|
-
end
|
882
|
-
|
883
|
-
context "when #style.border is :double_line" do
|
884
|
-
let(:style) do
|
885
|
-
CommandKit::Printing::Tables::Style.new(border: :double_line)
|
886
|
-
end
|
887
|
-
|
888
|
-
it "must yield the table with an ANSI double-line border" do
|
889
|
-
expect { |b|
|
890
|
-
subject.format(&b)
|
891
|
-
}.to yield_successive_args(
|
892
|
-
"╔══════╦══════╦══════╗",
|
893
|
-
"║ AAAA ║ BBBB ║ CCCC ║",
|
894
|
-
"║ DDDD ║ EEEE ║ FFFF ║",
|
895
|
-
"║ GGGG ║ HHHH ║ IIII ║",
|
896
|
-
"╚══════╩══════╩══════╝"
|
897
|
-
)
|
898
|
-
end
|
899
|
-
|
900
|
-
context "but when the table contains multi-line cells" do
|
901
|
-
let(:rows) { multiline_rows }
|
902
|
-
|
903
|
-
it "must yield each line of each row" do
|
904
|
-
expect { |b|
|
905
|
-
subject.format(&b)
|
906
|
-
}.to yield_successive_args(
|
907
|
-
"╔══════╦══════╦══════╗",
|
908
|
-
"║ AAAA ║ BBBB ║ CCCC ║",
|
909
|
-
"║ AA ║ ║ ║",
|
910
|
-
"║ DDDD ║ EEEE ║ FFFF ║",
|
911
|
-
"║ ║ EE ║ ║",
|
912
|
-
"║ GGGG ║ HHHH ║ IIII ║",
|
913
|
-
"║ ║ ║ II ║",
|
914
|
-
"╚══════╩══════╩══════╝"
|
915
|
-
)
|
916
|
-
end
|
917
|
-
end
|
918
|
-
|
919
|
-
context "but when the table contains empty cells" do
|
920
|
-
let(:rows) { rows_with_empty_cells }
|
921
|
-
|
922
|
-
it "must replace the empty cells with spaces" do
|
923
|
-
expect { |b|
|
924
|
-
subject.format(&b)
|
925
|
-
}.to yield_successive_args(
|
926
|
-
"╔══════╦══════╦══════╗",
|
927
|
-
"║ ║ BBBB ║ CCCC ║",
|
928
|
-
"║ DDDD ║ ║ FFFF ║",
|
929
|
-
"║ GGGG ║ HHHH ║ ║",
|
930
|
-
"╚══════╩══════╩══════╝"
|
931
|
-
)
|
932
|
-
end
|
933
|
-
end
|
934
|
-
|
935
|
-
context "but when the table contains empty cells" do
|
936
|
-
let(:rows) { rows_with_diff_row_lengths }
|
937
|
-
|
938
|
-
it "must pad the columns with empty cells" do
|
939
|
-
expect { |b|
|
940
|
-
subject.format(&b)
|
941
|
-
}.to yield_successive_args(
|
942
|
-
"╔══════╦══════╦══════╗",
|
943
|
-
"║ AAAA ║ ║ ║",
|
944
|
-
"║ DDDD ║ EEEE ║ ║",
|
945
|
-
"║ GGGG ║ HHHH ║ IIII ║",
|
946
|
-
"╚══════╩══════╩══════╝"
|
947
|
-
)
|
948
|
-
end
|
949
|
-
end
|
950
|
-
|
951
|
-
context "and when #style.separate_rows is true" do
|
952
|
-
let(:style) do
|
953
|
-
CommandKit::Printing::Tables::Style.new(
|
954
|
-
border: :double_line,
|
955
|
-
separate_rows: true
|
956
|
-
)
|
957
|
-
end
|
958
|
-
|
959
|
-
it "must yield each row with separator lines between each row" do
|
960
|
-
expect { |b|
|
961
|
-
subject.format(&b)
|
962
|
-
}.to yield_successive_args(
|
963
|
-
"╔══════╦══════╦══════╗",
|
964
|
-
"║ AAAA ║ BBBB ║ CCCC ║",
|
965
|
-
"╠══════╬══════╬══════╣",
|
966
|
-
"║ DDDD ║ EEEE ║ FFFF ║",
|
967
|
-
"╠══════╬══════╬══════╣",
|
968
|
-
"║ GGGG ║ HHHH ║ IIII ║",
|
969
|
-
"╚══════╩══════╩══════╝"
|
970
|
-
)
|
971
|
-
end
|
972
|
-
end
|
973
|
-
|
974
|
-
context "and when #style.justify is :left" do
|
975
|
-
let(:rows) { unjustified_rows }
|
976
|
-
|
977
|
-
let(:style) do
|
978
|
-
CommandKit::Printing::Tables::Style.new(
|
979
|
-
border: :double_line,
|
980
|
-
justify: :left
|
981
|
-
)
|
982
|
-
end
|
983
|
-
|
984
|
-
it "must left justify each cell" do
|
985
|
-
expect { |b|
|
986
|
-
subject.format(&b)
|
987
|
-
}.to yield_successive_args(
|
988
|
-
"╔══════╦══════╦══════╗",
|
989
|
-
"║ AAAA ║ BBBB ║ CCCC ║",
|
990
|
-
"║ DD ║ EE ║ FF ║",
|
991
|
-
"║ G ║ H ║ I ║",
|
992
|
-
"╚══════╩══════╩══════╝"
|
993
|
-
)
|
994
|
-
end
|
995
|
-
end
|
996
|
-
|
997
|
-
context "and when #style.justify is :right" do
|
998
|
-
let(:rows) { unjustified_rows }
|
999
|
-
|
1000
|
-
let(:style) do
|
1001
|
-
CommandKit::Printing::Tables::Style.new(
|
1002
|
-
border: :double_line,
|
1003
|
-
justify: :right
|
1004
|
-
)
|
1005
|
-
end
|
1006
|
-
|
1007
|
-
it "must right justify each cell" do
|
1008
|
-
expect { |b|
|
1009
|
-
subject.format(&b)
|
1010
|
-
}.to yield_successive_args(
|
1011
|
-
"╔══════╦══════╦══════╗",
|
1012
|
-
"║ AAAA ║ BBBB ║ CCCC ║",
|
1013
|
-
"║ DD ║ EE ║ FF ║",
|
1014
|
-
"║ G ║ H ║ I ║",
|
1015
|
-
"╚══════╩══════╩══════╝"
|
1016
|
-
)
|
1017
|
-
end
|
1018
|
-
end
|
1019
|
-
|
1020
|
-
context "and when #style.justify is :center" do
|
1021
|
-
let(:rows) { unjustified_rows }
|
1022
|
-
|
1023
|
-
let(:style) do
|
1024
|
-
CommandKit::Printing::Tables::Style.new(
|
1025
|
-
border: :double_line,
|
1026
|
-
justify: :center
|
1027
|
-
)
|
1028
|
-
end
|
1029
|
-
|
1030
|
-
it "must center justify each cell" do
|
1031
|
-
expect { |b|
|
1032
|
-
subject.format(&b)
|
1033
|
-
}.to yield_successive_args(
|
1034
|
-
"╔══════╦══════╦══════╗",
|
1035
|
-
"║ AAAA ║ BBBB ║ CCCC ║",
|
1036
|
-
"║ DD ║ EE ║ FF ║",
|
1037
|
-
"║ G ║ H ║ I ║",
|
1038
|
-
"╚══════╩══════╩══════╝"
|
1039
|
-
)
|
1040
|
-
end
|
1041
|
-
end
|
1042
|
-
|
1043
|
-
context "and when #table.header? is true" do
|
1044
|
-
let(:table) do
|
1045
|
-
CommandKit::Printing::Tables::TableBuilder.new(rows, header: header)
|
1046
|
-
end
|
1047
|
-
|
1048
|
-
it "must yield the center justified header row, then a separator line, then each row" do
|
1049
|
-
expect { |b|
|
1050
|
-
subject.format(&b)
|
1051
|
-
}.to yield_successive_args(
|
1052
|
-
"╔══════╦══════╦══════╗",
|
1053
|
-
"║ A ║ B ║ C ║",
|
1054
|
-
"╠══════╬══════╬══════╣",
|
1055
|
-
"║ AAAA ║ BBBB ║ CCCC ║",
|
1056
|
-
"║ DDDD ║ EEEE ║ FFFF ║",
|
1057
|
-
"║ GGGG ║ HHHH ║ IIII ║",
|
1058
|
-
"╚══════╩══════╩══════╝"
|
1059
|
-
)
|
1060
|
-
end
|
1061
|
-
|
1062
|
-
context "and when #style.separate_rows? is true" do
|
1063
|
-
let(:style) do
|
1064
|
-
CommandKit::Printing::Tables::Style.new(
|
1065
|
-
border: :double_line,
|
1066
|
-
separate_rows: true
|
1067
|
-
)
|
1068
|
-
end
|
1069
|
-
|
1070
|
-
it "must yield the header and each row with separator lines between them" do
|
1071
|
-
expect { |b|
|
1072
|
-
subject.format(&b)
|
1073
|
-
}.to yield_successive_args(
|
1074
|
-
"╔══════╦══════╦══════╗",
|
1075
|
-
"║ A ║ B ║ C ║",
|
1076
|
-
"╠══════╬══════╬══════╣",
|
1077
|
-
"║ AAAA ║ BBBB ║ CCCC ║",
|
1078
|
-
"╠══════╬══════╬══════╣",
|
1079
|
-
"║ DDDD ║ EEEE ║ FFFF ║",
|
1080
|
-
"╠══════╬══════╬══════╣",
|
1081
|
-
"║ GGGG ║ HHHH ║ IIII ║",
|
1082
|
-
"╚══════╩══════╩══════╝"
|
1083
|
-
)
|
1084
|
-
end
|
1085
|
-
end
|
1086
|
-
|
1087
|
-
context "and when #style.justify_header is :left" do
|
1088
|
-
let(:style) do
|
1089
|
-
CommandKit::Printing::Tables::Style.new(
|
1090
|
-
border: :double_line,
|
1091
|
-
justify_header: :left
|
1092
|
-
)
|
1093
|
-
end
|
1094
|
-
|
1095
|
-
it "must left justify the header cells" do
|
1096
|
-
expect { |b|
|
1097
|
-
subject.format(&b)
|
1098
|
-
}.to yield_successive_args(
|
1099
|
-
"╔══════╦══════╦══════╗",
|
1100
|
-
"║ A ║ B ║ C ║",
|
1101
|
-
"╠══════╬══════╬══════╣",
|
1102
|
-
"║ AAAA ║ BBBB ║ CCCC ║",
|
1103
|
-
"║ DDDD ║ EEEE ║ FFFF ║",
|
1104
|
-
"║ GGGG ║ HHHH ║ IIII ║",
|
1105
|
-
"╚══════╩══════╩══════╝"
|
1106
|
-
)
|
1107
|
-
end
|
1108
|
-
end
|
1109
|
-
|
1110
|
-
context "and when #style.justify_header is :right" do
|
1111
|
-
let(:style) do
|
1112
|
-
CommandKit::Printing::Tables::Style.new(
|
1113
|
-
border: :double_line,
|
1114
|
-
justify_header: :right
|
1115
|
-
)
|
1116
|
-
end
|
1117
|
-
|
1118
|
-
it "must right justify the header cells" do
|
1119
|
-
expect { |b|
|
1120
|
-
subject.format(&b)
|
1121
|
-
}.to yield_successive_args(
|
1122
|
-
"╔══════╦══════╦══════╗",
|
1123
|
-
"║ A ║ B ║ C ║",
|
1124
|
-
"╠══════╬══════╬══════╣",
|
1125
|
-
"║ AAAA ║ BBBB ║ CCCC ║",
|
1126
|
-
"║ DDDD ║ EEEE ║ FFFF ║",
|
1127
|
-
"║ GGGG ║ HHHH ║ IIII ║",
|
1128
|
-
"╚══════╩══════╩══════╝"
|
1129
|
-
)
|
1130
|
-
end
|
1131
|
-
end
|
1132
|
-
|
1133
|
-
context "and when #style.justify_header is :center" do
|
1134
|
-
let(:style) do
|
1135
|
-
CommandKit::Printing::Tables::Style.new(
|
1136
|
-
border: :double_line,
|
1137
|
-
justify_header: :center
|
1138
|
-
)
|
1139
|
-
end
|
1140
|
-
|
1141
|
-
it "must center justify the header cells" do
|
1142
|
-
expect { |b|
|
1143
|
-
subject.format(&b)
|
1144
|
-
}.to yield_successive_args(
|
1145
|
-
"╔══════╦══════╦══════╗",
|
1146
|
-
"║ A ║ B ║ C ║",
|
1147
|
-
"╠══════╬══════╬══════╣",
|
1148
|
-
"║ AAAA ║ BBBB ║ CCCC ║",
|
1149
|
-
"║ DDDD ║ EEEE ║ FFFF ║",
|
1150
|
-
"║ GGGG ║ HHHH ║ IIII ║",
|
1151
|
-
"╚══════╩══════╩══════╝"
|
1152
|
-
)
|
1153
|
-
end
|
1154
|
-
end
|
1155
|
-
end
|
1156
|
-
end
|
1157
|
-
|
1158
|
-
context "when given an invalid justify_header: value" do
|
1159
|
-
let(:justify) { :foo }
|
1160
|
-
|
1161
|
-
let(:table) do
|
1162
|
-
CommandKit::Printing::Tables::TableBuilder.new(rows, header: header)
|
1163
|
-
end
|
1164
|
-
|
1165
|
-
let(:style) do
|
1166
|
-
CommandKit::Printing::Tables::Style.new(justify_header: justify)
|
1167
|
-
end
|
1168
|
-
|
1169
|
-
it do
|
1170
|
-
expect { |b|
|
1171
|
-
subject.format(&b)
|
1172
|
-
}.to raise_error(ArgumentError,"invalid justify value (#{justify.inspect}), must be :left, :right, or :center")
|
1173
|
-
end
|
1174
|
-
end
|
1175
|
-
|
1176
|
-
context "when given an invalid justify: value" do
|
1177
|
-
let(:justify) { :foo }
|
1178
|
-
|
1179
|
-
let(:style) do
|
1180
|
-
CommandKit::Printing::Tables::Style.new(justify: justify)
|
1181
|
-
end
|
1182
|
-
|
1183
|
-
it do
|
1184
|
-
expect { |b|
|
1185
|
-
subject.format(&b)
|
1186
|
-
}.to raise_error(ArgumentError,"invalid justify value (#{justify.inspect}), must be :left, :right, or :center")
|
1187
|
-
end
|
1188
|
-
end
|
1189
|
-
end
|
1190
|
-
end
|