jubjub 0.0.3 → 0.0.4

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.
@@ -0,0 +1,72 @@
1
+ ---
2
+ - !ruby/struct:VCR::HTTPInteraction
3
+ request: !ruby/struct:VCR::Request
4
+ method: :post
5
+ uri: http://theozaurus%40theo-template.local:secret@127.0.0.1:8000/
6
+ body: stanza=%3c%3fxml%20version%3d%221.0%22%3f%3e%0a%3ciq%20type%3d%22set%22%20to%3d%22pubsub.theo-template.local%22%3e%0a%20%20%3cpubsub%20xmlns%3d%22http%3a%2f%2fjabber.org%2fprotocol%2fpubsub%22%3e%0a%20%20%20%20%3ccreate%20node%3d%22node_1%22%2f%3e%0a%20%20%3c%2fpubsub%3e%0a%3c%2fiq%3e%0a
7
+ headers:
8
+ content-type:
9
+ - application/x-www-form-urlencoded
10
+ response: !ruby/struct:VCR::Response
11
+ status: !ruby/struct:VCR::ResponseStatus
12
+ code: 200
13
+ message: ...
14
+ headers:
15
+ content-type:
16
+ - application/xml
17
+ content-length:
18
+ - "230"
19
+ body: |
20
+ <iq type="result" id="blather0045" from="pubsub.theo-template.local" to="theozaurus@theo-template.local/310086191298628414672003">
21
+ <pubsub xmlns="http://jabber.org/protocol/pubsub">
22
+ <create node="node_1"/>
23
+ </pubsub>
24
+ </iq>
25
+
26
+ http_version: "1.1"
27
+ - !ruby/struct:VCR::HTTPInteraction
28
+ request: !ruby/struct:VCR::Request
29
+ method: :post
30
+ uri: http://theozaurus%40theo-template.local:secret@127.0.0.1:8000/
31
+ body: stanza=%3c%3fxml%20version%3d%221.0%22%3f%3e%0a%3ciq%20type%3d%22set%22%20to%3d%22pubsub.theo-template.local%22%3e%0a%20%20%3cpubsub%20xmlns%3d%22http%3a%2f%2fjabber.org%2fprotocol%2fpubsub%22%3e%0a%20%20%20%20%3csubscribe%20node%3d%22node_1%22%20jid%3d%22theozaurus%40theo-template.local%22%2f%3e%0a%20%20%3c%2fpubsub%3e%0a%3c%2fiq%3e%0a
32
+ headers:
33
+ content-type:
34
+ - application/x-www-form-urlencoded
35
+ response: !ruby/struct:VCR::Response
36
+ status: !ruby/struct:VCR::ResponseStatus
37
+ code: 200
38
+ message: ...
39
+ headers:
40
+ content-type:
41
+ - application/xml
42
+ content-length:
43
+ - "307"
44
+ body: |
45
+ <iq type="result" id="blather0047" from="pubsub.theo-template.local" to="theozaurus@theo-template.local/310086191298628414672003">
46
+ <pubsub xmlns="http://jabber.org/protocol/pubsub">
47
+ <subscription jid="theozaurus@theo-template.local" subscription="subscribed" subid="512996CE5D7F4"/>
48
+ </pubsub>
49
+ </iq>
50
+
51
+ http_version: "1.1"
52
+ - !ruby/struct:VCR::HTTPInteraction
53
+ request: !ruby/struct:VCR::Request
54
+ method: :post
55
+ uri: http://theozaurus%40theo-template.local:secret@127.0.0.1:8000/
56
+ body: stanza=%3c%3fxml%20version%3d%221.0%22%3f%3e%0a%3ciq%20type%3d%22set%22%20to%3d%22pubsub.theo-template.local%22%3e%0a%20%20%3cpubsub%20xmlns%3d%22http%3a%2f%2fjabber.org%2fprotocol%2fpubsub%23owner%22%3e%0a%20%20%20%20%3cdelete%20node%3d%22node_1%22%2f%3e%0a%20%20%3c%2fpubsub%3e%0a%3c%2fiq%3e%0a
57
+ headers:
58
+ content-type:
59
+ - application/x-www-form-urlencoded
60
+ response: !ruby/struct:VCR::Response
61
+ status: !ruby/struct:VCR::ResponseStatus
62
+ code: 200
63
+ message: ...
64
+ headers:
65
+ content-type:
66
+ - application/xml
67
+ content-length:
68
+ - "132"
69
+ body: |
70
+ <iq type="result" id="blather0049" from="pubsub.theo-template.local" to="theozaurus@theo-template.local/310086191298628414672003"/>
71
+
72
+ http_version: "1.1"
@@ -0,0 +1,93 @@
1
+ ---
2
+ - !ruby/struct:VCR::HTTPInteraction
3
+ request: !ruby/struct:VCR::Request
4
+ method: :post
5
+ uri: http://theozaurus%40theo-template.local:secret@127.0.0.1:8000/
6
+ body: stanza=%3c%3fxml%20version%3d%221.0%22%3f%3e%0a%3ciq%20type%3d%22set%22%20to%3d%22pubsub.theo-template.local%22%3e%0a%20%20%3cpubsub%20xmlns%3d%22http%3a%2f%2fjabber.org%2fprotocol%2fpubsub%22%3e%0a%20%20%20%20%3ccreate%20node%3d%22node_1%22%2f%3e%0a%20%20%3c%2fpubsub%3e%0a%3c%2fiq%3e%0a
7
+ headers:
8
+ content-type:
9
+ - application/x-www-form-urlencoded
10
+ response: !ruby/struct:VCR::Response
11
+ status: !ruby/struct:VCR::ResponseStatus
12
+ code: 200
13
+ message: ...
14
+ headers:
15
+ content-type:
16
+ - application/xml
17
+ content-length:
18
+ - "232"
19
+ body: |
20
+ <iq type="result" id="blather0059" from="pubsub.theo-template.local" to="theozaurus@theo-template.local/10036730731298628601765031">
21
+ <pubsub xmlns="http://jabber.org/protocol/pubsub">
22
+ <create node="node_1"/>
23
+ </pubsub>
24
+ </iq>
25
+
26
+ http_version: "1.1"
27
+ - !ruby/struct:VCR::HTTPInteraction
28
+ request: !ruby/struct:VCR::Request
29
+ method: :post
30
+ uri: http://theozaurus%40theo-template.local:secret@127.0.0.1:8000/
31
+ body: stanza=%3c%3fxml%20version%3d%221.0%22%3f%3e%0a%3ciq%20type%3d%22set%22%20to%3d%22pubsub.theo-template.local%22%3e%0a%20%20%3cpubsub%20xmlns%3d%22http%3a%2f%2fjabber.org%2fprotocol%2fpubsub%22%3e%0a%20%20%20%20%3csubscribe%20node%3d%22node_1%22%20jid%3d%22theozaurus%40theo-template.local%22%2f%3e%0a%20%20%3c%2fpubsub%3e%0a%3c%2fiq%3e%0a
32
+ headers:
33
+ content-type:
34
+ - application/x-www-form-urlencoded
35
+ response: !ruby/struct:VCR::Response
36
+ status: !ruby/struct:VCR::ResponseStatus
37
+ code: 200
38
+ message: ...
39
+ headers:
40
+ content-type:
41
+ - application/xml
42
+ content-length:
43
+ - "309"
44
+ body: |
45
+ <iq type="result" id="blather005b" from="pubsub.theo-template.local" to="theozaurus@theo-template.local/10036730731298628601765031">
46
+ <pubsub xmlns="http://jabber.org/protocol/pubsub">
47
+ <subscription jid="theozaurus@theo-template.local" subscription="subscribed" subid="51299779D3E23"/>
48
+ </pubsub>
49
+ </iq>
50
+
51
+ http_version: "1.1"
52
+ - !ruby/struct:VCR::HTTPInteraction
53
+ request: !ruby/struct:VCR::Request
54
+ method: :post
55
+ uri: http://theozaurus%40theo-template.local:secret@127.0.0.1:8000/
56
+ body: stanza=%3c%3fxml%20version%3d%221.0%22%3f%3e%0a%3ciq%20type%3d%22set%22%20to%3d%22pubsub.theo-template.local%22%3e%0a%20%20%3cpubsub%20xmlns%3d%22http%3a%2f%2fjabber.org%2fprotocol%2fpubsub%22%3e%0a%20%20%20%20%3cunsubscribe%20node%3d%22node_1%22%20jid%3d%22theozaurus%40theo-template.local%22%2f%3e%0a%20%20%3c%2fpubsub%3e%0a%3c%2fiq%3e%0a
57
+ headers:
58
+ content-type:
59
+ - application/x-www-form-urlencoded
60
+ response: !ruby/struct:VCR::Response
61
+ status: !ruby/struct:VCR::ResponseStatus
62
+ code: 200
63
+ message: ...
64
+ headers:
65
+ content-type:
66
+ - application/xml
67
+ content-length:
68
+ - "134"
69
+ body: |
70
+ <iq type="result" id="blather005d" from="pubsub.theo-template.local" to="theozaurus@theo-template.local/10036730731298628601765031"/>
71
+
72
+ http_version: "1.1"
73
+ - !ruby/struct:VCR::HTTPInteraction
74
+ request: !ruby/struct:VCR::Request
75
+ method: :post
76
+ uri: http://theozaurus%40theo-template.local:secret@127.0.0.1:8000/
77
+ body: stanza=%3c%3fxml%20version%3d%221.0%22%3f%3e%0a%3ciq%20type%3d%22set%22%20to%3d%22pubsub.theo-template.local%22%3e%0a%20%20%3cpubsub%20xmlns%3d%22http%3a%2f%2fjabber.org%2fprotocol%2fpubsub%23owner%22%3e%0a%20%20%20%20%3cdelete%20node%3d%22node_1%22%2f%3e%0a%20%20%3c%2fpubsub%3e%0a%3c%2fiq%3e%0a
78
+ headers:
79
+ content-type:
80
+ - application/x-www-form-urlencoded
81
+ response: !ruby/struct:VCR::Response
82
+ status: !ruby/struct:VCR::ResponseStatus
83
+ code: 200
84
+ message: ...
85
+ headers:
86
+ content-type:
87
+ - application/xml
88
+ content-length:
89
+ - "134"
90
+ body: |
91
+ <iq type="result" id="blather005f" from="pubsub.theo-template.local" to="theozaurus@theo-template.local/10036730731298628601765031"/>
92
+
93
+ http_version: "1.1"
@@ -0,0 +1,93 @@
1
+ ---
2
+ - !ruby/struct:VCR::HTTPInteraction
3
+ request: !ruby/struct:VCR::Request
4
+ method: :post
5
+ uri: http://theozaurus%40theo-template.local:secret@127.0.0.1:8000/
6
+ body: stanza=%3c%3fxml%20version%3d%221.0%22%3f%3e%0a%3ciq%20type%3d%22set%22%20to%3d%22pubsub.theo-template.local%22%3e%0a%20%20%3cpubsub%20xmlns%3d%22http%3a%2f%2fjabber.org%2fprotocol%2fpubsub%22%3e%0a%20%20%20%20%3ccreate%20node%3d%22node_1%22%2f%3e%0a%20%20%3c%2fpubsub%3e%0a%3c%2fiq%3e%0a
7
+ headers:
8
+ content-type:
9
+ - application/x-www-form-urlencoded
10
+ response: !ruby/struct:VCR::Response
11
+ status: !ruby/struct:VCR::ResponseStatus
12
+ code: 200
13
+ message: ...
14
+ headers:
15
+ content-type:
16
+ - application/xml
17
+ content-length:
18
+ - "230"
19
+ body: |
20
+ <iq type="result" id="blather00ab" from="pubsub.theo-template.local" to="theozaurus@theo-template.local/665676628129862910568528">
21
+ <pubsub xmlns="http://jabber.org/protocol/pubsub">
22
+ <create node="node_1"/>
23
+ </pubsub>
24
+ </iq>
25
+
26
+ http_version: "1.1"
27
+ - !ruby/struct:VCR::HTTPInteraction
28
+ request: !ruby/struct:VCR::Request
29
+ method: :post
30
+ uri: http://theozaurus%40theo-template.local:secret@127.0.0.1:8000/
31
+ body: stanza=%3c%3fxml%20version%3d%221.0%22%3f%3e%0a%3ciq%20type%3d%22set%22%20to%3d%22pubsub.theo-template.local%22%3e%0a%20%20%3cpubsub%20xmlns%3d%22http%3a%2f%2fjabber.org%2fprotocol%2fpubsub%22%3e%0a%20%20%20%20%3csubscribe%20node%3d%22node_1%22%20jid%3d%22theozaurus%40theo-template.local%22%2f%3e%0a%20%20%3c%2fpubsub%3e%0a%3c%2fiq%3e%0a
32
+ headers:
33
+ content-type:
34
+ - application/x-www-form-urlencoded
35
+ response: !ruby/struct:VCR::Response
36
+ status: !ruby/struct:VCR::ResponseStatus
37
+ code: 200
38
+ message: ...
39
+ headers:
40
+ content-type:
41
+ - application/xml
42
+ content-length:
43
+ - "307"
44
+ body: |
45
+ <iq type="result" id="blather00ad" from="pubsub.theo-template.local" to="theozaurus@theo-template.local/665676628129862910568528">
46
+ <pubsub xmlns="http://jabber.org/protocol/pubsub">
47
+ <subscription jid="theozaurus@theo-template.local" subscription="subscribed" subid="5129997143EAA"/>
48
+ </pubsub>
49
+ </iq>
50
+
51
+ http_version: "1.1"
52
+ - !ruby/struct:VCR::HTTPInteraction
53
+ request: !ruby/struct:VCR::Request
54
+ method: :post
55
+ uri: http://theozaurus%40theo-template.local:secret@127.0.0.1:8000/
56
+ body: stanza=%3c%3fxml%20version%3d%221.0%22%3f%3e%0a%3ciq%20type%3d%22set%22%20to%3d%22pubsub.theo-template.local%22%3e%0a%20%20%3cpubsub%20xmlns%3d%22http%3a%2f%2fjabber.org%2fprotocol%2fpubsub%22%3e%0a%20%20%20%20%3cunsubscribe%20node%3d%22node_1%22%20jid%3d%22theozaurus%40theo-template.local%22%20subid%3d%225129997143EAA%22%2f%3e%0a%20%20%3c%2fpubsub%3e%0a%3c%2fiq%3e%0a
57
+ headers:
58
+ content-type:
59
+ - application/x-www-form-urlencoded
60
+ response: !ruby/struct:VCR::Response
61
+ status: !ruby/struct:VCR::ResponseStatus
62
+ code: 200
63
+ message: ...
64
+ headers:
65
+ content-type:
66
+ - application/xml
67
+ content-length:
68
+ - "132"
69
+ body: |
70
+ <iq type="result" id="blather00af" from="pubsub.theo-template.local" to="theozaurus@theo-template.local/665676628129862910568528"/>
71
+
72
+ http_version: "1.1"
73
+ - !ruby/struct:VCR::HTTPInteraction
74
+ request: !ruby/struct:VCR::Request
75
+ method: :post
76
+ uri: http://theozaurus%40theo-template.local:secret@127.0.0.1:8000/
77
+ body: stanza=%3c%3fxml%20version%3d%221.0%22%3f%3e%0a%3ciq%20type%3d%22set%22%20to%3d%22pubsub.theo-template.local%22%3e%0a%20%20%3cpubsub%20xmlns%3d%22http%3a%2f%2fjabber.org%2fprotocol%2fpubsub%23owner%22%3e%0a%20%20%20%20%3cdelete%20node%3d%22node_1%22%2f%3e%0a%20%20%3c%2fpubsub%3e%0a%3c%2fiq%3e%0a
78
+ headers:
79
+ content-type:
80
+ - application/x-www-form-urlencoded
81
+ response: !ruby/struct:VCR::Response
82
+ status: !ruby/struct:VCR::ResponseStatus
83
+ code: 200
84
+ message: ...
85
+ headers:
86
+ content-type:
87
+ - application/xml
88
+ content-length:
89
+ - "132"
90
+ body: |
91
+ <iq type="result" id="blather00b1" from="pubsub.theo-template.local" to="theozaurus@theo-template.local/665676628129862910568528"/>
92
+
93
+ http_version: "1.1"
@@ -131,6 +131,22 @@ describe Jubjub::User do
131
131
  @user.mucs('wibble.com').jid.should == Jubjub::Jid.new('wibble.com')
