Class: XMPPStanzaTest
Defined Under Namespace
Classes: MyStanza, MyXMPPStanza
Instance Method Summary
collapse
#assert_array_equal, expect, #run
Instance Method Details
#test_clone_and_dup ⇒ Object
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
|
# File 'lib/gems/xmpp4r-0.4/test/tc_xmppstanza.rb', line 111
def test_clone_and_dup
x = MyXMPPStanza.new
x.attributes['xyz'] = '123'
x.text = 'abc'
assert_equal(x.attributes['xyz'], '123')
assert_equal(x.text, 'abc')
x2 = x.clone
assert_kind_of(MyXMPPStanza, x2)
assert_equal('123', x2.attributes['xyz'])
assert_nil(x2.text)
x3 = x.dup
assert_kind_of(MyXMPPStanza, x3)
assert_equal('123', x3.attributes['xyz'])
assert_equal('abc', x3.text)
end
|
#test_error ⇒ Object
103
104
105
106
107
108
109
|
# File 'lib/gems/xmpp4r-0.4/test/tc_xmppstanza.rb', line 103
def test_error
x = MyXMPPStanza.new
assert_equal(nil, x.error)
x.typed_add(REXML::Element.new('error'))
assert_equal('<error/>', x.error.to_s)
assert_equal(ErrorResponse, x.error.class)
end
|
#test_from ⇒ Object
27
28
29
30
31
32
33
34
|
# File 'lib/gems/xmpp4r-0.4/test/tc_xmppstanza.rb', line 27
def test_from
x = MyXMPPStanza.new
assert_equal(nil, x.from)
assert_equal(x, x.set_from("blop"))
assert_equal("blop", x.from.to_s)
x.from = "tada"
assert_equal("tada", x.from.to_s)
end
|
45
46
47
48
49
50
51
52
|
# File 'lib/gems/xmpp4r-0.4/test/tc_xmppstanza.rb', line 45
def test_id
x = MyXMPPStanza.new
assert_equal(nil, x.id)
assert_equal(x, x.set_id("blop"))
assert_equal("blop", x.id)
x.id = "tada"
assert_equal("tada", x.id)
end
|
#test_import ⇒ Object
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
# File 'lib/gems/xmpp4r-0.4/test/tc_xmppstanza.rb', line 63
def test_import
x = MyXMPPStanza.new
x.id = "heya"
q = x.add_element("query")
q.add_namespace("about:blank")
q.add_element("b").text = "I am b"
q.add_text("I am text")
q.add_element("a").add_attribute("href", "http://home.gna.org/xmpp4r/")
x.add_text("yow")
x.add_element("query")
assert_raise(RuntimeError) { iq = Iq.import(x) }
x.name = 'iq'
iq = Iq.import(x)
assert_equal(x.id, iq.id)
assert_equal(q.to_s, iq.query.to_s)
assert_equal(x.to_s, iq.to_s)
assert_equal(q.namespace, iq.queryns)
end
|
#test_import_xml_entities ⇒ Object
94
95
96
97
98
99
100
101
|
# File 'lib/gems/xmpp4r-0.4/test/tc_xmppstanza.rb', line 94
def test_import_xml_entities
e = REXML::Element.new('e')
e.text = '&'
assert_equal('<e>&</e>', e.to_s)
e2 = REXML::Element.new('e').import(e)
assert_equal('<e>&</e>', e2.to_s)
end
|
36
37
38
39
40
41
42
43
|
# File 'lib/gems/xmpp4r-0.4/test/tc_xmppstanza.rb', line 36
def test_to
x = MyXMPPStanza.new
assert_equal(nil, x.to)
assert_equal(x, x.set_to("blop"))
assert_equal("blop", x.to.to_s)
x.to = "tada"
assert_equal("tada", x.to.to_s)
end
|
#test_type ⇒ Object
54
55
56
57
58
59
60
61
|
# File 'lib/gems/xmpp4r-0.4/test/tc_xmppstanza.rb', line 54
def test_type
x = MyXMPPStanza.new
assert_equal(nil, x.type)
assert_equal(x, x.set_type("blop"))
assert_equal("blop", x.type)
x.type = "tada"
assert_equal("tada", x.type)
end
|