jubjub 0.0.7 → 0.0.8

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.
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
@@ -0,0 +1,43 @@
1
+ require "equivalent-xml"
2
+ require "cgi"
3
+ require "vcr/request_matcher"
4
+ require "vcr/http_stubbing_adapters/common"
5
+ require "vcr/http_stubbing_adapters/webmock"
6
+
7
+ module VCR
8
+ module HttpStubbingAdapters
9
+ module WebMock
10
+
11
+ # Hack in stub to compare with :stanza
12
+ def stub_requests(http_interactions, match_attributes)
13
+ grouped_responses(http_interactions, match_attributes).each do |request_matcher, responses|
14
+ stub = ::WebMock.stub_request(request_matcher.method || :any, request_matcher.uri)
15
+
16
+ with_hash = request_signature_hash(request_matcher)
17
+ stub = stub.with{|r|
18
+ conditions = []
19
+ conditions << (r.headers == with_hash[:headers]) if with_hash.has_key? :headers
20
+ conditions << EquivalentXml.equivalent?(body_to_stanza(r.body), body_to_stanza(with_hash[:body]), {
21
+ :element_order => true,
22
+ :normalize_whitespace => true
23
+ }) if with_hash.has_key? :body
24
+ conditions.all?
25
+ } if with_hash.size > 0
26
+
27
+ stub.to_return(responses.map{ |r| response_hash(r) })
28
+ end
29
+ end
30
+
31
+ # Code to deal with the stanza
32
+ def body_to_stanza(body)
33
+ if body
34
+ # Split body at '&', then split each element at '=' creating the key and value. Unescape these and turn into hash.
35
+ params = Hash[ body.split("&").map{|c| c.split('=').map{|v| CGI.unescape(v) } } ]
36
+ # Pull out stanza attribute and turn into Nokogiri XML document
37
+ Nokogiri::XML params["stanza"]
38
+ end
39
+ end
40
+
41
+ end
42
+ end
43
+ 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: 17
4
+ hash: 15
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 7
10
- version: 0.0.7
9
+ - 8
10
+ version: 0.0.8
11
11
  platform: ruby
12
12
  authors:
13
13
  - Theo Cushion
@@ -15,8 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-06-21 00:00:00 +01:00
19
- default_executable:
18
+ date: 2012-01-05 00:00:00 Z
20
19
  dependencies:
21
20
  - !ruby/object:Gem::Dependency
22
21
  version_requirements: &id001 !ruby/object:Gem::Requirement
@@ -28,10 +27,10 @@ dependencies:
28
27
  segments:
29
28
  - 0
30
29
  version: "0"
30
+ requirement: *id001
31
+ prerelease: false
31
32
  name: nokogiri
32
33
  type: :runtime
33
- prerelease: false
34
- requirement: *id001
35
34
  - !ruby/object:Gem::Dependency
36
35
  version_requirements: &id002 !ruby/object:Gem::Requirement
37
36
  none: false
@@ -42,10 +41,10 @@ dependencies:
42
41
  segments:
43
42
  - 0
44
43
  version: "0"
44
+ requirement: *id002
45
+ prerelease: false
45
46
  name: rake
46
47
  type: :development
47
- prerelease: false
48
- requirement: *id002
49
48
  - !ruby/object:Gem::Dependency
50
49
  version_requirements: &id003 !ruby/object:Gem::Requirement
51
50
  none: false
@@ -56,10 +55,10 @@ dependencies:
56
55
  segments:
57
56
  - 0
58
57
  version: "0"
58
+ requirement: *id003
59
+ prerelease: false
59
60
  name: vcr
60
61
  type: :development
61
- prerelease: false
62
- requirement: *id003
63
62
  - !ruby/object:Gem::Dependency
64
63
  version_requirements: &id004 !ruby/object:Gem::Requirement
65
64
  none: false
@@ -71,10 +70,10 @@ dependencies:
71
70
  - 1
72
71
  - 6
73
72
  version: "1.6"
73
+ requirement: *id004
74
+ prerelease: false
74
75
  name: webmock
75
76
  type: :development
76
- prerelease: false
77
- requirement: *id004
78
77
  - !ruby/object:Gem::Dependency
79
78
  version_requirements: &id005 !ruby/object:Gem::Requirement
80
79
  none: false
@@ -86,10 +85,26 @@ dependencies:
86
85
  - 2
87
86
  - 4
88
87
  version: "2.4"
88
+ requirement: *id005
89
+ prerelease: false
89
90
  name: rspec
90
91
  type: :development
92
+ - !ruby/object:Gem::Dependency
93
+ version_requirements: &id006 !ruby/object:Gem::Requirement
94
+ none: false
95
+ requirements:
96
+ - - ~>
97
+ - !ruby/object:Gem::Version
98
+ hash: 25
99
+ segments:
100
+ - 0
101
+ - 2
102
+ - 7
103
+ version: 0.2.7
104
+ requirement: *id006
91
105
  prerelease: false
