Class: REXMLTest
Instance Method Summary
collapse
#assert_array_equal, expect, #run
Instance Method Details
#test_attribute_entites ⇒ Object
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
# File 'lib/gems/xmpp4r-0.4/test/tc_rexml.rb', line 49
def test_attribute_entites
e = REXML::Element.new('e')
e.attributes['x'] = '&'
assert_equal('&', e.attributes['x'])
e.attributes['x'] = '&'
assert_equal('&', e.attribute('x').to_s)
e.attributes['x'] = ' '
assert_equal(' ', e.attributes['x'])
e.attributes['x'] = ' '
assert_equal(' ', e.attributes['x'])
end
|
#test_element_equal_simple ⇒ Object
76
77
78
|
# File 'lib/gems/xmpp4r-0.4/test/tc_rexml.rb', line 76
def test_element_equal_simple
assert_equal(REXML::Element.new('foo'), REXML::Element.new('foo'))
end
|
#test_element_equal_when_all_are_same ⇒ Object
84
85
86
87
88
89
90
91
92
93
|
# File 'lib/gems/xmpp4r-0.4/test/tc_rexml.rb', line 84
def test_element_equal_when_all_are_same
e1 = REXML::Element.new('foo')
e1.add_namespace('a', 'urn:test:foo')
e1.attributes['a:bar'] = 'baz'
e2 = REXML::Element.new('foo')
e2.add_namespace('a', 'urn:test:foo')
e2.attributes['a:bar'] = 'baz'
assert_equal(e1, e2)
end
|
#test_element_not_equal_simple ⇒ Object
80
81
82
|
# File 'lib/gems/xmpp4r-0.4/test/tc_rexml.rb', line 80
def test_element_not_equal_simple
assert_not_equal(REXML::Element.new('foo'), REXML::Element.new('bar'))
end
|
#test_element_not_equal_when_attribute_name_differs ⇒ Object
117
118
119
120
121
122
123
124
125
126
|
# File 'lib/gems/xmpp4r-0.4/test/tc_rexml.rb', line 117
def test_element_not_equal_when_attribute_name_differs
e1 = REXML::Element.new('foo')
e1.add_namespace('a', 'urn:test:foo')
e1.attributes['a:bar'] = 'baz'
e2 = REXML::Element.new('foo')
e1.add_namespace('a', 'urn:test:foo')
e2.attributes['b:bar'] = 'baz'
assert_not_equal(e1, e2)
end
|
#test_element_not_equal_when_attribute_value_differs ⇒ Object
128
129
130
131
132
133
134
135
136
137
|
# File 'lib/gems/xmpp4r-0.4/test/tc_rexml.rb', line 128
def test_element_not_equal_when_attribute_value_differs
e1 = REXML::Element.new('foo')
e1.add_namespace('a', 'urn:test:foo')
e1.attributes['a:bar'] = 'baz'
e2 = REXML::Element.new('foo')
e1.add_namespace('a', 'urn:test:foo')
e2.attributes['a:bar'] = 'bar'
assert_not_equal(e1, e2)
end
|
#test_element_not_equal_when_namespace_name_differs ⇒ Object
95
96
97
98
99
100
101
102
103
104
|
# File 'lib/gems/xmpp4r-0.4/test/tc_rexml.rb', line 95
def test_element_not_equal_when_namespace_name_differs
e1 = REXML::Element.new('foo')
e1.add_namespace('a', 'urn:test:foo')
e1.attributes['a:bar'] = 'baz'
e2 = REXML::Element.new('foo')
e2.add_namespace('b', 'urn:test:foo')
e2.attributes['a:bar'] = 'baz'
assert_not_equal(e1, e2)
end
|
#test_element_not_equal_when_namespace_value_differs ⇒ Object
106
107
108
109
110
111
112
113
114
115
|
# File 'lib/gems/xmpp4r-0.4/test/tc_rexml.rb', line 106
def test_element_not_equal_when_namespace_value_differs
e1 = REXML::Element.new('foo')
e1.add_namespace('a', 'urn:test:foo')
e1.attributes['a:bar'] = 'baz'
e2 = REXML::Element.new('foo')
e2.add_namespace('a', 'urn:test:bar')
e2.attributes['a:bar'] = 'baz'
assert_not_equal(e1, e2)
end
|
#test_normalize ⇒ Object
16
17
18
19
20
21
|
# File 'lib/gems/xmpp4r-0.4/test/tc_rexml.rb', line 16
def test_normalize
assert_equal('&', REXML::Text::normalize('&'))
assert_equal('&', REXML::Text::normalize('&'))
assert_equal('&', REXML::Text::normalize('&'))
assert_equal(' ', REXML::Text::normalize(' '))
end
|
#test_passing_in_non_rexml_element_as_comparison_object ⇒ Object
71
72
73
74
|
# File 'lib/gems/xmpp4r-0.4/test/tc_rexml.rb', line 71
def test_passing_in_non_rexml_element_as_comparison_object
o = Object.new
assert_not_equal(REXML::Element.new('foo'), o)
end
|
#test_passing_in_non_rexml_element_as_self ⇒ Object
66
67
68
69
|
# File 'lib/gems/xmpp4r-0.4/test/tc_rexml.rb', line 66
def test_passing_in_non_rexml_element_as_self
o = Object.new
assert_not_equal(o, REXML::Element.new('foo'))
end
|
#test_simple ⇒ Object
9
10
11
12
13
14
|
# File 'lib/gems/xmpp4r-0.4/test/tc_rexml.rb', line 9
def test_simple
e = REXML::Element.new('e')
assert_kind_of(REXML::Element, e)
assert_nil(e.text)
assert_nil(e.attributes['x'])
end
|
#test_text_entities ⇒ Object
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
# File 'lib/gems/xmpp4r-0.4/test/tc_rexml.rb', line 31
def test_text_entities
e = REXML::Element.new('e')
e.text = '&'
assert_equal('<e>&</e>', e.to_s)
e.text = '&'
assert_equal('<e>&amp;</e>', e.to_s)
e.text = ' '
assert_equal('<e>&nbsp</e>', e.to_s)
e.text = ' '
assert_equal('<e>&nbsp;</e>', e.to_s)
e.text = '&<;'
assert_equal('<e>&<;</e>', e.to_s)
e.text = '<>"\''
assert_equal('<e><>"'</e>', e.to_s)
e.text = '<x>&</x>'
assert_equal('<e><x>&amp;</x></e>', e.to_s)
end
|
#test_unnormalize ⇒ Object
23
24
25
26
27
28
29
|
# File 'lib/gems/xmpp4r-0.4/test/tc_rexml.rb', line 23
def test_unnormalize
assert_equal('&', REXML::Text::unnormalize('&'))
assert_equal('&', REXML::Text::unnormalize('&amp;'))
assert_equal('&amp;', REXML::Text::unnormalize('&amp;amp;'))
assert_equal(' ', REXML::Text::unnormalize('&nbsp;'))
assert_equal(' ', REXML::Text::unnormalize(' ')) end
|