Class: TestFormatTable2
- Defined in:
- lib/format_table.rb
Instance Method Summary collapse
- #setup ⇒ Object
- #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
#setup ⇒ Object
444 445 446 |
# File 'lib/format_table.rb', line 444 def setup @table = { delimiter: '|' } end |
#test_basic_formatting ⇒ Object
448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 |
# File 'lib/format_table.rb', line 448 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, table: @table ) end |
#test_complete_rows ⇒ Object
540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 |
# File 'lib/format_table.rb', line 540 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, table: @table ) end |
#test_empty_lines ⇒ Object
530 531 532 533 534 535 536 537 538 |
# File 'lib/format_table.rb', line 530 def test_empty_lines lines = [] expected_output = [] assert_equal expected_output, MarkdownTableFormatter.format_table( lines: lines, column_count: 3, table: @table ) end |
#test_extra_column_count ⇒ Object
484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 |
# File 'lib/format_table.rb', line 484 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, table: @table ) end |
#test_incomplete_column_count ⇒ Object
466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 |
# File 'lib/format_table.rb', line 466 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, table: @table ) end |
#test_single_line ⇒ Object
520 521 522 523 524 525 526 527 528 |
# File 'lib/format_table.rb', line 520 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, table: @table ) end |
#test_varied_column_lengths ⇒ Object
502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 |
# File 'lib/format_table.rb', line 502 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, table: @table ) end |