blather 0.6.2 → 0.7.0
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/.rspec +3 -0
- data/.travis.yml +1 -8
- data/CHANGELOG.md +230 -0
- data/Guardfile +4 -4
- data/README.md +2 -8
- data/Rakefile +14 -27
- data/blather.gemspec +8 -18
- data/lib/blather.rb +1 -0
- data/lib/blather/client/client.rb +8 -0
- data/lib/blather/roster.rb +7 -0
- data/lib/blather/stanza/iq/roster.rb +1 -1
- data/lib/blather/stanza/message/muc_user.rb +2 -0
- data/lib/blather/stanza/muc/muc_user_base.rb +4 -3
- data/lib/blather/stanza/presence.rb +12 -14
- data/lib/blather/stanza/presence/c.rb +58 -62
- data/lib/blather/stanza/presence/muc.rb +14 -10
- data/lib/blather/stanza/presence/muc_user.rb +47 -36
- data/lib/blather/stanza/presence/status.rb +106 -101
- data/lib/blather/stanza/presence/subscription.rb +59 -60
- data/lib/blather/stream.rb +1 -3
- data/lib/blather/stream/features/resource.rb +0 -1
- data/lib/blather/version.rb +1 -2
- data/lib/blather/xmpp_node.rb +24 -3
- data/spec/blather/client/client_spec.rb +64 -64
- data/spec/blather/client/dsl/pubsub_spec.rb +127 -127
- data/spec/blather/client/dsl_spec.rb +11 -11
- data/spec/blather/errors/sasl_error_spec.rb +3 -3
- data/spec/blather/errors/stanza_error_spec.rb +26 -26
- data/spec/blather/errors/stream_error_spec.rb +22 -22
- data/spec/blather/errors_spec.rb +7 -7
- data/spec/blather/file_transfer_spec.rb +16 -18
- data/spec/blather/jid_spec.rb +29 -29
- data/spec/blather/roster_item_spec.rb +18 -18
- data/spec/blather/roster_spec.rb +18 -18
- data/spec/blather/stanza/discos/disco_info_spec.rb +56 -57
- data/spec/blather/stanza/discos/disco_items_spec.rb +33 -33
- data/spec/blather/stanza/iq/command_spec.rb +57 -57
- data/spec/blather/stanza/iq/ibb_spec.rb +27 -39
- data/spec/blather/stanza/iq/ping_spec.rb +13 -9
- data/spec/blather/stanza/iq/query_spec.rb +16 -16
- data/spec/blather/stanza/iq/roster_spec.rb +29 -30
- data/spec/blather/stanza/iq/s5b_spec.rb +10 -13
- data/spec/blather/stanza/iq/si_spec.rb +20 -23
- data/spec/blather/stanza/iq/vcard_spec.rb +22 -25
- data/spec/blather/stanza/iq_spec.rb +12 -12
- data/spec/blather/stanza/message/muc_user_spec.rb +36 -36
- data/spec/blather/stanza/message_spec.rb +56 -56
- data/spec/blather/stanza/presence/c_spec.rb +17 -7
- data/spec/blather/stanza/presence/muc_spec.rb +8 -8
- data/spec/blather/stanza/presence/muc_user_spec.rb +23 -23
- data/spec/blather/stanza/presence/status_spec.rb +42 -30
- data/spec/blather/stanza/presence/subscription_spec.rb +22 -23
- data/spec/blather/stanza/presence_spec.rb +72 -34
- data/spec/blather/stanza/pubsub/affiliations_spec.rb +12 -12
- data/spec/blather/stanza/pubsub/create_spec.rb +10 -10
- data/spec/blather/stanza/pubsub/event_spec.rb +31 -31
- data/spec/blather/stanza/pubsub/items_spec.rb +21 -21
- data/spec/blather/stanza/pubsub/publish_spec.rb +21 -21
- data/spec/blather/stanza/pubsub/retract_spec.rb +20 -20
- data/spec/blather/stanza/pubsub/subscribe_spec.rb +17 -17
- data/spec/blather/stanza/pubsub/subscription_spec.rb +28 -28
- data/spec/blather/stanza/pubsub/subscriptions_spec.rb +11 -11
- data/spec/blather/stanza/pubsub/unsubscribe_spec.rb +22 -22
- data/spec/blather/stanza/pubsub_owner/delete_spec.rb +9 -9
- data/spec/blather/stanza/pubsub_owner/purge_spec.rb +9 -9
- data/spec/blather/stanza/pubsub_owner_spec.rb +6 -6
- data/spec/blather/stanza/pubsub_spec.rb +16 -16
- data/spec/blather/stanza/x_spec.rb +53 -53
- data/spec/blather/stanza_spec.rb +39 -39
- data/spec/blather/stream/client_spec.rb +133 -133
- data/spec/blather/stream/component_spec.rb +7 -7
- data/spec/blather/stream/parser_spec.rb +24 -24
- data/spec/blather/stream/ssl_spec.rb +7 -7
- data/spec/blather/xmpp_node_spec.rb +17 -7
- data/spec/blather_spec.rb +4 -4
- data/spec/spec_helper.rb +6 -54
- metadata +53 -68
- data/CHANGELOG +0 -220
@@ -3,81 +3,81 @@ require 'fixtures/pubsub'
|
|
3
3
|
|
4
4
|
describe Blather::Stanza::PubSub::Publish do
|
5
5
|
it 'registers itself' do
|
6
|
-
Blather::XMPPNode.class_from_registration(:publish, 'http://jabber.org/protocol/pubsub').
|
6
|
+
Blather::XMPPNode.class_from_registration(:publish, 'http://jabber.org/protocol/pubsub').should == Blather::Stanza::PubSub::Publish
|
7
7
|
end
|
8
8
|
|
9
9
|
it 'can be imported' do
|
10
|
-
Blather::XMPPNode.
|
10
|
+
Blather::XMPPNode.parse(publish_xml).should be_instance_of Blather::Stanza::PubSub::Publish
|
11
11
|
end
|
12
12
|
|
13
13
|
it 'ensures an publish node is present on create' do
|
14
14
|
publish = Blather::Stanza::PubSub::Publish.new
|
15
|
-
publish.find('//ns:pubsub/ns:publish', :ns => Blather::Stanza::PubSub.registered_ns).
|
15
|
+
publish.find('//ns:pubsub/ns:publish', :ns => Blather::Stanza::PubSub.registered_ns).should_not be_empty
|
16
16
|
end
|
17
17
|
|
18
18
|
it 'ensures an publish node exists when calling #publish' do
|
19
19
|
publish = Blather::Stanza::PubSub::Publish.new
|
20
20
|
publish.pubsub.remove_children :publish
|
21
|
-
publish.find('//ns:pubsub/ns:publish', :ns => Blather::Stanza::PubSub.registered_ns).
|
21
|
+
publish.find('//ns:pubsub/ns:publish', :ns => Blather::Stanza::PubSub.registered_ns).should be_empty
|
22
22
|
|
23
|
-
publish.publish.
|
24
|
-
publish.find('//ns:pubsub/ns:publish', :ns => Blather::Stanza::PubSub.registered_ns).
|
23
|
+
publish.publish.should_not be_nil
|
24
|
+
publish.find('//ns:pubsub/ns:publish', :ns => Blather::Stanza::PubSub.registered_ns).should_not be_empty
|
25
25
|
end
|
26
26
|
|
27
27
|
it 'defaults to a set node' do
|
28
28
|
publish = Blather::Stanza::PubSub::Publish.new
|
29
|
-
publish.type.
|
29
|
+
publish.type.should == :set
|
30
30
|
end
|
31
31
|
|
32
32
|
it 'sets the host if requested' do
|
33
33
|
publish = Blather::Stanza::PubSub::Publish.new 'pubsub.jabber.local'
|
34
|
-
publish.to.
|
34
|
+
publish.to.should == Blather::JID.new('pubsub.jabber.local')
|
35
35
|
end
|
36
36
|
|
37
37
|
it 'sets the node' do
|
38
38
|
publish = Blather::Stanza::PubSub::Publish.new 'host', 'node-name'
|
39
|
-
publish.node.
|
39
|
+
publish.node.should == 'node-name'
|
40
40
|
end
|
41
41
|
|
42
42
|
it 'will iterate over each item' do
|
43
43
|
publish = Blather::Stanza::PubSub::Publish.new.inherit parse_stanza(publish_xml).root
|
44
44
|
count = 0
|
45
45
|
publish.each do |i|
|
46
|
-
i.
|
46
|
+
i.should be_instance_of Blather::Stanza::PubSub::PubSubItem
|
47
47
|
count += 1
|
48
48
|
end
|
49
|
-
count.
|
49
|
+
count.should == 1
|
50
50
|
end
|
51
51
|
|
52
52
|
it 'has a node attribute' do
|
53
53
|
publish = Blather::Stanza::PubSub::Publish.new
|
54
|
-
publish.
|
55
|
-
publish.node.
|
54
|
+
publish.should respond_to :node
|
55
|
+
publish.node.should be_nil
|
56
56
|
publish.node = 'node-name'
|
57
|
-
publish.node.
|
58
|
-
publish.xpath('//ns:publish[@node="node-name"]', :ns => Blather::Stanza::PubSub.registered_ns).
|
57
|
+
publish.node.should == 'node-name'
|
58
|
+
publish.xpath('//ns:publish[@node="node-name"]', :ns => Blather::Stanza::PubSub.registered_ns).should_not be_empty
|
59
59
|
end
|
60
60
|
|
61
61
|
it 'can set the payload with a hash' do
|
62
62
|
payload = {'id1' => 'payload1', 'id2' => 'payload2'}
|
63
63
|
publish = Blather::Stanza::PubSub::Publish.new
|
64
64
|
publish.payload = payload
|
65
|
-
publish.size.
|
66
|
-
publish.xpath('/iq/ns:pubsub/ns:publish[ns:item[@id="id1" and .="payload1"] and ns:item[@id="id2" and .="payload2"]]', :ns => Blather::Stanza::PubSub.registered_ns).
|
65
|
+
publish.size.should == 2
|
66
|
+
publish.xpath('/iq/ns:pubsub/ns:publish[ns:item[@id="id1" and .="payload1"] and ns:item[@id="id2" and .="payload2"]]', :ns => Blather::Stanza::PubSub.registered_ns).should_not be_empty
|
67
67
|
end
|
68
68
|
|
69
69
|
it 'can set the payload with an array' do
|
70
70
|
payload = %w[payload1 payload2]
|
71
71
|
publish = Blather::Stanza::PubSub::Publish.new
|
72
72
|
publish.payload = payload
|
73
|
-
publish.size.
|
74
|
-
publish.xpath('/iq/ns:pubsub/ns:publish[ns:item[.="payload1"] and ns:item[.="payload2"]]', :ns => Blather::Stanza::PubSub.registered_ns).
|
73
|
+
publish.size.should == 2
|
74
|
+
publish.xpath('/iq/ns:pubsub/ns:publish[ns:item[.="payload1"] and ns:item[.="payload2"]]', :ns => Blather::Stanza::PubSub.registered_ns).should_not be_empty
|
75
75
|
end
|
76
76
|
|
77
77
|
it 'can set the payload with a string' do
|
78
78
|
publish = Blather::Stanza::PubSub::Publish.new
|
79
79
|
publish.payload = 'payload'
|
80
|
-
publish.size.
|
81
|
-
publish.xpath('/iq/ns:pubsub/ns:publish[ns:item[.="payload"]]', :ns => Blather::Stanza::PubSub.registered_ns).
|
80
|
+
publish.size.should == 1
|
81
|
+
publish.xpath('/iq/ns:pubsub/ns:publish[ns:item[.="payload"]]', :ns => Blather::Stanza::PubSub.registered_ns).should_not be_empty
|
82
82
|
end
|
83
83
|
end
|
@@ -3,73 +3,73 @@ require 'fixtures/pubsub'
|
|
3
3
|
|
4
4
|
describe Blather::Stanza::PubSub::Retract do
|
5
5
|
it 'registers itself' do
|
6
|
-
Blather::XMPPNode.class_from_registration(:retract, 'http://jabber.org/protocol/pubsub').
|
6
|
+
Blather::XMPPNode.class_from_registration(:retract, 'http://jabber.org/protocol/pubsub').should == Blather::Stanza::PubSub::Retract
|
7
7
|
end
|
8
8
|
|
9
9
|
it 'can be imported' do
|
10
|
-
Blather::XMPPNode.
|
10
|
+
Blather::XMPPNode.parse(retract_xml).should be_instance_of Blather::Stanza::PubSub::Retract
|
11
11
|
end
|
12
12
|
|
13
13
|
it 'ensures an retract node is present on create' do
|
14
14
|
retract = Blather::Stanza::PubSub::Retract.new
|
15
|
-
retract.find('//ns:pubsub/ns:retract', :ns => Blather::Stanza::PubSub.registered_ns).
|
15
|
+
retract.find('//ns:pubsub/ns:retract', :ns => Blather::Stanza::PubSub.registered_ns).should_not be_empty
|
16
16
|
end
|
17
17
|
|
18
18
|
it 'ensures an retract node exists when calling #retract' do
|
19
19
|
retract = Blather::Stanza::PubSub::Retract.new
|
20
20
|
retract.pubsub.remove_children :retract
|
21
|
-
retract.find('//ns:pubsub/ns:retract', :ns => Blather::Stanza::PubSub.registered_ns).
|
21
|
+
retract.find('//ns:pubsub/ns:retract', :ns => Blather::Stanza::PubSub.registered_ns).should be_empty
|
22
22
|
|
23
|
-
retract.retract.
|
24
|
-
retract.find('//ns:pubsub/ns:retract', :ns => Blather::Stanza::PubSub.registered_ns).
|
23
|
+
retract.retract.should_not be_nil
|
24
|
+
retract.find('//ns:pubsub/ns:retract', :ns => Blather::Stanza::PubSub.registered_ns).should_not be_empty
|
25
25
|
end
|
26
26
|
|
27
27
|
it 'defaults to a set node' do
|
28
28
|
retract = Blather::Stanza::PubSub::Retract.new
|
29
|
-
retract.type.
|
29
|
+
retract.type.should == :set
|
30
30
|
end
|
31
31
|
|
32
32
|
it 'sets the host if requested' do
|
33
33
|
retract = Blather::Stanza::PubSub::Retract.new 'pubsub.jabber.local'
|
34
|
-
retract.to.
|
34
|
+
retract.to.should == Blather::JID.new('pubsub.jabber.local')
|
35
35
|
end
|
36
36
|
|
37
37
|
it 'sets the node' do
|
38
38
|
retract = Blather::Stanza::PubSub::Retract.new 'host', 'node-name'
|
39
|
-
retract.node.
|
39
|
+
retract.node.should == 'node-name'
|
40
40
|
end
|
41
41
|
|
42
42
|
it 'can set the retractions as a string' do
|
43
43
|
retract = Blather::Stanza::PubSub::Retract.new 'host', 'node'
|
44
44
|
retract.retractions = 'id1'
|
45
|
-
retract.xpath('//ns:retract[ns:item[@id="id1"]]', :ns => Blather::Stanza::PubSub.registered_ns).
|
45
|
+
retract.xpath('//ns:retract[ns:item[@id="id1"]]', :ns => Blather::Stanza::PubSub.registered_ns).should_not be_empty
|
46
46
|
end
|
47
47
|
|
48
48
|
it 'can set the retractions as an array' do
|
49
49
|
retract = Blather::Stanza::PubSub::Retract.new 'host', 'node'
|
50
50
|
retract.retractions = %w[id1 id2]
|
51
|
-
retract.xpath('//ns:retract[ns:item[@id="id1"] and ns:item[@id="id2"]]', :ns => Blather::Stanza::PubSub.registered_ns).
|
51
|
+
retract.xpath('//ns:retract[ns:item[@id="id1"] and ns:item[@id="id2"]]', :ns => Blather::Stanza::PubSub.registered_ns).should_not be_empty
|
52
52
|
end
|
53
53
|
|
54
54
|
it 'will iterate over each item' do
|
55
55
|
retract = Blather::Stanza::PubSub::Retract.new.inherit parse_stanza(retract_xml).root
|
56
|
-
retract.retractions.size.
|
57
|
-
retract.size.
|
58
|
-
retract.retractions.
|
56
|
+
retract.retractions.size.should == 1
|
57
|
+
retract.size.should == retract.retractions.size
|
58
|
+
retract.retractions.should == %w[ae890ac52d0df67ed7cfdf51b644e901]
|
59
59
|
end
|
60
60
|
|
61
61
|
it 'has a node attribute' do
|
62
62
|
retract = Blather::Stanza::PubSub::Retract.new
|
63
|
-
retract.
|
64
|
-
retract.node.
|
63
|
+
retract.should respond_to :node
|
64
|
+
retract.node.should be_nil
|
65
65
|
retract.node = 'node-name'
|
66
|
-
retract.node.
|
67
|
-
retract.xpath('//ns:retract[@node="node-name"]', :ns => Blather::Stanza::PubSub.registered_ns).
|
66
|
+
retract.node.should == 'node-name'
|
67
|
+
retract.xpath('//ns:retract[@node="node-name"]', :ns => Blather::Stanza::PubSub.registered_ns).should_not be_empty
|
68
68
|
end
|
69
69
|
|
70
70
|
it 'will iterate over each retraction' do
|
71
|
-
Blather::XMPPNode.
|
72
|
-
i.
|
71
|
+
Blather::XMPPNode.parse(retract_xml).each do |i|
|
72
|
+
i.should include "ae890ac52d0df67ed7cfdf51b644e901"
|
73
73
|
end
|
74
74
|
end
|
75
75
|
end
|
@@ -3,59 +3,59 @@ require 'fixtures/pubsub'
|
|
3
3
|
|
4
4
|
describe Blather::Stanza::PubSub::Subscribe do
|
5
5
|
it 'registers itself' do
|
6
|
-
Blather::XMPPNode.class_from_registration(:subscribe, 'http://jabber.org/protocol/pubsub').
|
6
|
+
Blather::XMPPNode.class_from_registration(:subscribe, 'http://jabber.org/protocol/pubsub').should == Blather::Stanza::PubSub::Subscribe
|
7
7
|
end
|
8
8
|
|
9
9
|
it 'can be imported' do
|
10
|
-
Blather::XMPPNode.
|
10
|
+
Blather::XMPPNode.parse(subscribe_xml).should be_instance_of Blather::Stanza::PubSub::Subscribe
|
11
11
|
end
|
12
12
|
|
13
13
|
it 'ensures an subscribe node is present on create' do
|
14
14
|
subscribe = Blather::Stanza::PubSub::Subscribe.new :set, 'host', 'node', 'jid'
|
15
|
-
subscribe.find('//ns:pubsub/ns:subscribe', :ns => Blather::Stanza::PubSub.registered_ns).
|
15
|
+
subscribe.find('//ns:pubsub/ns:subscribe', :ns => Blather::Stanza::PubSub.registered_ns).should_not be_empty
|
16
16
|
end
|
17
17
|
|
18
18
|
it 'ensures an subscribe node exists when calling #subscribe' do
|
19
19
|
subscribe = Blather::Stanza::PubSub::Subscribe.new :set, 'host', 'node', 'jid'
|
20
20
|
subscribe.pubsub.remove_children :subscribe
|
21
|
-
subscribe.find('//ns:pubsub/ns:subscribe', :ns => Blather::Stanza::PubSub.registered_ns).
|
21
|
+
subscribe.find('//ns:pubsub/ns:subscribe', :ns => Blather::Stanza::PubSub.registered_ns).should be_empty
|
22
22
|
|
23
|
-
subscribe.subscribe.
|
24
|
-
subscribe.find('//ns:pubsub/ns:subscribe', :ns => Blather::Stanza::PubSub.registered_ns).
|
23
|
+
subscribe.subscribe.should_not be_nil
|
24
|
+
subscribe.find('//ns:pubsub/ns:subscribe', :ns => Blather::Stanza::PubSub.registered_ns).should_not be_empty
|
25
25
|
end
|
26
26
|
|
27
27
|
it 'defaults to a set node' do
|
28
28
|
subscribe = Blather::Stanza::PubSub::Subscribe.new :set, 'host', 'node', 'jid'
|
29
|
-
subscribe.type.
|
29
|
+
subscribe.type.should == :set
|
30
30
|
end
|
31
31
|
|
32
32
|
it 'sets the host if requested' do
|
33
33
|
subscribe = Blather::Stanza::PubSub::Subscribe.new :set, 'pubsub.jabber.local', 'node', 'jid'
|
34
|
-
subscribe.to.
|
34
|
+
subscribe.to.should == Blather::JID.new('pubsub.jabber.local')
|
35
35
|
end
|
36
36
|
|
37
37
|
it 'sets the node' do
|
38
38
|
subscribe = Blather::Stanza::PubSub::Subscribe.new :set, 'host', 'node-name', 'jid'
|
39
|
-
subscribe.node.
|
39
|
+
subscribe.node.should == 'node-name'
|
40
40
|
end
|
41
41
|
|
42
42
|
it 'has a node attribute' do
|
43
43
|
subscribe = Blather::Stanza::PubSub::Subscribe.new :set, 'host', 'node-name', 'jid'
|
44
|
-
subscribe.find('//ns:pubsub/ns:subscribe[@node="node-name"]', :ns => Blather::Stanza::PubSub.registered_ns).
|
45
|
-
subscribe.node.
|
44
|
+
subscribe.find('//ns:pubsub/ns:subscribe[@node="node-name"]', :ns => Blather::Stanza::PubSub.registered_ns).should_not be_empty
|
45
|
+
subscribe.node.should == 'node-name'
|
46
46
|
|
47
47
|
subscribe.node = 'new-node'
|
48
|
-
subscribe.find('//ns:pubsub/ns:subscribe[@node="new-node"]', :ns => Blather::Stanza::PubSub.registered_ns).
|
49
|
-
subscribe.node.
|
48
|
+
subscribe.find('//ns:pubsub/ns:subscribe[@node="new-node"]', :ns => Blather::Stanza::PubSub.registered_ns).should_not be_empty
|
49
|
+
subscribe.node.should == 'new-node'
|
50
50
|
end
|
51
51
|
|
52
52
|
it 'has a jid attribute' do
|
53
53
|
subscribe = Blather::Stanza::PubSub::Subscribe.new :set, 'host', 'node-name', 'jid'
|
54
|
-
subscribe.find('//ns:pubsub/ns:subscribe[@jid="jid"]', :ns => Blather::Stanza::PubSub.registered_ns).
|
55
|
-
subscribe.jid.
|
54
|
+
subscribe.find('//ns:pubsub/ns:subscribe[@jid="jid"]', :ns => Blather::Stanza::PubSub.registered_ns).should_not be_empty
|
55
|
+
subscribe.jid.should == Blather::JID.new('jid')
|
56
56
|
|
57
57
|
subscribe.jid = Blather::JID.new('n@d/r')
|
58
|
-
subscribe.find('//ns:pubsub/ns:subscribe[@jid="n@d/r"]', :ns => Blather::Stanza::PubSub.registered_ns).
|
59
|
-
subscribe.jid.
|
58
|
+
subscribe.find('//ns:pubsub/ns:subscribe[@jid="n@d/r"]', :ns => Blather::Stanza::PubSub.registered_ns).should_not be_empty
|
59
|
+
subscribe.jid.should == Blather::JID.new('n@d/r')
|
60
60
|
end
|
61
61
|
end
|
@@ -3,94 +3,94 @@ require 'fixtures/pubsub'
|
|
3
3
|
|
4
4
|
describe Blather::Stanza::PubSub::Subscription do
|
5
5
|
it 'registers itself' do
|
6
|
-
Blather::XMPPNode.class_from_registration(:subscription, 'http://jabber.org/protocol/pubsub').
|
6
|
+
Blather::XMPPNode.class_from_registration(:subscription, 'http://jabber.org/protocol/pubsub').should == Blather::Stanza::PubSub::Subscription
|
7
7
|
end
|
8
8
|
|
9
9
|
it 'can be imported' do
|
10
|
-
Blather::XMPPNode.
|
10
|
+
Blather::XMPPNode.parse(subscription_xml).should be_instance_of Blather::Stanza::PubSub::Subscription
|
11
11
|
end
|
12
12
|
|
13
13
|
it 'ensures an subscription node is present on create' do
|
14
14
|
subscription = Blather::Stanza::PubSub::Subscription.new :set, 'host', 'node', 'jid', 'subid', :none
|
15
|
-
subscription.find('//ns:pubsub/ns:subscription', :ns => Blather::Stanza::PubSub.registered_ns).
|
15
|
+
subscription.find('//ns:pubsub/ns:subscription', :ns => Blather::Stanza::PubSub.registered_ns).should_not be_empty
|
16
16
|
end
|
17
17
|
|
18
18
|
it 'ensures an subscription node exists when calling #subscription_node' do
|
19
19
|
subscription = Blather::Stanza::PubSub::Subscription.new :set, 'host', 'node', 'jid', 'subid', :none
|
20
20
|
subscription.pubsub.remove_children :subscription
|
21
|
-
subscription.find('//ns:pubsub/ns:subscription', :ns => Blather::Stanza::PubSub.registered_ns).
|
21
|
+
subscription.find('//ns:pubsub/ns:subscription', :ns => Blather::Stanza::PubSub.registered_ns).should be_empty
|
22
22
|
|
23
|
-
subscription.subscription_node.
|
24
|
-
subscription.find('//ns:pubsub/ns:subscription', :ns => Blather::Stanza::PubSub.registered_ns).
|
23
|
+
subscription.subscription_node.should_not be_nil
|
24
|
+
subscription.find('//ns:pubsub/ns:subscription', :ns => Blather::Stanza::PubSub.registered_ns).should_not be_empty
|
25
25
|
end
|
26
26
|
|
27
27
|
it 'defaults to a set node' do
|
28
28
|
subscription = Blather::Stanza::PubSub::Subscription.new :set, 'host', 'node', 'jid', 'subid', :none
|
29
|
-
subscription.type.
|
29
|
+
subscription.type.should == :set
|
30
30
|
end
|
31
31
|
|
32
32
|
it 'sets the host if requested' do
|
33
33
|
subscription = Blather::Stanza::PubSub::Subscription.new :set, 'pubsub.jabber.local', 'node', 'jid', 'subid', :none
|
34
|
-
subscription.to.
|
34
|
+
subscription.to.should == Blather::JID.new('pubsub.jabber.local')
|
35
35
|
end
|
36
36
|
|
37
37
|
it 'sets the node' do
|
38
38
|
subscription = Blather::Stanza::PubSub::Subscription.new :set, 'host', 'node-name', 'jid', 'subid', :none
|
39
|
-
subscription.node.
|
39
|
+
subscription.node.should == 'node-name'
|
40
40
|
end
|
41
41
|
|
42
42
|
it 'has a node attribute' do
|
43
43
|
subscription = Blather::Stanza::PubSub::Subscription.new :set, 'host', 'node-name', 'jid', 'subid', :none
|
44
|
-
subscription.find('//ns:pubsub/ns:subscription[@node="node-name"]', :ns => Blather::Stanza::PubSub.registered_ns).
|
45
|
-
subscription.node.
|
44
|
+
subscription.find('//ns:pubsub/ns:subscription[@node="node-name"]', :ns => Blather::Stanza::PubSub.registered_ns).should_not be_empty
|
45
|
+
subscription.node.should == 'node-name'
|
46
46
|
|
47
47
|
subscription.node = 'new-node'
|
48
|
-
subscription.find('//ns:pubsub/ns:subscription[@node="new-node"]', :ns => Blather::Stanza::PubSub.registered_ns).
|
49
|
-
subscription.node.
|
48
|
+
subscription.find('//ns:pubsub/ns:subscription[@node="new-node"]', :ns => Blather::Stanza::PubSub.registered_ns).should_not be_empty
|
49
|
+
subscription.node.should == 'new-node'
|
50
50
|
end
|
51
51
|
|
52
52
|
it 'has a jid attribute' do
|
53
53
|
subscription = Blather::Stanza::PubSub::Subscription.new :set, 'host', 'node-name', 'jid', 'subid', :none
|
54
|
-
subscription.find('//ns:pubsub/ns:subscription[@jid="jid"]', :ns => Blather::Stanza::PubSub.registered_ns).
|
55
|
-
subscription.jid.
|
54
|
+
subscription.find('//ns:pubsub/ns:subscription[@jid="jid"]', :ns => Blather::Stanza::PubSub.registered_ns).should_not be_empty
|
55
|
+
subscription.jid.should == Blather::JID.new('jid')
|
56
56
|
|
57
57
|
subscription.jid = Blather::JID.new('n@d/r')
|
58
|
-
subscription.find('//ns:pubsub/ns:subscription[@jid="n@d/r"]', :ns => Blather::Stanza::PubSub.registered_ns).
|
59
|
-
subscription.jid.
|
58
|
+
subscription.find('//ns:pubsub/ns:subscription[@jid="n@d/r"]', :ns => Blather::Stanza::PubSub.registered_ns).should_not be_empty
|
59
|
+
subscription.jid.should == Blather::JID.new('n@d/r')
|
60
60
|
end
|
61
61
|
|
62
62
|
it 'has a subid attribute' do
|
63
63
|
subscription = Blather::Stanza::PubSub::Subscription.new :set, 'host', 'node-name', 'jid', 'subid', :none
|
64
|
-
subscription.find('//ns:pubsub/ns:subscription[@subid="subid"]', :ns => Blather::Stanza::PubSub.registered_ns).
|
65
|
-
subscription.subid.
|
64
|
+
subscription.find('//ns:pubsub/ns:subscription[@subid="subid"]', :ns => Blather::Stanza::PubSub.registered_ns).should_not be_empty
|
65
|
+
subscription.subid.should == 'subid'
|
66
66
|
|
67
67
|
subscription.subid = 'new-subid'
|
68
|
-
subscription.find('//ns:pubsub/ns:subscription[@subid="new-subid"]', :ns => Blather::Stanza::PubSub.registered_ns).
|
69
|
-
subscription.subid.
|
68
|
+
subscription.find('//ns:pubsub/ns:subscription[@subid="new-subid"]', :ns => Blather::Stanza::PubSub.registered_ns).should_not be_empty
|
69
|
+
subscription.subid.should == 'new-subid'
|
70
70
|
end
|
71
71
|
|
72
72
|
it 'has a subscription attribute' do
|
73
73
|
subscription = Blather::Stanza::PubSub::Subscription.new :set, 'host', 'node-name', 'jid', 'subid', :none
|
74
|
-
subscription.find('//ns:pubsub/ns:subscription[@subscription="none"]', :ns => Blather::Stanza::PubSub.registered_ns).
|
75
|
-
subscription.subscription.
|
74
|
+
subscription.find('//ns:pubsub/ns:subscription[@subscription="none"]', :ns => Blather::Stanza::PubSub.registered_ns).should_not be_empty
|
75
|
+
subscription.subscription.should == :none
|
76
76
|
|
77
77
|
subscription.subscription = :pending
|
78
|
-
subscription.find('//ns:pubsub/ns:subscription[@subscription="pending"]', :ns => Blather::Stanza::PubSub.registered_ns).
|
79
|
-
subscription.subscription.
|
78
|
+
subscription.find('//ns:pubsub/ns:subscription[@subscription="pending"]', :ns => Blather::Stanza::PubSub.registered_ns).should_not be_empty
|
79
|
+
subscription.subscription.should == :pending
|
80
80
|
end
|
81
81
|
|
82
82
|
it 'ensures subscription is one of Stanza::PubSub::Subscription::VALID_TYPES' do
|
83
|
-
lambda { Blather::Stanza::PubSub::Subscription.new :set, 'host', 'node-name', 'jid', 'subid', :invalid_type_name }.
|
83
|
+
lambda { Blather::Stanza::PubSub::Subscription.new :set, 'host', 'node-name', 'jid', 'subid', :invalid_type_name }.should raise_error(Blather::ArgumentError)
|
84
84
|
|
85
85
|
Blather::Stanza::PubSub::Subscription::VALID_TYPES.each do |valid_type|
|
86
86
|
n = Blather::Stanza::PubSub::Subscription.new :set, 'host', 'node-name', 'jid', 'subid', valid_type
|
87
|
-
n.subscription.
|
87
|
+
n.subscription.should == valid_type
|
88
88
|
end
|
89
89
|
end
|
90
90
|
|
91
91
|
Blather::Stanza::PubSub::Subscription::VALID_TYPES.each do |valid_type|
|
92
92
|
it "provides a helper (#{valid_type}?) for type #{valid_type}" do
|
93
|
-
Blather::Stanza::PubSub::Subscription.new.
|
93
|
+
Blather::Stanza::PubSub::Subscription.new.should respond_to :"#{valid_type}?"
|
94
94
|
end
|
95
95
|
end
|
96
96
|
|
@@ -10,50 +10,50 @@ end
|
|
10
10
|
|
11
11
|
describe Blather::Stanza::PubSub::Subscriptions do
|
12
12
|
it 'registers itself' do
|
13
|
-
Blather::XMPPNode.class_from_registration(:subscriptions, 'http://jabber.org/protocol/pubsub').
|
13
|
+
Blather::XMPPNode.class_from_registration(:subscriptions, 'http://jabber.org/protocol/pubsub').should == Blather::Stanza::PubSub::Subscriptions
|
14
14
|
end
|
15
15
|
|
16
16
|
it 'can be imported' do
|
17
|
-
Blather::XMPPNode.
|
17
|
+
Blather::XMPPNode.parse(subscriptions_xml).should be_instance_of Blather::Stanza::PubSub::Subscriptions
|
18
18
|
end
|
19
19
|
|
20
20
|
it 'ensures an subscriptions node is present on create' do
|
21
21
|
subscriptions = Blather::Stanza::PubSub::Subscriptions.new
|
22
|
-
subscriptions.find('//ns:pubsub/ns:subscriptions', :ns => Blather::Stanza::PubSub.registered_ns).
|
22
|
+
subscriptions.find('//ns:pubsub/ns:subscriptions', :ns => Blather::Stanza::PubSub.registered_ns).should_not be_empty
|
23
23
|
end
|
24
24
|
|
25
25
|
it 'ensures an subscriptions node exists when calling #subscriptions' do
|
26
26
|
subscriptions = Blather::Stanza::PubSub::Subscriptions.new
|
27
27
|
subscriptions.pubsub.remove_children :subscriptions
|
28
|
-
subscriptions.find('//ns:pubsub/ns:subscriptions', :ns => Blather::Stanza::PubSub.registered_ns).
|
28
|
+
subscriptions.find('//ns:pubsub/ns:subscriptions', :ns => Blather::Stanza::PubSub.registered_ns).should be_empty
|
29
29
|
|
30
|
-
subscriptions.subscriptions.
|
31
|
-
subscriptions.find('//ns:pubsub/ns:subscriptions', :ns => Blather::Stanza::PubSub.registered_ns).
|
30
|
+
subscriptions.subscriptions.should_not be_nil
|
31
|
+
subscriptions.find('//ns:pubsub/ns:subscriptions', :ns => Blather::Stanza::PubSub.registered_ns).should_not be_empty
|
32
32
|
end
|
33
33
|
|
34
34
|
it 'defaults to a get node' do
|
35
35
|
aff = Blather::Stanza::PubSub::Subscriptions.new
|
36
|
-
aff.type.
|
36
|
+
aff.type.should == :get
|
37
37
|
end
|
38
38
|
|
39
39
|
it 'sets the host if requested' do
|
40
40
|
aff = Blather::Stanza::PubSub::Subscriptions.new :get, 'pubsub.jabber.local'
|
41
|
-
aff.to.
|
41
|
+
aff.to.should == Blather::JID.new('pubsub.jabber.local')
|
42
42
|
end
|
43
43
|
|
44
44
|
it 'can import a subscriptions result node' do
|
45
45
|
node = parse_stanza(subscriptions_xml).root
|
46
46
|
|
47
47
|
subscriptions = Blather::Stanza::PubSub::Subscriptions.new.inherit node
|
48
|
-
subscriptions.size.
|
49
|
-
subscriptions.list.
|
48
|
+
subscriptions.size.should == 4
|
49
|
+
subscriptions.list.should == control_subscriptions
|
50
50
|
end
|
51
51
|
|
52
52
|
it 'will iterate over each subscription' do
|
53
53
|
node = parse_stanza(subscriptions_xml).root
|
54
54
|
subscriptions = Blather::Stanza::PubSub::Subscriptions.new.inherit node
|
55
55
|
subscriptions.each do |type, nodes|
|
56
|
-
nodes.
|
56
|
+
nodes.should == control_subscriptions[type]
|
57
57
|
end
|
58
58
|
end
|
59
59
|
end
|