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
@@ -12,15 +12,15 @@ describe Blather::DSL::PubSub do
|
|
12
12
|
|
13
13
|
it 'raises an error when trying to send a stanza without a host' do
|
14
14
|
@pubsub.host = nil
|
15
|
-
|
15
|
+
expect { @pubsub.affiliations }.to raise_error RuntimeError
|
16
16
|
end
|
17
17
|
|
18
18
|
it 'requests affiliations' do
|
19
19
|
@client.expects(:write_with_handler).with do |n|
|
20
|
-
n.
|
21
|
-
n.find('//ns:pubsub/ns:affiliations', :ns => Blather::Stanza::PubSub.registered_ns).
|
22
|
-
n.to.
|
23
|
-
n.type.
|
20
|
+
expect(n).to be_instance_of Blather::Stanza::PubSub::Affiliations
|
21
|
+
expect(n.find('//ns:pubsub/ns:affiliations', :ns => Blather::Stanza::PubSub.registered_ns)).not_to be_empty
|
22
|
+
expect(n.to).to eq(Blather::JID.new(@host))
|
23
|
+
expect(n.type).to eq(:get)
|
24
24
|
end
|
25
25
|
@pubsub.affiliations
|
26
26
|
end
|
@@ -28,20 +28,20 @@ describe Blather::DSL::PubSub do
|
|
28
28
|
it 'requests affiliations from a specified host' do
|
29
29
|
host = 'another.host'
|
30
30
|
@client.expects(:write_with_handler).with do |n|
|
31
|
-
n.
|
32
|
-
n.find('//ns:pubsub/ns:affiliations', :ns => Blather::Stanza::PubSub.registered_ns).
|
33
|
-
n.to.
|
34
|
-
n.type.
|
31
|
+
expect(n).to be_instance_of Blather::Stanza::PubSub::Affiliations
|
32
|
+
expect(n.find('//ns:pubsub/ns:affiliations', :ns => Blather::Stanza::PubSub.registered_ns)).not_to be_empty
|
33
|
+
expect(n.to).to eq(Blather::JID.new(host))
|
34
|
+
expect(n.type).to eq(:get)
|
35
35
|
end
|
36
36
|
@pubsub.affiliations host
|
37
37
|
end
|
38
38
|
|
39
39
|
it 'requests subscriptions' do
|
40
40
|
@client.expects(:write_with_handler).with do |n|
|
41
|
-
n.
|
42
|
-
n.find('//ns:pubsub/ns:subscriptions', :ns => Blather::Stanza::PubSub.registered_ns).
|
43
|
-
n.to.
|
44
|
-
n.type.
|
41
|
+
expect(n).to be_instance_of Blather::Stanza::PubSub::Subscriptions
|
42
|
+
expect(n.find('//ns:pubsub/ns:subscriptions', :ns => Blather::Stanza::PubSub.registered_ns)).not_to be_empty
|
43
|
+
expect(n.to).to eq(Blather::JID.new(@host))
|
44
|
+
expect(n.type).to eq(:get)
|
45
45
|
end
|
46
46
|
@pubsub.subscriptions
|
47
47
|
end
|
@@ -49,20 +49,20 @@ describe Blather::DSL::PubSub do
|
|
49
49
|
it 'requests subscriptions from a specified host' do
|
50
50
|
host = 'another.host'
|
51
51
|
@client.expects(:write_with_handler).with do |n|
|
52
|
-
n.
|
53
|
-
n.find('//ns:pubsub/ns:subscriptions', :ns => Blather::Stanza::PubSub.registered_ns).
|
54
|
-
n.to.
|
55
|
-
n.type.
|
52
|
+
expect(n).to be_instance_of Blather::Stanza::PubSub::Subscriptions
|
53
|
+
expect(n.find('//ns:pubsub/ns:subscriptions', :ns => Blather::Stanza::PubSub.registered_ns)).not_to be_empty
|
54
|
+
expect(n.to).to eq(Blather::JID.new(host))
|
55
|
+
expect(n.type).to eq(:get)
|
56
56
|
end
|
57
57
|
@pubsub.subscriptions host
|
58
58
|
end
|
59
59
|
|
60
60
|
it 'requests nodes defaulting to "/"' do
|
61
61
|
@client.expects(:write_with_handler).with do |n|
|
62
|
-
n.
|
63
|
-
n.find("/iq/ns:query[@node='/']", :ns => Blather::Stanza::DiscoItems.registered_ns).
|
64
|
-
n.to.
|
65
|
-
n.type.
|
62
|
+
expect(n).to be_instance_of Blather::Stanza::DiscoItems
|
63
|
+
expect(n.find("/iq/ns:query[@node='/']", :ns => Blather::Stanza::DiscoItems.registered_ns)).not_to be_empty
|
64
|
+
expect(n.to).to eq(Blather::JID.new(@host))
|
65
|
+
expect(n.type).to eq(:get)
|
66
66
|
end
|
67
67
|
@pubsub.nodes nil
|
68
68
|
end
|
@@ -70,200 +70,200 @@ describe Blather::DSL::PubSub do
|
|
70
70
|
it 'requests nodes from a specified host' do
|
71
71
|
host = 'another.host'
|
72
72
|
@client.expects(:write_with_handler).with do |n|
|
73
|
-
n.
|
74
|
-
n.find("/iq/ns:query[@node='/']", :ns => Blather::Stanza::DiscoItems.registered_ns).
|
75
|
-
n.to.
|
76
|
-
n.type.
|
73
|
+
expect(n).to be_instance_of Blather::Stanza::DiscoItems
|
74
|
+
expect(n.find("/iq/ns:query[@node='/']", :ns => Blather::Stanza::DiscoItems.registered_ns)).not_to be_empty
|
75
|
+
expect(n.to).to eq(Blather::JID.new(host))
|
76
|
+
expect(n.type).to eq(:get)
|
77
77
|
end
|
78
78
|
@pubsub.nodes nil, host
|
79
79
|
end
|
80
80
|
|
81
81
|
it 'requests nodes under a specified path' do
|
82
82
|
@client.expects(:write_with_handler).with do |n|
|
83
|
-
n.
|
84
|
-
n.find("/iq/ns:query[@node='/path/to/nodes']", :ns => Blather::Stanza::DiscoItems.registered_ns).
|
85
|
-
n.to.
|
86
|
-
n.type.
|
83
|
+
expect(n).to be_instance_of Blather::Stanza::DiscoItems
|
84
|
+
expect(n.find("/iq/ns:query[@node='/path/to/nodes']", :ns => Blather::Stanza::DiscoItems.registered_ns)).not_to be_empty
|
85
|
+
expect(n.to).to eq(Blather::JID.new(@host))
|
86
|
+
expect(n.type).to eq(:get)
|
87
87
|
end
|
88
88
|
@pubsub.nodes '/path/to/nodes'
|
89
89
|
end
|
90
90
|
|
91
91
|
it 'requests information on a node' do
|
92
92
|
@client.expects(:write_with_handler).with do |n|
|
93
|
-
n.
|
94
|
-
n.find("/iq/ns:query[@node='/path/to/node']", :ns => Blather::Stanza::DiscoInfo.registered_ns).
|
95
|
-
n.to.
|
96
|
-
n.type.
|
93
|
+
expect(n).to be_instance_of Blather::Stanza::DiscoInfo
|
94
|
+
expect(n.find("/iq/ns:query[@node='/path/to/node']", :ns => Blather::Stanza::DiscoInfo.registered_ns)).not_to be_empty
|
95
|
+
expect(n.to).to eq(Blather::JID.new(@host))
|
96
|
+
expect(n.type).to eq(:get)
|
97
97
|
end
|
98
98
|
@pubsub.node '/path/to/node'
|
99
99
|
end
|
100
100
|
|
101
101
|
it 'requests all items from a node' do
|
102
102
|
@client.expects(:write_with_handler).with do |n|
|
103
|
-
n.
|
104
|
-
n.find("/iq/ns:pubsub/ns:items[@node='/path/to/node']", :ns => Blather::Stanza::PubSub.registered_ns).
|
105
|
-
n.to.
|
106
|
-
n.type.
|
103
|
+
expect(n).to be_instance_of Blather::Stanza::PubSub::Items
|
104
|
+
expect(n.find("/iq/ns:pubsub/ns:items[@node='/path/to/node']", :ns => Blather::Stanza::PubSub.registered_ns)).not_to be_empty
|
105
|
+
expect(n.to).to eq(Blather::JID.new(@host))
|
106
|
+
expect(n.type).to eq(:get)
|
107
107
|
end
|
108
108
|
@pubsub.items '/path/to/node'
|
109
109
|
end
|
110
110
|
|
111
111
|
it 'requests specific items from a node' do
|
112
112
|
@client.expects(:write_with_handler).with do |n|
|
113
|
-
n.
|
114
|
-
n.find("/iq/ns:pubsub/ns:items[@node='/path/to/node'][ns:item[@id='item1']][ns:item[@id='item2']]", :ns => Blather::Stanza::PubSub.registered_ns).
|
115
|
-
n.to.
|
116
|
-
n.type.
|
113
|
+
expect(n).to be_instance_of Blather::Stanza::PubSub::Items
|
114
|
+
expect(n.find("/iq/ns:pubsub/ns:items[@node='/path/to/node'][ns:item[@id='item1']][ns:item[@id='item2']]", :ns => Blather::Stanza::PubSub.registered_ns)).not_to be_empty
|
115
|
+
expect(n.to).to eq(Blather::JID.new(@host))
|
116
|
+
expect(n.type).to eq(:get)
|
117
117
|
end
|
118
118
|
@pubsub.items '/path/to/node', %w[item1 item2]
|
119
119
|
end
|
120
120
|
|
121
121
|
it 'requests some items from a node' do
|
122
122
|
@client.expects(:write_with_handler).with do |n|
|
123
|
-
n.
|
124
|
-
n.find("/iq/ns:pubsub/ns:items[@node='/path/to/node' and @max_items='2']", :ns => Blather::Stanza::PubSub.registered_ns).
|
125
|
-
n.to.
|
126
|
-
n.type.
|
123
|
+
expect(n).to be_instance_of Blather::Stanza::PubSub::Items
|
124
|
+
expect(n.find("/iq/ns:pubsub/ns:items[@node='/path/to/node' and @max_items='2']", :ns => Blather::Stanza::PubSub.registered_ns)).not_to be_empty
|
125
|
+
expect(n.to).to eq(Blather::JID.new(@host))
|
126
|
+
expect(n.type).to eq(:get)
|
127
127
|
end
|
128
128
|
@pubsub.items '/path/to/node', nil, 2
|
129
129
|
end
|
130
130
|
|
131
131
|
it 'can publish items to a node with a hash' do
|
132
132
|
@client.expects(:write_with_handler).with do |n|
|
133
|
-
n.
|
134
|
-
n.find("/iq[@type='set']/ns:pubsub/ns:publish[@node='/path/to/node' and ns:item[@id='id1' and .='payload1'] and ns:item[@id='id2' and .='payload2']]", :ns => Blather::Stanza::PubSub.registered_ns).
|
135
|
-
n.to.
|
136
|
-
n.type.
|
133
|
+
expect(n).to be_instance_of Blather::Stanza::PubSub::Publish
|
134
|
+
expect(n.find("/iq[@type='set']/ns:pubsub/ns:publish[@node='/path/to/node' and ns:item[@id='id1' and .='payload1'] and ns:item[@id='id2' and .='payload2']]", :ns => Blather::Stanza::PubSub.registered_ns)).not_to be_empty
|
135
|
+
expect(n.to).to eq(Blather::JID.new(@host))
|
136
|
+
expect(n.type).to eq(:set)
|
137
137
|
end
|
138
138
|
@pubsub.publish '/path/to/node', {'id1' => 'payload1', 'id2' => 'payload2'}
|
139
139
|
end
|
140
140
|
|
141
141
|
it 'can publish items to a node with an array' do
|
142
142
|
@client.expects(:write_with_handler).with do |n|
|
143
|
-
n.
|
144
|
-
n.find("/iq[@type='set']/ns:pubsub/ns:publish[@node='/path/to/node' and ns:item[.='payload1'] and ns:item[.='payload2']]", :ns => Blather::Stanza::PubSub.registered_ns).
|
145
|
-
n.to.
|
146
|
-
n.type.
|
143
|
+
expect(n).to be_instance_of Blather::Stanza::PubSub::Publish
|
144
|
+
expect(n.find("/iq[@type='set']/ns:pubsub/ns:publish[@node='/path/to/node' and ns:item[.='payload1'] and ns:item[.='payload2']]", :ns => Blather::Stanza::PubSub.registered_ns)).not_to be_empty
|
145
|
+
expect(n.to).to eq(Blather::JID.new(@host))
|
146
|
+
expect(n.type).to eq(:set)
|
147
147
|
end
|
148
148
|
@pubsub.publish '/path/to/node', %w[payload1 payload2]
|
149
149
|
end
|
150
150
|
|
151
151
|
it 'can publish items to a node with a string' do
|
152
152
|
@client.expects(:write_with_handler).with do |n|
|
153
|
-
n.
|
154
|
-
n.find("/iq[@type='set']/ns:pubsub/ns:publish[@node='/path/to/node' and ns:item[.='payload']]", :ns => Blather::Stanza::PubSub.registered_ns).
|
155
|
-
n.to.
|
156
|
-
n.type.
|
153
|
+
expect(n).to be_instance_of Blather::Stanza::PubSub::Publish
|
154
|
+
expect(n.find("/iq[@type='set']/ns:pubsub/ns:publish[@node='/path/to/node' and ns:item[.='payload']]", :ns => Blather::Stanza::PubSub.registered_ns)).not_to be_empty
|
155
|
+
expect(n.to).to eq(Blather::JID.new(@host))
|
156
|
+
expect(n.type).to eq(:set)
|
157
157
|
end
|
158
158
|
@pubsub.publish '/path/to/node', 'payload'
|
159
159
|
end
|
160
160
|
|
161
161
|
it 'can retract an item with an array' do
|
162
162
|
@client.expects(:write_with_handler).with do |n|
|
163
|
-
n.
|
164
|
-
n.find("/iq[@type='set']/ns:pubsub/ns:retract[@node='/path/to/node' and ns:item[@id='id1'] and ns:item[@id='id2']]", :ns => Blather::Stanza::PubSub.registered_ns).
|
165
|
-
n.to.
|
166
|
-
n.type.
|
163
|
+
expect(n).to be_instance_of Blather::Stanza::PubSub::Retract
|
164
|
+
expect(n.find("/iq[@type='set']/ns:pubsub/ns:retract[@node='/path/to/node' and ns:item[@id='id1'] and ns:item[@id='id2']]", :ns => Blather::Stanza::PubSub.registered_ns)).not_to be_empty
|
165
|
+
expect(n.to).to eq(Blather::JID.new(@host))
|
166
|
+
expect(n.type).to eq(:set)
|
167
167
|
end
|
168
168
|
@pubsub.retract '/path/to/node', %w[id1 id2]
|
169
169
|
end
|
170
170
|
|
171
171
|
it 'can retract an item with a string' do
|
172
172
|
@client.expects(:write_with_handler).with do |n|
|
173
|
-
n.
|
174
|
-
n.find("/iq[@type='set']/ns:pubsub/ns:retract[@node='/path/to/node' and ns:item[@id='id1']]", :ns => Blather::Stanza::PubSub.registered_ns).
|
175
|
-
n.to.
|
176
|
-
n.type.
|
173
|
+
expect(n).to be_instance_of Blather::Stanza::PubSub::Retract
|
174
|
+
expect(n.find("/iq[@type='set']/ns:pubsub/ns:retract[@node='/path/to/node' and ns:item[@id='id1']]", :ns => Blather::Stanza::PubSub.registered_ns)).not_to be_empty
|
175
|
+
expect(n.to).to eq(Blather::JID.new(@host))
|
176
|
+
expect(n.type).to eq(:set)
|
177
177
|
end
|
178
178
|
@pubsub.retract '/path/to/node', 'id1'
|
179
179
|
end
|
180
180
|
|
181
181
|
it 'can subscribe to a node with the default jid' do
|
182
182
|
@client.expects(:write_with_handler).with do |n|
|
183
|
-
n.
|
184
|
-
n.find("/iq[@type='set']/ns:pubsub/ns:subscribe[@node='/path/to/node' and @jid='#{@client.jid.stripped}']", :ns => Blather::Stanza::PubSub.registered_ns).
|
185
|
-
n.to.
|
186
|
-
n.type.
|
183
|
+
expect(n).to be_instance_of Blather::Stanza::PubSub::Subscribe
|
184
|
+
expect(n.find("/iq[@type='set']/ns:pubsub/ns:subscribe[@node='/path/to/node' and @jid='#{@client.jid.stripped}']", :ns => Blather::Stanza::PubSub.registered_ns)).not_to be_empty
|
185
|
+
expect(n.to).to eq(Blather::JID.new(@host))
|
186
|
+
expect(n.type).to eq(:set)
|
187
187
|
end
|
188
188
|
@pubsub.subscribe '/path/to/node'
|
189
189
|
end
|
190
190
|
|
191
191
|
it 'can subscribe to a node with a specified jid as a string' do
|
192
192
|
@client.expects(:write_with_handler).with do |n|
|
193
|
-
n.
|
194
|
-
n.find("/iq[@type='set']/ns:pubsub/ns:subscribe[@node='/path/to/node' and @jid='jid@d/r']", :ns => Blather::Stanza::PubSub.registered_ns).
|
195
|
-
n.to.
|
196
|
-
n.type.
|
193
|
+
expect(n).to be_instance_of Blather::Stanza::PubSub::Subscribe
|
194
|
+
expect(n.find("/iq[@type='set']/ns:pubsub/ns:subscribe[@node='/path/to/node' and @jid='jid@d/r']", :ns => Blather::Stanza::PubSub.registered_ns)).not_to be_empty
|
195
|
+
expect(n.to).to eq(Blather::JID.new(@host))
|
196
|
+
expect(n.type).to eq(:set)
|
197
197
|
end
|
198
198
|
@pubsub.subscribe '/path/to/node', 'jid@d/r'
|
199
199
|
end
|
200
200
|
|
201
201
|
it 'can subscribe to a node with a specified jid as a Blather::JID' do
|
202
202
|
@client.expects(:write_with_handler).with do |n|
|
203
|
-
n.
|
204
|
-
n.find("/iq[@type='set']/ns:pubsub/ns:subscribe[@node='/path/to/node' and @jid='jid@d/r']", :ns => Blather::Stanza::PubSub.registered_ns).
|
205
|
-
n.to.
|
206
|
-
n.type.
|
203
|
+
expect(n).to be_instance_of Blather::Stanza::PubSub::Subscribe
|
204
|
+
expect(n.find("/iq[@type='set']/ns:pubsub/ns:subscribe[@node='/path/to/node' and @jid='jid@d/r']", :ns => Blather::Stanza::PubSub.registered_ns)).not_to be_empty
|
205
|
+
expect(n.to).to eq(Blather::JID.new(@host))
|
206
|
+
expect(n.type).to eq(:set)
|
207
207
|
end
|
208
208
|
@pubsub.subscribe '/path/to/node', Blather::JID.new('jid@d/r')
|
209
209
|
end
|
210
210
|
|
211
211
|
it 'can unsubscribe to a node with the default jid' do
|
212
212
|
@client.expects(:write_with_handler).with do |n|
|
213
|
-
n.
|
214
|
-
n.find("/iq[@type='set']/ns:pubsub/ns:unsubscribe[@node='/path/to/node' and @jid='#{@client.jid.stripped}']", :ns => Blather::Stanza::PubSub.registered_ns).
|
215
|
-
n.to.
|
216
|
-
n.type.
|
213
|
+
expect(n).to be_instance_of Blather::Stanza::PubSub::Unsubscribe
|
214
|
+
expect(n.find("/iq[@type='set']/ns:pubsub/ns:unsubscribe[@node='/path/to/node' and @jid='#{@client.jid.stripped}']", :ns => Blather::Stanza::PubSub.registered_ns)).not_to be_empty
|
215
|
+
expect(n.to).to eq(Blather::JID.new(@host))
|
216
|
+
expect(n.type).to eq(:set)
|
217
217
|
end
|
218
218
|
@pubsub.unsubscribe '/path/to/node'
|
219
219
|
end
|
220
220
|
|
221
221
|
it 'can unsubscribe to a node with a specified jid as a string' do
|
222
222
|
@client.expects(:write_with_handler).with do |n|
|
223
|
-
n.
|
224
|
-
n.find("/iq[@type='set']/ns:pubsub/ns:unsubscribe[@node='/path/to/node' and @jid='jid@d/r']", :ns => Blather::Stanza::PubSub.registered_ns).
|
225
|
-
n.to.
|
226
|
-
n.type.
|
223
|
+
expect(n).to be_instance_of Blather::Stanza::PubSub::Unsubscribe
|
224
|
+
expect(n.find("/iq[@type='set']/ns:pubsub/ns:unsubscribe[@node='/path/to/node' and @jid='jid@d/r']", :ns => Blather::Stanza::PubSub.registered_ns)).not_to be_empty
|
225
|
+
expect(n.to).to eq(Blather::JID.new(@host))
|
226
|
+
expect(n.type).to eq(:set)
|
227
227
|
end
|
228
228
|
@pubsub.unsubscribe '/path/to/node', 'jid@d/r'
|
229
229
|
end
|
230
230
|
|
231
231
|
it 'can unsubscribe to a node with a specified jid as a Blather::JID' do
|
232
232
|
@client.expects(:write_with_handler).with do |n|
|
233
|
-
n.
|
234
|
-
n.find("/iq[@type='set']/ns:pubsub/ns:unsubscribe[@node='/path/to/node' and @jid='jid@d/r']", :ns => Blather::Stanza::PubSub.registered_ns).
|
235
|
-
n.to.
|
236
|
-
n.type.
|
233
|
+
expect(n).to be_instance_of Blather::Stanza::PubSub::Unsubscribe
|
234
|
+
expect(n.find("/iq[@type='set']/ns:pubsub/ns:unsubscribe[@node='/path/to/node' and @jid='jid@d/r']", :ns => Blather::Stanza::PubSub.registered_ns)).not_to be_empty
|
235
|
+
expect(n.to).to eq(Blather::JID.new(@host))
|
236
|
+
expect(n.type).to eq(:set)
|
237
237
|
end
|
238
238
|
@pubsub.unsubscribe '/path/to/node', Blather::JID.new('jid@d/r')
|
239
239
|
end
|
240
240
|
|
241
241
|
it 'can unsubscribe with a particular subscription id' do
|
242
242
|
@client.expects(:write_with_handler).with do |n|
|
243
|
-
n.
|
244
|
-
n.find("/iq[@type='set']/ns:pubsub/ns:unsubscribe[@node='/path/to/node' and @jid='jid@d/r' and @subid='subid']", :ns => Blather::Stanza::PubSub.registered_ns).
|
245
|
-
n.subid.
|
246
|
-
n.type.
|
243
|
+
expect(n).to be_instance_of Blather::Stanza::PubSub::Unsubscribe
|
244
|
+
expect(n.find("/iq[@type='set']/ns:pubsub/ns:unsubscribe[@node='/path/to/node' and @jid='jid@d/r' and @subid='subid']", :ns => Blather::Stanza::PubSub.registered_ns)).not_to be_empty
|
245
|
+
expect(n.subid).to eq('subid')
|
246
|
+
expect(n.type).to eq(:set)
|
247
247
|
end
|
248
248
|
@pubsub.unsubscribe '/path/to/node', 'jid@d/r', 'subid'
|
249
249
|
end
|
250
250
|
|
251
251
|
it 'can purge a node' do
|
252
252
|
@client.expects(:write_with_handler).with do |n|
|
253
|
-
n.
|
254
|
-
n.find("/iq[@type='set']/ns:pubsub/ns:purge[@node='/path/to/node']", :ns => Blather::Stanza::PubSubOwner.registered_ns).
|
255
|
-
n.to.
|
256
|
-
n.type.
|
253
|
+
expect(n).to be_instance_of Blather::Stanza::PubSubOwner::Purge
|
254
|
+
expect(n.find("/iq[@type='set']/ns:pubsub/ns:purge[@node='/path/to/node']", :ns => Blather::Stanza::PubSubOwner.registered_ns)).not_to be_empty
|
255
|
+
expect(n.to).to eq(Blather::JID.new(@host))
|
256
|
+
expect(n.type).to eq(:set)
|
257
257
|
end
|
258
258
|
@pubsub.purge '/path/to/node'
|
259
259
|
end
|
260
260
|
|
261
261
|
it 'can create a node' do
|
262
262
|
@client.expects(:write_with_handler).with do |n|
|
263
|
-
n.
|
264
|
-
n.find("/iq[@type='set']/ns:pubsub/ns:create[@node='/path/to/node']", :ns => Blather::Stanza::PubSub.registered_ns).
|
265
|
-
n.to.
|
266
|
-
n.type.
|
263
|
+
expect(n).to be_instance_of Blather::Stanza::PubSub::Create
|
264
|
+
expect(n.find("/iq[@type='set']/ns:pubsub/ns:create[@node='/path/to/node']", :ns => Blather::Stanza::PubSub.registered_ns)).not_to be_empty
|
265
|
+
expect(n.to).to eq(Blather::JID.new(@host))
|
266
|
+
expect(n.type).to eq(:set)
|
267
267
|
end
|
268
268
|
@pubsub.create '/path/to/node'
|
269
269
|
end
|
@@ -279,21 +279,21 @@ describe Blather::DSL::PubSub do
|
|
279
279
|
{ :var => "pubsub#publish_model", :value => "open" }]
|
280
280
|
})
|
281
281
|
@client.expects(:write_with_handler).with do |n|
|
282
|
-
n.
|
283
|
-
n.find("/iq[@type='set']/ns:pubsub/ns:create[@node='/path/to/node']", :ns => Blather::Stanza::PubSub.registered_ns).
|
284
|
-
n.to.
|
285
|
-
n.type.
|
286
|
-
n.configure_node.
|
282
|
+
expect(n).to be_instance_of Blather::Stanza::PubSub::Create
|
283
|
+
expect(n.find("/iq[@type='set']/ns:pubsub/ns:create[@node='/path/to/node']", :ns => Blather::Stanza::PubSub.registered_ns)).not_to be_empty
|
284
|
+
expect(n.to).to eq(Blather::JID.new(@host))
|
285
|
+
expect(n.type).to eq(:set)
|
286
|
+
expect(n.configure_node).to eq(pubsub_configure)
|
287
287
|
end
|
288
288
|
@pubsub.create '/path/to/node', nil, pubsub_configure
|
289
289
|
end
|
290
290
|
|
291
291
|
it 'can delete a node' do
|
292
292
|
@client.expects(:write_with_handler).with do |n|
|
293
|
-
n.
|
294
|
-
n.find("/iq[@type='set']/ns:pubsub/ns:delete[@node='/path/to/node']", :ns => Blather::Stanza::PubSubOwner.registered_ns).
|
295
|
-
n.to.
|
296
|
-
n.type.
|
293
|
+
expect(n).to be_instance_of Blather::Stanza::PubSubOwner::Delete
|
294
|
+
expect(n.find("/iq[@type='set']/ns:pubsub/ns:delete[@node='/path/to/node']", :ns => Blather::Stanza::PubSubOwner.registered_ns)).not_to be_empty
|
295
|
+
expect(n.to).to eq(Blather::JID.new(@host))
|
296
|
+
expect(n.type).to eq(:set)
|
297
297
|
end
|
298
298
|
@pubsub.delete '/path/to/node'
|
299
299
|
end
|
@@ -309,7 +309,7 @@ describe 'Blather::DSL::PubSub callbacks' do
|
|
309
309
|
it 'returns a list of affiliations when requesting affiliations' do
|
310
310
|
affiliations = Blather::XMPPNode.parse(affiliations_xml)
|
311
311
|
response = mock()
|
312
|
-
response.expects(:call).with { |n| n.
|
312
|
+
response.expects(:call).with { |n| expect(n).to eq(affiliations.list) }
|
313
313
|
@client.stubs(:write).with do |n|
|
314
314
|
affiliations.id = n.id
|
315
315
|
@client.receive_data affiliations
|
@@ -321,7 +321,7 @@ describe 'Blather::DSL::PubSub callbacks' do
|
|
321
321
|
it 'returns a list of subscriptions when requesting subscriptions' do
|
322
322
|
subscriptions = Blather::XMPPNode.parse(subscriptions_xml)
|
323
323
|
response = mock()
|
324
|
-
response.expects(:call).with { |n| n.
|
324
|
+
response.expects(:call).with { |n| expect(n).to eq(subscriptions.list) }
|
325
325
|
@client.stubs(:write).with do |n|
|
326
326
|
subscriptions.id = n.id
|
327
327
|
@client.receive_data subscriptions
|
@@ -347,7 +347,7 @@ describe 'Blather::DSL::PubSub callbacks' do
|
|
347
347
|
</iq>
|
348
348
|
NODES
|
349
349
|
response = mock()
|
350
|
-
response.expects(:call).with { |n| n.
|
350
|
+
response.expects(:call).with { |n| expect(n).to eq(nodes.items) }
|
351
351
|
@client.stubs(:write).with do |n|
|
352
352
|
nodes.id = n.id
|
353
353
|
@client.receive_data nodes
|
@@ -369,7 +369,7 @@ describe 'Blather::DSL::PubSub callbacks' do
|
|
369
369
|
</iq>
|
370
370
|
NODES
|
371
371
|
response = mock()
|
372
|
-
response.expects(:call).with { |n| n.
|
372
|
+
response.expects(:call).with { |n| expect(n).to eq(node) }
|
373
373
|
@client.stubs(:write).with do |n|
|
374
374
|
node.id = n.id
|
375
375
|
@client.receive_data node
|
@@ -381,7 +381,7 @@ describe 'Blather::DSL::PubSub callbacks' do
|
|
381
381
|
it 'returns a set of items when requesting items' do
|
382
382
|
items = Blather::XMPPNode.parse(items_all_nodes_xml)
|
383
383
|
response = mock()
|
384
|
-
response.expects(:call).with { |n| n.map{|i|i.to_s}.
|
384
|
+
response.expects(:call).with { |n| expect(n.map{|i|i.to_s}).to eq(items.items.map{|i|i.to_s}) }
|
385
385
|
@client.stubs(:write).with do |n|
|
386
386
|
items.id = n.id
|
387
387
|
@client.receive_data items
|
@@ -393,7 +393,7 @@ describe 'Blather::DSL::PubSub callbacks' do
|
|
393
393
|
it 'returns aa subscription node when subscribing' do
|
394
394
|
subscription = Blather::XMPPNode.parse(subscription_xml)
|
395
395
|
response = mock()
|
396
|
-
response.expects(:call).with { |n| n.
|
396
|
+
response.expects(:call).with { |n| expect(n).to eq(subscription) }
|
397
397
|
@client.stubs(:write).with do |n|
|
398
398
|
subscription.id = n.id
|
399
399
|
@client.receive_data subscription
|
@@ -405,7 +405,7 @@ describe 'Blather::DSL::PubSub callbacks' do
|
|
405
405
|
it 'returns aa unsubscribe node when unsubscribing' do
|
406
406
|
unsubscribe = Blather::XMPPNode.parse(unsubscribe_xml)
|
407
407
|
response = mock()
|
408
|
-
response.expects(:call).with { |n| n.
|
408
|
+
response.expects(:call).with { |n| expect(n).to eq(unsubscribe) }
|
409
409
|
@client.stubs(:write).with do |n|
|
410
410
|
unsubscribe.id = n.id
|
411
411
|
@client.receive_data unsubscribe
|
@@ -428,7 +428,7 @@ describe 'Blather::DSL::PubSub callbacks' do
|
|
428
428
|
</iq>
|
429
429
|
NODE
|
430
430
|
response = mock()
|
431
|
-
response.expects(:call).with { |n| n.
|
431
|
+
response.expects(:call).with { |n| expect(n).to eq(result) }
|
432
432
|
@client.stubs(:write).with do |n|
|
433
433
|
result.id = n.id
|
434
434
|
@client.receive_data result
|
@@ -449,7 +449,7 @@ describe 'Blather::DSL::PubSub callbacks' do
|
|
449
449
|
</iq>
|
450
450
|
NODE
|
451
451
|
response = mock()
|
452
|
-
response.expects(:call).with { |n| n.
|
452
|
+
response.expects(:call).with { |n| expect(n).to eq(result) }
|
453
453
|
@client.stubs(:write).with do |n|
|
454
454
|
result.id = n.id
|
455
455
|
@client.receive_data result
|
@@ -465,7 +465,7 @@ describe 'Blather::DSL::PubSub callbacks' do
|
|
465
465
|
id='purge1'/>
|
466
466
|
NODE
|
467
467
|
response = mock()
|
468
|
-
response.expects(:call).with { |n| n.
|
468
|
+
response.expects(:call).with { |n| expect(n).to eq(result) }
|
469
469
|
@client.stubs(:write).with do |n|
|
470
470
|
result.id = n.id
|
471
471
|
@client.receive_data result
|
@@ -481,7 +481,7 @@ describe 'Blather::DSL::PubSub callbacks' do
|
|
481
481
|
id='delete1'/>
|
482
482
|
NODE
|
483
483
|
response = mock()
|
484
|
-
response.expects(:call).with { |n| n.
|
484
|
+
response.expects(:call).with { |n| expect(n).to eq(result) }
|
485
485
|
@client.stubs(:write).with do |n|
|
486
486
|
result.id = n.id
|
487
487
|
@client.receive_data result
|