Class: TestFormatTable2
- Defined in:
- lib/format_table.rb
Instance Method Summary collapse
- #test_basic_formatting ⇒ Object
- #test_complete_rows ⇒ Object
- #test_empty_lines ⇒ Object
- #test_extra_column_count ⇒ Object
- #test_incomplete_column_count ⇒ Object
- #test_single_line ⇒ Object
- #test_varied_column_lengths ⇒ Object
Instance Method Details
#test_basic_formatting ⇒ Object
363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 |
# File 'lib/format_table.rb', line 363 def test_basic_formatting lines = [ '| Name | Age | City |', '| John | 30 | New York |', '| Jane | 25 | Los Angeles |' ] expected_output = [ '| Name | Age | City |', '| John | 30 | New York |', '| Jane | 25 | Los Angeles |' ] assert_equal expected_output, MarkdownTableFormatter.format_table( lines: lines, column_count: 3 ) end |
#test_complete_rows ⇒ Object
449 450 451 452 453 454 455 456 457 458 459 460 461 462 |
# File 'lib/format_table.rb', line 449 def test_complete_rows lines = [ '| Name | Age |', '| John | 30 |' ] expected_output = [ '| Name | Age |', '| John | 30 |' ] assert_equal expected_output, MarkdownTableFormatter.format_table( lines: lines, column_count: 3 ) end |
#test_empty_lines ⇒ Object
440 441 442 443 444 445 446 447 |
# File 'lib/format_table.rb', line 440 def test_empty_lines lines = [] expected_output = [] assert_equal expected_output, MarkdownTableFormatter.format_table( lines: lines, column_count: 3 ) end |
#test_extra_column_count ⇒ Object
397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 |
# File 'lib/format_table.rb', line 397 def test_extra_column_count lines = [ '| Name | Age | City | Country |', '| John | 30 | New York | USA |', '| Jane | 25 | Los Angeles | USA |' ] expected_output = [ '| Name | Age | City | Country |', '| John | 30 | New York | USA |', '| Jane | 25 | Los Angeles | USA |' ] assert_equal expected_output, MarkdownTableFormatter.format_table( lines: lines, column_count: 4 ) end |
#test_incomplete_column_count ⇒ Object
380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 |
# File 'lib/format_table.rb', line 380 def test_incomplete_column_count lines = [ '| Name | Age |', '| John | 30 | New York |', '| Jane | 25 | Los Angeles |' ] expected_output = [ '| Name | Age | |', '| John | 30 | New York |', '| Jane | 25 | Los Angeles |' ] assert_equal expected_output, MarkdownTableFormatter.format_table( lines: lines, column_count: 3 ) end |
#test_single_line ⇒ Object
431 432 433 434 435 436 437 438 |
# File 'lib/format_table.rb', line 431 def test_single_line lines = ['| Name | Age | City |'] expected_output = ['| Name | Age | City |'] assert_equal expected_output, MarkdownTableFormatter.format_table( lines: lines, column_count: 3 ) end |
#test_varied_column_lengths ⇒ Object
414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 |
# File 'lib/format_table.rb', line 414 def test_varied_column_lengths lines = [ '| Name | Age |', '| Johnathan | 30 | New York |', '| Jane | 25 | LA |' ] expected_output = [ '| Name | Age | |', '| Johnathan | 30 | New York |', '| Jane | 25 | LA |' ] assert_equal expected_output, MarkdownTableFormatter.format_table( lines: lines, column_count: 3 ) end |