jubjub 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,115 @@
1
+ require 'spec_helper'
2
+
3
+ describe Jubjub::PubsubSubscription do
4
+
5
+ def pubsub_subscription_factory(override = {})
6
+ options = {
7
+ :jid => Jubjub::Jid.new("pubsub.foo.com"),
8
+ :node => 'node',
9
+ :subscriber => Jubjub::Jid.new("theo@foo.com"),
10
+ :subid => nil,
11
+ :subscription => 'subscribed',
12
+ :connection => "SHHHH CONNECTION OBJECT"
13
+ }.merge( override )
14
+
15
+ Jubjub::PubsubSubscription.new(
16
+ options[:jid],
17
+ options[:node],
18
+ options[:subscriber],
19
+ options[:subid],
20
+ options[:subscription],
21
+ options[:connection]
22
+ )
23
+ end
24
+
25
+ describe "instance method" do
26
+
27
+ describe "inspect" do
28
+
29
+ it "should not show connection information" do
30
+ p = pubsub_subscription_factory :connection => 'SHHHH CONNECTION OBJECT'
31
+ p.inspect.should_not match 'SHHHH CONNECTION OBJECT'
32
+ end
33
+
34
+ it "should show string version of jid" do
35
+ p = pubsub_subscription_factory :jid => Jubjub::Jid.new("pubsub.foo.com")
36
+ p.inspect.should match '@jid="pubsub.foo.com"'
37
+ end
38
+
39
+ it "should show node" do
40
+ p = pubsub_subscription_factory :node => "node"
41
+ p.inspect.should match '@node="node"'
42
+ end
43
+
44
+ it "should show string version of subscriber" do
45
+ p = pubsub_subscription_factory :subscriber => Jubjub::Jid.new("theo@foo.com")
46
+ p.inspect.should match '@subscriber="theo@foo.com"'
47
+ end
48
+
49
+ it "should show subid" do
50
+ p = pubsub_subscription_factory :subid => nil
51
+ p.inspect.should match '@subid=nil'
52
+
53
+ p = pubsub_subscription_factory :subid => "wibble"
54
+ p.inspect.should match '@subid="wibble"'
55
+ end
56
+
57
+ it "should show subscription" do
58
+ p = pubsub_subscription_factory :subscription => nil
59
+ p.inspect.should match '@subscription=nil'
60
+
61
+ p = pubsub_subscription_factory :subscription => 'subscribed'
62
+ p.inspect.should match '@subscription="subscribed"'
63
+ end
64
+
65
+ end
66
+
67
+ describe "jid" do
68
+ it "should return the jid" do
69
+ p = pubsub_subscription_factory :jid => 'foo.com'
70
+ p.jid.should == Jubjub::Jid.new('foo.com')
71
+ end
72
+ end
73
+
74
+ describe "node" do
75
+ it "should return the node" do
76
+ p = pubsub_subscription_factory :node => 'node_1'
77
+ p.node.should == 'node_1'
78
+ end
79
+ end
80
+
81
+ describe "subscriber" do
82
+ it "should return the subscriber jid" do
83
+ p = pubsub_subscription_factory :subscriber => 'theo@foo.com'
84
+ p.subscriber.should == Jubjub::Jid.new('theo@foo.com')
85
+ end
86
+ end
87
+
88
+ describe "subid" do
89
+ it "should return the subid" do
90
+ p = pubsub_subscription_factory :subid => 'as12'
91
+ p.subid.should == 'as12'
92
+ end
93
+ end
94
+
95
+ describe "subscription" do
96
+ it "should return the subscription" do
97
+ p = pubsub_subscription_factory :subscription => '32'
98
+ p.subscription.should == '32'
99
+ end
100
+ end
101
+
102
+ describe "unsubscribe" do
103
+ it "should call pubsub.unsubscribe on connection" do
104
+ @mock_connection = mock
105
+ @mock_connection.stub_chain :pubsub, :unsubscribe
106
+ @mock_connection.pubsub.should_receive(:unsubscribe).with( Jubjub::Jid.new( 'pubsub.foo.com' ), 'node', '123' )
107
+
108
+ p = pubsub_subscription_factory :jid => 'pubsub.foo.com', :node => 'node', :subid => '123', :connection => @mock_connection
109
+ p.unsubscribe
110
+ end
111
+ end
112
+
113
+ end
114
+
115
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jubjub
3
3
  version: !ruby/object:Gem::Version
4
- hash: 25
4
+ hash: 23
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 3
10
- version: 0.0.3
9
+ - 4
10
+ version: 0.0.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - Theo Cushion
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-02-02 00:00:00 +00:00
18
+ date: 2011-02-25 00:00:00 +00:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -101,26 +101,39 @@ extra_rdoc_files: []
101
101
  files:
