blather 1.2.0 → 2.0.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.
- 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
@@ -2,34 +2,34 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Blather::Stanza::Presence do
|
4
4
|
it 'registers itself' do
|
5
|
-
Blather::XMPPNode.class_from_registration(:presence, nil).
|
5
|
+
expect(Blather::XMPPNode.class_from_registration(:presence, nil)).to eq(Blather::Stanza::Presence)
|
6
6
|
end
|
7
7
|
|
8
8
|
it 'must be importable' do
|
9
|
-
Blather::XMPPNode.parse('<presence type="probe"/>').
|
9
|
+
expect(Blather::XMPPNode.parse('<presence type="probe"/>')).to be_instance_of Blather::Stanza::Presence
|
10
10
|
end
|
11
11
|
|
12
12
|
it 'ensures type is one of Blather::Stanza::Presence::VALID_TYPES' do
|
13
13
|
presence = Blather::Stanza::Presence.new
|
14
|
-
|
14
|
+
expect { presence.type = :invalid_type_name }.to raise_error(Blather::ArgumentError)
|
15
15
|
|
16
16
|
Blather::Stanza::Presence::VALID_TYPES.each do |valid_type|
|
17
17
|
presence.type = valid_type
|
18
|
-
presence.type.
|
18
|
+
expect(presence.type).to eq(valid_type)
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
22
|
Blather::Stanza::Presence::VALID_TYPES.each do |valid_type|
|
23
23
|
it "provides a helper (#{valid_type}?) for type #{valid_type}" do
|
24
|
-
Blather::Stanza::Presence.new.
|
24
|
+
expect(Blather::Stanza::Presence.new).to respond_to :"#{valid_type}?"
|
25
25
|
end
|
26
26
|
|
27
27
|
it "returns true on call to (#{valid_type}?) if type == #{valid_type}" do
|
28
28
|
method = "#{valid_type}?".to_sym
|
29
29
|
pres = Blather::Stanza::Presence.new
|
30
30
|
pres.type = valid_type
|
31
|
-
pres.
|
32
|
-
pres.__send__(method).
|
31
|
+
expect(pres).to respond_to method
|
32
|
+
expect(pres.__send__(method)).to eq(true)
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
@@ -43,30 +43,30 @@ describe Blather::Stanza::Presence do
|
|
43
43
|
</presence>
|
44
44
|
XML
|
45
45
|
s = Blather::Stanza::Presence.parse string
|
46
|
-
s.
|
47
|
-
s.node.
|
48
|
-
s.handler_hierarchy.
|
46
|
+
expect(s).to be_kind_of Blather::Stanza::Presence::C::InstanceMethods
|
47
|
+
expect(s.node).to eq('http://www.chatopus.com')
|
48
|
+
expect(s.handler_hierarchy).to include(:c)
|
49
49
|
end
|
50
50
|
|
51
51
|
it 'creates a Status object when importing a node with type == nil' do
|
52
52
|
s = Blather::Stanza::Presence.parse('<presence/>')
|
53
|
-
s.
|
54
|
-
s.state.
|
55
|
-
s.handler_hierarchy.
|
53
|
+
expect(s).to be_kind_of Blather::Stanza::Presence::Status::InstanceMethods
|
54
|
+
expect(s.state).to eq(:available)
|
55
|
+
expect(s.handler_hierarchy).to include(Blather::Stanza::Presence::Status.registered_name.to_sym)
|
56
56
|
end
|
57
57
|
|
58
58
|
it 'creates a Status object when importing a node with type == "unavailable"' do
|
59
59
|
s = Blather::Stanza::Presence.parse('<presence type="unavailable"/>')
|
60
|
-
s.
|
61
|
-
s.state.
|
62
|
-
s.handler_hierarchy.
|
60
|
+
expect(s).to be_kind_of Blather::Stanza::Presence::Status::InstanceMethods
|
61
|
+
expect(s.state).to eq(:unavailable)
|
62
|
+
expect(s.handler_hierarchy).to include(Blather::Stanza::Presence::Status.registered_name.to_sym)
|
63
63
|
end
|
64
64
|
|
65
65
|
it 'creates a Subscription object when importing a node with type == "subscribe"' do
|
66
66
|
s = Blather::Stanza::Presence.parse('<presence type="subscribe"/>')
|
67
|
-
s.
|
68
|
-
s.type.
|
69
|
-
s.handler_hierarchy.
|
67
|
+
expect(s).to be_kind_of Blather::Stanza::Presence::Subscription::InstanceMethods
|
68
|
+
expect(s.type).to eq(:subscribe)
|
69
|
+
expect(s.handler_hierarchy).to include(Blather::Stanza::Presence::Subscription.registered_name.to_sym)
|
70
70
|
end
|
71
71
|
|
72
72
|
it 'creates a MUC object when importing a node with a form in the MUC namespace' do
|
@@ -76,7 +76,7 @@ describe Blather::Stanza::Presence do
|
|
76
76
|
</presence>
|
77
77
|
XML
|
78
78
|
s = Blather::Stanza::Presence.parse string
|
79
|
-
s.
|
79
|
+
expect(s).to be_kind_of Blather::Stanza::Presence::MUC::InstanceMethods
|
80
80
|
end
|
81
81
|
|
82
82
|
it 'creates a MUCUser object when importing a node with a form in the MUC#user namespace' do
|
@@ -86,15 +86,15 @@ describe Blather::Stanza::Presence do
|
|
86
86
|
</presence>
|
87
87
|
XML
|
88
88
|
s = Blather::Stanza::Presence.parse string
|
89
|
-
s.
|
89
|
+
expect(s).to be_kind_of Blather::Stanza::Presence::MUCUser::InstanceMethods
|
90
90
|
end
|
91
91
|
|
92
92
|
it 'creates a Presence object when importing a node with type equal to something unknown' do
|
93
93
|
string = "<presence from='bard@shakespeare.lit/globe' type='foo'/>"
|
94
94
|
s = Blather::Stanza::Presence.parse string
|
95
|
-
s.
|
96
|
-
s.type.
|
97
|
-
s.handler_hierarchy.
|
95
|
+
expect(s).to be_kind_of Blather::Stanza::Presence
|
96
|
+
expect(s.type).to eq(:foo)
|
97
|
+
expect(s.handler_hierarchy).to include(Blather::Stanza::Presence.registered_name.to_sym)
|
98
98
|
end
|
99
99
|
|
100
100
|
it 'behaves like a C, a Status, and a MUCUser when all types of children are present' do
|
@@ -116,11 +116,11 @@ describe Blather::Stanza::Presence do
|
|
116
116
|
</presence>
|
117
117
|
XML
|
118
118
|
s = Blather::Stanza::Presence.parse string
|
119
|
-
s.state.
|
120
|
-
s.node.
|
121
|
-
s.role.
|
122
|
-
s.handler_hierarchy.
|
123
|
-
s.handler_hierarchy.
|
119
|
+
expect(s.state).to eq(:chat)
|
120
|
+
expect(s.node).to eq('http://www.chatopus.com')
|
121
|
+
expect(s.role).to eq(:participant)
|
122
|
+
expect(s.handler_hierarchy).to include(Blather::Stanza::Presence::C.registered_name.to_sym)
|
123
|
+
expect(s.handler_hierarchy).to include(Blather::Stanza::Presence::Status.registered_name.to_sym)
|
124
124
|
end
|
125
125
|
|
126
126
|
it "handle stanzas with nested elements that don't have a decorator module or are not stanzas" do
|
@@ -146,6 +146,6 @@ describe Blather::Stanza::Presence do
|
|
146
146
|
</presence>
|
147
147
|
XML
|
148
148
|
s = Blather::Stanza::Presence.parse string
|
149
|
-
s.
|
149
|
+
expect(s).to be_a Blather::Stanza::Presence
|
150
150
|
end
|
151
151
|
end
|
@@ -11,47 +11,47 @@ end
|
|
11
11
|
|
12
12
|
describe Blather::Stanza::PubSub::Affiliations do
|
13
13
|
it 'registers itself' do
|
14
|
-
Blather::XMPPNode.class_from_registration(:affiliations, Blather::Stanza::PubSub.registered_ns).
|
14
|
+
expect(Blather::XMPPNode.class_from_registration(:affiliations, Blather::Stanza::PubSub.registered_ns)).to eq(Blather::Stanza::PubSub::Affiliations)
|
15
15
|
end
|
16
16
|
|
17
17
|
it 'can be imported' do
|
18
|
-
Blather::XMPPNode.parse(affiliations_xml).
|
18
|
+
expect(Blather::XMPPNode.parse(affiliations_xml)).to be_instance_of Blather::Stanza::PubSub::Affiliations
|
19
19
|
end
|
20
20
|
|
21
21
|
it 'ensures an affiliations node is present on create' do
|
22
22
|
affiliations = Blather::Stanza::PubSub::Affiliations.new
|
23
|
-
affiliations.find_first('//ns:affiliations', :ns => Blather::Stanza::PubSub.registered_ns).
|
23
|
+
expect(affiliations.find_first('//ns:affiliations', :ns => Blather::Stanza::PubSub.registered_ns)).not_to be_nil
|
24
24
|
end
|
25
25
|
|
26
26
|
it 'ensures an affiliations node exists when calling #affiliations' do
|
27
27
|
affiliations = Blather::Stanza::PubSub::Affiliations.new
|
28
28
|
affiliations.pubsub.remove_children :affiliations
|
29
|
-
affiliations.find_first('//ns:affiliations', :ns => Blather::Stanza::PubSub.registered_ns).
|
29
|
+
expect(affiliations.find_first('//ns:affiliations', :ns => Blather::Stanza::PubSub.registered_ns)).to be_nil
|
30
30
|
|
31
|
-
affiliations.affiliations.
|
32
|
-
affiliations.find_first('//ns:affiliations', :ns => Blather::Stanza::PubSub.registered_ns).
|
31
|
+
expect(affiliations.affiliations).not_to be_nil
|
32
|
+
expect(affiliations.find_first('//ns:affiliations', :ns => Blather::Stanza::PubSub.registered_ns)).not_to be_nil
|
33
33
|
end
|
34
34
|
|
35
35
|
it 'defaults to a get node' do
|
36
|
-
Blather::Stanza::PubSub::Affiliations.new.type.
|
36
|
+
expect(Blather::Stanza::PubSub::Affiliations.new.type).to eq(:get)
|
37
37
|
end
|
38
38
|
|
39
39
|
it 'sets the host if requested' do
|
40
40
|
aff = Blather::Stanza::PubSub::Affiliations.new :get, 'pubsub.jabber.local'
|
41
|
-
aff.to.
|
41
|
+
expect(aff.to).to eq(Blather::JID.new('pubsub.jabber.local'))
|
42
42
|
end
|
43
43
|
|
44
44
|
it 'can import an affiliates result node' do
|
45
45
|
node = parse_stanza(affiliations_xml).root
|
46
46
|
|
47
47
|
affiliations = Blather::Stanza::PubSub::Affiliations.new.inherit node
|
48
|
-
affiliations.size.
|
49
|
-
affiliations.list.
|
48
|
+
expect(affiliations.size).to eq(5)
|
49
|
+
expect(affiliations.list).to eq(control_affiliations)
|
50
50
|
end
|
51
51
|
|
52
52
|
it 'will iterate over each affiliation' do
|
53
53
|
Blather::XMPPNode.parse(affiliations_xml).each do |type, nodes|
|
54
|
-
nodes.
|
54
|
+
expect(nodes).to eq(control_affiliations[type])
|
55
55
|
end
|
56
56
|
end
|
57
57
|
end
|
@@ -3,11 +3,11 @@ require 'fixtures/pubsub'
|
|
3
3
|
|
4
4
|
describe Blather::Stanza::PubSub::Create do
|
5
5
|
it 'registers itself' do
|
6
|
-
Blather::XMPPNode.class_from_registration(:create, 'http://jabber.org/protocol/pubsub').
|
6
|
+
expect(Blather::XMPPNode.class_from_registration(:create, 'http://jabber.org/protocol/pubsub')).to eq(Blather::Stanza::PubSub::Create)
|
7
7
|
end
|
8
8
|
|
9
9
|
it 'can be imported' do
|
10
|
-
Blather::XMPPNode.parse(<<-NODE).
|
10
|
+
expect(Blather::XMPPNode.parse(<<-NODE)).to be_instance_of Blather::Stanza::PubSub::Create
|
11
11
|
<iq type='set'
|
12
12
|
from='hamlet@denmark.lit/elsinore'
|
13
13
|
to='pubsub.shakespeare.lit'
|
@@ -22,35 +22,35 @@ describe Blather::Stanza::PubSub::Create do
|
|
22
22
|
|
23
23
|
it 'ensures a create node is present on create' do
|
24
24
|
create = Blather::Stanza::PubSub::Create.new
|
25
|
-
create.find('//ns:pubsub/ns:create', :ns => Blather::Stanza::PubSub.registered_ns).
|
25
|
+
expect(create.find('//ns:pubsub/ns:create', :ns => Blather::Stanza::PubSub.registered_ns)).not_to be_empty
|
26
26
|
end
|
27
27
|
|
28
28
|
it 'ensures a configure node is present on create' do
|
29
29
|
create = Blather::Stanza::PubSub::Create.new
|
30
|
-
create.find('//ns:pubsub/ns:configure', :ns => Blather::Stanza::PubSub.registered_ns).
|
30
|
+
expect(create.find('//ns:pubsub/ns:configure', :ns => Blather::Stanza::PubSub.registered_ns)).not_to be_empty
|
31
31
|
end
|
32
32
|
|
33
33
|
it 'ensures a create node exists when calling #create_node' do
|
34
34
|
create = Blather::Stanza::PubSub::Create.new
|
35
35
|
create.pubsub.remove_children :create
|
36
|
-
create.find('//ns:pubsub/ns:create', :ns => Blather::Stanza::PubSub.registered_ns).
|
36
|
+
expect(create.find('//ns:pubsub/ns:create', :ns => Blather::Stanza::PubSub.registered_ns)).to be_empty
|
37
37
|
|
38
|
-
create.create_node.
|
39
|
-
create.find('//ns:pubsub/ns:create', :ns => Blather::Stanza::PubSub.registered_ns).
|
38
|
+
expect(create.create_node).not_to be_nil
|
39
|
+
expect(create.find('//ns:pubsub/ns:create', :ns => Blather::Stanza::PubSub.registered_ns)).not_to be_empty
|
40
40
|
end
|
41
41
|
|
42
42
|
it 'defaults to a set node' do
|
43
43
|
create = Blather::Stanza::PubSub::Create.new
|
44
|
-
create.type.
|
44
|
+
expect(create.type).to eq(:set)
|
45
45
|
end
|
46
46
|
|
47
47
|
it 'sets the host if requested' do
|
48
48
|
create = Blather::Stanza::PubSub::Create.new :set, 'pubsub.jabber.local'
|
49
|
-
create.to.
|
49
|
+
expect(create.to).to eq(Blather::JID.new('pubsub.jabber.local'))
|
50
50
|
end
|
51
51
|
|
52
52
|
it 'sets the node' do
|
53
53
|
create = Blather::Stanza::PubSub::Create.new :set, 'host', 'node-name'
|
54
|
-
create.node.
|
54
|
+
expect(create.node).to eq('node-name')
|
55
55
|
end
|
56
56
|
end
|
@@ -3,56 +3,56 @@ require 'fixtures/pubsub'
|
|
3
3
|
|
4
4
|
describe Blather::Stanza::PubSub::Event do
|
5
5
|
it 'registers itself' do
|
6
|
-
Blather::XMPPNode.class_from_registration(:event, 'http://jabber.org/protocol/pubsub#event').
|
6
|
+
expect(Blather::XMPPNode.class_from_registration(:event, 'http://jabber.org/protocol/pubsub#event')).to eq(Blather::Stanza::PubSub::Event)
|
7
7
|
end
|
8
8
|
|
9
9
|
it 'is importable' do
|
10
|
-
Blather::XMPPNode.parse(event_notification_xml).
|
10
|
+
expect(Blather::XMPPNode.parse(event_notification_xml)).to be_instance_of Blather::Stanza::PubSub::Event
|
11
11
|
end
|
12
12
|
|
13
13
|
it 'ensures a query node is present on create' do
|
14
14
|
evt = Blather::Stanza::PubSub::Event.new
|
15
|
-
evt.find('ns:event', :ns => Blather::Stanza::PubSub::Event.registered_ns).
|
15
|
+
expect(evt.find('ns:event', :ns => Blather::Stanza::PubSub::Event.registered_ns)).not_to be_empty
|
16
16
|
end
|
17
17
|
|
18
18
|
it 'ensures an event node exists when calling #event_node' do
|
19
19
|
evt = Blather::Stanza::PubSub::Event.new
|
20
20
|
evt.remove_children :event
|
21
|
-
evt.find('*[local-name()="event"]').
|
21
|
+
expect(evt.find('*[local-name()="event"]')).to be_empty
|
22
22
|
|
23
|
-
evt.event_node.
|
24
|
-
evt.find('ns:event', :ns => Blather::Stanza::PubSub::Event.registered_ns).
|
23
|
+
expect(evt.event_node).not_to be_nil
|
24
|
+
expect(evt.find('ns:event', :ns => Blather::Stanza::PubSub::Event.registered_ns)).not_to be_empty
|
25
25
|
end
|
26
26
|
|
27
27
|
it 'ensures an items node exists when calling #items_node' do
|
28
28
|
evt = Blather::Stanza::PubSub::Event.new
|
29
29
|
evt.remove_children :items
|
30
|
-
evt.find('*[local-name()="items"]').
|
30
|
+
expect(evt.find('*[local-name()="items"]')).to be_empty
|
31
31
|
|
32
|
-
evt.items_node.
|
33
|
-
evt.find('ns:event/ns:items', :ns => Blather::Stanza::PubSub::Event.registered_ns).
|
32
|
+
expect(evt.items_node).not_to be_nil
|
33
|
+
expect(evt.find('ns:event/ns:items', :ns => Blather::Stanza::PubSub::Event.registered_ns)).not_to be_empty
|
34
34
|
end
|
35
35
|
|
36
36
|
it 'knows the associated node name' do
|
37
37
|
evt = Blather::XMPPNode.parse(event_with_payload_xml)
|
38
|
-
evt.node.
|
38
|
+
expect(evt.node).to eq('princely_musings')
|
39
39
|
end
|
40
40
|
|
41
41
|
it 'ensures newly inherited items are PubSubItem objects' do
|
42
42
|
evt = Blather::XMPPNode.parse(event_with_payload_xml)
|
43
|
-
evt.items
|
44
|
-
evt.retractions
|
45
|
-
evt.items.map { |i| i.class }.uniq.
|
43
|
+
expect(evt.items?).to eq(true)
|
44
|
+
expect(evt.retractions?).to eq(false)
|
45
|
+
expect(evt.items.map { |i| i.class }.uniq).to eq([Blather::Stanza::PubSub::PubSubItem])
|
46
46
|
end
|
47
47
|
|
48
48
|
it 'will iterate over each item' do
|
49
49
|
evt = Blather::XMPPNode.parse(event_with_payload_xml)
|
50
|
-
evt.items.each { |i| i.class.
|
50
|
+
evt.items.each { |i| expect(i.class).to eq(Blather::Stanza::PubSub::PubSubItem) }
|
51
51
|
end
|
52
52
|
|
53
53
|
it 'handles receiving subscription ids' do
|
54
54
|
evt = Blather::XMPPNode.parse(event_subids_xml)
|
55
|
-
evt.subscription_ids.
|
55
|
+
expect(evt.subscription_ids).to eq(['123-abc', '004-yyy'])
|
56
56
|
end
|
57
57
|
|
58
58
|
it 'can have a list of retractions' do
|
@@ -65,9 +65,9 @@ describe Blather::Stanza::PubSub::Event do
|
|
65
65
|
</event>
|
66
66
|
</message>
|
67
67
|
NODE
|
68
|
-
evt.retractions
|
69
|
-
evt.items
|
70
|
-
evt.retractions.
|
68
|
+
expect(evt.retractions?).to eq(true)
|
69
|
+
expect(evt.items?).to eq(false)
|
70
|
+
expect(evt.retractions).to eq(%w[ae890ac52d0df67ed7cfdf51b644e901])
|
71
71
|
end
|
72
72
|
|
73
73
|
it 'can be a purge' do
|
@@ -78,8 +78,8 @@ describe Blather::Stanza::PubSub::Event do
|
|
78
78
|
</event>
|
79
79
|
</message>
|
80
80
|
NODE
|
81
|
-
evt.purge
|
82
|
-
evt.node.
|
81
|
+
expect(evt.purge?).not_to be_nil
|
82
|
+
expect(evt.node).to eq('princely_musings')
|
83
83
|
end
|
84
84
|
|
85
85
|
it 'can be a subscription notification' do
|
@@ -90,9 +90,9 @@ describe Blather::Stanza::PubSub::Event do
|
|
90
90
|
</event>
|
91
91
|
</message>
|
92
92
|
NODE
|
93
|
-
evt.subscription
|
94
|
-
evt.subscription[:jid].
|
95
|
-
evt.subscription[:subscription].
|
96
|
-
evt.subscription[:node].
|
93
|
+
expect(evt.subscription?).not_to be_nil
|
94
|
+
expect(evt.subscription[:jid]).to eq('francisco@denmark.lit')
|
95
|
+
expect(evt.subscription[:subscription]).to eq('subscribed')
|
96
|
+
expect(evt.subscription[:node]).to eq('/example.com/test')
|
97
97
|
end
|
98
98
|
end
|
@@ -3,43 +3,43 @@ require 'fixtures/pubsub'
|
|
3
3
|
|
4
4
|
describe Blather::Stanza::PubSub::Items do
|
5
5
|
it 'registers itself' do
|
6
|
-
Blather::XMPPNode.class_from_registration(:items, 'http://jabber.org/protocol/pubsub').
|
6
|
+
expect(Blather::XMPPNode.class_from_registration(:items, 'http://jabber.org/protocol/pubsub')).to eq(Blather::Stanza::PubSub::Items)
|
7
7
|
end
|
8
8
|
|
9
9
|
it 'can be imported' do
|
10
|
-
Blather::XMPPNode.parse(items_all_nodes_xml).
|
10
|
+
expect(Blather::XMPPNode.parse(items_all_nodes_xml)).to be_instance_of Blather::Stanza::PubSub::Items
|
11
11
|
end
|
12
12
|
|
13
13
|
it 'ensures an items node is present on create' do
|
14
14
|
items = Blather::Stanza::PubSub::Items.new
|
15
|
-
items.find('//ns:pubsub/ns:items', :ns => Blather::Stanza::PubSub.registered_ns).
|
15
|
+
expect(items.find('//ns:pubsub/ns:items', :ns => Blather::Stanza::PubSub.registered_ns)).not_to be_empty
|
16
16
|
end
|
17
17
|
|
18
18
|
it 'ensures an items node exists when calling #items' do
|
19
19
|
items = Blather::Stanza::PubSub::Items.new
|
20
20
|
items.pubsub.remove_children :items
|
21
|
-
items.find('//ns:pubsub/ns:items', :ns => Blather::Stanza::PubSub.registered_ns).
|
21
|
+
expect(items.find('//ns:pubsub/ns:items', :ns => Blather::Stanza::PubSub.registered_ns)).to be_empty
|
22
22
|
|
23
|
-
items.items.
|
24
|
-
items.find('//ns:pubsub/ns:items', :ns => Blather::Stanza::PubSub.registered_ns).
|
23
|
+
expect(items.items).not_to be_nil
|
24
|
+
expect(items.find('//ns:pubsub/ns:items', :ns => Blather::Stanza::PubSub.registered_ns)).not_to be_empty
|
25
25
|
end
|
26
26
|
|
27
27
|
it 'defaults to a get node' do
|
28
28
|
aff = Blather::Stanza::PubSub::Items.new
|
29
|
-
aff.type.
|
29
|
+
expect(aff.type).to eq(:get)
|
30
30
|
end
|
31
31
|
|
32
32
|
it 'ensures newly inherited items are PubSubItem objects' do
|
33
33
|
items = Blather::XMPPNode.parse(items_all_nodes_xml)
|
34
|
-
items.map { |i| i.class }.uniq.
|
34
|
+
expect(items.map { |i| i.class }.uniq).to eq([Blather::Stanza::PubSub::PubSubItem])
|
35
35
|
end
|
36
36
|
|
37
37
|
it 'will iterate over each item' do
|
38
38
|
n = parse_stanza items_all_nodes_xml
|
39
39
|
items = Blather::Stanza::PubSub::Items.new.inherit n.root
|
40
40
|
count = 0
|
41
|
-
items.each { |i| i.
|
42
|
-
count.
|
41
|
+
items.each { |i| expect(i).to be_instance_of Blather::Stanza::PubSub::PubSubItem; count += 1 }
|
42
|
+
expect(count).to eq(4)
|
43
43
|
end
|
44
44
|
|
45
45
|
it 'can create an items request node to request all items' do
|
@@ -47,9 +47,9 @@ describe Blather::Stanza::PubSub::Items do
|
|
47
47
|
node = 'princely_musings'
|
48
48
|
|
49
49
|
items = Blather::Stanza::PubSub::Items.request host, node
|
50
|
-
items.find("//ns:items[@node=\"#{node}\"]", :ns => Blather::Stanza::PubSub.registered_ns).size.
|
51
|
-
items.to.
|
52
|
-
items.node.
|
50
|
+
expect(items.find("//ns:items[@node=\"#{node}\"]", :ns => Blather::Stanza::PubSub.registered_ns).size).to eq(1)
|
51
|
+
expect(items.to).to eq(Blather::JID.new(host))
|
52
|
+
expect(items.node).to eq(node)
|
53
53
|
end
|
54
54
|
|
55
55
|
it 'can create an items request node to request some items' do
|
@@ -60,9 +60,9 @@ describe Blather::Stanza::PubSub::Items do
|
|
60
60
|
items_xpath = items.map { |i| "@id=\"#{i}\"" } * ' or '
|
61
61
|
|
62
62
|
items = Blather::Stanza::PubSub::Items.request host, node, items
|
63
|
-
items.find("//ns:items[@node=\"#{node}\"]/ns:item[#{items_xpath}]", :ns => Blather::Stanza::PubSub.registered_ns).size.
|
64
|
-
items.to.
|
65
|
-
items.node.
|
63
|
+
expect(items.find("//ns:items[@node=\"#{node}\"]/ns:item[#{items_xpath}]", :ns => Blather::Stanza::PubSub.registered_ns).size).to eq(2)
|
64
|
+
expect(items.to).to eq(Blather::JID.new(host))
|
65
|
+
expect(items.node).to eq(node)
|
66
66
|
end
|
67
67
|
|
68
68
|
it 'can create an items request node to request "max_number" of items' do
|
@@ -71,9 +71,9 @@ describe Blather::Stanza::PubSub::Items do
|
|
71
71
|
max = 3
|
72
72
|
|
73
73
|
items = Blather::Stanza::PubSub::Items.request host, node, nil, max
|
74
|
-
items.find("//ns:pubsub/ns:items[@node=\"#{node}\" and @max_items=\"#{max}\"]", :ns => Blather::Stanza::PubSub.registered_ns).size.
|
75
|
-
items.to.
|
76
|
-
items.node.
|
77
|
-
items.max_items.
|
74
|
+
expect(items.find("//ns:pubsub/ns:items[@node=\"#{node}\" and @max_items=\"#{max}\"]", :ns => Blather::Stanza::PubSub.registered_ns).size).to eq(1)
|
75
|
+
expect(items.to).to eq(Blather::JID.new(host))
|
76
|
+
expect(items.node).to eq(node)
|
77
|
+
expect(items.max_items).to eq(max)
|
78
78
|
end
|
79
79
|
end
|