jubjub 0.0.7 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (62) hide show
  1. data/README.mdown +27 -1
  2. data/lib/jubjub.rb +1 -1
  3. data/lib/jubjub/connection/xmpp_gateway.rb +9 -9
  4. data/lib/jubjub/connection/xmpp_gateway/helper.rb +5 -5
  5. data/lib/jubjub/connection/xmpp_gateway/muc.rb +127 -32
  6. data/lib/jubjub/connection/xmpp_gateway/pubsub.rb +64 -64
  7. data/lib/jubjub/data_form.rb +16 -13
  8. data/lib/jubjub/errors.rb +2 -2
  9. data/lib/jubjub/helpers.rb +32 -0
  10. data/lib/jubjub/jid.rb +8 -8
  11. data/lib/jubjub/muc.rb +3 -1
  12. data/lib/jubjub/muc/affiliation.rb +77 -0
  13. data/lib/jubjub/muc/affiliations_collection.rb +31 -0
  14. data/lib/jubjub/muc/collection.rb +12 -19
  15. data/lib/jubjub/muc/configuration.rb +2 -2
  16. data/lib/jubjub/muc/muc.rb +24 -11
  17. data/lib/jubjub/pubsub.rb +1 -1
  18. data/lib/jubjub/pubsub/affiliation.rb +20 -20
  19. data/lib/jubjub/pubsub/affiliation_collection.rb +11 -18
  20. data/lib/jubjub/pubsub/collection.rb +14 -21
  21. data/lib/jubjub/pubsub/configuration.rb +2 -2
  22. data/lib/jubjub/pubsub/item.rb +8 -8
  23. data/lib/jubjub/pubsub/item_collection.rb +10 -17
  24. data/lib/jubjub/pubsub/pubsub.rb +17 -17
  25. data/lib/jubjub/pubsub/subscription.rb +6 -6
  26. data/lib/jubjub/response.rb +1 -1
  27. data/lib/jubjub/response/error.rb +6 -6
  28. data/lib/jubjub/response/proxy.rb +8 -8
  29. data/lib/jubjub/response/response.rb +10 -10
  30. data/lib/jubjub/user.rb +16 -15
  31. data/spec/connection/xmpp_gateway_muc_spec.rb +174 -40
  32. data/spec/connection/xmpp_gateway_pubsub_spec.rb +100 -104
  33. data/spec/fixtures/vcr_cassettes/muc_configuration.yml +73 -6
  34. data/spec/fixtures/vcr_cassettes/muc_create_with_configuration.yml +8 -8
  35. data/spec/fixtures/vcr_cassettes/muc_message.yml +89 -0
  36. data/spec/fixtures/vcr_cassettes/muc_modify_affiliations.yml +367 -0
  37. data/spec/fixtures/vcr_cassettes/muc_retrieve_affiliations.yml +93 -0
  38. data/spec/fixtures/vcr_cassettes/pubsub_publish_with_dataform_payload.yml +3 -3
  39. data/spec/fixtures/vcr_cassettes/pubsub_retrieve_items.yml +24 -18
  40. data/spec/mixins/user_spec.rb +37 -37
  41. data/spec/models/data_form_spec.rb +3 -3
  42. data/spec/models/jid_spec.rb +41 -41
  43. data/spec/models/muc_affiliation_collection_spec.rb +146 -0
  44. data/spec/models/muc_affiliation_spec.rb +215 -0
  45. data/spec/models/muc_collection_spec.rb +64 -32
  46. data/spec/models/muc_configuration_spec.rb +3 -3
  47. data/spec/models/muc_spec.rb +44 -23
  48. data/spec/models/pubsub_affiliation_collection_spec.rb +65 -30
  49. data/spec/models/pubsub_affiliation_spec.rb +50 -50
  50. data/spec/models/pubsub_collection_spec.rb +65 -49
  51. data/spec/models/pubsub_item_collection_spec.rb +17 -17
  52. data/spec/models/pubsub_item_spec.rb +18 -18
  53. data/spec/models/pubsub_spec.rb +41 -41
  54. data/spec/models/pubsub_subscription_spec.rb +23 -23
  55. data/spec/models/response_error_spec.rb +19 -19
  56. data/spec/models/response_proxy_spec.rb +51 -49
  57. data/spec/models/response_spec.rb +33 -33
  58. data/spec/support/helpers.rb +21 -1
  59. data/spec/support/matchers.rb +4 -4
  60. data/spec/support/shared_examples.rb +132 -94
  61. data/spec/support/webmock_stanza_matching.rb +43 -0
  62. metadata +45 -16