92
- requirement: *id005
106
+ name: equivalent-xml
107
+ type: :development
93
108
  description: jubjub is designed to provie a simple API for controller XMPP servers and their resources. Currently it should be used in conjunction with xmpp_gateway, but the architecture has been left so that other backends could be implemented.
94
109
  email: theo.c@zepler.net
95
110
  executables: []
@@ -105,7 +120,10 @@ files:
105
120
  - lib/jubjub/connection/xmpp_gateway.rb
106
121
  - lib/jubjub/data_form.rb
107
122
  - lib/jubjub/errors.rb
123
+ - lib/jubjub/helpers.rb
108
124
  - lib/jubjub/jid.rb
125
+ - lib/jubjub/muc/affiliation.rb
126
+ - lib/jubjub/muc/affiliations_collection.rb
109
127
  - lib/jubjub/muc/collection.rb
110
128
  - lib/jubjub/muc/configuration.rb
111
129
  - lib/jubjub/muc/muc.rb
@@ -136,6 +154,9 @@ files:
136
154
  - spec/fixtures/vcr_cassettes/muc_destroy.yml
137
155
  - spec/fixtures/vcr_cassettes/muc_exit.yml
138
156
  - spec/fixtures/vcr_cassettes/muc_list.yml
157
+ - spec/fixtures/vcr_cassettes/muc_message.yml
158
+ - spec/fixtures/vcr_cassettes/muc_modify_affiliations.yml
159
+ - spec/fixtures/vcr_cassettes/muc_retrieve_affiliations.yml
139
160
  - spec/fixtures/vcr_cassettes/pubsub_create.yml
140
161
  - spec/fixtures/vcr_cassettes/pubsub_default_configuration.yml
141
162
  - spec/fixtures/vcr_cassettes/pubsub_destroy.yml
@@ -156,6 +177,8 @@ files:
156
177
  - spec/mixins/user_spec.rb
157
178
  - spec/models/data_form_spec.rb
158
179
  - spec/models/jid_spec.rb
180
+ - spec/models/muc_affiliation_collection_spec.rb
181
+ - spec/models/muc_affiliation_spec.rb
159
182
  - spec/models/muc_collection_spec.rb
160
183
  - spec/models/muc_configuration_spec.rb
161
184
  - spec/models/muc_spec.rb
@@ -173,9 +196,9 @@ files:
173
196
  - spec/support/helpers.rb
174
197
  - spec/support/matchers.rb
175
198
  - spec/support/shared_examples.rb
199
+ - spec/support/webmock_stanza_matching.rb
176
200
  - .rspec
177
201
  - .infinity_test
178
- has_rdoc: true
179
202
  homepage: http://github.com/theozaurus/jubjub
180
203
  licenses:
181
204
  - MIT
@@ -207,7 +230,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
207
230
  requirements: []
208
231
 
209
232
  rubyforge_project:
210
- rubygems_version: 1.6.2
233
+ rubygems_version: 1.8.10
211
234
  signing_key:
212
235
  specification_version: 3
213
236
  summary: An Object to XMPP mapper to make managing XMPP resources easy
@@ -221,6 +244,9 @@ test_files:
221
244
  - spec/fixtures/vcr_cassettes/muc_destroy.yml
222
245
  - spec/fixtures/vcr_cassettes/muc_exit.yml
223
246
  - spec/fixtures/vcr_cassettes/muc_list.yml
247
+ - spec/fixtures/vcr_cassettes/muc_message.yml
248
+ - spec/fixtures/vcr_cassettes/muc_modify_affiliations.yml
249
+ - spec/fixtures/vcr_cassettes/muc_retrieve_affiliations.yml
224
250
  - spec/fixtures/vcr_cassettes/pubsub_create.yml
225
251
  - spec/fixtures/vcr_cassettes/pubsub_default_configuration.yml
226
252
  - spec/fixtures/vcr_cassettes/pubsub_destroy.yml
@@ -241,6 +267,8 @@ test_files:
241
267
  - spec/mixins/user_spec.rb
242
268
  - spec/models/data_form_spec.rb
243
269
  - spec/models/jid_spec.rb
270
+ - spec/models/muc_affiliation_collection_spec.rb
271
+ - spec/models/muc_affiliation_spec.rb
244
272
  - spec/models/muc_collection_spec.rb
245
273
  - spec/models/muc_configuration_spec.rb
246
274
  - spec/models/muc_spec.rb
@@ -258,5 +286,6 @@ test_files:
258
286
  - spec/support/helpers.rb
259
287
  - spec/support/matchers.rb
260
288
  - spec/support/shared_examples.rb
289
+ - spec/support/webmock_stanza_matching.rb
261
290
  - .rspec
262
291
  - .infinity_test