# encoding: utf-8 require 'helper' class TestHTMLIpsum < Test::Unit::TestCase include DeterministicHelper assert_methods_are_deterministic( FFaker::HTMLIpsum, :a, :p, :dl, :ul_short, :ul_long, :ol_short, :ol_long, :ul_links, :table, :body, :fancy_string ) def setup @tester = FFaker::HTMLIpsum end def test_a assert_match(/^[ \w]+<\/a>$/i, FFaker::HTMLIpsum.a) end def test_p # We can't predict the number of times the sentence pattern will repeat # because the FFaker::Lorem methods that we are using adds a random # number on top of what we specify for the count argument. assert_match(/^

([ \w]+\.)+<\/p>$/i, FFaker::HTMLIpsum.p) end def test_p_breaks # Here we can at least test how many
tags there are. assert_match(/^

(?:[ \w\.]+
){2}[ \w\.]+<\/p>$/i, FFaker::HTMLIpsum.p(3, include_breaks: true)) end def test_p_fancy # We can't predict the number of times the sentence pattern will repeat # because the FFaker::Lorem methods that we are using adds a random # number on top of what we specify for the count argument. We also have to # account for the other HTML that is being returned. str = FFaker::HTMLIpsum.p(5, fancy: true) assert_match(/^

/, str) assert_match(/<\/p>$/, str) assert str.length > 6, 'string contains more than

' end def test_p_fancy_breaks # Here we can at least test how many
tags there are. We also have to # account for the other HTML that is being returned. str = FFaker::HTMLIpsum.p(10, fancy: true, include_breaks: true) assert_equal 10, str.split('
').length end def test_dl assert_match(/^
(
[ \w]+<\/dt>
[ \w.]+<\/dd>){3}<\/dl>$/i, FFaker::HTMLIpsum.dl(3)) end def test_ul_short assert_match(/^