132
132
  end
133
133
  end
134
+
135
+ describe 'pubsub' do
136
+ before do
137
+ mock_jubjub_connection
138
+ end
139
+
140
+ it 'should return Jubjub::PubsubCollection for conference.biggles.com when no service specified' do
141
+ @user.pubsub.should be_a Jubjub::PubsubCollection
142
+ @user.pubsub.jid.should == Jubjub::Jid.new('pubsub.biggles.com')
143
+ end
144
+
145
+ it 'should return Jubjub::PubsubCollection for service when specified' do
146
+ @user.pubsub('wibble.com').should be_a Jubjub::PubsubCollection
147
+ @user.pubsub('wibble.com').jid.should == Jubjub::Jid.new('wibble.com')
148
+ end
149
+ end
134
150
 
135
151
  end
136
152
 
@@ -0,0 +1,122 @@
1
+ require 'spec_helper'
2
+
3
+ describe Jubjub::PubsubCollection do
4
+
5
+ describe "that are proxied like" do
6
+
7
+ before do
8
+ @mock_connection = mock
9
+ @nodes = [
10
+ Jubjub::Pubsub.new('pubsub.foo.com', 'node_1', @mock_connection),
11
+ Jubjub::Pubsub.new('pubsub.foo.com', 'node_2', @mock_connection)
12
+ ]
13
+ @mock_connection.stub_chain( :pubsub, :list ).and_return(@nodes)
14
+ end
15
+
16
+ describe "inspect" do
17
+
18
+ it "should show the list of rooms, not MucCollection" do
19
+ Jubjub::PubsubCollection.new('pubsub.foo.com', @mock_connection).inspect.should eql(@nodes.inspect)
20
+ end
21
+
22
+ end
23
+
24
+ describe "map" do
25
+
26
+ it "should pass the block to the rooms" do
27
+ c = Jubjub::PubsubCollection.new('pubsub.foo.com', @mock_connection)
28
+ c.map{|r| r.node.to_s }.should eql(['node_1', 'node_2'])
29
+ end
30
+
31
+ end
32
+
33
+ end
34
+
35
+ describe "instance method" do
36
+
37
+ describe "jid" do
38
+ it "should return the jid" do
39
+ p = Jubjub::PubsubCollection.new "pubsub.foo.com", mock
40
+ p.jid.should == Jubjub::Jid.new('pubsub.foo.com')
41
+ end
42
+ end
43
+
44
+ describe "subscribe" do
45
+ it "should call pubsub.subscribe on connection" do
46
+ @mock_connection = mock
47
+ @mock_connection.stub_chain :pubsub, :subscribe
48
+ @mock_connection.pubsub.should_receive(:subscribe).with( Jubjub::Jid.new( 'pubsub.foo.com' ), 'node' )
49
+
50
+ p = Jubjub::PubsubCollection.new "pubsub.foo.com", @mock_connection
51
+ p.subscribe "node"
52
+ end
53
+ end
54
+
55
+ describe "unsubscribe" do
56
+ before do
57
+ @mock_connection = mock
58
+ @mock_connection.stub_chain :pubsub, :unsubscribe
59
+ end
60
+
61
+ it "without subid should call pubsub.unsubscribe on connection" do
62
+ @mock_connection.pubsub.should_receive(:unsubscribe).with( Jubjub::Jid.new( 'pubsub.foo.com' ), 'node', nil )
63
+
64
+ p = Jubjub::PubsubCollection.new "pubsub.foo.com", @mock_connection
65
+ p.unsubscribe "node"
66
+ end
67
+
68
+ it "with subid should call pubsub.unsubscribe on connection" do
69
+ @mock_connection.pubsub.should_receive(:unsubscribe).with( Jubjub::Jid.new( 'pubsub.foo.com' ), 'node', '123' )
70
+
71
+ p = Jubjub::PubsubCollection.new "pubsub.foo.com", @mock_connection
72
+ p.unsubscribe "node", "123"
73
+ end
74
+ end
75
+
76
+ describe "create" do
77
+ it "should call pubsub.create on connection" do
78
+ @mock_connection = mock
79
+ @mock_connection.stub_chain :pubsub, :create
80
+
81
+ @mock_connection.pubsub.should_receive(:create).with( Jubjub::Jid.new( 'pubsub.foo.com' ), 'node' )
82
+
83
+ p = Jubjub::PubsubCollection.new "pubsub.foo.com", @mock_connection
84
+ p.create "node"
85
+ end
86
+ end
87
+
88
+ describe "destroy" do
89
+ it "with redirect should call pubsub.destroy on connection" do
90
+ @mock_connection = mock
91
+ @mock_connection.stub_chain :pubsub, :destroy
92
+
93
+ @mock_connection.pubsub.should_receive(:destroy).with(
94
+ Jubjub::Jid.new('pubsub.foo.com'),
95
+ 'node',
96
+ Jubjub::Jid.new('pubsub.new.com'),
97
+ 'node_2'
98
+ )
99
+
100
+ p = Jubjub::PubsubCollection.new "pubsub.foo.com", @mock_connection
101
+ p.destroy "node", "pubsub.new.com", "node_2"
102
+ end
103
+
104
+ it "without redirect should call pubsub.destroy on connection" do
105
+ @mock_connection = mock
106
+ @mock_connection.stub_chain :pubsub, :destroy
107
+
108
+ @mock_connection.pubsub.should_receive(:destroy).with(
109
+ Jubjub::Jid.new('pubsub.foo.com'),
110
+ 'node',
111
+ nil,
112
+ nil
113
+ )
114
+
115
+ p = Jubjub::PubsubCollection.new "pubsub.foo.com", @mock_connection
116
+ p.destroy "node"
117
+ end
118
+ end
119
+
120
+ end
121
+
122
+ end
@@ -0,0 +1,108 @@
1
+ require 'spec_helper'
2
+
3
+ describe Jubjub::Pubsub do
4
+
5
+ describe "instance method" do
6
+
7
+ describe "inspect" do
8
+
9
+ it "should not show connection information" do
10
+ m = Jubjub::Pubsub.new(Jubjub::Jid.new("pubsub.foo.com"),'node',"SHHHH CONNECTION OBJECT")
11
+ m.inspect.should_not match 'SHHHH CONNECTION OBJECT'
12
+ end
13
+
14
+ it "should show string version of jid" do
15
+ m = Jubjub::Pubsub.new(Jubjub::Jid.new("pubsub.foo.com"),'node',mock)
16
+ m.inspect.should match '@jid="pubsub.foo.com"'
17
+ end
18
+
19
+ it "should show node" do
20
+ m = Jubjub::Pubsub.new(Jubjub::Jid.new("pubsub.foo.com"),nil,mock)
21
+ m.inspect.should match '@node=nil'
22
+
23
+ m = Jubjub::Pubsub.new(Jubjub::Jid.new("pubsub.foo.com"),'node',mock)
24
+ m.inspect.should match '@node="node"'
25
+ end
26
+
27
+ end
28
+
29
+ describe "jid" do
30
+ it "should return the jid" do
31
+ Jubjub::Pubsub.new('pubsub.foo.com','node', mock).jid.should == Jubjub::Jid.new('pubsub.foo.com')
32
+ end
33
+ end
34
+
35
+ describe "node" do
36
+ it "should return the node" do
37
+ Jubjub::Pubsub.new('pubsub.foo.com','node', mock).node.should == 'node'
38
+ end
39
+ end
40
+
41
+ describe "subscribe" do
42
+ it "should call pubsub.subscribe on connection" do
43
+ @mock_connection = mock
44
+ @mock_connection.stub_chain :pubsub, :subscribe
45
+ @mock_connection.pubsub.should_receive(:subscribe).with( Jubjub::Jid.new( 'pubsub.foo.com' ), 'node' )
46
+
47
+ m = Jubjub::Pubsub.new 'pubsub.foo.com', 'node', @mock_connection
48
+ m.subscribe
49
+ end
50
+ end
51
+
52
+ describe "unsubscribe" do
53
+
54
+ before do
55
+ @mock_connection = mock
56
+ @mock_connection.stub_chain :pubsub, :unsubscribe
57
+ end
58
+
59
+ describe "with subid" do
60
+ it "should call pubsub.unsubscribe on connection" do
61
+ @mock_connection.pubsub.should_receive(:unsubscribe).with( Jubjub::Jid.new( 'pubsub.foo.com' ), 'node', 'wibble' )
62
+
63
+ m = Jubjub::Pubsub.new 'pubsub.foo.com', 'node', @mock_connection
64
+ m.unsubscribe 'wibble'
65
+ end
66
+ end
67
+
68
+ describe "without subid" do
69
+ it "should call pubsub.unsubscribe on connection" do
70
+ @mock_connection.pubsub.should_receive(:unsubscribe).with( Jubjub::Jid.new( 'pubsub.foo.com' ), 'node', nil )
71
+
72
+ m = Jubjub::Pubsub.new 'pubsub.foo.com', 'node', @mock_connection
73
+ m.unsubscribe
74
+ end
75
+ end
76
+
77
+ end
78
+
79
+ describe "destroy" do
80
+
81
+ before do
82
+ @mock_connection = mock
83
+ @mock_connection.stub_chain :pubsub, :destroy
84
+ end
85
+
86
+ it "without redirect should call pubsub.destroy on connection" do
87
+ @mock_connection.pubsub.should_receive(:destroy).with( Jubjub::Jid.new( 'pubsub.foo.com' ), 'node', nil, nil )
88
+
89
+ m = Jubjub::Pubsub.new 'pubsub.foo.com', 'node', @mock_connection
90
+ m.destroy
91
+ end
92
+
93
+ it "with redirect should call pubsub.destroy on connection" do
94
+ @mock_connection.pubsub.should_receive(:destroy).with(
95
+ Jubjub::Jid.new('pubsub.foo.com'),
96
+ 'node',
97
+ Jubjub::Jid.new('pubsub.new.com'),
98
+ 'node_2' )
99
+
100
+ m = Jubjub::Pubsub.new 'pubsub.foo.com', 'node', @mock_connection
101
+ m.destroy 'pubsub.new.com', 'node_2'
102
+ end
103
+
104
+ end
105
+
106
+ end
107
+
108
+ end