diff options
| author | Dan Allen <dan.j.allen@gmail.com> | 2013-08-28 18:06:50 -0600 |
|---|---|---|
| committer | Dan Allen <dan.j.allen@gmail.com> | 2013-08-28 19:02:33 -0600 |
| commit | a53a62ad8ac2847cfae79befd505ebfab5a19ec6 (patch) | |
| tree | f7c755eec60e2ec75fb2c71e1da2c1823389c245 /test/text_test.rb | |
| parent | b066a90f80d4d7345279b0fbc7bc66f58bb233ad (diff) | |
rework #455 to pass Markdown horizontal rule tests
Diffstat (limited to 'test/text_test.rb')
| -rw-r--r-- | test/text_test.rb | 83 |
1 files changed, 74 insertions, 9 deletions
diff --git a/test/text_test.rb b/test/text_test.rb index 22e1825e..522db3de 100644 --- a/test/text_test.rb +++ b/test/text_test.rb @@ -84,22 +84,87 @@ This line is separated by a horizontal rule... '- - -', '***', '* * *', - '\' \' \'' + '___', + '_ _ _' + ] + + offsets = [ + '', + ' ', + ' ', + ' ' ] variants.each do |variant| - input = <<-EOS + offsets.each do |offset| + input = <<-EOS This line is separated by a horizontal rule... -#{variant} +#{offset}#{variant} ...from this line. - EOS - output = render_embedded_string input - assert_xpath "//hr", output, 1 - assert_xpath "/*[@class='paragraph']", output, 2 - assert_xpath "(/*[@class='paragraph'])[1]/following-sibling::hr", output, 1 - assert_xpath "/hr/following-sibling::*[@class='paragraph']", output, 1 + EOS + output = render_embedded_string input + assert_xpath "//hr", output, 1 + assert_xpath "/*[@class='paragraph']", output, 2 + assert_xpath "(/*[@class='paragraph'])[1]/following-sibling::hr", output, 1 + assert_xpath "/hr/following-sibling::*[@class='paragraph']", output, 1 + end + end + end + + test 'markdown horizontal rules negative case' do + + bad_variants = [ + '- - - -', + '* * * *', + '_ _ _ _' + ] + + good_offsets = [ + '', + ' ', + ' ', + ' ' + ] + + bad_variants.each do |variant| + good_offsets.each do |offset| + input = <<-EOS +This line is separated something that is not a horizontal rule... + +#{offset}#{variant} + +...from this line. + EOS + output = render_embedded_string input + assert_xpath '//hr', output, 0 + end + end + + good_variants = [ + '- - -', + '* * *', + '_ _ _' + ] + + bad_offsets = [ + "\t", + ' ' + ] + + good_variants.each do |variant| + bad_offsets.each do |offset| + input = <<-EOS +This line is separated something that is not a horizontal rule... + +#{offset}#{variant} + +...from this line. + EOS + output = render_embedded_string input + assert_xpath '//hr', output, 0 + end end end |