@@ -1,18 +1,18 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Jubjub::Pubsub::Collection do
4
-
4
+
5
5
  describe "that are proxied like" do
6
-
6
+
7
7
  before do
8
8
  @mock_connection = mock
9
9
  @nodes = [
10
10
  Jubjub::Pubsub.new('pubsub.foo.com', 'node_1', @mock_connection),
11
- Jubjub::Pubsub.new('pubsub.foo.com', 'node_2', @mock_connection)
11
+ Jubjub::Pubsub.new('pubsub.foo.com', 'node_2', @mock_connection)
12
12
  ]
13
13
  @mock_connection.stub_chain( :pubsub, :list ).and_return(@nodes)
14
14
  end
15
-
15
+
16
16
  describe "inspect" do
17
17
 
18
18
  it "should show the list of rooms, not Muc::Collection" do
@@ -29,42 +29,42 @@ describe Jubjub::Pubsub::Collection do
29
29
  end
30
30
 
31
31
  end
32
-
32
+
33
33
  end
34
-
34
+
35
35
  describe "instance method" do
36
-
36
+
37
37
  describe "jid" do
38
38
  it "should return the jid" do
39
39
  p = Jubjub::Pubsub::Collection.new "pubsub.foo.com", mock
40
40
  p.jid.should == Jubjub::Jid.new('pubsub.foo.com')
41
41
  end
42
42
  end
43
-
43
+
44
44
  describe "subscribe" do
45
45
  it "should call pubsub.subscribe on connection" do
46
46
  @mock_connection = mock
47
47
  @mock_connection.stub_chain :pubsub, :subscribe
48
48
  @mock_connection.pubsub.should_receive(:subscribe).with( Jubjub::Jid.new( 'pubsub.foo.com' ), 'node' )
49
-
49
+
50
50
  p = Jubjub::Pubsub::Collection.new "pubsub.foo.com", @mock_connection
51
- p.subscribe "node"
51
+ p.subscribe "node"
52
52
  end
53
53
  end
54
-
54
+
55
55
  describe "unsubscribe" do
56
56
  before do
57
57
  @mock_connection = mock
58
58
  @mock_connection.stub_chain :pubsub, :unsubscribe
59
59
  end
60
-
60
+
61
61
  it "without subid should call pubsub.unsubscribe on connection" do
62
62
  @mock_connection.pubsub.should_receive(:unsubscribe).with( Jubjub::Jid.new( 'pubsub.foo.com' ), 'node', nil )
63
63
 
64
64
  p = Jubjub::Pubsub::Collection.new "pubsub.foo.com", @mock_connection
65
- p.unsubscribe "node"
65
+ p.unsubscribe "node"
66
66
  end
67
-
67
+
68
68
  it "with subid should call pubsub.unsubscribe on connection" do
69
69
  @mock_connection.pubsub.should_receive(:unsubscribe).with( Jubjub::Jid.new( 'pubsub.foo.com' ), 'node', '123' )
70
70
 
@@ -72,109 +72,125 @@ describe Jubjub::Pubsub::Collection do
72
72
  p.unsubscribe "node", "123"
73
73
  end
74
74
  end
75
-
75
+
76
76
  describe "create" do
77
77
  before do
78
78
  @mock_connection = mock
79
- @mock_connection.stub_chain :pubsub, :create
79
+ @mock_connection.stub_chain :pubsub, :create
80
80
  end
81
-
81
+
82
82
  it "should call pubsub.create on connection" do
83
83
  @mock_connection.pubsub.should_receive(:create).with( Jubjub::Jid.new( 'pubsub.foo.com' ), 'node', nil )
84
-
84
+
85
85
  p = Jubjub::Pubsub::Collection.new "pubsub.foo.com", @mock_connection
