blather 0.3.0 → 0.3.1
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/README.rdoc +17 -2
- data/Rakefile +1 -1
- data/examples/ping_pong.rb +37 -0
- data/lib/blather.rb +1 -4
- data/lib/blather/client.rb +75 -3
- data/lib/blather/client/client.rb +67 -53
- data/lib/blather/client/dsl.rb +13 -18
- data/lib/blather/stanza/disco/disco_info.rb +0 -12
- data/lib/blather/stanza/disco/disco_items.rb +0 -7
- data/lib/blather/stream.rb +4 -4
- data/lib/blather/stream/component.rb +1 -1
- data/spec/blather/client/client_spec.rb +385 -0
- data/spec/blather/client/dsl_spec.rb +101 -0
- data/spec/blather/stream/client_spec.rb +18 -18
- data/spec/blather/stream/component_spec.rb +3 -3
- data/spec/spec_helper.rb +4 -1
- metadata +4 -6
- data/lib/blather/stanza/pubsub/subscriber.rb +0 -64
- data/spec/blather/client_spec.rb +0 -0
- data/spec/blather/stanza/pubsub/subscriber_spec.rb +0 -70
@@ -1,4 +1,105 @@
|
|
1
1
|
require File.join(File.dirname(__FILE__), *%w[.. .. spec_helper])
|
2
|
+
require 'blather/client/dsl'
|
2
3
|
|
3
4
|
describe 'Blather::DSL' do
|
5
|
+
before do
|
6
|
+
@client = mock()
|
7
|
+
@dsl = class MockDSL; include Blather::DSL; end.new
|
8
|
+
Client.stubs(:new).returns(@client)
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'wraps the setup' do
|
12
|
+
args = ['jid', 'pass', 'host', 0000]
|
13
|
+
@client.expects(:setup).with *args
|
14
|
+
@dsl.setup *args
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'allows host to be nil in setup' do
|
18
|
+
args = ['jid', 'pass']
|
19
|
+
@client.expects(:setup).with *(args + [nil, nil])
|
20
|
+
@dsl.setup *args
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'allows port to be nil in setup' do
|
24
|
+
args = ['jid', 'pass', 'host']
|
25
|
+
@client.expects(:setup).with *(args + [nil])
|
26
|
+
@dsl.setup *args
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'stops when shutdown is called' do
|
30
|
+
@client.expects(:close)
|
31
|
+
@dsl.shutdown
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'sets up handlers' do
|
35
|
+
type = :message
|
36
|
+
guards = [:chat?, {:body => 'exit'}]
|
37
|
+
@client.expects(:register_handler).with type, *guards
|
38
|
+
@dsl.handle type, *guards
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'provides a helper for ready state' do
|
42
|
+
@client.expects(:register_handler).with :ready
|
43
|
+
@dsl.when_ready
|
44
|
+
end
|
45
|
+
|
46
|
+
it 'sets the initial status' do
|
47
|
+
state = :away
|
48
|
+
msg = 'do not disturb'
|
49
|
+
@client.expects(:status=).with [state, msg]
|
50
|
+
@dsl.set_status state, msg
|
51
|
+
end
|
52
|
+
|
53
|
+
it 'provides a roster accessor' do
|
54
|
+
@client.expects :roster
|
55
|
+
@dsl.my_roster
|
56
|
+
end
|
57
|
+
|
58
|
+
it 'provides a writer' do
|
59
|
+
stanza = Blather::Stanza::Iq.new
|
60
|
+
@client.expects(:write).with stanza
|
61
|
+
@dsl.write stanza
|
62
|
+
end
|
63
|
+
|
64
|
+
it 'provides a "say" helper' do
|
65
|
+
to, msg = 'me@me.com', 'hello!'
|
66
|
+
Blather::Stanza::Message.stubs(:next_id).returns 0
|
67
|
+
@client.expects(:write).with Blather::Stanza::Message.new(to, msg)
|
68
|
+
@dsl.say to, msg
|
69
|
+
end
|
70
|
+
|
71
|
+
it 'provides a JID accessor' do
|
72
|
+
@client.expects :jid
|
73
|
+
@dsl.jid
|
74
|
+
end
|
75
|
+
|
76
|
+
it 'provides a disco helper for items' do
|
77
|
+
what, who, where = :items, 'me@me.com', 'my/node'
|
78
|
+
Blather::Stanza::Disco::DiscoItems.stubs(:next_id).returns 0
|
79
|
+
@client.expects(:temporary_handler).with '0'
|
80
|
+
expected_stanza = Blather::Stanza::Disco::DiscoItems.new
|
81
|
+
expected_stanza.to = who
|
82
|
+
expected_stanza.node = where
|
83
|
+
@client.expects(:write).with expected_stanza
|
84
|
+
@dsl.discover what, who, where
|
85
|
+
end
|
86
|
+
|
87
|
+
it 'provides a disco helper for info' do
|
88
|
+
what, who, where = :info, 'me@me.com', 'my/node'
|
89
|
+
Blather::Stanza::Disco::DiscoInfo.stubs(:next_id).returns 0
|
90
|
+
@client.expects(:temporary_handler).with '0'
|
91
|
+
expected_stanza = Blather::Stanza::Disco::DiscoInfo.new
|
92
|
+
expected_stanza.to = who
|
93
|
+
expected_stanza.node = where
|
94
|
+
@client.expects(:write).with expected_stanza
|
95
|
+
@dsl.discover what, who, where
|
96
|
+
end
|
97
|
+
|
98
|
+
Blather::Stanza.handler_list.each do |handler_method|
|
99
|
+
it "provides a helper method for #{handler_method}" do
|
100
|
+
guards = [:chat?, {:body => 'exit'}]
|
101
|
+
@client.expects(:register_handler).with handler_method, *guards
|
102
|
+
@dsl.__send__(handler_method, *guards)
|
103
|
+
end
|
104
|
+
end
|
4
105
|
end
|
@@ -11,7 +11,7 @@ describe 'Blather::Stream::Client' do
|
|
11
11
|
|
12
12
|
def mocked_server(times = nil, &block)
|
13
13
|
@client ||= mock()
|
14
|
-
@client.stubs(:
|
14
|
+
@client.stubs(:unbind) unless @client.respond_to?(:unbind)
|
15
15
|
@client.stubs(:jid=) unless @client.respond_to?(:jid=)
|
16
16
|
|
17
17
|
MockServer.any_instance.expects(:receive_data).send(*(times ? [:times, times] : [:at_least, 1])).with &block
|
@@ -58,7 +58,7 @@ describe 'Blather::Stream::Client' do
|
|
58
58
|
|
59
59
|
it 'sends stanzas to the client when the stream is ready' do
|
60
60
|
@client = mock()
|
61
|
-
@client.expects(:
|
61
|
+
@client.expects(:receive_data).with do |n|
|
62
62
|
EM.stop
|
63
63
|
n.kind_of?(Stanza::Message) && @stream.ready?.must_equal(true)
|
64
64
|
end
|
@@ -72,7 +72,7 @@ describe 'Blather::Stream::Client' do
|
|
72
72
|
|
73
73
|
it 'puts itself in the stopped state and calls @client.stopped when stopped' do
|
74
74
|
@client = mock()
|
75
|
-
@client.expects(:
|
75
|
+
@client.expects(:unbind).at_least_once
|
76
76
|
|
77
77
|
started = false
|
78
78
|
mocked_server(2) do |val, server|
|
@@ -95,8 +95,8 @@ describe 'Blather::Stream::Client' do
|
|
95
95
|
it 'will be in the negotiating state during feature negotiations' do
|
96
96
|
state = nil
|
97
97
|
@client = mock()
|
98
|
-
@client.stubs(:
|
99
|
-
@client.expects(:
|
98
|
+
@client.stubs(:post_init)
|
99
|
+
@client.expects(:receive_data).with do |n|
|
100
100
|
EM.stop
|
101
101
|
state.must_equal(:negotiated) && @stream.negotiating?.must_equal(false)
|
102
102
|
end
|
@@ -154,7 +154,7 @@ describe 'Blather::Stream::Client' do
|
|
154
154
|
|
155
155
|
it 'sends client an error on stream:error' do
|
156
156
|
@client = mock()
|
157
|
-
@client.expects(:
|
157
|
+
@client.expects(:receive_data).with do |v|
|
158
158
|
v.name.must_equal :conflict
|
159
159
|
v.text.must_equal 'Already signed in'
|
160
160
|
v.to_s.must_equal "Stream Error (conflict): #{v.text}"
|
@@ -216,7 +216,7 @@ describe 'Blather::Stream::Client' do
|
|
216
216
|
it 'will fail if TLS negotiation fails' do
|
217
217
|
state = nil
|
218
218
|
@client = mock()
|
219
|
-
@client.expects(:
|
219
|
+
@client.expects(:receive_data).with { |v| v.must_be_kind_of TLSFailure }
|
220
220
|
mocked_server(3) do |val, server|
|
221
221
|
case state
|
222
222
|
when nil
|
@@ -245,7 +245,7 @@ describe 'Blather::Stream::Client' do
|
|
245
245
|
it 'will fail if a bad node comes through TLS negotiations' do
|
246
246
|
state = nil
|
247
247
|
@client = mock()
|
248
|
-
@client.expects(:
|
248
|
+
@client.expects(:receive_data).with do |v|
|
249
249
|
v.must_be_kind_of UnknownResponse
|
250
250
|
v.node.element_name.must_equal 'foo-bar'
|
251
251
|
end
|
@@ -400,7 +400,7 @@ describe 'Blather::Stream::Client' do
|
|
400
400
|
it 'tries each possible mechanism until it fails completely' do
|
401
401
|
state = nil
|
402
402
|
@client = mock()
|
403
|
-
@client.expects(:
|
403
|
+
@client.expects(:receive_data).with do |n|
|
404
404
|
n.must_be_kind_of(SASLError)
|
405
405
|
n.name.must_equal :not_authorized
|
406
406
|
end
|
@@ -473,7 +473,7 @@ describe 'Blather::Stream::Client' do
|
|
473
473
|
|
474
474
|
it 'sends client an error when an unknown mechanism is sent' do
|
475
475
|
@client = mock()
|
476
|
-
@client.expects(:
|
476
|
+
@client.expects(:receive_data).with { |v| v.must_be_kind_of(Stream::SASL::UnknownMechanism) }
|
477
477
|
started = false
|
478
478
|
mocked_server(2) do |val, server|
|
479
479
|
if !started
|
@@ -500,7 +500,7 @@ describe 'Blather::Stream::Client' do
|
|
500
500
|
].each do |error_type|
|
501
501
|
it "fails on #{error_type}" do
|
502
502
|
@client = mock()
|
503
|
-
@client.expects(:
|
503
|
+
@client.expects(:receive_data).with do |n|
|
504
504
|
n.name.must_equal error_type.gsub('-','_').to_sym
|
505
505
|
end
|
506
506
|
state = nil
|
@@ -532,7 +532,7 @@ describe 'Blather::Stream::Client' do
|
|
532
532
|
|
533
533
|
it 'fails when an unkown node comes through during SASL negotiation' do
|
534
534
|
@client = mock()
|
535
|
-
@client.expects(:
|
535
|
+
@client.expects(:receive_data).with do |n|
|
536
536
|
n.must_be_instance_of UnknownResponse
|
537
537
|
n.node.element_name.must_equal 'foo-bar'
|
538
538
|
end
|
@@ -629,7 +629,7 @@ describe 'Blather::Stream::Client' do
|
|
629
629
|
it 'will return an error if resource binding errors out' do
|
630
630
|
state = nil
|
631
631
|
@client = mock()
|
632
|
-
@client.expects(:
|
632
|
+
@client.expects(:receive_data).with do |n|
|
633
633
|
n.name.must_equal :bad_request
|
634
634
|
end
|
635
635
|
mocked_server(3) do |val, server|
|
@@ -660,7 +660,7 @@ describe 'Blather::Stream::Client' do
|
|
660
660
|
it 'will return an error if an unkown node comes through during resouce binding' do
|
661
661
|
state = nil
|
662
662
|
@client = mock()
|
663
|
-
@client.expects(:
|
663
|
+
@client.expects(:receive_data).with do |n|
|
664
664
|
n.must_be_instance_of UnknownResponse
|
665
665
|
n.node.element_name.must_equal 'foo-bar'
|
666
666
|
end
|
@@ -692,7 +692,7 @@ describe 'Blather::Stream::Client' do
|
|
692
692
|
it 'will establish a session if requested' do
|
693
693
|
state = nil
|
694
694
|
@client = mock()
|
695
|
-
@client.expects(:
|
695
|
+
@client.expects(:post_init)
|
696
696
|
|
697
697
|
mocked_server(3) do |val, server|
|
698
698
|
case state
|
@@ -723,7 +723,7 @@ describe 'Blather::Stream::Client' do
|
|
723
723
|
it 'will return an error if session establishment errors out' do
|
724
724
|
state = nil
|
725
725
|
@client = mock()
|
726
|
-
@client.expects(:
|
726
|
+
@client.expects(:receive_data).with do |n|
|
727
727
|
n.name.must_equal :internal_server_error
|
728
728
|
end
|
729
729
|
mocked_server(3) do |val, server|
|
@@ -754,7 +754,7 @@ describe 'Blather::Stream::Client' do
|
|
754
754
|
it 'will return an error if an unknown node come through during session establishment' do
|
755
755
|
state = nil
|
756
756
|
@client = mock()
|
757
|
-
@client.expects(:
|
757
|
+
@client.expects(:receive_data).with do |n|
|
758
758
|
n.must_be_instance_of UnknownResponse
|
759
759
|
n.node.element_name.must_equal 'foo-bar'
|
760
760
|
end
|
@@ -785,7 +785,7 @@ describe 'Blather::Stream::Client' do
|
|
785
785
|
|
786
786
|
it 'sends client an error on parse error' do
|
787
787
|
@client = mock()
|
788
|
-
@client.expects(:
|
788
|
+
@client.expects(:receive_data).with do |v|
|
789
789
|
v.must_be_kind_of ParseError
|
790
790
|
v.message.must_match(/generate\-parse\-error/)
|
791
791
|
end
|
@@ -11,7 +11,7 @@ describe 'Blather::Stream::Component' do
|
|
11
11
|
|
12
12
|
def mocked_server(times = nil, &block)
|
13
13
|
@client ||= mock()
|
14
|
-
@client.stubs(:
|
14
|
+
@client.stubs(:unbind) unless @client.respond_to?(:unbind)
|
15
15
|
@client.stubs(:jid=) unless @client.respond_to?(:jid=)
|
16
16
|
|
17
17
|
MockServer.any_instance.expects(:receive_data).send(*(times ? [:times, times] : [:at_least, 1])).with &block
|
@@ -60,8 +60,8 @@ describe 'Blather::Stream::Component' do
|
|
60
60
|
end
|
61
61
|
|
62
62
|
it 'sends stanzas to the client when the stream is ready' do
|
63
|
-
@client = mock(:
|
64
|
-
@client.expects(:
|
63
|
+
@client = mock(:post_init)
|
64
|
+
@client.expects(:receive_data).with do |n|
|
65
65
|
EM.stop
|
66
66
|
n.kind_of?(Stanza::Message) && @stream.ready?.must_equal(true)
|
67
67
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,4 +1,7 @@
|
|
1
|
-
|
1
|
+
$:.unshift File.expand_path(File.join(File.dirname(__FILE__), '..'))
|
2
|
+
$:.unshift File.expand_path(File.join(File.dirname(__FILE__), *%w[.. lib]))
|
3
|
+
|
4
|
+
require 'blather'
|
2
5
|
require 'rubygems'
|
3
6
|
require 'minitest/spec'
|
4
7
|
require 'mocha'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: blather
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeff Smick
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-05-
|
12
|
+
date: 2009-05-14 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -30,7 +30,7 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 1.1.
|
33
|
+
version: 1.1.2
|
34
34
|
version:
|
35
35
|
description:
|
36
36
|
email: sprsquish@gmail.com
|
@@ -44,6 +44,7 @@ extra_rdoc_files:
|
|
44
44
|
files:
|
45
45
|
- examples/drb_client.rb
|
46
46
|
- examples/echo.rb
|
47
|
+
- examples/ping_pong.rb
|
47
48
|
- examples/print_heirarchy.rb
|
48
49
|
- ext/extconf.rb
|
49
50
|
- ext/push_parser.c
|
@@ -71,7 +72,6 @@ files:
|
|
71
72
|
- lib/blather/stanza/presence.rb
|
72
73
|
- lib/blather/stanza/presence/status.rb
|
73
74
|
- lib/blather/stanza/presence/subscription.rb
|
74
|
-
- lib/blather/stanza/pubsub/subscriber.rb
|
75
75
|
- lib/blather/stream.rb
|
76
76
|
- lib/blather/stream/client.rb
|
77
77
|
- lib/blather/stream/component.rb
|
@@ -115,7 +115,6 @@ summary: An evented XMPP library written on EventMachine and libxml-ruby
|
|
115
115
|
test_files:
|
116
116
|
- spec/blather/client/client_spec.rb
|
117
117
|
- spec/blather/client/dsl_spec.rb
|
118
|
-
- spec/blather/client_spec.rb
|
119
118
|
- spec/blather/core_ext/libxml_spec.rb
|
120
119
|
- spec/blather/errors/sasl_error_spec.rb
|
121
120
|
- spec/blather/errors/stanza_error_spec.rb
|
@@ -133,7 +132,6 @@ test_files:
|
|
133
132
|
- spec/blather/stanza/presence/status_spec.rb
|
134
133
|
- spec/blather/stanza/presence/subscription_spec.rb
|
135
134
|
- spec/blather/stanza/presence_spec.rb
|
136
|
-
- spec/blather/stanza/pubsub/subscriber_spec.rb
|
137
135
|
- spec/blather/stanza_spec.rb
|
138
136
|
- spec/blather/stream/client_spec.rb
|
139
137
|
- spec/blather/stream/component_spec.rb
|
@@ -1,64 +0,0 @@
|
|
1
|
-
module Blather
|
2
|
-
class Stanza
|
3
|
-
class PubSub
|
4
|
-
|
5
|
-
module Subscriber
|
6
|
-
def self.included(base)
|
7
|
-
base.class_eval do
|
8
|
-
extend ClassMethods
|
9
|
-
include InstanceMethods
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
module ClassMethods
|
14
|
-
def subscribe(host, node, jid)
|
15
|
-
stanza = self.new(:set, host)
|
16
|
-
subscription = XMPPNode.new 'subscription'
|
17
|
-
subscription.attributes[:node] = node
|
18
|
-
subscription.attributes[:jid] = JID.new(jid).stripped
|
19
|
-
stanza.pubsub << subscription
|
20
|
-
stanza
|
21
|
-
end
|
22
|
-
|
23
|
-
def unsubscribe(host, node, jid, subid = nil)
|
24
|
-
stanza = self.new(:set, host)
|
25
|
-
unsubscription = XMPPNode.new 'unsubscribe'
|
26
|
-
unsubscription.attributes[:node] = node
|
27
|
-
unsubscription.attributes[:jid] = JID.new(jid).stripped
|
28
|
-
unsubscription.attributes[:subid] = subid
|
29
|
-
stanza.pubsub << unsubscription
|
30
|
-
stanza
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
module InstanceMethods
|
35
|
-
def subscription
|
36
|
-
if sub = subscription?
|
37
|
-
{ :node => sub.attributes[:node],
|
38
|
-
:jid => JID.new(sub.attributes[:jid]),
|
39
|
-
:subid => sub.attributes[:subid],
|
40
|
-
:subscription => sub.attributes[:subscription] }
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
def subscription?
|
45
|
-
find_first('//pubsub_ns:pubsub/pubsub_ns:subscription', :pubsub_ns => self.ns)
|
46
|
-
end
|
47
|
-
|
48
|
-
def unsubscribe
|
49
|
-
if sub = unsubscribe?
|
50
|
-
{ :node => sub.attributes[:node],
|
51
|
-
:jid => JID.new(sub.attributes[:jid]) }
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
def unsubscribe?
|
56
|
-
find_first('//pubsub_ns:pubsub/pubsub_ns:unsubscribe', :pubsub_ns => self.ns)
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
end #Subscriber
|
61
|
-
|
62
|
-
end #PubSub
|
63
|
-
end #Stanza
|
64
|
-
end #Blather
|
data/spec/blather/client_spec.rb
DELETED
File without changes
|
@@ -1,70 +0,0 @@
|
|
1
|
-
__END__
|
2
|
-
require File.join(File.dirname(__FILE__), *%w[.. .. .. spec_helper])
|
3
|
-
require File.join(File.dirname(__FILE__), *%w[.. .. .. fixtures pubsub])
|
4
|
-
|
5
|
-
describe 'Blather::Stanza::PubSub::Subscriber' do
|
6
|
-
it 'can request a subscription' do
|
7
|
-
sub = Blather::Stanza::PubSub.subscribe 'host.name', 'node_name', 'j@i.d'
|
8
|
-
sub.to.must_equal JID.new('host.name')
|
9
|
-
sub.set?.must_equal true
|
10
|
-
sub.find_first('//pubsub/subscription[@node="node_name" and @jid="j@i.d"]').wont_be_nil
|
11
|
-
end
|
12
|
-
|
13
|
-
it 'can request an unsubscribe' do
|
14
|
-
sub = Blather::Stanza::PubSub.unsubscribe 'host.name', 'node_name', 'j@i.d'
|
15
|
-
sub.to.must_equal JID.new('host.name')
|
16
|
-
sub.set?.must_equal true
|
17
|
-
sub.find_first('//pubsub/unsubscribe[@node="node_name" and @jid="j@i.d"]').wont_be_nil
|
18
|
-
end
|
19
|
-
|
20
|
-
it 'can request an unsubscribe with a subscription id' do
|
21
|
-
sub = Blather::Stanza::PubSub.unsubscribe 'host.name', 'node_name', 'j@i.d', 'subid'
|
22
|
-
sub.to.must_equal JID.new('host.name')
|
23
|
-
sub.set?.must_equal true
|
24
|
-
sub.find_first('//pubsub/unsubscribe[@node="node_name" and @jid="j@i.d" and @subid="subid"]').wont_be_nil
|
25
|
-
end
|
26
|
-
|
27
|
-
it 'knows if it is a subscription' do
|
28
|
-
node = XML::Document.string(subscriber_xml).root
|
29
|
-
stanza = Blather::Stanza::PubSub.import node
|
30
|
-
stanza.subscription?.wont_be_nil
|
31
|
-
end
|
32
|
-
|
33
|
-
it 'knows if it is not a subscription' do
|
34
|
-
node = XML::Document.string(unsubscribe_xml).root
|
35
|
-
stanza = Blather::Stanza::PubSub.import node
|
36
|
-
stanza.subscription?.must_be_nil
|
37
|
-
end
|
38
|
-
|
39
|
-
it 'knows the values of a subscription' do
|
40
|
-
node = XML::Document.string(subscriber_xml).root
|
41
|
-
stanza = Blather::Stanza::PubSub.import node
|
42
|
-
stanza.subscription.must_equal({
|
43
|
-
:node => 'princely_musings',
|
44
|
-
:jid => JID.new('francisco@denmark.lit'),
|
45
|
-
:subid => 'ba49252aaa4f5d320c24d3766f0bdcade78c78d3',
|
46
|
-
:subscription => 'subscribed'
|
47
|
-
})
|
48
|
-
end
|
49
|
-
|
50
|
-
it 'knows if it is a unsubscribe' do
|
51
|
-
node = XML::Document.string(unsubscribe_xml).root
|
52
|
-
stanza = Blather::Stanza::PubSub.import node
|
53
|
-
stanza.unsubscribe?.wont_be_nil
|
54
|
-
end
|
55
|
-
|
56
|
-
it 'knows if it is not a unsubscribe' do
|
57
|
-
node = XML::Document.string(subscriber_xml).root
|
58
|
-
stanza = Blather::Stanza::PubSub.import node
|
59
|
-
stanza.unsubscribe?.must_be_nil
|
60
|
-
end
|
61
|
-
|
62
|
-
it 'knows the values of the unsubscribe' do
|
63
|
-
node = XML::Document.string(unsubscribe_xml).root
|
64
|
-
stanza = Blather::Stanza::PubSub.import node
|
65
|
-
stanza.unsubscribe.must_equal({
|
66
|
-
:node => 'princely_musings',
|
67
|
-
:jid => JID.new('francisco@denmark.lit')
|
68
|
-
})
|
69
|
-
end
|
70
|
-
end
|