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
@@ -25,75 +25,74 @@ class Presence
|
|
25
25
|
node
|
26
26
|
end
|
27
27
|
|
28
|
-
|
29
|
-
def inherit(node)
|
30
|
-
inherit_attrs node.attributes
|
31
|
-
self
|
32
|
-
end
|
28
|
+
module InstanceMethods
|
33
29
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
30
|
+
# Set the to value on the stanza
|
31
|
+
#
|
32
|
+
# @param [Blather::JID, #to_s] to a JID to subscribe to
|
33
|
+
def to=(to)
|
34
|
+
super JID.new(to).stripped
|
35
|
+
end
|
40
36
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
37
|
+
# Transform the stanza into an approve stanza
|
38
|
+
# makes approving requests simple
|
39
|
+
#
|
40
|
+
# @example approve an incoming request
|
41
|
+
# subscription(:request?) { |s| write_to_stream s.approve! }
|
42
|
+
# @return [self]
|
43
|
+
def approve!
|
44
|
+
self.type = :subscribed
|
45
|
+
reply_if_needed!
|
46
|
+
end
|
51
47
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
48
|
+
# Transform the stanza into a refuse stanza
|
49
|
+
# makes refusing requests simple
|
50
|
+
#
|
51
|
+
# @example refuse an incoming request
|
52
|
+
# subscription(:request?) { |s| write_to_stream s.refuse! }
|
53
|
+
# @return [self]
|
54
|
+
def refuse!
|
55
|
+
self.type = :unsubscribed
|
56
|
+
reply_if_needed!
|
57
|
+
end
|
62
58
|
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
59
|
+
# Transform the stanza into an unsubscribe stanza
|
60
|
+
# makes unsubscribing simple
|
61
|
+
#
|
62
|
+
# @return [self]
|
63
|
+
def unsubscribe!
|
64
|
+
self.type = :unsubscribe
|
65
|
+
reply_if_needed!
|
66
|
+
end
|
71
67
|
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
68
|
+
# Transform the stanza into a cancel stanza
|
69
|
+
# makes canceling simple
|
70
|
+
#
|
71
|
+
# @return [self]
|
72
|
+
def cancel!
|
73
|
+
self.type = :unsubscribed
|
74
|
+
reply_if_needed!
|
75
|
+
end
|
80
76
|
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
77
|
+
# Transform the stanza into a request stanza
|
78
|
+
# makes requests simple
|
79
|
+
#
|
80
|
+
# @return [self]
|
81
|
+
def request!
|
82
|
+
self.type = :subscribe
|
83
|
+
reply_if_needed!
|
84
|
+
end
|
89
85
|
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
86
|
+
# Check if the stanza is a request
|
87
|
+
#
|
88
|
+
# @return [true, false]
|
89
|
+
def request?
|
90
|
+
self.type == :subscribe
|
91
|
+
end
|
95
92
|
end
|
96
93
|
|
94
|
+
include InstanceMethods
|
95
|
+
|
97
96
|
end #Subscription
|
98
97
|
|
99
98
|
end #Presence
|
data/lib/blather/stream.rb
CHANGED
@@ -161,8 +161,6 @@ module Blather
|
|
161
161
|
# Called by EM with data from the wire
|
162
162
|
# @private
|
163
163
|
def receive_data(data)
|
164
|
-
Blather.log "\n#{'-'*30}\n"
|
165
|
-
Blather.log "STREAM IN: #{data}"
|
166
164
|
@parser << data
|
167
165
|
|
168
166
|
rescue ParseError => e
|
@@ -237,7 +235,7 @@ module Blather
|
|
237
235
|
# Ensure the JID gets attached to the client
|
238
236
|
# @private
|
239
237
|
def jid=(new_jid)
|
240
|
-
Blather.log "
|
238
|
+
Blather.log "USING JID: #{new_jid}"
|
241
239
|
@jid = JID.new new_jid
|
242
240
|
end
|
243
241
|
|
data/lib/blather/version.rb
CHANGED
data/lib/blather/xmpp_node.rb
CHANGED
@@ -40,16 +40,24 @@ module Blather
|
|
40
40
|
# elements of the XML::Node
|
41
41
|
# @param [XML::Node] node the node to import
|
42
42
|
# @return the appropriate object based on the node name and namespace
|
43
|
-
def self.import(node)
|
43
|
+
def self.import(node, *decorators)
|
44
44
|
ns = (node.namespace.href if node.namespace)
|
45
45
|
klass = class_from_registration(node.element_name, ns)
|
46
46
|
if klass && klass != self
|
47
|
-
klass.import(node)
|
47
|
+
klass.import(node, *decorators)
|
48
48
|
else
|
49
|
-
new(node.element_name).inherit(node)
|
49
|
+
new(node.element_name).decorate(*decorators).inherit(node)
|
50
50
|
end
|
51
51
|
end
|
52
52
|
|
53
|
+
# Parse a string as XML and import to the appropriate class
|
54
|
+
#
|
55
|
+
# @param [String] string the string to parse
|
56
|
+
# @return the appropriate object based on the node name and namespace
|
57
|
+
def self.parse(string)
|
58
|
+
import Nokogiri::XML(string).root
|
59
|
+
end
|
60
|
+
|
53
61
|
# Create a new Node object
|
54
62
|
#
|
55
63
|
# @param [String, nil] name the element name
|
@@ -60,6 +68,19 @@ module Blather
|
|
60
68
|
super name, doc, BASE_NAMES.include?(name.to_s) ? nil : self.registered_ns
|
61
69
|
end
|
62
70
|
|
71
|
+
def self.decorator_modules
|
72
|
+
[self::InstanceMethods]
|
73
|
+
end
|
74
|
+
|
75
|
+
def decorate(*decorators)
|
76
|
+
decorators.each do |decorator|
|
77
|
+
decorator.decorator_modules.each do |mod|
|
78
|
+
extend mod
|
79
|
+
end
|
80
|
+
end
|
81
|
+
self
|
82
|
+
end
|
83
|
+
|
63
84
|
# Turn the object into a proper stanza
|
64
85
|
#
|
65
86
|
# @return a stanza object
|
@@ -11,41 +11,41 @@ describe Blather::Client do
|
|
11
11
|
|
12
12
|
it 'provides a Blather::JID reader' do
|
13
13
|
@client.post_init @stream, @jid
|
14
|
-
@client.
|
15
|
-
@client.jid.
|
14
|
+
@client.should respond_to :jid
|
15
|
+
@client.jid.should == @jid
|
16
16
|
end
|
17
17
|
|
18
18
|
it 'provides a reader for the roster' do
|
19
|
-
@client.
|
20
|
-
@client.roster.
|
19
|
+
@client.should respond_to :roster
|
20
|
+
@client.roster.should be_kind_of Blather::Roster
|
21
21
|
end
|
22
22
|
|
23
23
|
it 'provides a status reader' do
|
24
24
|
@client.post_init @stream, @jid
|
25
|
-
@client.
|
25
|
+
@client.should respond_to :status
|
26
26
|
@client.status = :away
|
27
|
-
@client.status.
|
27
|
+
@client.status.should == :away
|
28
28
|
end
|
29
29
|
|
30
30
|
it 'should have a caps handler' do
|
31
|
-
@client.
|
32
|
-
@client.caps.
|
31
|
+
@client.should respond_to :caps
|
32
|
+
@client.caps.should be_kind_of Blather::Stanza::Capabilities
|
33
33
|
end
|
34
34
|
|
35
35
|
it 'can be setup' do
|
36
|
-
@client.
|
37
|
-
@client.setup('me@me.com', 'pass').
|
36
|
+
@client.should respond_to :setup
|
37
|
+
@client.setup('me@me.com', 'pass').should == @client
|
38
38
|
end
|
39
39
|
|
40
40
|
it 'knows if it has been setup' do
|
41
|
-
@client.
|
42
|
-
@client.setup?.
|
41
|
+
@client.should respond_to :setup?
|
42
|
+
@client.setup?.should == false
|
43
43
|
@client.setup 'me@me.com', 'pass'
|
44
|
-
@client.setup?.
|
44
|
+
@client.setup?.should == true
|
45
45
|
end
|
46
46
|
|
47
47
|
it 'cannot be run before being setup' do
|
48
|
-
lambda { @client.run }.
|
48
|
+
lambda { @client.run }.should raise_error RuntimeError
|
49
49
|
end
|
50
50
|
|
51
51
|
it 'starts up a Component connection when setup without a node' do
|
@@ -63,8 +63,8 @@ describe Blather::Client do
|
|
63
63
|
end
|
64
64
|
|
65
65
|
it 'knows if it is disconnected' do
|
66
|
-
@client.
|
67
|
-
@client.connected?.
|
66
|
+
@client.should respond_to :connected?
|
67
|
+
@client.connected?.should == false
|
68
68
|
end
|
69
69
|
|
70
70
|
it 'knows if it is connected' do
|
@@ -72,13 +72,13 @@ describe Blather::Client do
|
|
72
72
|
stream.expects(:stopped?).returns false
|
73
73
|
@client.setup('me.com', 'secret')
|
74
74
|
@client.post_init stream, Blather::JID.new('me.com')
|
75
|
-
@client.connected?.
|
75
|
+
@client.connected?.should == true
|
76
76
|
end
|
77
77
|
|
78
78
|
describe 'if it has been setup but not connected yet' do
|
79
79
|
it 'should consider itself disconnected' do
|
80
80
|
@client.setup('me.com', 'secret')
|
81
|
-
@client.connected?.
|
81
|
+
@client.connected?.should == false
|
82
82
|
end
|
83
83
|
end
|
84
84
|
|
@@ -151,7 +151,7 @@ describe Blather::Client do
|
|
151
151
|
response.expects(:call)
|
152
152
|
@client.expects(:write).with do |s|
|
153
153
|
@client.receive_data stanza
|
154
|
-
s.
|
154
|
+
s.should == stanza
|
155
155
|
end
|
156
156
|
@client.write_with_handler(stanza) { |_| response.call }
|
157
157
|
end
|
@@ -242,24 +242,24 @@ describe 'Blather::Client#status=' do
|
|
242
242
|
|
243
243
|
it 'updates the state when not sending to a Blather::JID' do
|
244
244
|
@stream.stubs(:write)
|
245
|
-
@client.status.
|
245
|
+
@client.status.should_not equal :away
|
246
246
|
@client.status = :away, 'message'
|
247
|
-
@client.status.
|
247
|
+
@client.status.should == :away
|
248
248
|
end
|
249
249
|
|
250
250
|
it 'does not update the state when sending to a Blather::JID' do
|
251
251
|
@stream.stubs(:write)
|
252
|
-
@client.status.
|
252
|
+
@client.status.should_not equal :away
|
253
253
|
@client.status = :away, 'message', 'me@me.com'
|
254
|
-
@client.status.
|
254
|
+
@client.status.should_not equal :away
|
255
255
|
end
|
256
256
|
|
257
257
|
it 'writes the new status to the stream' do
|
258
258
|
Blather::Stanza::Presence::Status.stubs(:next_id).returns 0
|
259
259
|
status = [:away, 'message']
|
260
260
|
@stream.expects(:send).with do |s|
|
261
|
-
s.
|
262
|
-
s.to_s.
|
261
|
+
s.should be_kind_of Blather::Stanza::Presence::Status
|
262
|
+
s.to_s.should == Blather::Stanza::Presence::Status.new(*status).to_s
|
263
263
|
end
|
264
264
|
@client.status = status
|
265
265
|
end
|
@@ -275,7 +275,7 @@ describe 'Blather::Client default handlers' do
|
|
275
275
|
|
276
276
|
it 're-raises errors' do
|
277
277
|
err = Blather::BlatherError.new
|
278
|
-
lambda { @client.receive_data err }.
|
278
|
+
lambda { @client.receive_data err }.should raise_error Blather::BlatherError
|
279
279
|
end
|
280
280
|
|
281
281
|
# it 'responds to iq:get with a "service-unavailable" error' do
|
@@ -288,21 +288,21 @@ describe 'Blather::Client default handlers' do
|
|
288
288
|
# it 'responds to iq:get with a "service-unavailable" error' do
|
289
289
|
# get = Blather::Stanza::Iq.new :get
|
290
290
|
# err = Blather::StanzaError.new(get, 'service-unavailable', :cancel).to_node
|
291
|
-
# @client.expects(:write).with { |n| n.to_s.
|
291
|
+
# @client.expects(:write).with { |n| n.to_s.should == err.to_s }
|
292
292
|
# @client.receive_data get
|
293
293
|
# end
|
294
294
|
|
295
295
|
# it 'responds to iq:set with a "service-unavailable" error' do
|
296
296
|
# get = Blather::Stanza::Iq.new :set
|
297
297
|
# err = Blather::StanzaError.new(get, 'service-unavailable', :cancel).to_node
|
298
|
-
# @client.expects(:write).with { |n| n.to_s.
|
298
|
+
# @client.expects(:write).with { |n| n.to_s.should == err.to_s }
|
299
299
|
# @client.receive_data get
|
300
300
|
# end
|
301
301
|
|
302
302
|
it 'responds to s2c pings with a pong' do
|
303
303
|
ping = Blather::Stanza::Iq::Ping.new :get
|
304
304
|
pong = ping.reply
|
305
|
-
@client.expects(:write).with { |n| n.to_s.
|
305
|
+
@client.expects(:write).with { |n| n.to_s.should == pong.to_s }
|
306
306
|
@client.receive_data ping
|
307
307
|
end
|
308
308
|
|
@@ -378,7 +378,7 @@ describe 'Blather::Client with a Client stream' do
|
|
378
378
|
end
|
379
379
|
|
380
380
|
it 'sends a request for the roster when post_init is called' do
|
381
|
-
@stream.expects(:send).with { |stanza| stanza.
|
381
|
+
@stream.expects(:send).with { |stanza| stanza.should be_kind_of Blather::Stanza::Iq::Roster }
|
382
382
|
@client.post_init @stream, Blather::JID.new('n@d/r')
|
383
383
|
end
|
384
384
|
|
@@ -402,7 +402,7 @@ describe 'Blather::Client filters' do
|
|
402
402
|
end
|
403
403
|
|
404
404
|
it 'raises an error when an invalid filter type is registered' do
|
405
|
-
lambda { @client.register_filter(:invalid) {} }.
|
405
|
+
lambda { @client.register_filter(:invalid) {} }.should raise_error RuntimeError
|
406
406
|
end
|
407
407
|
|
408
408
|
it 'can be guarded' do
|
@@ -426,11 +426,11 @@ describe 'Blather::Client filters' do
|
|
426
426
|
it 'runs them in order' do
|
427
427
|
stanza = Blather::Stanza::Iq.new
|
428
428
|
count = 0
|
429
|
-
@client.register_filter(:before) { |_| count.
|
430
|
-
@client.register_filter(:before) { |_| count.
|
431
|
-
@client.register_handler(:iq) { |_| count.
|
432
|
-
@client.register_filter(:after) { |_| count.
|
433
|
-
@client.register_filter(:after) { |_| count.
|
429
|
+
@client.register_filter(:before) { |_| count.should == 0; count = 1 }
|
430
|
+
@client.register_filter(:before) { |_| count.should == 1; count = 2 }
|
431
|
+
@client.register_handler(:iq) { |_| count.should == 2; count = 3 }
|
432
|
+
@client.register_filter(:after) { |_| count.should == 3; count = 4 }
|
433
|
+
@client.register_filter(:after) { |_| count.should == 4 }
|
434
434
|
@client.receive_data stanza
|
435
435
|
end
|
436
436
|
|
@@ -581,27 +581,27 @@ describe 'Blather::Client guards' do
|
|
581
581
|
|
582
582
|
it 'can be an xpath and will send the result to the handler' do
|
583
583
|
@response.expects(:call).with do |stanza, xpath|
|
584
|
-
xpath.
|
585
|
-
xpath.
|
586
|
-
stanza.
|
584
|
+
xpath.should be_instance_of Nokogiri::XML::NodeSet
|
585
|
+
xpath.should_not be_empty
|
586
|
+
stanza.should == @stanza
|
587
587
|
end
|
588
588
|
@client.register_handler(:iq, "/iq[@id='#{@stanza.id}']") { |stanza, xpath| @response.call stanza, xpath }
|
589
589
|
@client.receive_data @stanza
|
590
590
|
end
|
591
591
|
|
592
592
|
it 'can be an xpath with namespaces and will send the result to the handler' do
|
593
|
-
@stanza = Blather::Stanza.
|
593
|
+
@stanza = Blather::Stanza.parse('<message><foo xmlns="http://bar.com"></message>')
|
594
594
|
@response.expects(:call).with do |stanza, xpath|
|
595
|
-
xpath.
|
596
|
-
xpath.
|
597
|
-
stanza.
|
595
|
+
xpath.should be_instance_of Nokogiri::XML::NodeSet
|
596
|
+
xpath.should_not be_empty
|
597
|
+
stanza.should == @stanza
|
598
598
|
end
|
599
599
|
@client.register_handler(:message, "/message/bar:foo", :bar => 'http://bar.com') { |stanza, xpath| @response.call stanza, xpath }
|
600
600
|
@client.receive_data @stanza
|
601
601
|
end
|
602
602
|
|
603
603
|
it 'raises an error when a bad guard is tried' do
|
604
|
-
lambda { @client.register_handler(:iq, 0) {} }.
|
604
|
+
lambda { @client.register_handler(:iq, 0) {} }.should raise_error RuntimeError
|
605
605
|
end
|
606
606
|
end
|
607
607
|
|
@@ -615,51 +615,51 @@ describe 'Blather::Client::Caps' do
|
|
615
615
|
end
|
616
616
|
|
617
617
|
it 'must be of type result' do
|
618
|
-
@caps.
|
619
|
-
@caps.type.
|
618
|
+
@caps.should respond_to :type
|
619
|
+
@caps.type.should == :result
|
620
620
|
end
|
621
621
|
|
622
622
|
it 'can have a client node set' do
|
623
|
-
@caps.
|
623
|
+
@caps.should respond_to :node=
|
624
624
|
@caps.node = "somenode"
|
625
625
|
end
|
626
626
|
|
627
627
|
it 'provides a client node reader' do
|
628
|
-
@caps.
|
628
|
+
@caps.should respond_to :node
|
629
629
|
@caps.node = "somenode"
|
630
|
-
@caps.node.
|
630
|
+
@caps.node.should == "somenode##{@caps.ver}"
|
631
631
|
end
|
632
632
|
|
633
633
|
it 'can have identities set' do
|
634
|
-
@caps.
|
634
|
+
@caps.should respond_to :identities=
|
635
635
|
@caps.identities = [{:name => "name", :type => "type", :category => "cat"}]
|
636
636
|
end
|
637
637
|
|
638
638
|
it 'provides an identities reader' do
|
639
|
-
@caps.
|
639
|
+
@caps.should respond_to :identities
|
640
640
|
@caps.identities = [{:name => "name", :type => "type", :category => "cat"}]
|
641
|
-
@caps.identities.
|
641
|
+
@caps.identities.should == [Blather::Stanza::Iq::DiscoInfo::Identity.new({:name => "name", :type => "type", :category => "cat"})]
|
642
642
|
end
|
643
643
|
|
644
644
|
it 'can have features set' do
|
645
|
-
@caps.
|
646
|
-
@caps.features.size.
|
645
|
+
@caps.should respond_to :features=
|
646
|
+
@caps.features.size.should == 0
|
647
647
|
@caps.features = ["feature1"]
|
648
|
-
@caps.features.size.
|
648
|
+
@caps.features.size.should == 1
|
649
649
|
@caps.features += [Blather::Stanza::Iq::DiscoInfo::Feature.new("feature2")]
|
650
|
-
@caps.features.size.
|
650
|
+
@caps.features.size.should == 2
|
651
651
|
@caps.features = nil
|
652
|
-
@caps.features.size.
|
652
|
+
@caps.features.size.should == 0
|
653
653
|
end
|
654
654
|
|
655
655
|
it 'provides a features reader' do
|
656
|
-
@caps.
|
656
|
+
@caps.should respond_to :features
|
657
657
|
@caps.features = %w{feature1 feature2}
|
658
|
-
@caps.features.
|
658
|
+
@caps.features.should == [Blather::Stanza::Iq::DiscoInfo::Feature.new("feature1"), Blather::Stanza::Iq::DiscoInfo::Feature.new("feature2")]
|
659
659
|
end
|
660
660
|
|
661
661
|
it 'provides a client ver reader' do
|
662
|
-
@caps.
|
662
|
+
@caps.should respond_to :ver
|
663
663
|
@caps.node = 'http://code.google.com/p/exodus'
|
664
664
|
@caps.identities = [Blather::Stanza::Iq::DiscoInfo::Identity.new({:name => 'Exodus 0.9.1', :type => 'pc', :category => 'client'})]
|
665
665
|
@caps.features = %w{
|
@@ -668,12 +668,12 @@ describe 'Blather::Client::Caps' do
|
|
668
668
|
http://jabber.org/protocol/disco#items
|
669
669
|
http://jabber.org/protocol/muc
|
670
670
|
}
|
671
|
-
@caps.ver.
|
672
|
-
@caps.node.
|
671
|
+
@caps.ver.should == 'QgayPKawpkPSDYmwT/WM94uAlu0='
|
672
|
+
@caps.node.should == "http://code.google.com/p/exodus#QgayPKawpkPSDYmwT/WM94uAlu0="
|
673
673
|
end
|
674
674
|
|
675
675
|
it 'can construct caps presence correctly' do
|
676
|
-
@caps.
|
676
|
+
@caps.should respond_to :c
|
677
677
|
@caps.node = 'http://code.google.com/p/exodus'
|
678
678
|
@caps.identities = [Blather::Stanza::Iq::DiscoInfo::Identity.new({:name => 'Exodus 0.9.1', :type => 'pc', :category => 'client'})]
|
679
679
|
@caps.features = %w{
|
@@ -682,6 +682,6 @@ describe 'Blather::Client::Caps' do
|
|
682
682
|
http://jabber.org/protocol/disco#items
|
683
683
|
http://jabber.org/protocol/muc
|
684
684
|
}
|
685
|
-
@caps.c.inspect.
|
685
|
+
@caps.c.inspect.should == "<presence>\n <c xmlns=\"http://jabber.org/protocol/caps\" hash=\"sha-1\" node=\"http://code.google.com/p/exodus\" ver=\"QgayPKawpkPSDYmwT/WM94uAlu0=\"/>\n</presence>"
|
686
686
|
end
|
687
687
|
end
|