86
86
  p.create "node"
87
87
  end
88
-
88
+
89
89
  it "should yield a Pubsub::Configuration if a block is given" do
90
90
  @config = Jubjub::Pubsub::Configuration.new( "foo" => { :type => "boolean", :value => "1", :label => "Foo" } )
91
-
91
+
92
92
  @mock_connection.pubsub.should_receive( :default_configuration ).with( Jubjub::Jid.new( 'pubsub.foo.com' ) ).and_return( @config )
93
93
  @mock_connection.pubsub.should_receive( :create ).with( Jubjub::Jid.new( 'pubsub.foo.com' ), 'node', @config )
94
-
94
+
95
95
  Jubjub::Pubsub::Collection.new( "pubsub.foo.com", @mock_connection ).create( 'node' ){|config|
96
96
  config.should == @config
97
97
  }
98
98
  end
99
99
  end
100
-
100
+
101
101
  describe "[]" do
102
102
  before do
103
103
  @mock_connection = mock
104
104
  @nodes = [
105
105
  Jubjub::Pubsub.new('pubsub.foo.com', 'node_1', @mock_connection),
106
- Jubjub::Pubsub.new('pubsub.foo.com', 'node_2', @mock_connection)
106
+ Jubjub::Pubsub.new('pubsub.foo.com', 'node_2', @mock_connection)
107
107
  ]
108
108
  @mock_connection.stub_chain( :pubsub, :list ).and_return(@nodes)
109
109
  end
110
-
110
+
111
111
  subject { Jubjub::Pubsub::Collection.new "pubsub.foo.com", @mock_connection }
112
-
112
+
113
113
  it "should work like a normal array when passed a Fixnum" do
114
114
  subject[1].should == @nodes[1]
115
115
  end
116
-
117
- it "should search by node if a String" do
118
- subject["node_1"].should == @nodes[0]
119
- end
120
-
121
- it "should return Jubjub::Pubsub item if nothing found as it may still exist" do
122
- subject['made-up'].should == Jubjub::Pubsub.new( 'pubsub.foo.com', 'made-up', @mock_connection )
116
+
117
+ describe "searching by node if a String" do
118
+
119
+ it "should return cached result if it has already searched" do
120
+ # Trigger lookup
121
+ @mock_connection.pubsub.should_receive(:list)
122
+ subject.first
123
+ subject["node_1"].should equal @nodes[0]
124
+ end
125
+
126
+ it "should return default result if it has already searched and does not exist" do
127
+ # Trigger lookup
128
+ @mock_connection.pubsub.should_receive(:list)
129
+ subject.first
130
+ subject['made-up'].should == Jubjub::Pubsub.new( 'pubsub.foo.com', 'made-up', @mock_connection )
131
+ end
132
+
133
+ it "should return default result if it has not already searched" do
134
+ @mock_connection.pubsub.should_not_receive(:list)
135
+ subject['node_1'].should_not equal @nodes[0]
136
+ subject['node_1'].should == Jubjub::Pubsub.new( 'pubsub.foo.com', 'node_1', @mock_connection )
137
+ end
138
+
123
139
  end
124
140
  end
125
-
126
-
141
+
142
+
127
143
  describe "destroy" do
128
144
  it "with redirect should call pubsub.destroy on connection" do
129
145
  @mock_connection = mock
130
146
  @mock_connection.stub_chain :pubsub, :destroy
