blather 0.4.14 → 0.4.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/blather.rb +8 -0
- data/lib/blather/client/client.rb +9 -1
- data/lib/blather/client/dsl/pubsub.rb +2 -2
- data/lib/blather/core_ext/active_support.rb +1 -0
- data/lib/blather/core_ext/eventmachine.rb +122 -0
- data/lib/blather/errors/stanza_error.rb +1 -0
- data/lib/blather/file_transfer.rb +100 -0
- data/lib/blather/file_transfer/ibb.rb +68 -0
- data/lib/blather/file_transfer/s5b.rb +104 -0
- data/lib/blather/roster_item.rb +2 -2
- data/lib/blather/stanza/disco/disco_info.rb +17 -2
- data/lib/blather/stanza/iq/ibb.rb +83 -0
- data/lib/blather/stanza/iq/s5b.rb +205 -0
- data/lib/blather/stanza/iq/si.rb +410 -0
- data/lib/blather/stanza/iq/vcard.rb +147 -0
- data/lib/blather/stanza/message.rb +10 -2
- data/lib/blather/stanza/presence/status.rb +11 -3
- data/lib/blather/stanza/pubsub.rb +3 -1
- data/lib/blather/stanza/pubsub/event.rb +18 -0
- data/lib/blather/stanza/pubsub/subscriptions.rb +4 -2
- data/lib/blather/stanza/pubsub/unsubscribe.rb +17 -1
- data/lib/blather/stanza/x.rb +12 -2
- data/lib/blather/stream/parser.rb +1 -0
- data/lib/test.rb +55 -0
- data/spec/blather/client/client_spec.rb +18 -4
- data/spec/blather/client/dsl/pubsub_spec.rb +12 -2
- data/spec/blather/client/dsl_spec.rb +1 -1
- data/spec/blather/core_ext/nokogiri_spec.rb +1 -1
- data/spec/blather/errors/sasl_error_spec.rb +1 -1
- data/spec/blather/errors/stanza_error_spec.rb +1 -1
- data/spec/blather/errors/stream_error_spec.rb +1 -1
- data/spec/blather/errors_spec.rb +1 -1
- data/spec/blather/file_transfer_spec.rb +100 -0
- data/spec/blather/jid_spec.rb +1 -1
- data/spec/blather/roster_item_spec.rb +32 -2
- data/spec/blather/roster_spec.rb +1 -1
- data/spec/blather/stanza/discos/disco_info_spec.rb +12 -3
- data/spec/blather/stanza/discos/disco_items_spec.rb +1 -1
- data/spec/blather/stanza/iq/command_spec.rb +1 -1
- data/spec/blather/stanza/iq/ibb_spec.rb +136 -0
- data/spec/blather/stanza/iq/query_spec.rb +1 -1
- data/spec/blather/stanza/iq/roster_spec.rb +1 -1
- data/spec/blather/stanza/iq/s5b_spec.rb +60 -0
- data/spec/blather/stanza/iq/si_spec.rb +101 -0
- data/spec/blather/stanza/iq/vcard_spec.rb +96 -0
- data/spec/blather/stanza/iq_spec.rb +1 -1
- data/spec/blather/stanza/message_spec.rb +48 -2
- data/spec/blather/stanza/presence/status_spec.rb +1 -1
- data/spec/blather/stanza/presence/subscription_spec.rb +1 -1
- data/spec/blather/stanza/presence_spec.rb +1 -1
- data/spec/blather/stanza/pubsub/affiliations_spec.rb +2 -2
- data/spec/blather/stanza/pubsub/create_spec.rb +2 -2
- data/spec/blather/stanza/pubsub/event_spec.rb +16 -2
- data/spec/blather/stanza/pubsub/items_spec.rb +2 -2
- data/spec/blather/stanza/pubsub/publish_spec.rb +2 -2
- data/spec/blather/stanza/pubsub/retract_spec.rb +2 -2
- data/spec/blather/stanza/pubsub/subscribe_spec.rb +2 -2
- data/spec/blather/stanza/pubsub/subscription_spec.rb +2 -2
- data/spec/blather/stanza/pubsub/subscriptions_spec.rb +3 -3
- data/spec/blather/stanza/pubsub/unsubscribe_spec.rb +15 -2
- data/spec/blather/stanza/pubsub_owner/delete_spec.rb +2 -2
- data/spec/blather/stanza/pubsub_owner/purge_spec.rb +2 -2
- data/spec/blather/stanza/pubsub_owner_spec.rb +2 -2
- data/spec/blather/stanza/pubsub_spec.rb +14 -2
- data/spec/blather/stanza/x_spec.rb +1 -1
- data/spec/blather/stanza_spec.rb +1 -1
- data/spec/blather/stream/client_spec.rb +1 -1
- data/spec/blather/stream/component_spec.rb +1 -1
- data/spec/blather/stream/parser_spec.rb +11 -1
- data/spec/blather/xmpp_node_spec.rb +1 -1
- data/spec/fixtures/pubsub.rb +2 -2
- data/spec/spec_helper.rb +27 -0
- metadata +85 -23
@@ -0,0 +1,60 @@
|
|
1
|
+
require File.expand_path "../../../../spec_helper", __FILE__
|
2
|
+
|
3
|
+
def s5b_open_xml
|
4
|
+
<<-XML
|
5
|
+
<iq from='requester@example.com/foo'
|
6
|
+
id='hu3vax16'
|
7
|
+
to='target@example.org/bar'
|
8
|
+
type='set'>
|
9
|
+
<query xmlns='http://jabber.org/protocol/bytestreams'
|
10
|
+
sid='vxf9n471bn46'>
|
11
|
+
<streamhost
|
12
|
+
jid='requester@example.com/foo'
|
13
|
+
host='192.168.4.1'
|
14
|
+
port='5086'/>
|
15
|
+
<streamhost
|
16
|
+
jid='requester2@example.com/foo'
|
17
|
+
host='192.168.4.2'
|
18
|
+
port='5087'/>
|
19
|
+
</query>
|
20
|
+
</iq>
|
21
|
+
XML
|
22
|
+
end
|
23
|
+
|
24
|
+
describe Blather::Stanza::Iq::S5b do
|
25
|
+
it 'registers itself' do
|
26
|
+
Blather::XMPPNode.class_from_registration(:query, 'http://jabber.org/protocol/bytestreams').must_equal Blather::Stanza::Iq::S5b
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'can be imported' do
|
30
|
+
doc = parse_stanza s5b_open_xml
|
31
|
+
node = Blather::XMPPNode.import(doc.root)
|
32
|
+
node.must_be_instance_of Blather::Stanza::Iq::S5b
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'can get sid' do
|
36
|
+
doc = parse_stanza s5b_open_xml
|
37
|
+
node = Blather::XMPPNode.import(doc.root)
|
38
|
+
node.sid.must_equal 'vxf9n471bn46'
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'can get streamhosts' do
|
42
|
+
doc = parse_stanza s5b_open_xml
|
43
|
+
node = Blather::XMPPNode.import(doc.root)
|
44
|
+
node.streamhosts.size.must_equal 2
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'can set streamhosts' do
|
48
|
+
node = Blather::Stanza::Iq::S5b.new
|
49
|
+
node.streamhosts += [{:jid => 'test@example.com/foo', :host => '192.168.5.1', :port => 123}]
|
50
|
+
node.streamhosts.size.must_equal 1
|
51
|
+
node.streamhosts += [Blather::Stanza::Iq::S5b::StreamHost.new('test2@example.com/foo', '192.168.5.2', 123)]
|
52
|
+
node.streamhosts.size.must_equal 2
|
53
|
+
end
|
54
|
+
|
55
|
+
it 'can get and set streamhost-used' do
|
56
|
+
node = Blather::Stanza::Iq::S5b.new
|
57
|
+
node.streamhost_used = 'used@example.com/foo'
|
58
|
+
node.streamhost_used.jid.to_s.must_equal 'used@example.com/foo'
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,101 @@
|
|
1
|
+
require File.expand_path "../../../../spec_helper", __FILE__
|
2
|
+
|
3
|
+
def si_xml
|
4
|
+
<<-XML
|
5
|
+
<iq type='set' id='offer1' to='juliet@capulet.com/balcony' from='romeo@montague.net/orchard'>
|
6
|
+
<si xmlns='http://jabber.org/protocol/si'
|
7
|
+
id='a0'
|
8
|
+
mime-type='text/plain'
|
9
|
+
profile='http://jabber.org/protocol/si/profile/file-transfer'>
|
10
|
+
<file xmlns='http://jabber.org/protocol/si/profile/file-transfer'
|
11
|
+
name='test.txt'
|
12
|
+
size='1022'>
|
13
|
+
<range/>
|
14
|
+
</file>
|
15
|
+
<feature xmlns='http://jabber.org/protocol/feature-neg'>
|
16
|
+
<x xmlns='jabber:x:data' type='form'>
|
17
|
+
<field var='stream-method' type='list-single'>
|
18
|
+
<option><value>http://jabber.org/protocol/bytestreams</value></option>
|
19
|
+
<option><value>http://jabber.org/protocol/ibb</value></option>
|
20
|
+
</field>
|
21
|
+
</x>
|
22
|
+
</feature>
|
23
|
+
</si>
|
24
|
+
</iq>
|
25
|
+
XML
|
26
|
+
end
|
27
|
+
|
28
|
+
describe Blather::Stanza::Iq::Si do
|
29
|
+
it 'registers itself' do
|
30
|
+
Blather::XMPPNode.class_from_registration(:si, 'http://jabber.org/protocol/si').must_equal Blather::Stanza::Iq::Si
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'can be imported' do
|
34
|
+
doc = parse_stanza si_xml
|
35
|
+
node = Blather::XMPPNode.import(doc.root)
|
36
|
+
node.must_be_instance_of Blather::Stanza::Iq::Si
|
37
|
+
node.si.must_be_instance_of Blather::Stanza::Iq::Si::Si
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'ensures a si node is present on create' do
|
41
|
+
iq = Blather::Stanza::Iq::Si.new
|
42
|
+
iq.xpath('ns:si', :ns => 'http://jabber.org/protocol/si').wont_be_empty
|
43
|
+
end
|
44
|
+
|
45
|
+
it 'ensures a si node exists when calling #si' do
|
46
|
+
iq = Blather::Stanza::Iq::Si.new
|
47
|
+
iq.si.remove
|
48
|
+
iq.xpath('ns:si', :ns => 'http://jabber.org/protocol/si').must_be_empty
|
49
|
+
|
50
|
+
iq.si.wont_be_nil
|
51
|
+
iq.xpath('ns:si', :ns => 'http://jabber.org/protocol/si').wont_be_empty
|
52
|
+
end
|
53
|
+
|
54
|
+
it 'ensures a si node is replaced when calling #si=' do
|
55
|
+
doc = parse_stanza si_xml
|
56
|
+
iq = Blather::XMPPNode.import(doc.root)
|
57
|
+
|
58
|
+
new_si = Blather::Stanza::Iq::Si::Si.new
|
59
|
+
new_si.id = 'a1'
|
60
|
+
|
61
|
+
iq.si = new_si
|
62
|
+
|
63
|
+
iq.xpath('ns:si', :ns => 'http://jabber.org/protocol/si').size.must_equal 1
|
64
|
+
iq.si.id.must_equal 'a1'
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
describe Blather::Stanza::Iq::Si::Si do
|
69
|
+
it 'can set and get attributes' do
|
70
|
+
si = Blather::Stanza::Iq::Si::Si.new
|
71
|
+
si.id = 'a1'
|
72
|
+
si.mime_type = 'text/plain'
|
73
|
+
si.profile = 'http://jabber.org/protocol/si/profile/file-transfer'
|
74
|
+
si.id.must_equal 'a1'
|
75
|
+
si.mime_type.must_equal 'text/plain'
|
76
|
+
si.profile.must_equal 'http://jabber.org/protocol/si/profile/file-transfer'
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
describe Blather::Stanza::Iq::Si::Si::File do
|
81
|
+
it 'can be initialized with name and size' do
|
82
|
+
file = Blather::Stanza::Iq::Si::Si::File.new('test.txt', 123)
|
83
|
+
file.name.must_equal 'test.txt'
|
84
|
+
file.size.must_equal 123
|
85
|
+
end
|
86
|
+
|
87
|
+
it 'can be initialized with node' do
|
88
|
+
doc = parse_stanza si_xml
|
89
|
+
node = Blather::XMPPNode.import(doc.root)
|
90
|
+
|
91
|
+
file = Blather::Stanza::Iq::Si::Si::File.new node.find_first('.//ns:file', :ns => 'http://jabber.org/protocol/si/profile/file-transfer')
|
92
|
+
file.name.must_equal 'test.txt'
|
93
|
+
file.size.must_equal 1022
|
94
|
+
end
|
95
|
+
|
96
|
+
it 'can set and get description' do
|
97
|
+
file = Blather::Stanza::Iq::Si::Si::File.new('test.txt', 123)
|
98
|
+
file.desc = 'This is a test. If this were a real file...'
|
99
|
+
file.desc.must_equal 'This is a test. If this were a real file...'
|
100
|
+
end
|
101
|
+
end
|
@@ -0,0 +1,96 @@
|
|
1
|
+
require File.expand_path "../../../../spec_helper", __FILE__
|
2
|
+
|
3
|
+
def vcard_xml
|
4
|
+
<<-XML
|
5
|
+
<iq type="result" id="blather0007" to="romeo@example.net">
|
6
|
+
<vCard xmlns="vcard-temp">
|
7
|
+
<NICKNAME>Romeo</NICKNAME>
|
8
|
+
</vCard>
|
9
|
+
</iq>
|
10
|
+
XML
|
11
|
+
end
|
12
|
+
|
13
|
+
describe Blather::Stanza::Iq::Vcard do
|
14
|
+
it 'registers itself' do
|
15
|
+
Blather::XMPPNode.class_from_registration(:vCard, 'vcard-temp').must_equal Blather::Stanza::Iq::Vcard
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'can be imported' do
|
19
|
+
doc = parse_stanza vcard_xml
|
20
|
+
query = Blather::XMPPNode.import(doc.root)
|
21
|
+
query.must_be_instance_of Blather::Stanza::Iq::Vcard
|
22
|
+
query.vcard.must_be_instance_of Blather::Stanza::Iq::Vcard::Vcard
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'ensures a vcard node is present on create' do
|
26
|
+
query = Blather::Stanza::Iq::Vcard.new
|
27
|
+
query.xpath('ns:vCard', :ns => 'vcard-temp').wont_be_empty
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'ensures a vcard node exists when calling #vcard' do
|
31
|
+
query = Blather::Stanza::Iq::Vcard.new
|
32
|
+
query.vcard.remove
|
33
|
+
query.xpath('ns:vCard', :ns => 'vcard-temp').must_be_empty
|
34
|
+
|
35
|
+
query.vcard.wont_be_nil
|
36
|
+
query.xpath('ns:vCard', :ns => 'vcard-temp').wont_be_empty
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'ensures a vcard node is replaced when calling #vcard=' do
|
40
|
+
doc = parse_stanza vcard_xml
|
41
|
+
query = Blather::XMPPNode.import(doc.root)
|
42
|
+
|
43
|
+
new_vcard = Blather::Stanza::Iq::Vcard::Vcard.new
|
44
|
+
new_vcard["NICKNAME"] = 'Mercutio'
|
45
|
+
|
46
|
+
query.vcard = new_vcard
|
47
|
+
|
48
|
+
query.xpath('ns:vCard', :ns => 'vcard-temp').size.must_equal 1
|
49
|
+
query.find_first('ns:vCard/ns:NICKNAME', :ns => 'vcard-temp').content.must_equal 'Mercutio'
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
describe Blather::Stanza::Iq::Vcard::Vcard do
|
54
|
+
it 'can set vcard elements' do
|
55
|
+
query = Blather::Stanza::Iq::Vcard.new :set
|
56
|
+
query.vcard['NICKNAME'] = 'Romeo'
|
57
|
+
query.find_first('ns:vCard/ns:NICKNAME', :ns => 'vcard-temp').content.must_equal 'Romeo'
|
58
|
+
end
|
59
|
+
|
60
|
+
it 'can set deep vcard elements' do
|
61
|
+
query = Blather::Stanza::Iq::Vcard.new :set
|
62
|
+
query.vcard['PHOTO/TYPE'] = 'image/png'
|
63
|
+
query.vcard['PHOTO/BINVAL'] = '===='
|
64
|
+
query.find_first('ns:vCard/ns:PHOTO', :ns => 'vcard-temp').children.size.must_equal 2
|
65
|
+
query.find_first('ns:vCard/ns:PHOTO', :ns => 'vcard-temp').children.detect { |n| n.element_name == 'TYPE' && n.content == 'image/png' }.wont_be_nil
|
66
|
+
query.find_first('ns:vCard/ns:PHOTO', :ns => 'vcard-temp').children.detect { |n| n.element_name == 'BINVAL' && n.content == '====' }.wont_be_nil
|
67
|
+
end
|
68
|
+
|
69
|
+
it 'can get vcard elements' do
|
70
|
+
query = Blather::Stanza::Iq::Vcard.new :set
|
71
|
+
query.vcard['NICKNAME'] = 'Romeo'
|
72
|
+
query.vcard['NICKNAME'].must_equal 'Romeo'
|
73
|
+
end
|
74
|
+
|
75
|
+
it 'can get deep vcard elements' do
|
76
|
+
query = Blather::Stanza::Iq::Vcard.new :set
|
77
|
+
query.vcard['PHOTO/TYPE'] = 'image/png'
|
78
|
+
query.vcard['PHOTO/BINVAL'] = '===='
|
79
|
+
query.vcard['PHOTO/TYPE'].must_equal 'image/png'
|
80
|
+
query.vcard['PHOTO/BINVAL'].must_equal '===='
|
81
|
+
end
|
82
|
+
|
83
|
+
it 'returns nil on vcard elements which does not exist' do
|
84
|
+
query = Blather::Stanza::Iq::Vcard.new :set
|
85
|
+
query.vcard['NICKNAME'] = 'Romeo'
|
86
|
+
query.vcard['FN'].must_be_nil
|
87
|
+
end
|
88
|
+
|
89
|
+
it 'can update vcard elements' do
|
90
|
+
doc = parse_stanza vcard_xml
|
91
|
+
query = Blather::XMPPNode.import(doc.root)
|
92
|
+
query.vcard['NICKNAME'].must_equal 'Romeo'
|
93
|
+
query.vcard['NICKNAME'] = 'Mercutio'
|
94
|
+
query.vcard['NICKNAME'].must_equal 'Mercutio'
|
95
|
+
end
|
96
|
+
end
|
@@ -1,4 +1,39 @@
|
|
1
|
-
require File.
|
1
|
+
require File.expand_path "../../../spec_helper", __FILE__
|
2
|
+
|
3
|
+
def ichat_message_xml
|
4
|
+
<<-XML
|
5
|
+
<message from="juliet@example.com/balcony" to="romeo@example.net" type="chat" id="iChat_5FA6C6DC">
|
6
|
+
<body>Hello</body>
|
7
|
+
<html xmlns="http://www.w3.org/1999/xhtml">
|
8
|
+
<body style="background-color:#7bb5ee;color:#000000;">
|
9
|
+
<span style="font-family: 'Arial';font-size: 12px;color: #262626;">Hello</span>
|
10
|
+
<img alt="f5ad3a04d218d7160fa02415e02d41b3.jpg" src="message-attachments:1" width="30" height="30"/>
|
11
|
+
</body>
|
12
|
+
</html>
|
13
|
+
|
14
|
+
<x xmlns="http://www.apple.com/xmpp/message-attachments">
|
15
|
+
<attachment id="1">
|
16
|
+
<sipub xmlns="http://jabber.org/protocol/sipub" from="juliet@example.com/balcony" id="sipubid_77933F62" mime-type="binary/octet-stream" profile="http://jabber.org/protocol/si/profile/file-transfer">
|
17
|
+
<file xmlns="http://jabber.org/protocol/si/profile/file-transfer" xmlns:ichat="apple:profile:transfer-extensions" name="f5ad3a04d218d7160fa02415e02d41b3.jpg" size="1245" posixflags="000001A4"/>
|
18
|
+
</sipub>
|
19
|
+
</attachment>
|
20
|
+
</x>
|
21
|
+
|
22
|
+
<iq type="set" id="iChat_4CC32F1F" to="romeo@example.net">
|
23
|
+
<si xmlns="http://jabber.org/protocol/si" id="sid_60C2D273" mime-type="binary/octet-stream" profile="http://jabber.org/protocol/si/profile/file-transfer">
|
24
|
+
<file xmlns="http://jabber.org/protocol/si/profile/file-transfer" xmlns:ichat="apple:profile:transfer-extensions" name="f5ad3a04d218d7160fa02415e02d41b3.jpg" size="1245" posixflags="000001A4"/>
|
25
|
+
<feature xmlns="http://jabber.org/protocol/feature-neg">
|
26
|
+
<x xmlns="jabber:x:data" type="form">
|
27
|
+
<field type="list-single" var="stream-method">
|
28
|
+
<option><value>http://jabber.org/protocol/bytestreams</value></option>
|
29
|
+
</field>
|
30
|
+
</x>
|
31
|
+
</feature>
|
32
|
+
</si>
|
33
|
+
</iq>
|
34
|
+
</message>
|
35
|
+
XML
|
36
|
+
end
|
2
37
|
|
3
38
|
def message_xml
|
4
39
|
<<-XML
|
@@ -11,6 +46,7 @@ def message_xml
|
|
11
46
|
<x xmlns='jabber:x:data' type='form'>
|
12
47
|
<field var='field-name' type='text-single' label='description' />
|
13
48
|
</x>
|
49
|
+
<paused xmlns="http://jabber.org/protocol/chatstates"/>
|
14
50
|
</message>
|
15
51
|
XML
|
16
52
|
end
|
@@ -22,6 +58,7 @@ describe Blather::Stanza::Message do
|
|
22
58
|
|
23
59
|
it 'must be importable' do
|
24
60
|
Blather::XMPPNode.import(parse_stanza(message_xml).root).must_be_instance_of Blather::Stanza::Message
|
61
|
+
Blather::XMPPNode.import(parse_stanza(ichat_message_xml).root).must_be_instance_of Blather::Stanza::Message
|
25
62
|
end
|
26
63
|
|
27
64
|
it 'provides "attr_accessor" for body' do
|
@@ -144,6 +181,11 @@ describe Blather::Stanza::Message do
|
|
144
181
|
msg.xhtml.must_equal(xhtml)
|
145
182
|
end
|
146
183
|
|
184
|
+
it 'finds xhtml body when html wrapper has wrong namespace' do
|
185
|
+
msg = Blather::XMPPNode.import(parse_stanza(ichat_message_xml).root)
|
186
|
+
msg.xhtml.must_equal "<span style=\"font-family: 'Arial';font-size: 12px;color: #262626;\">Hello</span>\n <img alt=\"f5ad3a04d218d7160fa02415e02d41b3.jpg\" src=\"message-attachments:1\" width=\"30\" height=\"30\"></img>"
|
187
|
+
end
|
188
|
+
|
147
189
|
it 'has a chat state setter' do
|
148
190
|
msg = Blather::Stanza::Message.new
|
149
191
|
msg.chat_state = :composing
|
@@ -157,7 +199,7 @@ describe Blather::Stanza::Message do
|
|
157
199
|
|
158
200
|
msg.xpath('ns:*', :ns => Blather::Stanza::Message::CHAT_STATE_NS).size.must_equal(1)
|
159
201
|
end
|
160
|
-
|
202
|
+
|
161
203
|
it 'ensures chat state setter accepts strings' do
|
162
204
|
msg = Blather::Stanza::Message.new
|
163
205
|
msg.chat_state = "gone"
|
@@ -183,6 +225,10 @@ describe Blather::Stanza::Message do
|
|
183
225
|
msg.chat_state.must_equal(:paused)
|
184
226
|
end
|
185
227
|
|
228
|
+
it 'imports correct chat state' do
|
229
|
+
Blather::XMPPNode.import(parse_stanza(message_xml).root).chat_state.must_equal :paused
|
230
|
+
end
|
231
|
+
|
186
232
|
it 'makes a form child available' do
|
187
233
|
n = Blather::XMPPNode.import(parse_stanza(message_xml).root)
|
188
234
|
n.form.fields.size.must_equal 1
|
@@ -1,5 +1,5 @@
|
|
1
|
-
require File.
|
2
|
-
require File.
|
1
|
+
require File.expand_path "../../../../spec_helper", __FILE__
|
2
|
+
require File.expand_path "../../../../fixtures/pubsub", __FILE__
|
3
3
|
|
4
4
|
def control_affiliations
|
5
5
|
{ :owner => ['node1', 'node2'],
|
@@ -1,5 +1,5 @@
|
|
1
|
-
require File.
|
2
|
-
require File.
|
1
|
+
require File.expand_path "../../../../spec_helper", __FILE__
|
2
|
+
require File.expand_path "../../../../fixtures/pubsub", __FILE__
|
3
3
|
|
4
4
|
describe Blather::Stanza::PubSub::Create do
|
5
5
|
it 'registers itself' do
|
@@ -1,5 +1,5 @@
|
|
1
|
-
require File.
|
2
|
-
require File.
|
1
|
+
require File.expand_path "../../../../spec_helper", __FILE__
|
2
|
+
require File.expand_path "../../../../fixtures/pubsub", __FILE__
|
3
3
|
|
4
4
|
describe Blather::Stanza::PubSub::Event do
|
5
5
|
it 'registers itself' do
|
@@ -81,4 +81,18 @@ describe Blather::Stanza::PubSub::Event do
|
|
81
81
|
evt.purge?.wont_be_nil
|
82
82
|
evt.node.must_equal 'princely_musings'
|
83
83
|
end
|
84
|
+
|
85
|
+
it 'can be a subscription notification' do
|
86
|
+
evt = Blather::XMPPNode.import(parse_stanza(<<-NODE).root)
|
87
|
+
<message from='pubsub.shakespeare.lit' to='francisco@denmark.lit' id='foo'>
|
88
|
+
<event xmlns='http://jabber.org/protocol/pubsub#event'>
|
89
|
+
<subscription jid='francisco@denmark.lit' subscription='subscribed' node='/example.com/test'/>
|
90
|
+
</event>
|
91
|
+
</message>
|
92
|
+
NODE
|
93
|
+
evt.subscription?.wont_be_nil
|
94
|
+
evt.subscription[:jid].must_equal 'francisco@denmark.lit'
|
95
|
+
evt.subscription[:subscription].must_equal 'subscribed'
|
96
|
+
evt.subscription[:node].must_equal '/example.com/test'
|
97
|
+
end
|
84
98
|
end
|
@@ -1,5 +1,5 @@
|
|
1
|
-
require File.
|
2
|
-
require File.
|
1
|
+
require File.expand_path "../../../../spec_helper", __FILE__
|
2
|
+
require File.expand_path "../../../../fixtures/pubsub", __FILE__
|
3
3
|
|
4
4
|
describe Blather::Stanza::PubSub::Items do
|
5
5
|
it 'registers itself' do
|
@@ -1,5 +1,5 @@
|
|
1
|
-
require File.
|
2
|
-
require File.
|
1
|
+
require File.expand_path "../../../../spec_helper", __FILE__
|
2
|
+
require File.expand_path "../../../../fixtures/pubsub", __FILE__
|
3
3
|
|
4
4
|
describe Blather::Stanza::PubSub::Publish do
|
5
5
|
it 'registers itself' do
|
@@ -1,5 +1,5 @@
|
|
1
|
-
require File.
|
2
|
-
require File.
|
1
|
+
require File.expand_path "../../../../spec_helper", __FILE__
|
2
|
+
require File.expand_path "../../../../fixtures/pubsub", __FILE__
|
3
3
|
|
4
4
|
describe Blather::Stanza::PubSub::Retract do
|
5
5
|
it 'registers itself' do
|