# encoding: utf-8 require 'helper' class TestHTMLIpsum < Test::Unit::TestCase def setup @tester = Faker::HTMLIpsum end def test_a assert_match /^[ \w]+<\/a>$/i, Faker::HTMLIpsum.a end def test_p # We can't predict the number of times the sentence pattern will repeat # because the Faker::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, Faker::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, Faker::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 Faker::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 = Faker::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 = Faker::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, Faker::HTMLIpsum.dl(3) end def test_ul_short assert_match /^