blather 1.2.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.travis.yml +7 -7
- data/CHANGELOG.md +8 -0
- data/blather.gemspec +6 -6
- data/lib/blather.rb +1 -1
- data/lib/blather/client/client.rb +30 -6
- data/lib/blather/version.rb +1 -1
- data/spec/blather/client/client_spec.rb +73 -68
- data/spec/blather/client/dsl/pubsub_spec.rb +121 -121
- data/spec/blather/client/dsl_spec.rb +9 -9
- 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 +9 -9
- 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 -56
- data/spec/blather/stanza/discos/disco_items_spec.rb +33 -33
- data/spec/blather/stanza/iq/command_spec.rb +51 -51
- data/spec/blather/stanza/iq/ibb_spec.rb +15 -15
- data/spec/blather/stanza/iq/ping_spec.rb +8 -8
- data/spec/blather/stanza/iq/query_spec.rb +15 -15
- data/spec/blather/stanza/iq/roster_spec.rb +29 -29
- data/spec/blather/stanza/iq/s5b_spec.rb +7 -7
- data/spec/blather/stanza/iq/si_spec.rb +17 -17
- data/spec/blather/stanza/iq/vcard_spec.rb +19 -19
- data/spec/blather/stanza/iq_spec.rb +11 -11
- data/spec/blather/stanza/message/muc_user_spec.rb +32 -32
- data/spec/blather/stanza/message_spec.rb +53 -54
- data/spec/blather/stanza/presence/c_spec.rb +11 -11
- data/spec/blather/stanza/presence/muc_spec.rb +7 -7
- data/spec/blather/stanza/presence/muc_user_spec.rb +22 -22
- data/spec/blather/stanza/presence/status_spec.rb +33 -33
- data/spec/blather/stanza/presence/subscription_spec.rb +22 -22
- data/spec/blather/stanza/presence_spec.rb +30 -30
- data/spec/blather/stanza/pubsub/affiliations_spec.rb +11 -11
- data/spec/blather/stanza/pubsub/create_spec.rb +10 -10
- data/spec/blather/stanza/pubsub/event_spec.rb +24 -24
- data/spec/blather/stanza/pubsub/items_spec.rb +20 -20
- data/spec/blather/stanza/pubsub/publish_spec.rb +21 -21
- data/spec/blather/stanza/pubsub/retract_spec.rb +19 -19
- 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 +13 -13
- 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 +15 -15
- data/spec/blather/stanza/x_spec.rb +53 -53
- data/spec/blather/stanza_spec.rb +39 -39
- data/spec/blather/stream/client_spec.rb +160 -160
- data/spec/blather/stream/component_spec.rb +8 -10
- data/spec/blather/stream/parser_spec.rb +25 -25
- data/spec/blather/stream/ssl_spec.rb +3 -3
- data/spec/blather/xmpp_node_spec.rb +9 -9
- data/spec/blather_spec.rb +1 -1
- data/spec/spec_helper.rb +1 -1
- metadata +26 -27
@@ -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
|
+
expect(Blather::XMPPNode.class_from_registration(:publish, 'http://jabber.org/protocol/pubsub')).to eq(Blather::Stanza::PubSub::Publish)
|
7
7
|
end
|
8
8
|
|
9
9
|
it 'can be imported' do
|
10
|
-
Blather::XMPPNode.parse(publish_xml).
|
10
|
+
expect(Blather::XMPPNode.parse(publish_xml)).to 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
|
+
expect(publish.find('//ns:pubsub/ns:publish', :ns => Blather::Stanza::PubSub.registered_ns)).not_to 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
|
+
expect(publish.find('//ns:pubsub/ns:publish', :ns => Blather::Stanza::PubSub.registered_ns)).to be_empty
|
22
22
|
|
23
|
-
publish.publish.
|
24
|
-
publish.find('//ns:pubsub/ns:publish', :ns => Blather::Stanza::PubSub.registered_ns).
|
23
|
+
expect(publish.publish).not_to be_nil
|
24
|
+
expect(publish.find('//ns:pubsub/ns:publish', :ns => Blather::Stanza::PubSub.registered_ns)).not_to 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
|
+
expect(publish.type).to eq(: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
|
+
expect(publish.to).to eq(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
|
+
expect(publish.node).to eq('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
|
+
expect(i).to be_instance_of Blather::Stanza::PubSub::PubSubItem
|
47
47
|
count += 1
|
48
48
|
end
|
49
|
-
count.
|
49
|
+
expect(count).to eq(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
|
+
expect(publish).to respond_to :node
|
55
|
+
expect(publish.node).to 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
|
+
expect(publish.node).to eq('node-name')
|
58
|
+
expect(publish.xpath('//ns:publish[@node="node-name"]', :ns => Blather::Stanza::PubSub.registered_ns)).not_to 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
|
+
expect(publish.size).to eq(2)
|
66
|
+
expect(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)).not_to 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
|
+
expect(publish.size).to eq(2)
|
74
|
+
expect(publish.xpath('/iq/ns:pubsub/ns:publish[ns:item[.="payload1"] and ns:item[.="payload2"]]', :ns => Blather::Stanza::PubSub.registered_ns)).not_to 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
|
+
expect(publish.size).to eq(1)
|
81
|
+
expect(publish.xpath('/iq/ns:pubsub/ns:publish[ns:item[.="payload"]]', :ns => Blather::Stanza::PubSub.registered_ns)).not_to 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
|
+
expect(Blather::XMPPNode.class_from_registration(:retract, 'http://jabber.org/protocol/pubsub')).to eq(Blather::Stanza::PubSub::Retract)
|
7
7
|
end
|
8
8
|
|
9
9
|
it 'can be imported' do
|
10
|
-
Blather::XMPPNode.parse(retract_xml).
|
10
|
+
expect(Blather::XMPPNode.parse(retract_xml)).to 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
|
+
expect(retract.find('//ns:pubsub/ns:retract', :ns => Blather::Stanza::PubSub.registered_ns)).not_to 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
|
+
expect(retract.find('//ns:pubsub/ns:retract', :ns => Blather::Stanza::PubSub.registered_ns)).to be_empty
|
22
22
|
|
23
|
-
retract.retract.
|
24
|
-
retract.find('//ns:pubsub/ns:retract', :ns => Blather::Stanza::PubSub.registered_ns).
|
23
|
+
expect(retract.retract).not_to be_nil
|
24
|
+
expect(retract.find('//ns:pubsub/ns:retract', :ns => Blather::Stanza::PubSub.registered_ns)).not_to 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
|
+
expect(retract.type).to eq(: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
|
+
expect(retract.to).to eq(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
|
+
expect(retract.node).to eq('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
|
+
expect(retract.xpath('//ns:retract[ns:item[@id="id1"]]', :ns => Blather::Stanza::PubSub.registered_ns)).not_to 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
|
+
expect(retract.xpath('//ns:retract[ns:item[@id="id1"] and ns:item[@id="id2"]]', :ns => Blather::Stanza::PubSub.registered_ns)).not_to 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
|
+
expect(retract.retractions.size).to eq(1)
|
57
|
+
expect(retract.size).to eq(retract.retractions.size)
|
58
|
+
expect(retract.retractions).to eq(%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
|
+
expect(retract).to respond_to :node
|
64
|
+
expect(retract.node).to 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
|
+
expect(retract.node).to eq('node-name')
|
67
|
+
expect(retract.xpath('//ns:retract[@node="node-name"]', :ns => Blather::Stanza::PubSub.registered_ns)).not_to be_empty
|
68
68
|
end
|
69
69
|
|
70
70
|
it 'will iterate over each retraction' do
|
71
71
|
Blather::XMPPNode.parse(retract_xml).each do |i|
|
72
|
-
i.
|
72
|
+
expect(i).to 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
|
+
expect(Blather::XMPPNode.class_from_registration(:subscribe, 'http://jabber.org/protocol/pubsub')).to eq(Blather::Stanza::PubSub::Subscribe)
|
7
7
|
end
|
8
8
|
|
9
9
|
it 'can be imported' do
|
10
|
-
Blather::XMPPNode.parse(subscribe_xml).
|
10
|
+
expect(Blather::XMPPNode.parse(subscribe_xml)).to 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
|
+
expect(subscribe.find('//ns:pubsub/ns:subscribe', :ns => Blather::Stanza::PubSub.registered_ns)).not_to 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
|
+
expect(subscribe.find('//ns:pubsub/ns:subscribe', :ns => Blather::Stanza::PubSub.registered_ns)).to be_empty
|
22
22
|
|
23
|
-
subscribe.subscribe.
|
24
|
-
subscribe.find('//ns:pubsub/ns:subscribe', :ns => Blather::Stanza::PubSub.registered_ns).
|
23
|
+
expect(subscribe.subscribe).not_to be_nil
|
24
|
+
expect(subscribe.find('//ns:pubsub/ns:subscribe', :ns => Blather::Stanza::PubSub.registered_ns)).not_to 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
|
+
expect(subscribe.type).to eq(: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
|
+
expect(subscribe.to).to eq(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
|
+
expect(subscribe.node).to eq('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
|
+
expect(subscribe.find('//ns:pubsub/ns:subscribe[@node="node-name"]', :ns => Blather::Stanza::PubSub.registered_ns)).not_to be_empty
|
45
|
+
expect(subscribe.node).to eq('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
|
+
expect(subscribe.find('//ns:pubsub/ns:subscribe[@node="new-node"]', :ns => Blather::Stanza::PubSub.registered_ns)).not_to be_empty
|
49
|
+
expect(subscribe.node).to eq('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
|
+
expect(subscribe.find('//ns:pubsub/ns:subscribe[@jid="jid"]', :ns => Blather::Stanza::PubSub.registered_ns)).not_to be_empty
|
55
|
+
expect(subscribe.jid).to eq(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
|
+
expect(subscribe.find('//ns:pubsub/ns:subscribe[@jid="n@d/r"]', :ns => Blather::Stanza::PubSub.registered_ns)).not_to be_empty
|
59
|
+
expect(subscribe.jid).to eq(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
|
+
expect(Blather::XMPPNode.class_from_registration(:subscription, 'http://jabber.org/protocol/pubsub')).to eq(Blather::Stanza::PubSub::Subscription)
|
7
7
|
end
|
8
8
|
|
9
9
|
it 'can be imported' do
|
10
|
-
Blather::XMPPNode.parse(subscription_xml).
|
10
|
+
expect(Blather::XMPPNode.parse(subscription_xml)).to 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
|
+
expect(subscription.find('//ns:pubsub/ns:subscription', :ns => Blather::Stanza::PubSub.registered_ns)).not_to 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
|
+
expect(subscription.find('//ns:pubsub/ns:subscription', :ns => Blather::Stanza::PubSub.registered_ns)).to be_empty
|
22
22
|
|
23
|
-
subscription.subscription_node.
|
24
|
-
subscription.find('//ns:pubsub/ns:subscription', :ns => Blather::Stanza::PubSub.registered_ns).
|
23
|
+
expect(subscription.subscription_node).not_to be_nil
|
24
|
+
expect(subscription.find('//ns:pubsub/ns:subscription', :ns => Blather::Stanza::PubSub.registered_ns)).not_to 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
|
+
expect(subscription.type).to eq(: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
|
+
expect(subscription.to).to eq(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
|
+
expect(subscription.node).to eq('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
|
+
expect(subscription.find('//ns:pubsub/ns:subscription[@node="node-name"]', :ns => Blather::Stanza::PubSub.registered_ns)).not_to be_empty
|
45
|
+
expect(subscription.node).to eq('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
|
+
expect(subscription.find('//ns:pubsub/ns:subscription[@node="new-node"]', :ns => Blather::Stanza::PubSub.registered_ns)).not_to be_empty
|
49
|
+
expect(subscription.node).to eq('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
|
+
expect(subscription.find('//ns:pubsub/ns:subscription[@jid="jid"]', :ns => Blather::Stanza::PubSub.registered_ns)).not_to be_empty
|
55
|
+
expect(subscription.jid).to eq(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
|
+
expect(subscription.find('//ns:pubsub/ns:subscription[@jid="n@d/r"]', :ns => Blather::Stanza::PubSub.registered_ns)).not_to be_empty
|
59
|
+
expect(subscription.jid).to eq(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
|
+
expect(subscription.find('//ns:pubsub/ns:subscription[@subid="subid"]', :ns => Blather::Stanza::PubSub.registered_ns)).not_to be_empty
|
65
|
+
expect(subscription.subid).to eq('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
|
+
expect(subscription.find('//ns:pubsub/ns:subscription[@subid="new-subid"]', :ns => Blather::Stanza::PubSub.registered_ns)).not_to be_empty
|
69
|
+
expect(subscription.subid).to eq('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
|
+
expect(subscription.find('//ns:pubsub/ns:subscription[@subscription="none"]', :ns => Blather::Stanza::PubSub.registered_ns)).not_to be_empty
|
75
|
+
expect(subscription.subscription).to eq(: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
|
+
expect(subscription.find('//ns:pubsub/ns:subscription[@subscription="pending"]', :ns => Blather::Stanza::PubSub.registered_ns)).not_to be_empty
|
79
|
+
expect(subscription.subscription).to eq(:pending)
|
80
80
|
end
|
81
81
|
|
82
82
|
it 'ensures subscription is one of Stanza::PubSub::Subscription::VALID_TYPES' do
|
83
|
-
|
83
|
+
expect { Blather::Stanza::PubSub::Subscription.new :set, 'host', 'node-name', 'jid', 'subid', :invalid_type_name }.to 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
|
+
expect(n.subscription).to eq(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
|
+
expect(Blather::Stanza::PubSub::Subscription.new).to respond_to :"#{valid_type}?"
|
94
94
|
end
|
95
95
|
end
|
96
96
|
|
@@ -10,59 +10,59 @@ 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
|
+
expect(Blather::XMPPNode.class_from_registration(:subscriptions, 'http://jabber.org/protocol/pubsub')).to eq(Blather::Stanza::PubSub::Subscriptions)
|
14
14
|
end
|
15
15
|
|
16
16
|
it 'can be imported' do
|
17
|
-
Blather::XMPPNode.parse(subscriptions_xml).
|
17
|
+
expect(Blather::XMPPNode.parse(subscriptions_xml)).to 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
|
+
expect(subscriptions.find('//ns:pubsub/ns:subscriptions', :ns => Blather::Stanza::PubSub.registered_ns)).not_to 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
|
+
expect(subscriptions.find('//ns:pubsub/ns:subscriptions', :ns => Blather::Stanza::PubSub.registered_ns)).to be_empty
|
29
29
|
|
30
|
-
subscriptions.subscriptions.
|
31
|
-
subscriptions.find('//ns:pubsub/ns:subscriptions', :ns => Blather::Stanza::PubSub.registered_ns).
|
30
|
+
expect(subscriptions.subscriptions).not_to be_nil
|
31
|
+
expect(subscriptions.find('//ns:pubsub/ns:subscriptions', :ns => Blather::Stanza::PubSub.registered_ns)).not_to be_empty
|
32
32
|
end
|
33
33
|
|
34
34
|
it 'ensures the subscriptions node is not duplicated when calling #subscriptions' do
|
35
35
|
subscriptions = Blather::Stanza::PubSub::Subscriptions.new
|
36
36
|
subscriptions.pubsub.remove_children :subscriptions
|
37
|
-
subscriptions.find('//ns:pubsub/ns:subscriptions', :ns => Blather::Stanza::PubSub.registered_ns).
|
37
|
+
expect(subscriptions.find('//ns:pubsub/ns:subscriptions', :ns => Blather::Stanza::PubSub.registered_ns)).to be_empty
|
38
38
|
|
39
39
|
5.times { subscriptions.subscriptions }
|
40
|
-
subscriptions.find('//ns:pubsub/ns:subscriptions', :ns => Blather::Stanza::PubSub.registered_ns).count.
|
40
|
+
expect(subscriptions.find('//ns:pubsub/ns:subscriptions', :ns => Blather::Stanza::PubSub.registered_ns).count).to eq(1)
|
41
41
|
end
|
42
42
|
|
43
43
|
it 'defaults to a get node' do
|
44
44
|
aff = Blather::Stanza::PubSub::Subscriptions.new
|
45
|
-
aff.type.
|
45
|
+
expect(aff.type).to eq(:get)
|
46
46
|
end
|
47
47
|
|
48
48
|
it 'sets the host if requested' do
|
49
49
|
aff = Blather::Stanza::PubSub::Subscriptions.new :get, 'pubsub.jabber.local'
|
50
|
-
aff.to.
|
50
|
+
expect(aff.to).to eq(Blather::JID.new('pubsub.jabber.local'))
|
51
51
|
end
|
52
52
|
|
53
53
|
it 'can import a subscriptions result node' do
|
54
54
|
node = parse_stanza(subscriptions_xml).root
|
55
55
|
|
56
56
|
subscriptions = Blather::Stanza::PubSub::Subscriptions.new.inherit node
|
57
|
-
subscriptions.size.
|
58
|
-
subscriptions.list.
|
57
|
+
expect(subscriptions.size).to eq(4)
|
58
|
+
expect(subscriptions.list).to eq(control_subscriptions)
|
59
59
|
end
|
60
60
|
|
61
61
|
it 'will iterate over each subscription' do
|
62
62
|
node = parse_stanza(subscriptions_xml).root
|
63
63
|
subscriptions = Blather::Stanza::PubSub::Subscriptions.new.inherit node
|
64
64
|
subscriptions.each do |type, nodes|
|
65
|
-
nodes.
|
65
|
+
expect(nodes).to eq(control_subscriptions[type])
|
66
66
|
end
|
67
67
|
end
|
68
68
|
end
|