Class: XHTML::HTMLTest

Inherits:
Test::Unit::TestCase
  • Object
show all
Defined in:
lib/gems/xmpp4r-0.4/test/xhtml/tc_html.rb

Instance Method Summary collapse

Instance Method Details

#test_parseObject



26
27
28
29
# File 'lib/gems/xmpp4r-0.4/test/xhtml/tc_html.rb', line 26

def test_parse
  html = XHTML::HTML.new('There is a fine <a href="http://home.gna.org/xmpp4r/">library</a>')
  assert_equal("<html xmlns='http://jabber.org/protocol/xhtml-im'><body xmlns='http://www.w3.org/1999/xhtml'>There is a fine <a href='http://home.gna.org/xmpp4r/'>library</a></body></html>", html.to_s)
end

#test_setObject



12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/gems/xmpp4r-0.4/test/xhtml/tc_html.rb', line 12

def test_set
  contents1 = REXML::Element.new('p')
  contents1.text = 'Hello'
  html = XHTML::HTML.new(contents1)
  assert_kind_of(XHTML::Body, html.first_element('body'))
  assert_equal("<html xmlns='http://jabber.org/protocol/xhtml-im'><body xmlns='http://www.w3.org/1999/xhtml'><p>Hello</p></body></html>", html.to_s)

  contents2 = REXML::Element.new('a')
  contents2.attributes['href'] = 'about:blank'
  contents2.text = 'nothing'
  html.contents = ["Look at ", contents2]
  assert_equal("<html xmlns='http://jabber.org/protocol/xhtml-im'><body xmlns='http://www.w3.org/1999/xhtml'>Look at <a href='about:blank'>nothing</a></body></html>", html.to_s)
end

#test_textObject



31
32
33
34
35
36
37
38
39
40
# File 'lib/gems/xmpp4r-0.4/test/xhtml/tc_html.rb', line 31

def test_text
  a1 = REXML::Element.new('a')
  a1.attributes['href'] = 'http://www.jabber.org/'
  a1.text = 'Jabber'
  a2 = REXML::Element.new('a')
  a2.attributes['href'] = 'http://home.gna.org/xmpp4r/'
  a2.text = 'XMPP4R'
  html = XHTML::HTML.new(["Look at ", a1, " & ", a2])
  assert_equal("Look at Jabber & XMPP4R", html.to_text)
end