Sha256: b12ba01072d8bb43a716932a4aee105e7ceb09704ae47e8f112cc6d1011cb1ba

Contents?: true

Size: 1.59 KB

Versions: 3

Compression:

Stored size: 1.59 KB

Contents

require 'minitest_helper'

# I'm sorry, I concat Ruby strings
# the reason is: the table ends with spaces
# and whenever I hit cmd+s, a textmate plugin
# deletes all trailing spaces in my file

module RenderAsMarkdown
  class TableTest < MiniTest::Unit::TestCase

    def test_simple_table
      t = RenderAsMarkdown::Table.new %w{eins zwei superkalifrageristric}
      t << %w{hoch-soll-er-leben 3 mal-hoch}

      assert_equal t.render, \
        "eins              |zwei|superkalifrageristric\n"+
        "------------------|----|---------------------\n"+
        "hoch-soll-er-leben|3   |mal-hoch             \n"

    end

    def test_header_with_numbers
      header = [1,2,3]
      t = RenderAsMarkdown::Table.new header
      t << [3,2,1]
      t << [4,5,6]

      assert_equal t.render, \
        "1|2|3\n"+
        "-|-|-\n"+
        "3|2|1\n"+
        "4|5|6\n"

    end

    def test_numbers
      header = [1,2,3]
      t = RenderAsMarkdown::Table.new header
      t << [3,2,1]
      t << [4,5,6]

      assert_equal t.render, \
        "1|2|3\n"+
        "-|-|-\n"+
        "3|2|1\n"+
        "4|5|6\n"

    end

    def test_nil
      header = [nil, "eins", "zwei"]
      t = RenderAsMarkdown::Table.new header
      t << [nil, 1, 2]

      assert_equal t.render, \
        " |eins|zwei\n"+
        "-|----|----\n"+
        " |1   |2   \n"
    end


    def test_single_column
      t = RenderAsMarkdown::Table.new "nr"
      t << 1
      t << 2
      t << 3
      t << 4

      assert_equal t.render,
        "nr\n"+
        "--\n"+
        "1 \n"+
        "2 \n"+
        "3 \n"+
        "4 \n"
    end


  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
render-as-markdown-0.0.6 test/table_test.rb
render-as-markdown-0.0.5 test/table_test.rb
render-as-markdown-0.0.4 test/table_test.rb