102
102
  - lib/jubjub/connection/xmpp_gateway/helper.rb
103
103
  - lib/jubjub/connection/xmpp_gateway/muc.rb
104
+ - lib/jubjub/connection/xmpp_gateway/pubsub.rb
104
105
  - lib/jubjub/connection/xmpp_gateway.rb
105
106
  - lib/jubjub/errors.rb
106
107
  - lib/jubjub/jid.rb
107
108
  - lib/jubjub/muc.rb
109
+ - lib/jubjub/pubsub.rb
108
110
  - lib/jubjub/user.rb
109
111
  - lib/jubjub.rb
110
112
  - LICENSE
111
113
  - README.mdown
112
- - spec/connection/xmpp_gateway_spec.rb
114
+ - spec/connection/xmpp_gateway_muc_spec.rb
115
+ - spec/connection/xmpp_gateway_pubsub_spec.rb
113
116
  - spec/fixtures/vcr_cassettes/muc_configuration.yml
114
117
  - spec/fixtures/vcr_cassettes/muc_create.yml
115
118
  - spec/fixtures/vcr_cassettes/muc_create_with_configuration.yml
116
119
  - spec/fixtures/vcr_cassettes/muc_destroy.yml
117
120
  - spec/fixtures/vcr_cassettes/muc_exit.yml
118
121
  - spec/fixtures/vcr_cassettes/muc_list.yml
122
+ - spec/fixtures/vcr_cassettes/pubsub_create.yml
123
+ - spec/fixtures/vcr_cassettes/pubsub_destroy.yml
124
+ - spec/fixtures/vcr_cassettes/pubsub_destroy_with_redirect.yml
125
+ - spec/fixtures/vcr_cassettes/pubsub_list.yml
126
+ - spec/fixtures/vcr_cassettes/pubsub_subscribe.yml
127
+ - spec/fixtures/vcr_cassettes/pubsub_unsubscribe.yml
128
+ - spec/fixtures/vcr_cassettes/pubsub_unsubscribe_with_subid.yml
119
129
  - spec/mixins/user_spec.rb
120
130
  - spec/models/jid_spec.rb
121
131
  - spec/models/muc_collection_spec.rb
122
132
  - spec/models/muc_configuration_spec.rb
123
133
  - spec/models/muc_spec.rb
134
+ - spec/models/pubsub_collection_spec.rb
135
+ - spec/models/pubsub_spec.rb
136
+ - spec/models/pubsub_subscription_spec.rb
124
137
  - spec/spec_helper.rb
125
138
  - .rspec
126
139
  - .infinity_test
@@ -161,18 +174,29 @@ signing_key:
161
174
  specification_version: 3
162
175
  summary: An Object to XMPP mapper to make managing XMPP resources easy
163
176
  test_files:
164
- - spec/connection/xmpp_gateway_spec.rb
177
+ - spec/connection/xmpp_gateway_muc_spec.rb
178
+ - spec/connection/xmpp_gateway_pubsub_spec.rb
165
179
  - spec/fixtures/vcr_cassettes/muc_configuration.yml
166
180
  - spec/fixtures/vcr_cassettes/muc_create.yml
167
181
  - spec/fixtures/vcr_cassettes/muc_create_with_configuration.yml
168
182
  - spec/fixtures/vcr_cassettes/muc_destroy.yml
169
183
  - spec/fixtures/vcr_cassettes/muc_exit.yml
170
184
  - spec/fixtures/vcr_cassettes/muc_list.yml
185
+ - spec/fixtures/vcr_cassettes/pubsub_create.yml
186
+ - spec/fixtures/vcr_cassettes/pubsub_destroy.yml
187
+ - spec/fixtures/vcr_cassettes/pubsub_destroy_with_redirect.yml
188
+ - spec/fixtures/vcr_cassettes/pubsub_list.yml
189
+ - spec/fixtures/vcr_cassettes/pubsub_subscribe.yml
190
+ - spec/fixtures/vcr_cassettes/pubsub_unsubscribe.yml
191
+ - spec/fixtures/vcr_cassettes/pubsub_unsubscribe_with_subid.yml
171
192
  - spec/mixins/user_spec.rb
172
193
  - spec/models/jid_spec.rb
173
194
  - spec/models/muc_collection_spec.rb
174
195
  - spec/models/muc_configuration_spec.rb
175
196
  - spec/models/muc_spec.rb
197
+ - spec/models/pubsub_collection_spec.rb
198
+ - spec/models/pubsub_spec.rb
199
+ - spec/models/pubsub_subscription_spec.rb
176
200
  - spec/spec_helper.rb
177
201
  - .rspec
178
202
  - .infinity_test