class MARKDOWNBuilderTest

Public Instance Methods

setup() click to toggle source
# File ../../../../../test/test_markdownbuilder.rb, line 11
def setup
  @builder = MARKDOWNBuilder.new()
  @config = {
    "secnolevel" => 2, # for IDGXMLBuilder, HTMLBuilder
    "stylesheet" => nil, # for HTMLBuilder
  }
  @book = Book::Base.new(".")
  @book.config = @config
  @compiler = ReVIEW::Compiler.new(@builder)
  @chapter = Book::Chapter.new(@book, 1, '-', nil, StringIO.new)
  location = Location.new(nil, nil)
  @builder.bind(@compiler, @chapter, location)
end
test_cmd() click to toggle source
# File ../../../../../test/test_markdownbuilder.rb, line 70
def test_cmd
  actual = compile_block("//cmd{\nlineA\nlineB\n//}\n")
  assert_equal "```shell-session\nlineA\nlineB\n```\n", actual
end
test_comment() click to toggle source
# File ../../../../../test/test_markdownbuilder.rb, line 91
def test_comment
  actual = compile_block("//comment[コメント]")
  assert_equal %Q||, actual
end
test_comment_for_draft() click to toggle source
# File ../../../../../test/test_markdownbuilder.rb, line 96
def test_comment_for_draft
  @config["draft"] = true
  actual = compile_block("//comment[コメント]")
  assert_equal %Q|<div class="red">コメント</div>\n|, actual
end
test_dlist() click to toggle source
# File ../../../../../test/test_markdownbuilder.rb, line 75
def test_dlist
  actual = compile_block(": foo\n  foo.\n  bar.\n")
  assert_equal %Q|<dl>\n<dt>foo</dt>\n<dd>foo.bar.</dd>\n</dl>\n|, actual
end
test_dlist_with_bracket() click to toggle source
# File ../../../../../test/test_markdownbuilder.rb, line 80
def test_dlist_with_bracket
  actual = compile_block(": foo[bar]\n    foo.\n    bar.\n")
  assert_equal %Q|<dl>\n<dt>foo[bar]</dt>\n<dd>foo.bar.</dd>\n</dl>\n|, actual
end
test_dlist_with_comment() click to toggle source
# File ../../../../../test/test_markdownbuilder.rb, line 85
def test_dlist_with_comment
  source = ": title\n  body\n\#@ comment\n\#@ comment\n: title2\n  body2\n"
  actual = compile_block(source)
  assert_equal %Q|<dl>\n<dt>title</dt>\n<dd>body</dd>\n<dt>title2</dt>\n<dd>body2</dd>\n</dl>\n|, actual
end
test_emlist_lang() click to toggle source
# File ../../../../../test/test_markdownbuilder.rb, line 138
  def test_emlist_lang
    actual = compile_block("//emlist[caption][ruby]{
AAA
BBB
//}
")

    assert_equal "
caption

```ruby
AAA
BBB
```

", actual
  end
test_inline_comment() click to toggle source
# File ../../../../../test/test_markdownbuilder.rb, line 48
def test_inline_comment
  actual = compile_inline("test @<comment>{コメント} test2")
  assert_equal %Q|test  test2|, actual
end
test_inline_comment_for_draft() click to toggle source
# File ../../../../../test/test_markdownbuilder.rb, line 53
def test_inline_comment_for_draft
  @config["draft"] = true
  actual = compile_inline("test @<comment>{コメント} test2")
  assert_equal %Q|test <span class="red">コメント</span> test2|, actual
end
test_inline_em() click to toggle source
# File ../../../../../test/test_markdownbuilder.rb, line 30
def test_inline_em
  assert_equal "test*foo*abc", compile_inline("test@<em>{foo}abc")
end
test_inline_strong() click to toggle source
# File ../../../../../test/test_markdownbuilder.rb, line 34
def test_inline_strong
  assert_equal "test**foo**abc", compile_inline("test@<strong>{foo}abc")
end
test_list() click to toggle source
# File ../../../../../test/test_markdownbuilder.rb, line 102
  def test_list
    actual = compile_block("//list[name][caption]{
AAA
BBB
//}
")

    assert_equal "リスト1.1 caption

```
AAA
BBB
```
", actual
  end
test_list_lang() click to toggle source
# File ../../../../../test/test_markdownbuilder.rb, line 120
  def test_list_lang
    actual = compile_block("//list[name][caption][ruby]{
AAA
BBB
//}
")

    assert_equal "リスト1.1 caption

```ruby
AAA
BBB
```
", actual
  end
test_quote() click to toggle source
# File ../../../../../test/test_markdownbuilder.rb, line 25
def test_quote
  actual = compile_block("//quote{\nfoo\nbar\n\nbuz\n//}\n")
  assert_equal %Q|\n> foobar\n> \n> buz\n\n|, actual
end
test_ruby() click to toggle source
# File ../../../../../test/test_markdownbuilder.rb, line 163
def test_ruby
  actual = compile_block("@<ruby>{謳,うた}い文句")
  assert_equal "<ruby><rb>謳</rb><rp>(</rp><rt>うた</rt><rp>)</rp></ruby>い文句\n\n", actual
end
test_table() click to toggle source
# File ../../../../../test/test_markdownbuilder.rb, line 158
def test_table
  actual = compile_block("//table{\ntestA\ttestB\n------------\ncontentA\tcontentB\n//}\n")
  assert_equal "|testA|testB|\n|:--|:--|\n|contentA|contentB|\n\n", actual
end
test_ul() click to toggle source
# File ../../../../../test/test_markdownbuilder.rb, line 38
  def test_ul
    src =<<-EOS
  * AAA
  * BBB
EOS
    expected = "\n* AAA\n* BBB\n\n"
    actual = compile_block(src)
    assert_equal expected, actual
  end
test_ul_nest1() click to toggle source
# File ../../../../../test/test_markdownbuilder.rb, line 59
  def test_ul_nest1
    src =<<-EOS
  * AAA
  ** AA
  *** A
EOS
    expected = "\n* AAA\n  * AA\n    * A\n\n"
    actual = compile_block(src)
    assert_equal expected, actual
  end