131
-
132
- @mock_connection.pubsub.should_receive(:destroy).with(
147
+
148
+ @mock_connection.pubsub.should_receive(:destroy).with(
133
149
  Jubjub::Jid.new('pubsub.foo.com'),
134
150
  'node',
135
151
  Jubjub::Jid.new('pubsub.new.com'),
136
152
  'node_2'
137
153
  )
138
-
154
+
139
155
  p = Jubjub::Pubsub::Collection.new "pubsub.foo.com", @mock_connection
140
156
  p.destroy "node", "pubsub.new.com", "node_2"
141
157
  end
142
-
158
+
143
159
  it "without redirect should call pubsub.destroy on connection" do
144
160
  @mock_connection = mock
145
161
  @mock_connection.stub_chain :pubsub, :destroy
146
-
147
- @mock_connection.pubsub.should_receive(:destroy).with(
162
+
163
+ @mock_connection.pubsub.should_receive(:destroy).with(
148
164
  Jubjub::Jid.new('pubsub.foo.com'),
149
165
  'node',
150
166
  nil,
151
167
  nil
152
168
  )
153
-
169
+
154
170
  p = Jubjub::Pubsub::Collection.new "pubsub.foo.com", @mock_connection
155
171
  p.destroy "node"
156
172
  end
157
173
  end
158
-
174
+
159
175
  describe "purge" do
160
-
176
+
161
177
  before do
162
178
  @mock_connection = mock
163
179
  @mock_connection.stub_chain :pubsub, :purge
164
180
  end
165
-
181
+
166
182
  it "should call pubsub.purge on connection" do
167
183
  @mock_connection.pubsub.should_receive(:purge).with(
168
184
  Jubjub::Jid.new('pubsub.foo.com'),
169
185
  'node'
170
186
  )
171
-
187
+
172
188
  m = Jubjub::Pubsub::Collection.new 'pubsub.foo.com', @mock_connection
173
189
  m.purge('node')
174
190
  end
175
-
191
+
176
192
  end
177
-
193
+
178
194
  end
179
-
180
- end
195
+
196
+ end
@@ -1,18 +1,18 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Jubjub::Pubsub::ItemCollection do
4
-
4
+
5
5
  describe "that are proxied like" do
6
-
6
+
7
7
  before do
8
8
  @mock_connection = mock
9
9
  @items = [
10
10
  Jubjub::Pubsub::Item.new('pubsub.foo.com', 'node_1', 'abc', '<foo></foo>', @mock_connection),
11
- Jubjub::Pubsub::Item.new('pubsub.foo.com', 'node_1', 'efg', '<bar></bar>', @mock_connection)
11
+ Jubjub::Pubsub::Item.new('pubsub.foo.com', 'node_1', 'efg', '<bar></bar>', @mock_connection)
12
12
  ]
13
13
  @mock_connection.stub_chain( :pubsub, :retrieve_items ).and_return(@items)
14
14
  end
15
-
15
+
16
16
  describe "inspect" do
17
17
 
18
18
  it "should show the list of items, not Pubsub::ItemCollection" do
@@ -29,48 +29,48 @@ describe Jubjub::Pubsub::ItemCollection do
29
29
  end
30
30
 
31
31
  end
32
-
32
+
33
33
  end
34
-
34
+
35
35
  describe "instance method" do
36
-
36
+
37
37
  describe "jid" do
38
38
  it "should return the jid" do
39
39
  Jubjub::Pubsub::ItemCollection.new("pubsub.foo.com", "node", mock).jid.should == Jubjub::Jid.new("pubsub.foo.com")
40
40
  end
41
41
  end
42
-
42
+
43
43
  describe "node" do
44
44
  it "should return the node" do
45
45
  Jubjub::Pubsub::ItemCollection.new("pubsub.foo.com", "node", mock).node.should == 'node'
46
46
  end
47
47
  end
48
-
48
+
49
49
  describe "[]" do
50
50
  before do
51
51
  @mock_connection = mock
52
52
  @nodes = [
53
53
  Jubjub::Pubsub::Item.new('pubsub.foo.com', 'node_1', 'abc', '<foo></foo>', @mock_connection),
54
- Jubjub::Pubsub::Item.new('pubsub.foo.com', 'node_1', 'efg', '<bar></bar>', @mock_connection)
54
+ Jubjub::Pubsub::Item.new('pubsub.foo.com', 'node_1', 'efg', '<bar></bar>', @mock_connection)
55
55
  ]
56
56
  @mock_connection.stub_chain( :pubsub, :retrieve_items ).and_return(@nodes)
57
57
  end
58
-
58
+
59
59
  subject { Jubjub::Pubsub::ItemCollection.new "pubsub.foo.com", "node_1", @mock_connection }
60
-
60
+
61
61
  it "should work like a normal array when passed a Fixnum" do
62
62
  subject[1].should == @nodes[1]
63
63
  end
64
-
64
+
65
65
  it "should search by node if a String" do
66
66
  subject["abc"].should == @nodes[0]
67
67
  end
68
-
68
+
69
69
  it "should return nil if nothing found" do
70
70
  subject['made-up'].should be_nil
71
71
  end
72
72
  end
73
-
73
+
74
74
  end
75
-
76
- end
75
+
76
+ end
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Jubjub::Pubsub::Item do
4
-
4
+
5
5
  def pubsub_item_factory(override = {})
6
6
  options = {
7
7
  :jid => Jubjub::Jid.new("pubsub.foo.com"),
@@ -10,7 +10,7 @@ describe Jubjub::Pubsub::Item do
10
10
  :data => 'foo',
11
11
  :connection => "SHHHH CONNECTION OBJECT"
12
12
  }.merge( override )
13
-
13
+
14
14
  Jubjub::Pubsub::Item.new(
15
15
  options[:jid],
16
16
  options[:node],
@@ -19,76 +19,76 @@ describe Jubjub::Pubsub::Item do
19
19
  options[:connection]
20
20
  )
21
21
  end
22
-
22
+
23
23
  describe "instance method" do
24
-
24
+
25
25
  describe "jid" do
26
26
  it "should return the jid" do
27
27
  p = pubsub_item_factory :jid => 'foo.com'
28
28
  p.jid.should == Jubjub::Jid.new('foo.com')
29
29
  end
30
30
  end
31
-
31
+
32
32
  describe "node" do
33
33
  it "should return the node" do
34
34
  p = pubsub_item_factory :node => 'node_1'
35
35
  p.node.should == 'node_1'
36
36
  end
37
37
  end
38
-
38
+
39
39
  describe "data" do
40
40
  it "should return the data" do
41
41
  p = pubsub_item_factory :data => 'hello'
42
42
  p.data.should == 'hello'
43
43
  end
44
44
  end
45
-
45
+
46
46
  describe "item_id" do
47
47
  it "should return the item_id" do
48
48
  p = pubsub_item_factory :item_id => 'as12'
49
49
  p.item_id.should == 'as12'
50
50
  end
51
51
  end
52
-
52
+
53
53
  describe "uri" do
54
54
  it "should return the uri of the item" do
55
55
  item = pubsub_item_factory :jid => "theozaurus@foo.com", :node => "blah", :item_id => "123"
56
56
  item.uri.should == "xmpp:theozaurus@foo.com?;node=blah;item=123"
57
57
  end
58
58
  end
59
-
59
+
60
60
  describe "retract" do
61
61
  it "should call pubsub.retract on connection" do
62
62
  @mock_connection = mock
63
63
  @mock_connection.stub_chain :pubsub, :retract
64
64
  @mock_connection.pubsub.should_receive(:retract).with( Jubjub::Jid.new( 'pubsub.foo.com' ), 'node', '123' )
65
-
65
+
66
66
  p = pubsub_item_factory :jid => 'pubsub.foo.com', :node => 'node', :item_id => '123', :connection => @mock_connection
67
67
  p.retract
68
68
  end
69
69
  end
70
-
70
+
71
71
  describe "==" do
72
72
  it "should match equivalent objects" do
73
73
  pubsub_item_factory.should == pubsub_item_factory
74
74
  end
75
-
75
+
76
76
  it "should not distinguish between connections" do
77
77
  pubsub_item_factory(:connection => 'wibble').should == pubsub_item_factory(:connection => 'wobble')
78
78
  end
79
-
79
+
80
80
  it "should still match no matter how jid is initialized" do
81
81
  pubsub_item_factory(:jid => 'foo@bar.com').should == pubsub_item_factory(:jid => Jubjub::Jid.new('foo@bar.com'))
82
82
  end
83
-
83
+
84
84
  it "should not match objects with different attributes" do
85
- pubsub_item_factory(:jid => 'a.b.com').should_not == pubsub_item_factory
85
+ pubsub_item_factory(:jid => 'a.b.com').should_not == pubsub_item_factory
86
86
  pubsub_item_factory(:node => 'adsafsd').should_not == pubsub_item_factory
87
87
  pubsub_item_factory(:item_id => '23').should_not == pubsub_item_factory
88
88
  pubsub_item_factory(:data => '<wibble></wibble').should_not == pubsub_item_factory
89
89
  end
90
90
  end
91
-
91
+
92
92
  end
93
-
94
- end
93
+
94
+ end
@@ -1,49 +1,49 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Jubjub::Pubsub do
4
-
4
+
5
5
  describe "instance method" do
6
-
6
+
7
7
  describe "inspect" do
8
-
8
+
9
9
  it "should not show connection information" do
10
10
  m = Jubjub::Pubsub.new(Jubjub::Jid.new("pubsub.foo.com"),'node',"SHHHH CONNECTION OBJECT")
11
11
  m.inspect.should_not match 'SHHHH CONNECTION OBJECT'
12
12
  end
13
-
13
+
14
14
  it "should show string version of jid" do
15
15
  m = Jubjub::Pubsub.new(Jubjub::Jid.new("pubsub.foo.com"),'node',mock)
16
16
  m.inspect.should match '@jid="pubsub.foo.com"'
17
17
  end
18
-
18
+
19
19
  it "should show node" do
20
20
  m = Jubjub::Pubsub.new(Jubjub::Jid.new("pubsub.foo.com"),nil,mock)
21
21
  m.inspect.should match '@node=nil'
22
-
22
+
23
23
  m = Jubjub::Pubsub.new(Jubjub::Jid.new("pubsub.foo.com"),'node',mock)
24
24
  m.inspect.should match '@node="node"'
25
25
  end
26
-
26
+
27
27
  end
28
-
28
+
29
29
  describe "jid" do
30
30
  it "should return the jid" do
31
31
  Jubjub::Pubsub.new('pubsub.foo.com','node', mock).jid.should == Jubjub::Jid.new('pubsub.foo.com')
32
32
  end
33
33
  end
34
-
34
+
35
35
  describe "node" do
36
36
  it "should return the node" do
37
37
  Jubjub::Pubsub.new('pubsub.foo.com','node', mock).node.should == 'node'
38
38
  end
39
39
  end
40
-
40
+
41
41
  describe "uri" do
42
42
  it "should return the uri of the node" do
43
43
  Jubjub::Pubsub.new(Jubjub::Jid.new('theozaurus@foo.com'), 'blah', mock ).uri.should == "xmpp:theozaurus@foo.com?;node=blah"
44
44
  end
45
45
  end
46
-
46
+
47
47
  describe "subscribe" do
48
48
  it "should call pubsub.subscribe on connection" do
49
49
  @mock_connection = mock
@@ -54,14 +54,14 @@ describe Jubjub::Pubsub do
54
54
  m.subscribe
55
55
  end
56
56
  end
57
-
57
+
58
58
  describe "unsubscribe" do
59
-
59
+
60
60
  before do
61
61
  @mock_connection = mock
62
62
  @mock_connection.stub_chain :pubsub, :unsubscribe
63
63
  end
64
-
64
+
65
65
  describe "with subid" do
66
66
  it "should call pubsub.unsubscribe on connection" do
67
67
  @mock_connection.pubsub.should_receive(:unsubscribe).with( Jubjub::Jid.new( 'pubsub.foo.com' ), 'node', 'wibble' )
@@ -70,7 +70,7 @@ describe Jubjub::Pubsub do
70
70
  m.unsubscribe 'wibble'
71
71
  end
72
72
  end
73
-
73
+
74
74
  describe "without subid" do
75
75
  it "should call pubsub.unsubscribe on connection" do
76
76
  @mock_connection.pubsub.should_receive(:unsubscribe).with( Jubjub::Jid.new( 'pubsub.foo.com' ), 'node', nil )
@@ -79,16 +79,16 @@ describe Jubjub::Pubsub do
79
79
  m.unsubscribe
80
80
  end
81
81
  end
82
-
82
+
83
83
  end
84
-
84
+
85
85
  describe "publish" do
86
-
86
+
87
87
  before do
88
88
  @mock_connection = mock
89
89
  @mock_connection.stub_chain :pubsub, :publish
90
90
  end
91
-
91
+
92
92
  describe "with item id" do
93
93
  it "should call pubsub.publish on connection" do
94
94
  @mock_connection.pubsub.should_receive(:publish).with( Jubjub::Jid.new( 'pubsub.foo.com' ), 'node', 'data', '123' )
@@ -97,7 +97,7 @@ describe Jubjub::Pubsub do
97
97
  m.publish 'data', '123'
98
98
  end
99
99
  end
100
-
100
+
101
101
  describe "without item id" do
102
102
  it "should call pubsub.publish on connection" do
103
103
  @mock_connection.pubsub.should_receive(:publish).with( Jubjub::Jid.new( 'pubsub.foo.com' ), 'node', 'data', nil )
@@ -106,36 +106,36 @@ describe Jubjub::Pubsub do
106
106
  m.publish 'data'
107
107
  end
108
108
  end
109
-
109
+
110
110
  end
111
-
111
+
112
112
  describe "retract" do
113
113
  it "should call pubsub.retract on connection" do
114
114
  @mock_connection = mock
115
115
  @mock_connection.stub_chain :pubsub, :retract
116
116
  @mock_connection.pubsub.should_receive(:retract).with( Jubjub::Jid.new( 'pubsub.foo.com' ), 'node', '123' )
117
-
117
+
118
118
  m = Jubjub::Pubsub.new 'pubsub.foo.com', 'node', @mock_connection
119
119
  m.retract('123')
120
120
  end
121
121
  end
122
-
122
+
123
123
  describe "destroy" do
124
-
124
+
125
125
  before do
126
126
  @mock_connection = mock
127
127
  @mock_connection.stub_chain :pubsub, :destroy
128
128
  end
129
-
129
+
130
130
  it "without redirect should call pubsub.destroy on connection" do
131
131
  @mock_connection.pubsub.should_receive(:destroy).with( Jubjub::Jid.new( 'pubsub.foo.com' ), 'node', nil, nil )
132
132
 
133
133
  m = Jubjub::Pubsub.new 'pubsub.foo.com', 'node', @mock_connection
134
134
  m.destroy
135
135
  end
136
-
136
+
137
137
  it "with redirect should call pubsub.destroy on connection" do
138
- @mock_connection.pubsub.should_receive(:destroy).with(
138
+ @mock_connection.pubsub.should_receive(:destroy).with(
139
139
  Jubjub::Jid.new('pubsub.foo.com'),
140
140
  'node',
141
141
  Jubjub::Jid.new('pubsub.new.com'),
@@ -144,43 +144,43 @@ describe Jubjub::Pubsub do
144
144
  m = Jubjub::Pubsub.new 'pubsub.foo.com', 'node', @mock_connection
145
145
  m.destroy 'pubsub.new.com', 'node_2'
146
146
  end
147
-
147
+
148
148
  end
149
-
149
+
150
150
  describe "purge" do
151
-
151
+
152
152
  before do
153
153
  @mock_connection = mock
154
154
  @mock_connection.stub_chain :pubsub, :purge
155
155
  end
156
-
156
+
157
157
  it "should call pubsub.purge on connection" do
158
158
  @mock_connection.pubsub.should_receive(:purge).with(
159
159
  Jubjub::Jid.new('pubsub.foo.com'),
160
160
  'node'
161
161
  )
162
-
162
+
163
163
  m = Jubjub::Pubsub.new 'pubsub.foo.com', 'node', @mock_connection
164
164
  m.purge
165
165
  end
166
-
166
+
167
167
  end
168
-
168
+
169
169
  describe "items" do
170
-
170
+
171
171
  before do
172
172
  @mock_connection = mock
173
173
  end
174
-
174
+
175
175
  it 'should return Jubjub::Pubsub::ItemCollection' do
176
176
  @pubsub_node = Jubjub::Pubsub.new 'pubsub.foo.com', 'node', @mock_connection
177
177
  @pubsub_node.items.should be_a Jubjub::Pubsub::ItemCollection
178
178
  @pubsub_node.items.jid.should == Jubjub::Jid.new('pubsub.foo.com')
179
179
  @pubsub_node.items.node.should == 'node'
180
180
  end
181
-
181
+
182
182
  end
183
-
183
+
184
184
  end
185
-
186
- end
185
+
186
+ end