pubnub 3.4.1 → 3.5.1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of pubnub might be problematic. Click here for more details.

Files changed (467) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/CHANGELOG +5 -3
  4. data/README.md +267 -41
  5. data/VERSION +1 -1
  6. data/examples/demo_console.rb +191 -32
  7. data/examples/demo_console.rb~ +307 -0
  8. data/examples/pubnub_livestream/Gemfile +1 -1
  9. data/examples/pubnub_livestream/Gemfile.lock +43 -74
  10. data/examples/serial_publish.rb +2 -6
  11. data/fixtures/vcr_cassettes/audit-nonssl-block-invalid-200-async.yml +44 -0
  12. data/fixtures/vcr_cassettes/audit-nonssl-block-invalid-200-sync.yml +44 -0
  13. data/fixtures/vcr_cassettes/audit-nonssl-block-invalid-non-200-async.yml +44 -0
  14. data/fixtures/vcr_cassettes/audit-nonssl-block-invalid-non-200-sync.yml +44 -0
  15. data/fixtures/vcr_cassettes/audit-nonssl-block-valid-200-async.yml +45 -0
  16. data/fixtures/vcr_cassettes/audit-nonssl-block-valid-200-sync.yml +45 -0
  17. data/fixtures/vcr_cassettes/audit-nonssl-block-valid-non-200-async.yml +45 -0
  18. data/fixtures/vcr_cassettes/audit-nonssl-block-valid-non-200-sync.yml +45 -0
  19. data/fixtures/vcr_cassettes/audit-nonssl-parameter-invalid-200-async.yml +44 -0
  20. data/fixtures/vcr_cassettes/audit-nonssl-parameter-invalid-200-sync.yml +44 -0
  21. data/fixtures/vcr_cassettes/audit-nonssl-parameter-invalid-non-200-async.yml +44 -0
  22. data/fixtures/vcr_cassettes/audit-nonssl-parameter-invalid-non-200-sync.yml +44 -0
  23. data/fixtures/vcr_cassettes/audit-nonssl-parameter-valid-200-async.yml +45 -0
  24. data/fixtures/vcr_cassettes/audit-nonssl-parameter-valid-200-sync.yml +45 -0
  25. data/fixtures/vcr_cassettes/audit-nonssl-parameter-valid-non-200-async.yml +45 -0
  26. data/fixtures/vcr_cassettes/audit-nonssl-parameter-valid-non-200-sync.yml +45 -0
  27. data/fixtures/vcr_cassettes/audit-ssl-block-invalid-200-async.yml +44 -0
  28. data/fixtures/vcr_cassettes/audit-ssl-block-invalid-200-sync.yml +44 -0
  29. data/fixtures/vcr_cassettes/audit-ssl-block-invalid-non-200-async.yml +44 -0
  30. data/fixtures/vcr_cassettes/audit-ssl-block-invalid-non-200-sync.yml +44 -0
  31. data/fixtures/vcr_cassettes/audit-ssl-block-valid-200-async.yml +45 -0
  32. data/fixtures/vcr_cassettes/audit-ssl-block-valid-200-sync.yml +45 -0
  33. data/fixtures/vcr_cassettes/audit-ssl-block-valid-non-200-async.yml +45 -0
  34. data/fixtures/vcr_cassettes/audit-ssl-block-valid-non-200-sync.yml +45 -0
  35. data/fixtures/vcr_cassettes/audit-ssl-parameter-invalid-200-async.yml +44 -0
  36. data/fixtures/vcr_cassettes/audit-ssl-parameter-invalid-200-sync.yml +44 -0
  37. data/fixtures/vcr_cassettes/audit-ssl-parameter-invalid-non-200-async.yml +44 -0
  38. data/fixtures/vcr_cassettes/audit-ssl-parameter-invalid-non-200-sync.yml +44 -0
  39. data/fixtures/vcr_cassettes/audit-ssl-parameter-valid-200-async.yml +45 -0
  40. data/fixtures/vcr_cassettes/audit-ssl-parameter-valid-200-sync.yml +45 -0
  41. data/fixtures/vcr_cassettes/audit-ssl-parameter-valid-non-200-async.yml +45 -0
  42. data/fixtures/vcr_cassettes/audit-ssl-parameter-valid-non-200-sync.yml +45 -0
  43. data/fixtures/vcr_cassettes/formatting-envelope-subscribe-cipherkey-many-channels-array.yml +89 -0
  44. data/fixtures/vcr_cassettes/formatting-envelope-subscribe-cipherkey-many-channels-hash.yml +89 -0
  45. data/fixtures/vcr_cassettes/formatting-envelope-subscribe-cipherkey-many-channels-integer.yml +89 -0
  46. data/fixtures/vcr_cassettes/formatting-envelope-subscribe-cipherkey-many-channels-mix.yml +89 -0
  47. data/fixtures/vcr_cassettes/formatting-envelope-subscribe-cipherkey-many-channels-multi-mix.yml +89 -0
  48. data/fixtures/vcr_cassettes/formatting-envelope-subscribe-cipherkey-many-channels-string.yml +89 -0
  49. data/fixtures/vcr_cassettes/formatting-envelope-subscribe-cipherkey-one-channel-array.yml +89 -0
  50. data/fixtures/vcr_cassettes/formatting-envelope-subscribe-cipherkey-one-channel-hash.yml +89 -0
  51. data/fixtures/vcr_cassettes/formatting-envelope-subscribe-cipherkey-one-channel-integer.yml +89 -0
  52. data/fixtures/vcr_cassettes/formatting-envelope-subscribe-cipherkey-one-channel-mix.yml +89 -0
  53. data/fixtures/vcr_cassettes/formatting-envelope-subscribe-cipherkey-one-channel-string.yml +89 -0
  54. data/fixtures/vcr_cassettes/formatting-envelope-subscribe-without-cipherkey-many-channels-array.yml +89 -0
  55. data/fixtures/vcr_cassettes/formatting-envelope-subscribe-without-cipherkey-many-channels-hash.yml +89 -0
  56. data/fixtures/vcr_cassettes/formatting-envelope-subscribe-without-cipherkey-many-channels-integer.yml +89 -0
  57. data/fixtures/vcr_cassettes/formatting-envelope-subscribe-without-cipherkey-many-channels-mix.yml +89 -0
  58. data/fixtures/vcr_cassettes/formatting-envelope-subscribe-without-cipherkey-many-channels-multi-mix.yml +89 -0
  59. data/fixtures/vcr_cassettes/formatting-envelope-subscribe-without-cipherkey-many-channels-string.yml +89 -0
  60. data/fixtures/vcr_cassettes/formatting-envelope-subscribe-without-cipherkey-one-channel-array.yml +89 -0
  61. data/fixtures/vcr_cassettes/formatting-envelope-subscribe-without-cipherkey-one-channel-hash.yml +89 -0
  62. data/fixtures/vcr_cassettes/formatting-envelope-subscribe-without-cipherkey-one-channel-integer.yml +89 -0
  63. data/fixtures/vcr_cassettes/formatting-envelope-subscribe-without-cipherkey-one-channel-mix.yml +89 -0
  64. data/fixtures/vcr_cassettes/formatting-envelope-subscribe-without-cipherkey-one-channel-string.yml +89 -0
  65. data/fixtures/vcr_cassettes/grant-nonssl-block-invalid-200-async.yml +44 -0
  66. data/fixtures/vcr_cassettes/grant-nonssl-block-invalid-200-sync.yml +44 -0
  67. data/fixtures/vcr_cassettes/grant-nonssl-block-invalid-non-200-async.yml +44 -0
  68. data/fixtures/vcr_cassettes/grant-nonssl-block-invalid-non-200-sync.yml +44 -0
  69. data/fixtures/vcr_cassettes/grant-nonssl-block-valid-200-async.yml +45 -0
  70. data/fixtures/vcr_cassettes/grant-nonssl-block-valid-200-sync.yml +45 -0
  71. data/fixtures/vcr_cassettes/grant-nonssl-block-valid-non-200-async.yml +45 -0
  72. data/fixtures/vcr_cassettes/grant-nonssl-block-valid-non-200-sync.yml +45 -0
  73. data/fixtures/vcr_cassettes/grant-nonssl-parameter-invalid-200-async.yml +44 -0
  74. data/fixtures/vcr_cassettes/grant-nonssl-parameter-invalid-200-sync.yml +44 -0
  75. data/fixtures/vcr_cassettes/grant-nonssl-parameter-invalid-non-200-async.yml +44 -0
  76. data/fixtures/vcr_cassettes/grant-nonssl-parameter-invalid-non-200-sync.yml +44 -0
  77. data/fixtures/vcr_cassettes/grant-nonssl-parameter-valid-200-async.yml +45 -0
  78. data/fixtures/vcr_cassettes/grant-nonssl-parameter-valid-200-sync.yml +45 -0
  79. data/fixtures/vcr_cassettes/grant-nonssl-parameter-valid-non-200-async.yml +45 -0
  80. data/fixtures/vcr_cassettes/grant-nonssl-parameter-valid-non-200-sync.yml +45 -0
  81. data/fixtures/vcr_cassettes/grant-ssl-block-invalid-200-async.yml +44 -0
  82. data/fixtures/vcr_cassettes/grant-ssl-block-invalid-200-sync.yml +44 -0
  83. data/fixtures/vcr_cassettes/grant-ssl-block-invalid-non-200-async.yml +44 -0
  84. data/fixtures/vcr_cassettes/grant-ssl-block-invalid-non-200-sync.yml +44 -0
  85. data/fixtures/vcr_cassettes/grant-ssl-block-valid-200-async.yml +45 -0
  86. data/fixtures/vcr_cassettes/grant-ssl-block-valid-200-sync.yml +45 -0
  87. data/fixtures/vcr_cassettes/grant-ssl-block-valid-non-200-async.yml +45 -0
  88. data/fixtures/vcr_cassettes/grant-ssl-block-valid-non-200-sync.yml +45 -0
  89. data/fixtures/vcr_cassettes/grant-ssl-parameter-invalid-200-async.yml +44 -0
  90. data/fixtures/vcr_cassettes/grant-ssl-parameter-invalid-200-sync.yml +44 -0
  91. data/fixtures/vcr_cassettes/grant-ssl-parameter-invalid-non-200-async.yml +44 -0
  92. data/fixtures/vcr_cassettes/grant-ssl-parameter-invalid-non-200-sync.yml +44 -0
  93. data/fixtures/vcr_cassettes/grant-ssl-parameter-valid-200-async.yml +45 -0
  94. data/fixtures/vcr_cassettes/grant-ssl-parameter-valid-200-sync.yml +45 -0
  95. data/fixtures/vcr_cassettes/grant-ssl-parameter-valid-non-200-async.yml +45 -0
  96. data/fixtures/vcr_cassettes/grant-ssl-parameter-valid-non-200-sync.yml +45 -0
  97. data/fixtures/vcr_cassettes/here_now-nonssl-block-invalid-200-async.yml +48 -0
  98. data/fixtures/vcr_cassettes/here_now-nonssl-block-invalid-200-sync.yml +48 -0
  99. data/fixtures/vcr_cassettes/here_now-nonssl-block-invalid-non-200-async.yml +48 -0
  100. data/fixtures/vcr_cassettes/here_now-nonssl-block-invalid-non-200-sync.yml +48 -0
  101. data/fixtures/vcr_cassettes/here_now-nonssl-block-valid-200-async.yml +48 -0
  102. data/fixtures/vcr_cassettes/here_now-nonssl-block-valid-200-sync.yml +48 -0
  103. data/fixtures/vcr_cassettes/here_now-nonssl-block-valid-non-200-async.yml +48 -0
  104. data/fixtures/vcr_cassettes/here_now-nonssl-block-valid-non-200-sync.yml +48 -0
  105. data/fixtures/vcr_cassettes/here_now-nonssl-parameter-invalid-200-async.yml +48 -0
  106. data/fixtures/vcr_cassettes/here_now-nonssl-parameter-invalid-200-sync.yml +48 -0
  107. data/fixtures/vcr_cassettes/here_now-nonssl-parameter-invalid-non-200-async.yml +48 -0
  108. data/fixtures/vcr_cassettes/here_now-nonssl-parameter-invalid-non-200-sync.yml +48 -0
  109. data/fixtures/vcr_cassettes/here_now-nonssl-parameter-valid-200-async.yml +48 -0
  110. data/fixtures/vcr_cassettes/here_now-nonssl-parameter-valid-200-sync.yml +48 -0
  111. data/fixtures/vcr_cassettes/here_now-nonssl-parameter-valid-non-200-async.yml +48 -0
  112. data/fixtures/vcr_cassettes/here_now-nonssl-parameter-valid-non-200-sync.yml +48 -0
  113. data/fixtures/vcr_cassettes/here_now-ssl-block-invalid-200-async.yml +48 -0
  114. data/fixtures/vcr_cassettes/here_now-ssl-block-invalid-200-sync.yml +48 -0
  115. data/fixtures/vcr_cassettes/here_now-ssl-block-invalid-non-200-async.yml +48 -0
  116. data/fixtures/vcr_cassettes/here_now-ssl-block-invalid-non-200-sync.yml +48 -0
  117. data/fixtures/vcr_cassettes/here_now-ssl-block-valid-200-async.yml +48 -0
  118. data/fixtures/vcr_cassettes/here_now-ssl-block-valid-200-sync.yml +48 -0
  119. data/fixtures/vcr_cassettes/here_now-ssl-block-valid-non-200-async.yml +48 -0
  120. data/fixtures/vcr_cassettes/here_now-ssl-block-valid-non-200-sync.yml +48 -0
  121. data/fixtures/vcr_cassettes/here_now-ssl-parameter-invalid-200-async.yml +48 -0
  122. data/fixtures/vcr_cassettes/here_now-ssl-parameter-invalid-200-sync.yml +48 -0
  123. data/fixtures/vcr_cassettes/here_now-ssl-parameter-invalid-non-200-async.yml +48 -0
  124. data/fixtures/vcr_cassettes/here_now-ssl-parameter-invalid-non-200-sync.yml +48 -0
  125. data/fixtures/vcr_cassettes/here_now-ssl-parameter-valid-200-async.yml +48 -0
  126. data/fixtures/vcr_cassettes/here_now-ssl-parameter-valid-200-sync.yml +48 -0
  127. data/fixtures/vcr_cassettes/here_now-ssl-parameter-valid-non-200-async.yml +48 -0
  128. data/fixtures/vcr_cassettes/here_now-ssl-parameter-valid-non-200-sync.yml +48 -0
  129. data/fixtures/vcr_cassettes/history-nonssl-block-invalid-200-async.yml +48 -0
  130. data/fixtures/vcr_cassettes/history-nonssl-block-invalid-200-sync.yml +48 -0
  131. data/fixtures/vcr_cassettes/history-nonssl-block-invalid-non-200-async.yml +48 -0
  132. data/fixtures/vcr_cassettes/history-nonssl-block-invalid-non-200-sync.yml +48 -0
  133. data/fixtures/vcr_cassettes/history-nonssl-block-valid-200-async.yml +48 -0
  134. data/fixtures/vcr_cassettes/history-nonssl-block-valid-200-sync.yml +48 -0
  135. data/fixtures/vcr_cassettes/history-nonssl-block-valid-non-200-async.yml +48 -0
  136. data/fixtures/vcr_cassettes/history-nonssl-block-valid-non-200-sync.yml +48 -0
  137. data/fixtures/vcr_cassettes/history-nonssl-parameter-invalid-200-async.yml +48 -0
  138. data/fixtures/vcr_cassettes/history-nonssl-parameter-invalid-200-sync.yml +48 -0
  139. data/fixtures/vcr_cassettes/history-nonssl-parameter-invalid-non-200-async.yml +48 -0
  140. data/fixtures/vcr_cassettes/history-nonssl-parameter-invalid-non-200-sync.yml +48 -0
  141. data/fixtures/vcr_cassettes/history-nonssl-parameter-valid-200-async.yml +48 -0
  142. data/fixtures/vcr_cassettes/history-nonssl-parameter-valid-200-sync.yml +48 -0
  143. data/fixtures/vcr_cassettes/history-nonssl-parameter-valid-non-200-async.yml +48 -0
  144. data/fixtures/vcr_cassettes/history-nonssl-parameter-valid-non-200-sync.yml +48 -0
  145. data/fixtures/vcr_cassettes/history-ssl-block-invalid-200-async.yml +48 -0
  146. data/fixtures/vcr_cassettes/history-ssl-block-invalid-200-sync.yml +48 -0
  147. data/fixtures/vcr_cassettes/history-ssl-block-invalid-non-200-async.yml +48 -0
  148. data/fixtures/vcr_cassettes/history-ssl-block-invalid-non-200-sync.yml +48 -0
  149. data/fixtures/vcr_cassettes/history-ssl-block-valid-200-async.yml +48 -0
  150. data/fixtures/vcr_cassettes/history-ssl-block-valid-200-sync.yml +48 -0
  151. data/fixtures/vcr_cassettes/history-ssl-block-valid-non-200-async.yml +48 -0
  152. data/fixtures/vcr_cassettes/history-ssl-block-valid-non-200-sync.yml +48 -0
  153. data/fixtures/vcr_cassettes/history-ssl-parameter-invalid-200-async.yml +48 -0
  154. data/fixtures/vcr_cassettes/history-ssl-parameter-invalid-200-sync.yml +48 -0
  155. data/fixtures/vcr_cassettes/history-ssl-parameter-invalid-non-200-async.yml +48 -0
  156. data/fixtures/vcr_cassettes/history-ssl-parameter-invalid-non-200-sync.yml +48 -0
  157. data/fixtures/vcr_cassettes/history-ssl-parameter-valid-200-async.yml +48 -0
  158. data/fixtures/vcr_cassettes/history-ssl-parameter-valid-200-sync.yml +48 -0
  159. data/fixtures/vcr_cassettes/history-ssl-parameter-valid-non-200-async.yml +48 -0
  160. data/fixtures/vcr_cassettes/history-ssl-parameter-valid-non-200-sync.yml +48 -0
  161. data/fixtures/vcr_cassettes/leave-nonssl-block-invalid-200-async.yml +48 -0
  162. data/fixtures/vcr_cassettes/leave-nonssl-block-invalid-200-sync.yml +48 -0
  163. data/fixtures/vcr_cassettes/leave-nonssl-block-invalid-non-200-async.yml +48 -0
  164. data/fixtures/vcr_cassettes/leave-nonssl-block-invalid-non-200-sync.yml +48 -0
  165. data/fixtures/vcr_cassettes/leave-nonssl-block-valid-200-async.yml +48 -0
  166. data/fixtures/vcr_cassettes/leave-nonssl-block-valid-200-sync.yml +48 -0
  167. data/fixtures/vcr_cassettes/leave-nonssl-block-valid-non-200-async.yml +48 -0
  168. data/fixtures/vcr_cassettes/leave-nonssl-block-valid-non-200-sync.yml +48 -0
  169. data/fixtures/vcr_cassettes/leave-nonssl-parameter-invalid-200-async.yml +48 -0
  170. data/fixtures/vcr_cassettes/leave-nonssl-parameter-invalid-200-sync.yml +48 -0
  171. data/fixtures/vcr_cassettes/leave-nonssl-parameter-invalid-non-200-async.yml +48 -0
  172. data/fixtures/vcr_cassettes/leave-nonssl-parameter-invalid-non-200-sync.yml +48 -0
  173. data/fixtures/vcr_cassettes/leave-nonssl-parameter-valid-200-async.yml +48 -0
  174. data/fixtures/vcr_cassettes/leave-nonssl-parameter-valid-200-sync.yml +48 -0
  175. data/fixtures/vcr_cassettes/leave-nonssl-parameter-valid-non-200-async.yml +48 -0
  176. data/fixtures/vcr_cassettes/leave-nonssl-parameter-valid-non-200-sync.yml +48 -0
  177. data/fixtures/vcr_cassettes/leave-ssl-block-invalid-200-async.yml +48 -0
  178. data/fixtures/vcr_cassettes/leave-ssl-block-invalid-200-sync.yml +48 -0
  179. data/fixtures/vcr_cassettes/leave-ssl-block-invalid-non-200-async.yml +48 -0
  180. data/fixtures/vcr_cassettes/leave-ssl-block-invalid-non-200-sync.yml +48 -0
  181. data/fixtures/vcr_cassettes/leave-ssl-block-valid-200-async.yml +48 -0
  182. data/fixtures/vcr_cassettes/leave-ssl-block-valid-200-sync.yml +48 -0
  183. data/fixtures/vcr_cassettes/leave-ssl-block-valid-non-200-async.yml +48 -0
  184. data/fixtures/vcr_cassettes/leave-ssl-block-valid-non-200-sync.yml +48 -0
  185. data/fixtures/vcr_cassettes/leave-ssl-parameter-invalid-200-async.yml +48 -0
  186. data/fixtures/vcr_cassettes/leave-ssl-parameter-invalid-200-sync.yml +48 -0
  187. data/fixtures/vcr_cassettes/leave-ssl-parameter-invalid-non-200-async.yml +48 -0
  188. data/fixtures/vcr_cassettes/leave-ssl-parameter-invalid-non-200-sync.yml +48 -0
  189. data/fixtures/vcr_cassettes/leave-ssl-parameter-valid-200-async.yml +48 -0
  190. data/fixtures/vcr_cassettes/leave-ssl-parameter-valid-200-sync.yml +48 -0
  191. data/fixtures/vcr_cassettes/leave-ssl-parameter-valid-non-200-async.yml +48 -0
  192. data/fixtures/vcr_cassettes/leave-ssl-parameter-valid-non-200-sync.yml +48 -0
  193. data/fixtures/vcr_cassettes/new_ones/publish/publish-encrypted-array-of-hashes.yml +42 -0
  194. data/fixtures/vcr_cassettes/new_ones/publish/publish-encrypted-http-200-invalid.yml +42 -0
  195. data/fixtures/vcr_cassettes/new_ones/publish/publish-encrypted-http-200-valid.yml +42 -0
  196. data/fixtures/vcr_cassettes/new_ones/publish/publish-encrypted-http-auth_key-200-invalid.yml +42 -0
  197. data/fixtures/vcr_cassettes/new_ones/publish/publish-encrypted-http-auth_key-200-valid.yml +42 -0
  198. data/fixtures/vcr_cassettes/new_ones/publish/publish-encrypted-http-auth_key-non200-invalid.yml +42 -0
  199. data/fixtures/vcr_cassettes/new_ones/publish/publish-encrypted-http-auth_key-non200-valid.yml +42 -0
  200. data/fixtures/vcr_cassettes/new_ones/publish/publish-encrypted-http-non200-invalid.yml +42 -0
  201. data/fixtures/vcr_cassettes/new_ones/publish/publish-encrypted-http-non200-valid.yml +42 -0
  202. data/fixtures/vcr_cassettes/new_ones/publish/publish-encrypted-https-200-invalid.yml +42 -0
  203. data/fixtures/vcr_cassettes/new_ones/publish/publish-encrypted-https-200-valid.yml +42 -0
  204. data/fixtures/vcr_cassettes/new_ones/publish/publish-encrypted-https-auth_key-200-invalid.yml +42 -0
  205. data/fixtures/vcr_cassettes/new_ones/publish/publish-encrypted-https-auth_key-200-valid.yml +42 -0
  206. data/fixtures/vcr_cassettes/new_ones/publish/publish-encrypted-https-auth_key-non200-invalid.yml +42 -0
  207. data/fixtures/vcr_cassettes/new_ones/publish/publish-encrypted-https-auth_key-non200-valid.yml +42 -0
  208. data/fixtures/vcr_cassettes/new_ones/publish/publish-encrypted-https-non200-invalid.yml +42 -0
  209. data/fixtures/vcr_cassettes/new_ones/publish/publish-encrypted-https-non200-valid.yml +42 -0
  210. data/fixtures/vcr_cassettes/new_ones/publish/publish-http-200-invalid.yml +42 -0
  211. data/fixtures/vcr_cassettes/new_ones/publish/publish-http-200-valid.yml +42 -0
  212. data/fixtures/vcr_cassettes/new_ones/publish/publish-http-auth_key-200-invalid.yml +42 -0
  213. data/fixtures/vcr_cassettes/new_ones/publish/publish-http-auth_key-200-valid.yml +42 -0
  214. data/fixtures/vcr_cassettes/new_ones/publish/publish-http-auth_key-non200-invalid.yml +42 -0
  215. data/fixtures/vcr_cassettes/new_ones/publish/publish-http-auth_key-non200-valid.yml +42 -0
  216. data/fixtures/vcr_cassettes/new_ones/publish/publish-http-non200-invalid.yml +42 -0
  217. data/fixtures/vcr_cassettes/new_ones/publish/publish-http-non200-valid.yml +42 -0
  218. data/fixtures/vcr_cassettes/new_ones/publish/publish-https-200-invalid.yml +42 -0
  219. data/fixtures/vcr_cassettes/new_ones/publish/publish-https-200-valid.yml +42 -0
  220. data/fixtures/vcr_cassettes/new_ones/publish/publish-https-auth_key-200-invalid.yml +42 -0
  221. data/fixtures/vcr_cassettes/new_ones/publish/publish-https-auth_key-200-valid.yml +42 -0
  222. data/fixtures/vcr_cassettes/new_ones/publish/publish-https-auth_key-non200-invalid.yml +42 -0
  223. data/fixtures/vcr_cassettes/new_ones/publish/publish-https-auth_key-non200-valid.yml +42 -0
  224. data/fixtures/vcr_cassettes/new_ones/publish/publish-https-non200-invalid.yml +42 -0
  225. data/fixtures/vcr_cassettes/new_ones/publish/publish-https-non200-valid.yml +42 -0
  226. data/fixtures/vcr_cassettes/new_ones/publish/publish-plain-array-of-hashes.yml +42 -0
  227. data/fixtures/vcr_cassettes/pam1.yml +35 -0
  228. data/fixtures/vcr_cassettes/pam10.yml +35 -0
  229. data/fixtures/vcr_cassettes/pam11.yml +35 -0
  230. data/fixtures/vcr_cassettes/pam12.yml +35 -0
  231. data/fixtures/vcr_cassettes/pam13.yml +35 -0
  232. data/fixtures/vcr_cassettes/pam14.yml +35 -0
  233. data/fixtures/vcr_cassettes/pam15.yml +35 -0
  234. data/fixtures/vcr_cassettes/pam17.yml +35 -0
  235. data/fixtures/vcr_cassettes/pam2.yml +35 -0
  236. data/fixtures/vcr_cassettes/pam20.yml +35 -0
  237. data/fixtures/vcr_cassettes/pam21.yml +35 -0
  238. data/fixtures/vcr_cassettes/pam22.yml +97 -0
  239. data/fixtures/vcr_cassettes/pam4.yml +35 -0
  240. data/fixtures/vcr_cassettes/pam5.yml +66 -0
  241. data/fixtures/vcr_cassettes/pam6.yml +96 -0
  242. data/fixtures/vcr_cassettes/presence-nonssl-block-invalid-200-async.yml +85 -0
  243. data/fixtures/vcr_cassettes/presence-nonssl-block-invalid-200-sync.yml +85 -0
  244. data/fixtures/vcr_cassettes/presence-nonssl-block-invalid-non-200-async.yml +85 -0
  245. data/fixtures/vcr_cassettes/presence-nonssl-block-invalid-non-200-sync.yml +85 -0
  246. data/fixtures/vcr_cassettes/presence-nonssl-block-valid-200-async.yml +87 -0
  247. data/fixtures/vcr_cassettes/presence-nonssl-block-valid-200-sync.yml +87 -0
  248. data/fixtures/vcr_cassettes/presence-nonssl-block-valid-non-200-async.yml +87 -0
  249. data/fixtures/vcr_cassettes/presence-nonssl-block-valid-non-200-sync.yml +87 -0
  250. data/fixtures/vcr_cassettes/presence-nonssl-parameter-invalid-200-async.yml +85 -0
  251. data/fixtures/vcr_cassettes/presence-nonssl-parameter-invalid-200-sync.yml +85 -0
  252. data/fixtures/vcr_cassettes/presence-nonssl-parameter-invalid-non-200-async.yml +85 -0
  253. data/fixtures/vcr_cassettes/presence-nonssl-parameter-invalid-non-200-sync.yml +85 -0
  254. data/fixtures/vcr_cassettes/presence-nonssl-parameter-valid-200-async.yml +87 -0
  255. data/fixtures/vcr_cassettes/presence-nonssl-parameter-valid-200-sync.yml +87 -0
  256. data/fixtures/vcr_cassettes/presence-nonssl-parameter-valid-non-200-async.yml +87 -0
  257. data/fixtures/vcr_cassettes/presence-nonssl-parameter-valid-non-200-sync.yml +87 -0
  258. data/fixtures/vcr_cassettes/presence-ssl-block-invalid-200-async.yml +85 -0
  259. data/fixtures/vcr_cassettes/presence-ssl-block-invalid-200-sync.yml +85 -0
  260. data/fixtures/vcr_cassettes/presence-ssl-block-invalid-non-200-async.yml +85 -0
  261. data/fixtures/vcr_cassettes/presence-ssl-block-invalid-non-200-sync.yml +85 -0
  262. data/fixtures/vcr_cassettes/presence-ssl-block-valid-200-async.yml +87 -0
  263. data/fixtures/vcr_cassettes/presence-ssl-block-valid-200-sync-new.yml +81 -0
  264. data/fixtures/vcr_cassettes/presence-ssl-block-valid-200-sync.yml +85 -0
  265. data/fixtures/vcr_cassettes/presence-ssl-block-valid-non-200-async.yml +87 -0
  266. data/fixtures/vcr_cassettes/presence-ssl-block-valid-non-200-sync.yml +87 -0
  267. data/fixtures/vcr_cassettes/presence-ssl-parameter-invalid-200-async.yml +85 -0
  268. data/fixtures/vcr_cassettes/presence-ssl-parameter-invalid-200-sync.yml +85 -0
  269. data/fixtures/vcr_cassettes/presence-ssl-parameter-invalid-non-200-async.yml +85 -0
  270. data/fixtures/vcr_cassettes/presence-ssl-parameter-invalid-non-200-sync.yml +85 -0
  271. data/fixtures/vcr_cassettes/presence-ssl-parameter-valid-200-async.yml +87 -0
  272. data/fixtures/vcr_cassettes/presence-ssl-parameter-valid-200-sync.yml +87 -0
  273. data/fixtures/vcr_cassettes/presence-ssl-parameter-valid-non-200-async.yml +87 -0
  274. data/fixtures/vcr_cassettes/presence-ssl-parameter-valid-non-200-sync.yml +87 -0
  275. data/fixtures/vcr_cassettes/publish-nonssl-block-invalid-200-async.yml +44 -0
  276. data/fixtures/vcr_cassettes/publish-nonssl-block-invalid-200-sync.yml +44 -0
  277. data/fixtures/vcr_cassettes/publish-nonssl-block-invalid-non-200-async.yml +44 -0
  278. data/fixtures/vcr_cassettes/publish-nonssl-block-invalid-non-200-sync.yml +44 -0
  279. data/fixtures/vcr_cassettes/publish-nonssl-block-valid-200-async.yml +44 -0
  280. data/fixtures/vcr_cassettes/publish-nonssl-block-valid-200-sync.yml +44 -0
  281. data/fixtures/vcr_cassettes/publish-nonssl-block-valid-non-200-async.yml +44 -0
  282. data/fixtures/vcr_cassettes/publish-nonssl-block-valid-non-200-sync.yml +44 -0
  283. data/fixtures/vcr_cassettes/publish-nonssl-parameter-invalid-200-async.yml +44 -0
  284. data/fixtures/vcr_cassettes/publish-nonssl-parameter-invalid-200-sync.yml +44 -0
  285. data/fixtures/vcr_cassettes/publish-nonssl-parameter-invalid-non-200-async.yml +44 -0
  286. data/fixtures/vcr_cassettes/publish-nonssl-parameter-invalid-non-200-sync.yml +44 -0
  287. data/fixtures/vcr_cassettes/publish-nonssl-parameter-valid-200-async.yml +44 -0
  288. data/fixtures/vcr_cassettes/publish-nonssl-parameter-valid-200-sync.yml +44 -0
  289. data/fixtures/vcr_cassettes/publish-nonssl-parameter-valid-non-200-async.yml +44 -0
  290. data/fixtures/vcr_cassettes/publish-nonssl-parameter-valid-non-200-sync.yml +44 -0
  291. data/fixtures/vcr_cassettes/publish-ssl-block-invalid-200-async.yml +44 -0
  292. data/fixtures/vcr_cassettes/publish-ssl-block-invalid-200-sync.yml +44 -0
  293. data/fixtures/vcr_cassettes/publish-ssl-block-invalid-non-200-async.yml +44 -0
  294. data/fixtures/vcr_cassettes/publish-ssl-block-invalid-non-200-sync.yml +44 -0
  295. data/fixtures/vcr_cassettes/publish-ssl-block-valid-200-async.yml +44 -0
  296. data/fixtures/vcr_cassettes/publish-ssl-block-valid-200-sync.yml +44 -0
  297. data/fixtures/vcr_cassettes/publish-ssl-block-valid-non-200-async.yml +44 -0
  298. data/fixtures/vcr_cassettes/publish-ssl-block-valid-non-200-sync.yml +44 -0
  299. data/fixtures/vcr_cassettes/publish-ssl-parameter-invalid-200-async.yml +44 -0
  300. data/fixtures/vcr_cassettes/publish-ssl-parameter-invalid-200-sync.yml +44 -0
  301. data/fixtures/vcr_cassettes/publish-ssl-parameter-invalid-non-200-async.yml +44 -0
  302. data/fixtures/vcr_cassettes/publish-ssl-parameter-invalid-non-200-sync.yml +44 -0
  303. data/fixtures/vcr_cassettes/publish-ssl-parameter-valid-200-async.yml +44 -0
  304. data/fixtures/vcr_cassettes/publish-ssl-parameter-valid-200-sync.yml +44 -0
  305. data/fixtures/vcr_cassettes/publish-ssl-parameter-valid-non-200-async.yml +44 -0
  306. data/fixtures/vcr_cassettes/publish-ssl-parameter-valid-non-200-sync.yml +44 -0
  307. data/fixtures/vcr_cassettes/revoke-nonssl-block-invalid-200-async.yml +44 -0
  308. data/fixtures/vcr_cassettes/revoke-nonssl-block-invalid-200-sync.yml +44 -0
  309. data/fixtures/vcr_cassettes/revoke-nonssl-block-invalid-non-200-async.yml +44 -0
  310. data/fixtures/vcr_cassettes/revoke-nonssl-block-invalid-non-200-sync.yml +44 -0
  311. data/fixtures/vcr_cassettes/revoke-nonssl-block-valid-200-async.yml +45 -0
  312. data/fixtures/vcr_cassettes/revoke-nonssl-block-valid-200-sync.yml +45 -0
  313. data/fixtures/vcr_cassettes/revoke-nonssl-block-valid-non-200-async.yml +45 -0
  314. data/fixtures/vcr_cassettes/revoke-nonssl-block-valid-non-200-sync.yml +45 -0
  315. data/fixtures/vcr_cassettes/revoke-nonssl-parameter-invalid-200-async.yml +44 -0
  316. data/fixtures/vcr_cassettes/revoke-nonssl-parameter-invalid-200-sync.yml +44 -0
  317. data/fixtures/vcr_cassettes/revoke-nonssl-parameter-invalid-non-200-async.yml +44 -0
  318. data/fixtures/vcr_cassettes/revoke-nonssl-parameter-invalid-non-200-sync.yml +44 -0
  319. data/fixtures/vcr_cassettes/revoke-nonssl-parameter-valid-200-async.yml +45 -0
  320. data/fixtures/vcr_cassettes/revoke-nonssl-parameter-valid-200-sync.yml +45 -0
  321. data/fixtures/vcr_cassettes/revoke-nonssl-parameter-valid-non-200-async.yml +45 -0
  322. data/fixtures/vcr_cassettes/revoke-nonssl-parameter-valid-non-200-sync.yml +45 -0
  323. data/fixtures/vcr_cassettes/revoke-ssl-block-invalid-200-async.yml +44 -0
  324. data/fixtures/vcr_cassettes/revoke-ssl-block-invalid-200-sync.yml +44 -0
  325. data/fixtures/vcr_cassettes/revoke-ssl-block-invalid-non-200-async.yml +44 -0
  326. data/fixtures/vcr_cassettes/revoke-ssl-block-invalid-non-200-sync.yml +44 -0
  327. data/fixtures/vcr_cassettes/revoke-ssl-block-valid-200-async.yml +45 -0
  328. data/fixtures/vcr_cassettes/revoke-ssl-block-valid-200-sync.yml +45 -0
  329. data/fixtures/vcr_cassettes/revoke-ssl-block-valid-non-200-async.yml +45 -0
  330. data/fixtures/vcr_cassettes/revoke-ssl-block-valid-non-200-sync.yml +45 -0
  331. data/fixtures/vcr_cassettes/revoke-ssl-parameter-invalid-200-async.yml +44 -0
  332. data/fixtures/vcr_cassettes/revoke-ssl-parameter-invalid-200-sync.yml +44 -0
  333. data/fixtures/vcr_cassettes/revoke-ssl-parameter-invalid-non-200-async.yml +44 -0
  334. data/fixtures/vcr_cassettes/revoke-ssl-parameter-invalid-non-200-sync.yml +44 -0
  335. data/fixtures/vcr_cassettes/revoke-ssl-parameter-valid-200-async.yml +45 -0
  336. data/fixtures/vcr_cassettes/revoke-ssl-parameter-valid-200-sync.yml +45 -0
  337. data/fixtures/vcr_cassettes/revoke-ssl-parameter-valid-non-200-async.yml +45 -0
  338. data/fixtures/vcr_cassettes/revoke-ssl-parameter-valid-non-200-sync.yml +45 -0
  339. data/fixtures/vcr_cassettes/single-event-invalid-json.yml +208 -0
  340. data/fixtures/vcr_cassettes/single-event-non200.yml +44 -0
  341. data/fixtures/vcr_cassettes/subscribe-nonssl-block-invalid-200-async.yml +85 -0
  342. data/fixtures/vcr_cassettes/subscribe-nonssl-block-invalid-200-sync.yml +85 -0
  343. data/fixtures/vcr_cassettes/subscribe-nonssl-block-invalid-non-200-async.yml +85 -0
  344. data/fixtures/vcr_cassettes/subscribe-nonssl-block-invalid-non-200-sync.yml +85 -0
  345. data/fixtures/vcr_cassettes/subscribe-nonssl-block-valid-200-async.yml +85 -0
  346. data/fixtures/vcr_cassettes/subscribe-nonssl-block-valid-200-sync.yml +85 -0
  347. data/fixtures/vcr_cassettes/subscribe-nonssl-block-valid-non-200-async.yml +85 -0
  348. data/fixtures/vcr_cassettes/subscribe-nonssl-block-valid-non-200-sync.yml +85 -0
  349. data/fixtures/vcr_cassettes/subscribe-nonssl-parameter-invalid-200-async.yml +85 -0
  350. data/fixtures/vcr_cassettes/subscribe-nonssl-parameter-invalid-200-sync.yml +85 -0
  351. data/fixtures/vcr_cassettes/subscribe-nonssl-parameter-invalid-non-200-async.yml +85 -0
  352. data/fixtures/vcr_cassettes/subscribe-nonssl-parameter-invalid-non-200-sync.yml +85 -0
  353. data/fixtures/vcr_cassettes/subscribe-nonssl-parameter-valid-200-async.yml +85 -0
  354. data/fixtures/vcr_cassettes/subscribe-nonssl-parameter-valid-200-sync.yml +85 -0
  355. data/fixtures/vcr_cassettes/subscribe-nonssl-parameter-valid-non-200-async.yml +85 -0
  356. data/fixtures/vcr_cassettes/subscribe-nonssl-parameter-valid-non-200-sync.yml +85 -0
  357. data/fixtures/vcr_cassettes/subscribe-ssl-block-invalid-200-async.yml +85 -0
  358. data/fixtures/vcr_cassettes/subscribe-ssl-block-invalid-200-sync.yml +85 -0
  359. data/fixtures/vcr_cassettes/subscribe-ssl-block-invalid-non-200-async.yml +85 -0
  360. data/fixtures/vcr_cassettes/subscribe-ssl-block-invalid-non-200-sync.yml +85 -0
  361. data/fixtures/vcr_cassettes/subscribe-ssl-block-valid-200-async.yml +85 -0
  362. data/fixtures/vcr_cassettes/subscribe-ssl-block-valid-200-sync.yml +85 -0
  363. data/fixtures/vcr_cassettes/subscribe-ssl-block-valid-non-200-async.yml +85 -0
  364. data/fixtures/vcr_cassettes/subscribe-ssl-block-valid-non-200-sync.yml +85 -0
  365. data/fixtures/vcr_cassettes/subscribe-ssl-parameter-invalid-200-async.yml +85 -0
  366. data/fixtures/vcr_cassettes/subscribe-ssl-parameter-invalid-200-sync.yml +85 -0
  367. data/fixtures/vcr_cassettes/subscribe-ssl-parameter-invalid-non-200-async.yml +85 -0
  368. data/fixtures/vcr_cassettes/subscribe-ssl-parameter-invalid-non-200-sync.yml +85 -0
  369. data/fixtures/vcr_cassettes/subscribe-ssl-parameter-valid-200-async.yml +85 -0
  370. data/fixtures/vcr_cassettes/subscribe-ssl-parameter-valid-200-sync.yml +85 -0
  371. data/fixtures/vcr_cassettes/subscribe-ssl-parameter-valid-non-200-async.yml +85 -0
  372. data/fixtures/vcr_cassettes/subscribe-ssl-parameter-valid-non-200-sync.yml +85 -0
  373. data/fixtures/vcr_cassettes/subscription-event-invalid-json.yml +454 -0
  374. data/fixtures/vcr_cassettes/subscription-event-non200.yml +208 -0
  375. data/fixtures/vcr_cassettes/time-nonssl-block-invalid-200-async.yml +44 -0
  376. data/fixtures/vcr_cassettes/time-nonssl-block-invalid-200-sync.yml +44 -0
  377. data/fixtures/vcr_cassettes/time-nonssl-block-invalid-non-200-async.yml +44 -0
  378. data/fixtures/vcr_cassettes/time-nonssl-block-invalid-non-200-sync.yml +44 -0
  379. data/fixtures/vcr_cassettes/time-nonssl-block-valid-200-async.yml +44 -0
  380. data/fixtures/vcr_cassettes/time-nonssl-block-valid-200-sync.yml +44 -0
  381. data/fixtures/vcr_cassettes/time-nonssl-block-valid-non-200-async.yml +44 -0
  382. data/fixtures/vcr_cassettes/time-nonssl-block-valid-non-200-sync.yml +44 -0
  383. data/fixtures/vcr_cassettes/time-nonssl-parameter-invalid-200-async.yml +44 -0
  384. data/fixtures/vcr_cassettes/time-nonssl-parameter-invalid-200-sync.yml +44 -0
  385. data/fixtures/vcr_cassettes/time-nonssl-parameter-invalid-non-200-async.yml +44 -0
  386. data/fixtures/vcr_cassettes/time-nonssl-parameter-invalid-non-200-sync.yml +44 -0
  387. data/fixtures/vcr_cassettes/time-nonssl-parameter-valid-200-async.yml +44 -0
  388. data/fixtures/vcr_cassettes/time-nonssl-parameter-valid-200-sync.yml +44 -0
  389. data/fixtures/vcr_cassettes/time-nonssl-parameter-valid-non-200-async.yml +44 -0
  390. data/fixtures/vcr_cassettes/time-nonssl-parameter-valid-non-200-sync.yml +44 -0
  391. data/fixtures/vcr_cassettes/time-ssl-block-invalid-200-async.yml +44 -0
  392. data/fixtures/vcr_cassettes/time-ssl-block-invalid-200-sync.yml +44 -0
  393. data/fixtures/vcr_cassettes/time-ssl-block-invalid-non-200-async.yml +44 -0
  394. data/fixtures/vcr_cassettes/time-ssl-block-invalid-non-200-sync.yml +44 -0
  395. data/fixtures/vcr_cassettes/time-ssl-block-valid-200-async.yml +44 -0
  396. data/fixtures/vcr_cassettes/time-ssl-block-valid-200-sync.yml +44 -0
  397. data/fixtures/vcr_cassettes/time-ssl-block-valid-non-200-async.yml +44 -0
  398. data/fixtures/vcr_cassettes/time-ssl-block-valid-non-200-sync.yml +44 -0
  399. data/fixtures/vcr_cassettes/time-ssl-parameter-invalid-200-async.yml +44 -0
  400. data/fixtures/vcr_cassettes/time-ssl-parameter-invalid-200-sync.yml +44 -0
  401. data/fixtures/vcr_cassettes/time-ssl-parameter-invalid-non-200-async.yml +44 -0
  402. data/fixtures/vcr_cassettes/time-ssl-parameter-invalid-non-200-sync.yml +44 -0
  403. data/fixtures/vcr_cassettes/time-ssl-parameter-valid-200-async.yml +44 -0
  404. data/fixtures/vcr_cassettes/time-ssl-parameter-valid-200-sync.yml +44 -0
  405. data/fixtures/vcr_cassettes/time-ssl-parameter-valid-non-200-async.yml +44 -0
  406. data/fixtures/vcr_cassettes/time-ssl-parameter-valid-non-200-sync.yml +44 -0
  407. data/lib/pubnub.rb +7 -15
  408. data/lib/pubnub/client.rb +189 -468
  409. data/lib/pubnub/configuration.rb +27 -20
  410. data/lib/pubnub/crypto.rb +11 -4
  411. data/lib/pubnub/envelope.rb +45 -0
  412. data/lib/pubnub/event.rb +470 -0
  413. data/lib/pubnub/events/audit.rb +38 -0
  414. data/lib/pubnub/events/grant.rb +59 -0
  415. data/lib/pubnub/events/here_now.rb +55 -0
  416. data/lib/pubnub/events/history.rb +110 -0
  417. data/lib/pubnub/events/leave.rb +73 -0
  418. data/lib/pubnub/events/presence.rb +35 -0
  419. data/lib/pubnub/events/publish.rb +71 -0
  420. data/lib/pubnub/events/revoke.rb +56 -0
  421. data/lib/pubnub/events/subscribe.rb +34 -0
  422. data/lib/pubnub/events/time.rb +52 -0
  423. data/lib/pubnub/exceptions.rb +50 -0
  424. data/lib/pubnub/formatter.rb +45 -0
  425. data/lib/pubnub/pam.rb +59 -0
  426. data/lib/pubnub/parser.rb +21 -0
  427. data/lib/pubnub/validator.rb +29 -0
  428. data/lib/version.rb +3 -0
  429. data/pubnub.gemspec +3 -5
  430. data/spec/lib/client_spec.rb +27 -325
  431. data/spec/lib/encoder_spec.rb +51 -0
  432. data/spec/lib/formatting_envelope_spec.rb +304 -0
  433. data/spec/lib/integration/audit_spec.rb +544 -0
  434. data/spec/lib/integration/grant_spec.rb +544 -0
  435. data/spec/lib/integration/here_now_spec.rb +543 -0
  436. data/spec/lib/integration/history_spec.rb +541 -0
  437. data/spec/lib/integration/leave_spec.rb +540 -0
  438. data/spec/lib/integration/presence_spec.rb +557 -0
  439. data/spec/lib/integration/publish_spec.rb +541 -0
  440. data/spec/lib/integration/revoke_spec.rb +544 -0
  441. data/spec/lib/integration/subscribe_spec.rb +564 -0
  442. data/spec/lib/integration/time_spec.rb +541 -0
  443. data/spec/lib/new_integration/publish_spec.rb +1867 -0
  444. data/spec/lib/retry_logic_spec.rb +53 -0
  445. data/spec/spec_helper.rb +28 -2
  446. data/spec/tools/pam-test-generator.rb +367 -0
  447. data/spec/tools/test-generator.rb +310 -0
  448. metadata +434 -50
  449. data/.yardoc/checksums +0 -13
  450. data/.yardoc/object_types +0 -0
  451. data/.yardoc/objects/root.dat +0 -0
  452. data/.yardoc/proxy_types +0 -0
  453. data/lib/pubnub/error.rb +0 -23
  454. data/lib/pubnub/request.rb +0 -288
  455. data/lib/pubnub/response.rb +0 -126
  456. data/lib/pubnub/subscription.rb +0 -24
  457. data/lib/pubnub/version.rb +0 -3
  458. data/lib/tasks/examples.rake +0 -39
  459. data/spec/lib/crypto_spec.rb +0 -89
  460. data/spec/lib/history_integration_spec.rb +0 -0
  461. data/spec/lib/presence_integration_spec.rb +0 -16
  462. data/spec/lib/publish_integration_spec.rb +0 -994
  463. data/spec/lib/pubnub_spec.rb +0 -12
  464. data/spec/lib/request_spec.rb +0 -151
  465. data/spec/lib/subscribe_integration_spec.rb +0 -944
  466. data/spec/lib/subscribe_timeout_spec.rb +0 -65
  467. data/spec/lib/time_integration_spec.rb +0 -0
@@ -0,0 +1,1867 @@
1
+ require 'spec_helper'
2
+
3
+ describe '#publish' do
4
+ before(:each) do
5
+ @envelopes = Array.new
6
+ @error_envelopes = Array.new
7
+
8
+ @callback = lambda do |envelope|
9
+ @envelopes << envelope
10
+ end
11
+
12
+ @error_callback = lambda do |envelope|
13
+ @error_envelopes << envelope
14
+ end
15
+ end
16
+
17
+ context 'uses http' do
18
+ context 'with auth_key provided' do
19
+ context 'without encrypting message' do
20
+
21
+ before(:each) do
22
+ @pubnub = Pubnub.new(
23
+ :max_retries => 0,
24
+ :subscribe_key => :demo,
25
+ :publish_key => :demo,
26
+ :auth_key => :demoish_authkey,
27
+ :secret_key => 'some_secret_key',
28
+ :error_callback => @error_callback
29
+ )
30
+
31
+ @pubnub.uuid = 'tester'
32
+ end
33
+
34
+ context 'gets status 200 response' do
35
+ context 'with valid json' do
36
+ context 'its asynchronous' do
37
+ it 'publishes valid message' do
38
+ VCR.use_cassette('new_ones/publish/publish-http-auth_key-200-valid', :record => :none) do
39
+
40
+ @pubnub.publish(
41
+ :message => {:text => 'sometext'},
42
+ :channel => 'ruby_demo_channel',
43
+ :callback => @callback
44
+ )
45
+
46
+ eventually do
47
+ @envelopes.size.should eq 1
48
+ @envelopes.first.response_message.should eq 'Sent'
49
+ @envelopes.first.status.should eq 200
50
+ @envelopes.first.channel.should eq 'ruby_demo_channel'
51
+ @envelopes.first.message.should eq({:text => 'sometext'})
52
+ @envelopes.first.timetoken.blank?.should eq false
53
+ end
54
+
55
+ end
56
+ end
57
+ end
58
+
59
+ context 'its synchronous' do
60
+ it 'publishes valid message' do
61
+ VCR.use_cassette('new_ones/publish/publish-http-auth_key-200-valid', :record => :none) do
62
+
63
+ @pubnub.publish(
64
+ :message => {:text => 'sometext'},
65
+ :channel => 'ruby_demo_channel',
66
+ :callback => @callback,
67
+ :http_sync => true
68
+ )
69
+
70
+ @envelopes.size.should eq 1
71
+ @envelopes.first.response_message.should eq 'Sent'
72
+ @envelopes.first.status.should eq 200
73
+ @envelopes.first.channel.should eq 'ruby_demo_channel'
74
+ @envelopes.first.message.should eq({:text => 'sometext'})
75
+ @envelopes.first.timetoken.blank?.should eq false
76
+
77
+ end
78
+ end
79
+ end
80
+ end
81
+
82
+ context 'with invalid json' do
83
+ context 'its asynchronous' do
84
+ it 'handles invalid json gracefully' do
85
+ VCR.use_cassette('new_ones/publish/publish-http-auth_key-200-invalid', :record => :none) do
86
+
87
+ @pubnub.publish(
88
+ :message => {:text => 'sometext'},
89
+ :channel => 'ruby_demo_channel',
90
+ :callback => @callback
91
+ )
92
+
93
+ eventually do
94
+ @envelopes.size.should eq 0
95
+ @error_envelopes.size.should eq 1
96
+ @error_envelopes.first.response_message.should eq nil
97
+ @error_envelopes.first.response.should eq('[1,"Sent","13936818988607190"')
98
+ @error_envelopes.first.status.should eq 200
99
+ @error_envelopes.first.channel.should eq('ruby_demo_channel')
100
+ @error_envelopes.first.message.should eq('[0,"Invalid JSON in response."]')
101
+ @error_envelopes.first.timetoken.blank?.should eq true
102
+ end
103
+
104
+ end
105
+ end
106
+ end
107
+
108
+ context 'its synchronous' do
109
+ it 'handles invalid json gracefully' do
110
+ VCR.use_cassette('new_ones/publish/publish-http-auth_key-200-invalid', :record => :none) do
111
+
112
+ @pubnub.publish(
113
+ :message => {:text => 'sometext'},
114
+ :channel => 'ruby_demo_channel',
115
+ :callback => @callback,
116
+ :http_sync => true
117
+ )
118
+
119
+ @envelopes.size.should eq 0
120
+ @error_envelopes.size.should eq 1
121
+ @error_envelopes.first.response_message.should eq nil
122
+ @error_envelopes.first.response.should eq('[1,"Sent","13936818988607190"')
123
+ @error_envelopes.first.status.should eq 200
124
+ @error_envelopes.first.channel.should eq('ruby_demo_channel')
125
+ @error_envelopes.first.message.should eq('[0,"Invalid JSON in response."]')
126
+ @error_envelopes.first.timetoken.blank?.should eq true
127
+
128
+ end
129
+ end
130
+ end
131
+ end
132
+ end
133
+
134
+ context 'gets status non200 response' do
135
+ context 'with valid json' do
136
+ context 'its asynchronous' do
137
+ it 'handles non200 response gracefully' do
138
+ VCR.use_cassette('new_ones/publish/publish-http-auth_key-non200-valid', :record => :none) do
139
+
140
+ @pubnub.publish(
141
+ :message => {:text => 'sometext'},
142
+ :channel => 'ruby_demo_channel',
143
+ :callback => @callback
144
+ )
145
+
146
+ eventually do
147
+ @envelopes.size.should eq 0
148
+ @error_envelopes.size.should eq 1
149
+ @error_envelopes.first.response_message.should eq 'Sent'
150
+ @error_envelopes.first.response.should eq('[1,"Sent","13936818988607190"]')
151
+ @error_envelopes.first.status.should eq 500
152
+ @error_envelopes.first.channel.should eq('ruby_demo_channel')
153
+ @error_envelopes.first.message.should eq('[0,"Non 2xx server response."]')
154
+ @error_envelopes.first.timetoken.blank?.should eq false
155
+ end
156
+
157
+ end
158
+ end
159
+ end
160
+
161
+ context 'its synchronous' do
162
+ it 'handles non200 response gracefully' do
163
+ VCR.use_cassette('new_ones/publish/publish-http-auth_key-non200-valid', :record => :none) do
164
+
165
+ @pubnub.publish(
166
+ :message => {:text => 'sometext'},
167
+ :channel => 'ruby_demo_channel',
168
+ :callback => @callback,
169
+ :http_sync => true
170
+ )
171
+
172
+ @envelopes.size.should eq 0
173
+ @error_envelopes.size.should eq 1
174
+ @error_envelopes.first.response_message.should eq 'Sent'
175
+ @error_envelopes.first.response.should eq('[1,"Sent","13936818988607190"]')
176
+ @error_envelopes.first.status.should eq 500
177
+ @error_envelopes.first.channel.should eq('ruby_demo_channel')
178
+ @error_envelopes.first.message.should eq('[0,"Non 2xx server response."]')
179
+ @error_envelopes.first.timetoken.blank?.should eq false
180
+
181
+ end
182
+ end
183
+ end
184
+ end
185
+
186
+ context 'with invalid json' do
187
+ context 'its asynchronous' do
188
+ it 'handles invalid json and non200 response gracefully' do
189
+ VCR.use_cassette('new_ones/publish/publish-http-auth_key-non200-invalid', :record => :none) do
190
+
191
+ @pubnub.publish(
192
+ :message => {:text => 'sometext'},
193
+ :channel => 'ruby_demo_channel',
194
+ :callback => @callback
195
+ )
196
+
197
+ eventually do
198
+ @envelopes.size.should eq 0
199
+ @error_envelopes.size.should eq 1
200
+ @error_envelopes.first.response_message.should eq nil
201
+ @error_envelopes.first.response.should eq('[1,"Sent","13936818988607190"')
202
+ @error_envelopes.first.status.should eq 500
203
+ @error_envelopes.first.channel.should eq('ruby_demo_channel')
204
+ @error_envelopes.first.message.should eq('[0,"Invalid JSON in response."]')
205
+ @error_envelopes.first.timetoken.blank?.should eq true
206
+ end
207
+
208
+ end
209
+ end
210
+ end
211
+
212
+ context 'its synchronous' do
213
+ it 'handles invalid json and non200 response gracefully' do
214
+ VCR.use_cassette('new_ones/publish/publish-http-auth_key-non200-invalid', :record => :none) do
215
+
216
+ @pubnub.publish(
217
+ :message => {:text => 'sometext'},
218
+ :channel => 'ruby_demo_channel',
219
+ :callback => @callback,
220
+ :http_sync => true
221
+ )
222
+
223
+ @envelopes.size.should eq 0
224
+ @error_envelopes.size.should eq 1
225
+ @error_envelopes.first.response_message.should eq nil
226
+ @error_envelopes.first.response.should eq('[1,"Sent","13936818988607190"')
227
+ @error_envelopes.first.status.should eq 500
228
+ @error_envelopes.first.channel.should eq('ruby_demo_channel')
229
+ @error_envelopes.first.message.should eq('[0,"Invalid JSON in response."]')
230
+ @error_envelopes.first.timetoken.blank?.should eq true
231
+
232
+ end
233
+ end
234
+ end
235
+ end
236
+ end
237
+ end
238
+
239
+ context 'with encrypting message' do
240
+
241
+ before(:each) do
242
+ @pubnub = Pubnub.new(
243
+ :max_retries => 0,
244
+ :subscribe_key => :demo,
245
+ :publish_key => :demo,
246
+ :auth_key => :demoish_authkey,
247
+ :secret_key => 'some_secret_key',
248
+ :cipher_key => 'secret',
249
+ :error_callback => @error_callback
250
+ )
251
+
252
+ @pubnub.uuid = 'tester'
253
+ end
254
+
255
+ context 'gets status 200 response' do
256
+ context 'with valid json' do
257
+ context 'its asynchronous' do
258
+ it 'publishes valid message' do
259
+ VCR.use_cassette('new_ones/publish/publish-encrypted-http-auth_key-200-valid', :record => :none) do
260
+
261
+ @pubnub.publish(
262
+ :message => {:text => 'sometext'},
263
+ :channel => 'ruby_demo_channel',
264
+ :callback => @callback
265
+ )
266
+
267
+ eventually do
268
+ @envelopes.size.should eq 1
269
+ @envelopes.first.response_message.should eq 'Sent'
270
+ @envelopes.first.status.should eq 200
271
+ @envelopes.first.channel.should eq 'ruby_demo_channel'
272
+ @envelopes.first.message.should eq({:text => 'sometext'})
273
+ @envelopes.first.timetoken.blank?.should eq false
274
+ end
275
+
276
+ end
277
+ end
278
+ end
279
+
280
+ context 'its synchronous' do
281
+ it 'publishes valid message' do
282
+ VCR.use_cassette('new_ones/publish/publish-encrypted-http-auth_key-200-valid', :record => :none) do
283
+
284
+ @pubnub.publish(
285
+ :message => {:text => 'sometext'},
286
+ :channel => 'ruby_demo_channel',
287
+ :callback => @callback,
288
+ :http_sync => true
289
+ )
290
+
291
+ @envelopes.size.should eq 1
292
+ @envelopes.first.response_message.should eq 'Sent'
293
+ @envelopes.first.status.should eq 200
294
+ @envelopes.first.channel.should eq 'ruby_demo_channel'
295
+ @envelopes.first.message.should eq({:text => 'sometext'})
296
+ @envelopes.first.timetoken.blank?.should eq false
297
+
298
+ end
299
+ end
300
+ end
301
+ end
302
+
303
+ context 'with invalid json' do
304
+ context 'its asynchronous' do
305
+ it 'handles invalid json gracefully' do
306
+ VCR.use_cassette('new_ones/publish/publish-encrypted-http-auth_key-200-invalid', :record => :none) do
307
+
308
+ @pubnub.publish(
309
+ :message => {:text => 'sometext'},
310
+ :channel => 'ruby_demo_channel',
311
+ :callback => @callback
312
+ )
313
+
314
+ eventually do
315
+ @envelopes.size.should eq 0
316
+ @error_envelopes.size.should eq 1
317
+ @error_envelopes.first.response_message.should eq nil
318
+ @error_envelopes.first.response.should eq('[1,"Sent","13937904716672898"')
319
+ @error_envelopes.first.status.should eq 200
320
+ @error_envelopes.first.channel.should eq('ruby_demo_channel')
321
+ @error_envelopes.first.message.should eq('[0,"Invalid JSON in response."]')
322
+ @error_envelopes.first.timetoken.blank?.should eq true
323
+ end
324
+
325
+ end
326
+ end
327
+ end
328
+
329
+ context 'its synchronous' do
330
+ it 'handles invalid json gracefully' do
331
+ VCR.use_cassette('new_ones/publish/publish-encrypted-http-auth_key-200-invalid', :record => :none) do
332
+
333
+ @pubnub.publish(
334
+ :message => {:text => 'sometext'},
335
+ :channel => 'ruby_demo_channel',
336
+ :callback => @callback,
337
+ :http_sync => true
338
+ )
339
+
340
+ @envelopes.size.should eq 0
341
+ @error_envelopes.size.should eq 1
342
+ @error_envelopes.first.response_message.should eq nil
343
+ @error_envelopes.first.response.should eq('[1,"Sent","13937904716672898"')
344
+ @error_envelopes.first.status.should eq 200
345
+ @error_envelopes.first.channel.should eq('ruby_demo_channel')
346
+ @error_envelopes.first.message.should eq('[0,"Invalid JSON in response."]')
347
+ @error_envelopes.first.timetoken.blank?.should eq true
348
+
349
+ end
350
+ end
351
+ end
352
+ end
353
+ end
354
+
355
+ context 'gets status non200 response' do
356
+ context 'with valid json' do
357
+ context 'its asynchronous' do
358
+ it 'handles non200 response gracefully' do
359
+ VCR.use_cassette('new_ones/publish/publish-encrypted-http-auth_key-non200-valid', :record => :none) do
360
+
361
+ @pubnub.publish(
362
+ :message => {:text => 'sometext'},
363
+ :channel => 'ruby_demo_channel',
364
+ :callback => @callback
365
+ )
366
+
367
+ eventually do
368
+ @envelopes.size.should eq 0
369
+ @error_envelopes.size.should eq 1
370
+ @error_envelopes.first.response_message.should eq 'Sent'
371
+ @error_envelopes.first.response.should eq('[1,"Sent","13937904716672898"]')
372
+ @error_envelopes.first.status.should eq 500
373
+ @error_envelopes.first.channel.should eq('ruby_demo_channel')
374
+ @error_envelopes.first.message.should eq('[0,"Non 2xx server response."]')
375
+ @error_envelopes.first.timetoken.blank?.should eq false
376
+ end
377
+
378
+ end
379
+ end
380
+ end
381
+
382
+ context 'its synchronous' do
383
+ it 'handles non200 response gracefully' do
384
+ VCR.use_cassette('new_ones/publish/publish-encrypted-http-auth_key-non200-valid', :record => :none) do
385
+
386
+ @pubnub.publish(
387
+ :message => {:text => 'sometext'},
388
+ :channel => 'ruby_demo_channel',
389
+ :callback => @callback,
390
+ :http_sync => true
391
+ )
392
+
393
+ @envelopes.size.should eq 0
394
+ @error_envelopes.size.should eq 1
395
+ @error_envelopes.first.response_message.should eq 'Sent'
396
+ @error_envelopes.first.response.should eq('[1,"Sent","13937904716672898"]')
397
+ @error_envelopes.first.status.should eq 500
398
+ @error_envelopes.first.channel.should eq('ruby_demo_channel')
399
+ @error_envelopes.first.message.should eq('[0,"Non 2xx server response."]')
400
+ @error_envelopes.first.timetoken.blank?.should eq false
401
+
402
+ end
403
+ end
404
+ end
405
+ end
406
+
407
+ context 'with invalid json' do
408
+ context 'its asynchronous' do
409
+ it 'handles invalid json and non200 response gracefully' do
410
+ VCR.use_cassette('new_ones/publish/publish-encrypted-http-auth_key-non200-invalid', :record => :none) do
411
+
412
+ @pubnub.publish(
413
+ :message => {:text => 'sometext'},
414
+ :channel => 'ruby_demo_channel',
415
+ :callback => @callback
416
+ )
417
+
418
+ eventually do
419
+ @envelopes.size.should eq 0
420
+ @error_envelopes.size.should eq 1
421
+ @error_envelopes.first.response_message.should eq nil
422
+ @error_envelopes.first.response.should eq('[1,"Sent","13937904716672898"')
423
+ @error_envelopes.first.status.should eq 500
424
+ @error_envelopes.first.channel.should eq('ruby_demo_channel')
425
+ @error_envelopes.first.message.should eq('[0,"Invalid JSON in response."]')
426
+ @error_envelopes.first.timetoken.blank?.should eq true
427
+ end
428
+
429
+ end
430
+ end
431
+ end
432
+
433
+ context 'its synchronous' do
434
+ it 'handles invalid json and non200 response gracefully' do
435
+ VCR.use_cassette('new_ones/publish/publish-encrypted-http-auth_key-non200-invalid', :record => :none) do
436
+
437
+ @pubnub.publish(
438
+ :message => {:text => 'sometext'},
439
+ :channel => 'ruby_demo_channel',
440
+ :callback => @callback,
441
+ :http_sync => true
442
+ )
443
+
444
+ @envelopes.size.should eq 0
445
+ @error_envelopes.size.should eq 1
446
+ @error_envelopes.first.response_message.should eq nil
447
+ @error_envelopes.first.response.should eq('[1,"Sent","13937904716672898"')
448
+ @error_envelopes.first.status.should eq 500
449
+ @error_envelopes.first.channel.should eq('ruby_demo_channel')
450
+ @error_envelopes.first.message.should eq('[0,"Invalid JSON in response."]')
451
+ @error_envelopes.first.timetoken.blank?.should eq true
452
+
453
+ end
454
+ end
455
+ end
456
+ end
457
+ end
458
+ end
459
+ end
460
+
461
+ context 'without auth_key provided' do
462
+ context 'without encrypting message' do
463
+
464
+ before(:each) do
465
+ @pubnub = Pubnub.new(
466
+ :max_retries => 0,
467
+ :subscribe_key => :demo,
468
+ :publish_key => :demo,
469
+ :secret_key => 'some_secret_key',
470
+ :error_callback => @error_callback
471
+ )
472
+
473
+ @pubnub.uuid = 'tester'
474
+ end
475
+
476
+ context 'gets status 200 response' do
477
+ context 'with valid json' do
478
+ context 'its asynchronous' do
479
+ it 'publishes valid message' do
480
+ VCR.use_cassette('new_ones/publish/publish-http-200-valid', :record => :none) do
481
+
482
+ @pubnub.publish(
483
+ :message => {:text => 'sometext'},
484
+ :channel => 'ruby_demo_channel',
485
+ :callback => @callback
486
+ )
487
+
488
+ eventually do
489
+ @envelopes.size.should eq 1
490
+ @envelopes.first.response_message.should eq 'Sent'
491
+ @envelopes.first.status.should eq 200
492
+ @envelopes.first.channel.should eq 'ruby_demo_channel'
493
+ @envelopes.first.message.should eq({:text => 'sometext'})
494
+ @envelopes.first.timetoken.blank?.should eq false
495
+ end
496
+
497
+ end
498
+ end
499
+ end
500
+
501
+ context 'its synchronous' do
502
+ it 'publishes valid message' do
503
+ VCR.use_cassette('new_ones/publish/publish-http-200-valid', :record => :none) do
504
+
505
+ @pubnub.publish(
506
+ :message => {:text => 'sometext'},
507
+ :channel => 'ruby_demo_channel',
508
+ :callback => @callback,
509
+ :http_sync => true
510
+ )
511
+
512
+ @envelopes.size.should eq 1
513
+ @envelopes.first.response_message.should eq 'Sent'
514
+ @envelopes.first.status.should eq 200
515
+ @envelopes.first.channel.should eq 'ruby_demo_channel'
516
+ @envelopes.first.message.should eq({:text => 'sometext'})
517
+ @envelopes.first.timetoken.blank?.should eq false
518
+
519
+ end
520
+ end
521
+ end
522
+ end
523
+
524
+ context 'with invalid json' do
525
+ context 'its asynchronous' do
526
+ it 'handles invalid json gracefully' do
527
+ VCR.use_cassette('new_ones/publish/publish-http-200-invalid', :record => :none) do
528
+
529
+ @pubnub.publish(
530
+ :message => {:text => 'sometext'},
531
+ :channel => 'ruby_demo_channel',
532
+ :callback => @callback
533
+ )
534
+
535
+ eventually do
536
+ @envelopes.size.should eq 0
537
+ @error_envelopes.size.should eq 1
538
+ @error_envelopes.first.response_message.should eq nil
539
+ @error_envelopes.first.response.should eq('[1,"Sent","13936818988607190"')
540
+ @error_envelopes.first.status.should eq 200
541
+ @error_envelopes.first.channel.should eq('ruby_demo_channel')
542
+ @error_envelopes.first.message.should eq('[0,"Invalid JSON in response."]')
543
+ @error_envelopes.first.timetoken.blank?.should eq true
544
+ end
545
+
546
+ end
547
+ end
548
+ end
549
+
550
+ context 'its synchronous' do
551
+ it 'handles invalid json gracefully' do
552
+ VCR.use_cassette('new_ones/publish/publish-http-200-invalid', :record => :none) do
553
+
554
+ @pubnub.publish(
555
+ :message => {:text => 'sometext'},
556
+ :channel => 'ruby_demo_channel',
557
+ :callback => @callback,
558
+ :http_sync => true
559
+ )
560
+
561
+ @envelopes.size.should eq 0
562
+ @error_envelopes.size.should eq 1
563
+ @error_envelopes.first.response_message.should eq nil
564
+ @error_envelopes.first.response.should eq('[1,"Sent","13936818988607190"')
565
+ @error_envelopes.first.status.should eq 200
566
+ @error_envelopes.first.channel.should eq('ruby_demo_channel')
567
+ @error_envelopes.first.message.should eq('[0,"Invalid JSON in response."]')
568
+ @error_envelopes.first.timetoken.blank?.should eq true
569
+
570
+ end
571
+ end
572
+ end
573
+ end
574
+ end
575
+
576
+ context 'gets status non200 response' do
577
+ context 'with valid json' do
578
+ context 'its asynchronous' do
579
+ it 'handles non200 response gracefully' do
580
+ VCR.use_cassette('new_ones/publish/publish-http-non200-valid', :record => :none) do
581
+
582
+ @pubnub.publish(
583
+ :message => {:text => 'sometext'},
584
+ :channel => 'ruby_demo_channel',
585
+ :callback => @callback
586
+ )
587
+
588
+ eventually do
589
+ @envelopes.size.should eq 0
590
+ @error_envelopes.size.should eq 1
591
+ @error_envelopes.first.response_message.should eq 'Sent'
592
+ @error_envelopes.first.response.should eq('[1,"Sent","13936818988607190"]')
593
+ @error_envelopes.first.status.should eq 500
594
+ @error_envelopes.first.channel.should eq('ruby_demo_channel')
595
+ @error_envelopes.first.message.should eq('[0,"Non 2xx server response."]')
596
+ @error_envelopes.first.timetoken.blank?.should eq false
597
+ end
598
+
599
+ end
600
+ end
601
+ end
602
+
603
+ context 'its synchronous' do
604
+ it 'handles non200 response gracefully' do
605
+ VCR.use_cassette('new_ones/publish/publish-http-non200-valid', :record => :none) do
606
+
607
+ @pubnub.publish(
608
+ :message => {:text => 'sometext'},
609
+ :channel => 'ruby_demo_channel',
610
+ :callback => @callback,
611
+ :http_sync => true
612
+ )
613
+
614
+ @envelopes.size.should eq 0
615
+ @error_envelopes.size.should eq 1
616
+ @error_envelopes.first.response_message.should eq 'Sent'
617
+ @error_envelopes.first.response.should eq('[1,"Sent","13936818988607190"]')
618
+ @error_envelopes.first.status.should eq 500
619
+ @error_envelopes.first.channel.should eq('ruby_demo_channel')
620
+ @error_envelopes.first.message.should eq('[0,"Non 2xx server response."]')
621
+ @error_envelopes.first.timetoken.blank?.should eq false
622
+
623
+ end
624
+ end
625
+ end
626
+ end
627
+
628
+ context 'with invalid json' do
629
+ context 'its asynchronous' do
630
+ it 'handles invalid json and non200 response gracefully' do
631
+ VCR.use_cassette('new_ones/publish/publish-http-non200-invalid', :record => :none) do
632
+
633
+ @pubnub.publish(
634
+ :message => {:text => 'sometext'},
635
+ :channel => 'ruby_demo_channel',
636
+ :callback => @callback
637
+ )
638
+
639
+ eventually do
640
+ @envelopes.size.should eq 0
641
+ @error_envelopes.size.should eq 1
642
+ @error_envelopes.first.response_message.should eq nil
643
+ @error_envelopes.first.response.should eq('[1,"Sent","13936818988607190"')
644
+ @error_envelopes.first.status.should eq 500
645
+ @error_envelopes.first.channel.should eq('ruby_demo_channel')
646
+ @error_envelopes.first.message.should eq('[0,"Invalid JSON in response."]')
647
+ @error_envelopes.first.timetoken.blank?.should eq true
648
+ end
649
+
650
+ end
651
+ end
652
+ end
653
+
654
+ context 'its synchronous' do
655
+ it 'handles invalid json and non200 response gracefully' do
656
+ VCR.use_cassette('new_ones/publish/publish-http-non200-invalid', :record => :none) do
657
+
658
+ @pubnub.publish(
659
+ :message => {:text => 'sometext'},
660
+ :channel => 'ruby_demo_channel',
661
+ :callback => @callback,
662
+ :http_sync => true
663
+ )
664
+
665
+ @envelopes.size.should eq 0
666
+ @error_envelopes.size.should eq 1
667
+ @error_envelopes.first.response_message.should eq nil
668
+ @error_envelopes.first.response.should eq('[1,"Sent","13936818988607190"')
669
+ @error_envelopes.first.status.should eq 500
670
+ @error_envelopes.first.channel.should eq('ruby_demo_channel')
671
+ @error_envelopes.first.message.should eq('[0,"Invalid JSON in response."]')
672
+ @error_envelopes.first.timetoken.blank?.should eq true
673
+
674
+ end
675
+ end
676
+ end
677
+ end
678
+ end
679
+ end
680
+
681
+ context 'with encrypting message' do
682
+
683
+ before(:each) do
684
+ @pubnub = Pubnub.new(
685
+ :max_retries => 0,
686
+ :subscribe_key => :demo,
687
+ :publish_key => :demo,
688
+ :secret_key => 'some_secret_key',
689
+ :cipher_key => 'secret',
690
+ :error_callback => @error_callback
691
+ )
692
+
693
+ @pubnub.uuid = 'tester'
694
+ end
695
+
696
+ context 'gets status 200 response' do
697
+ context 'with valid json' do
698
+ context 'its asynchronous' do
699
+ it 'publishes valid message' do
700
+ VCR.use_cassette('new_ones/publish/publish-encrypted-http-200-valid', :record => :none) do
701
+
702
+ @pubnub.publish(
703
+ :message => {:text => 'sometext'},
704
+ :channel => 'ruby_demo_channel',
705
+ :callback => @callback
706
+ )
707
+
708
+ eventually do
709
+ @envelopes.size.should eq 1
710
+ @envelopes.first.response_message.should eq 'Sent'
711
+ @envelopes.first.status.should eq 200
712
+ @envelopes.first.channel.should eq 'ruby_demo_channel'
713
+ @envelopes.first.message.should eq({:text => 'sometext'})
714
+ @envelopes.first.timetoken.blank?.should eq false
715
+ end
716
+
717
+ end
718
+ end
719
+ end
720
+
721
+ context 'its synchronous' do
722
+ it 'publishes valid message' do
723
+ VCR.use_cassette('new_ones/publish/publish-encrypted-http-200-valid', :record => :none) do
724
+
725
+ @pubnub.publish(
726
+ :message => {:text => 'sometext'},
727
+ :channel => 'ruby_demo_channel',
728
+ :callback => @callback,
729
+ :http_sync => true
730
+ )
731
+
732
+ @envelopes.size.should eq 1
733
+ @envelopes.first.response_message.should eq 'Sent'
734
+ @envelopes.first.status.should eq 200
735
+ @envelopes.first.channel.should eq 'ruby_demo_channel'
736
+ @envelopes.first.message.should eq({:text => 'sometext'})
737
+ @envelopes.first.timetoken.blank?.should eq false
738
+
739
+ end
740
+ end
741
+ end
742
+ end
743
+
744
+ context 'with invalid json' do
745
+ context 'its asynchronous' do
746
+ it 'handles invalid json gracefully' do
747
+ VCR.use_cassette('new_ones/publish/publish-encrypted-http-200-invalid', :record => :none) do
748
+
749
+ @pubnub.publish(
750
+ :message => {:text => 'sometext'},
751
+ :channel => 'ruby_demo_channel',
752
+ :callback => @callback
753
+ )
754
+
755
+ eventually do
756
+ @envelopes.size.should eq 0
757
+ @error_envelopes.size.should eq 1
758
+ @error_envelopes.first.response_message.should eq nil
759
+ @error_envelopes.first.response.should eq('[1,"Sent","13937904716672898"')
760
+ @error_envelopes.first.status.should eq 200
761
+ @error_envelopes.first.channel.should eq('ruby_demo_channel')
762
+ @error_envelopes.first.message.should eq('[0,"Invalid JSON in response."]')
763
+ @error_envelopes.first.timetoken.blank?.should eq true
764
+ end
765
+
766
+ end
767
+ end
768
+ end
769
+
770
+ context 'its synchronous' do
771
+ it 'handles invalid json gracefully' do
772
+ VCR.use_cassette('new_ones/publish/publish-encrypted-http-200-invalid', :record => :none) do
773
+
774
+ @pubnub.publish(
775
+ :message => {:text => 'sometext'},
776
+ :channel => 'ruby_demo_channel',
777
+ :callback => @callback,
778
+ :http_sync => true
779
+ )
780
+
781
+ @envelopes.size.should eq 0
782
+ @error_envelopes.size.should eq 1
783
+ @error_envelopes.first.response_message.should eq nil
784
+ @error_envelopes.first.response.should eq('[1,"Sent","13937904716672898"')
785
+ @error_envelopes.first.status.should eq 200
786
+ @error_envelopes.first.channel.should eq('ruby_demo_channel')
787
+ @error_envelopes.first.message.should eq('[0,"Invalid JSON in response."]')
788
+ @error_envelopes.first.timetoken.blank?.should eq true
789
+
790
+ end
791
+ end
792
+ end
793
+ end
794
+ end
795
+
796
+ context 'gets status non200 response' do
797
+ context 'with valid json' do
798
+ context 'its asynchronous' do
799
+ it 'handles non200 response gracefully' do
800
+ VCR.use_cassette('new_ones/publish/publish-encrypted-http-non200-valid', :record => :none) do
801
+
802
+ @pubnub.publish(
803
+ :message => {:text => 'sometext'},
804
+ :channel => 'ruby_demo_channel',
805
+ :callback => @callback
806
+ )
807
+
808
+ eventually do
809
+ @envelopes.size.should eq 0
810
+ @error_envelopes.size.should eq 1
811
+ @error_envelopes.first.response_message.should eq 'Sent'
812
+ @error_envelopes.first.response.should eq('[1,"Sent","13937904716672898"]')
813
+ @error_envelopes.first.status.should eq 500
814
+ @error_envelopes.first.channel.should eq('ruby_demo_channel')
815
+ @error_envelopes.first.message.should eq('[0,"Non 2xx server response."]')
816
+ @error_envelopes.first.timetoken.blank?.should eq false
817
+ end
818
+
819
+ end
820
+ end
821
+ end
822
+
823
+ context 'its synchronous' do
824
+ it 'handles non200 response gracefully' do
825
+ VCR.use_cassette('new_ones/publish/publish-encrypted-http-non200-valid', :record => :none) do
826
+
827
+ @pubnub.publish(
828
+ :message => {:text => 'sometext'},
829
+ :channel => 'ruby_demo_channel',
830
+ :callback => @callback,
831
+ :http_sync => true
832
+ )
833
+
834
+ @envelopes.size.should eq 0
835
+ @error_envelopes.size.should eq 1
836
+ @error_envelopes.first.response_message.should eq 'Sent'
837
+ @error_envelopes.first.response.should eq('[1,"Sent","13937904716672898"]')
838
+ @error_envelopes.first.status.should eq 500
839
+ @error_envelopes.first.channel.should eq('ruby_demo_channel')
840
+ @error_envelopes.first.message.should eq('[0,"Non 2xx server response."]')
841
+ @error_envelopes.first.timetoken.blank?.should eq false
842
+
843
+ end
844
+ end
845
+ end
846
+ end
847
+
848
+ context 'with invalid json' do
849
+ context 'its asynchronous' do
850
+ it 'handles invalid json and non200 response gracefully' do
851
+ VCR.use_cassette('new_ones/publish/publish-encrypted-http-non200-invalid', :record => :none) do
852
+
853
+ @pubnub.publish(
854
+ :message => {:text => 'sometext'},
855
+ :channel => 'ruby_demo_channel',
856
+ :callback => @callback
857
+ )
858
+
859
+ eventually do
860
+ @envelopes.size.should eq 0
861
+ @error_envelopes.size.should eq 1
862
+ @error_envelopes.first.response_message.should eq nil
863
+ @error_envelopes.first.response.should eq('[1,"Sent","13937904716672898"')
864
+ @error_envelopes.first.status.should eq 500
865
+ @error_envelopes.first.channel.should eq('ruby_demo_channel')
866
+ @error_envelopes.first.message.should eq('[0,"Invalid JSON in response."]')
867
+ @error_envelopes.first.timetoken.blank?.should eq true
868
+ end
869
+
870
+ end
871
+ end
872
+ end
873
+
874
+ context 'its synchronous' do
875
+ it 'handles invalid json and non200 response gracefully' do
876
+ VCR.use_cassette('new_ones/publish/publish-encrypted-http-non200-invalid', :record => :none) do
877
+
878
+ @pubnub.publish(
879
+ :message => {:text => 'sometext'},
880
+ :channel => 'ruby_demo_channel',
881
+ :callback => @callback,
882
+ :http_sync => true
883
+ )
884
+
885
+ @envelopes.size.should eq 0
886
+ @error_envelopes.size.should eq 1
887
+ @error_envelopes.first.response_message.should eq nil
888
+ @error_envelopes.first.response.should eq('[1,"Sent","13937904716672898"')
889
+ @error_envelopes.first.status.should eq 500
890
+ @error_envelopes.first.channel.should eq('ruby_demo_channel')
891
+ @error_envelopes.first.message.should eq('[0,"Invalid JSON in response."]')
892
+ @error_envelopes.first.timetoken.blank?.should eq true
893
+
894
+ end
895
+ end
896
+ end
897
+ end
898
+ end
899
+ end
900
+ end
901
+ end
902
+
903
+ context 'uses https' do
904
+ context 'with auth_key provided' do
905
+ context 'without encrypting message' do
906
+
907
+ before(:each) do
908
+ @pubnub = Pubnub.new(
909
+ :max_retries => 0,
910
+ :subscribe_key => :demo,
911
+ :publish_key => :demo,
912
+ :auth_key => :demoish_authkey,
913
+ :secret_key => 'some_secret_key',
914
+ :error_callback => @error_callback,
915
+ :ssl => true
916
+ )
917
+
918
+ @pubnub.uuid = 'tester'
919
+ end
920
+
921
+ context 'gets status 200 response' do
922
+ context 'with valid json' do
923
+ context 'its asynchronous' do
924
+ it 'publishes valid message' do
925
+ VCR.use_cassette('new_ones/publish/publish-https-auth_key-200-valid', :record => :none) do
926
+
927
+ @pubnub.publish(
928
+ :message => {:text => 'sometext'},
929
+ :channel => 'ruby_demo_channel',
930
+ :callback => @callback
931
+ )
932
+
933
+ eventually do
934
+ @envelopes.size.should eq 1
935
+ @envelopes.first.response_message.should eq 'Sent'
936
+ @envelopes.first.status.should eq 200
937
+ @envelopes.first.channel.should eq 'ruby_demo_channel'
938
+ @envelopes.first.message.should eq({:text => 'sometext'})
939
+ @envelopes.first.timetoken.blank?.should eq false
940
+ end
941
+
942
+ end
943
+ end
944
+ end
945
+
946
+ context 'its synchronous' do
947
+ it 'publishes valid message' do
948
+ VCR.use_cassette('new_ones/publish/publish-https-auth_key-200-valid', :record => :none) do
949
+
950
+ @pubnub.publish(
951
+ :message => {:text => 'sometext'},
952
+ :channel => 'ruby_demo_channel',
953
+ :callback => @callback,
954
+ :http_sync => true
955
+ )
956
+
957
+ @envelopes.size.should eq 1
958
+ @envelopes.first.response_message.should eq 'Sent'
959
+ @envelopes.first.status.should eq 200
960
+ @envelopes.first.channel.should eq 'ruby_demo_channel'
961
+ @envelopes.first.message.should eq({:text => 'sometext'})
962
+ @envelopes.first.timetoken.blank?.should eq false
963
+
964
+ end
965
+ end
966
+ end
967
+ end
968
+
969
+ context 'with invalid json' do
970
+ context 'its asynchronous' do
971
+ it 'handles invalid json gracefully' do
972
+ VCR.use_cassette('new_ones/publish/publish-https-auth_key-200-invalid', :record => :none) do
973
+
974
+ @pubnub.publish(
975
+ :message => {:text => 'sometext'},
976
+ :channel => 'ruby_demo_channel',
977
+ :callback => @callback
978
+ )
979
+
980
+ eventually do
981
+ @envelopes.size.should eq 0
982
+ @error_envelopes.size.should eq 1
983
+ @error_envelopes.first.response_message.should eq nil
984
+ @error_envelopes.first.response.should eq('[1,"Sent","13936818988607190"')
985
+ @error_envelopes.first.status.should eq 200
986
+ @error_envelopes.first.channel.should eq('ruby_demo_channel')
987
+ @error_envelopes.first.message.should eq('[0,"Invalid JSON in response."]')
988
+ @error_envelopes.first.timetoken.blank?.should eq true
989
+ end
990
+
991
+ end
992
+ end
993
+ end
994
+
995
+ context 'its synchronous' do
996
+ it 'handles invalid json gracefully' do
997
+ VCR.use_cassette('new_ones/publish/publish-https-auth_key-200-invalid', :record => :none) do
998
+
999
+ @pubnub.publish(
1000
+ :message => {:text => 'sometext'},
1001
+ :channel => 'ruby_demo_channel',
1002
+ :callback => @callback,
1003
+ :http_sync => true
1004
+ )
1005
+
1006
+ @envelopes.size.should eq 0
1007
+ @error_envelopes.size.should eq 1
1008
+ @error_envelopes.first.response_message.should eq nil
1009
+ @error_envelopes.first.response.should eq('[1,"Sent","13936818988607190"')
1010
+ @error_envelopes.first.status.should eq 200
1011
+ @error_envelopes.first.channel.should eq('ruby_demo_channel')
1012
+ @error_envelopes.first.message.should eq('[0,"Invalid JSON in response."]')
1013
+ @error_envelopes.first.timetoken.blank?.should eq true
1014
+
1015
+ end
1016
+ end
1017
+ end
1018
+ end
1019
+ end
1020
+
1021
+ context 'gets status non200 response' do
1022
+ context 'with valid json' do
1023
+ context 'its asynchronous' do
1024
+ it 'handles non200 response gracefully' do
1025
+ VCR.use_cassette('new_ones/publish/publish-https-auth_key-non200-valid', :record => :none) do
1026
+
1027
+ @pubnub.publish(
1028
+ :message => {:text => 'sometext'},
1029
+ :channel => 'ruby_demo_channel',
1030
+ :callback => @callback
1031
+ )
1032
+
1033
+ eventually do
1034
+ @envelopes.size.should eq 0
1035
+ @error_envelopes.size.should eq 1
1036
+ @error_envelopes.first.response_message.should eq 'Sent'
1037
+ @error_envelopes.first.response.should eq('[1,"Sent","13936818988607190"]')
1038
+ @error_envelopes.first.status.should eq 500
1039
+ @error_envelopes.first.channel.should eq('ruby_demo_channel')
1040
+ @error_envelopes.first.message.should eq('[0,"Non 2xx server response."]')
1041
+ @error_envelopes.first.timetoken.blank?.should eq false
1042
+ end
1043
+
1044
+ end
1045
+ end
1046
+ end
1047
+
1048
+ context 'its synchronous' do
1049
+ it 'handles non200 response gracefully' do
1050
+ VCR.use_cassette('new_ones/publish/publish-https-auth_key-non200-valid', :record => :none) do
1051
+
1052
+ @pubnub.publish(
1053
+ :message => {:text => 'sometext'},
1054
+ :channel => 'ruby_demo_channel',
1055
+ :callback => @callback,
1056
+ :http_sync => true
1057
+ )
1058
+
1059
+ @envelopes.size.should eq 0
1060
+ @error_envelopes.size.should eq 1
1061
+ @error_envelopes.first.response_message.should eq 'Sent'
1062
+ @error_envelopes.first.response.should eq('[1,"Sent","13936818988607190"]')
1063
+ @error_envelopes.first.status.should eq 500
1064
+ @error_envelopes.first.channel.should eq('ruby_demo_channel')
1065
+ @error_envelopes.first.message.should eq('[0,"Non 2xx server response."]')
1066
+ @error_envelopes.first.timetoken.blank?.should eq false
1067
+
1068
+ end
1069
+ end
1070
+ end
1071
+ end
1072
+
1073
+ context 'with invalid json' do
1074
+ context 'its asynchronous' do
1075
+ it 'handles invalid json and non200 response gracefully' do
1076
+ VCR.use_cassette('new_ones/publish/publish-https-auth_key-non200-invalid', :record => :none) do
1077
+
1078
+ @pubnub.publish(
1079
+ :message => {:text => 'sometext'},
1080
+ :channel => 'ruby_demo_channel',
1081
+ :callback => @callback
1082
+ )
1083
+
1084
+ eventually do
1085
+ @envelopes.size.should eq 0
1086
+ @error_envelopes.size.should eq 1
1087
+ @error_envelopes.first.response_message.should eq nil
1088
+ @error_envelopes.first.response.should eq('[1,"Sent","13936818988607190"')
1089
+ @error_envelopes.first.status.should eq 500
1090
+ @error_envelopes.first.channel.should eq('ruby_demo_channel')
1091
+ @error_envelopes.first.message.should eq('[0,"Invalid JSON in response."]')
1092
+ @error_envelopes.first.timetoken.blank?.should eq true
1093
+ end
1094
+
1095
+ end
1096
+ end
1097
+ end
1098
+
1099
+ context 'its synchronous' do
1100
+ it 'handles invalid json and non200 response gracefully' do
1101
+ VCR.use_cassette('new_ones/publish/publish-https-auth_key-non200-invalid', :record => :none) do
1102
+
1103
+ @pubnub.publish(
1104
+ :message => {:text => 'sometext'},
1105
+ :channel => 'ruby_demo_channel',
1106
+ :callback => @callback,
1107
+ :http_sync => true
1108
+ )
1109
+
1110
+ @envelopes.size.should eq 0
1111
+ @error_envelopes.size.should eq 1
1112
+ @error_envelopes.first.response_message.should eq nil
1113
+ @error_envelopes.first.response.should eq('[1,"Sent","13936818988607190"')
1114
+ @error_envelopes.first.status.should eq 500
1115
+ @error_envelopes.first.channel.should eq('ruby_demo_channel')
1116
+ @error_envelopes.first.message.should eq('[0,"Invalid JSON in response."]')
1117
+ @error_envelopes.first.timetoken.blank?.should eq true
1118
+
1119
+ end
1120
+ end
1121
+ end
1122
+ end
1123
+ end
1124
+ end
1125
+
1126
+ context 'with encrypting message' do
1127
+
1128
+ before(:each) do
1129
+ @pubnub = Pubnub.new(
1130
+ :max_retries => 0,
1131
+ :subscribe_key => :demo,
1132
+ :publish_key => :demo,
1133
+ :auth_key => :demoish_authkey,
1134
+ :secret_key => 'some_secret_key',
1135
+ :cipher_key => 'secret',
1136
+ :error_callback => @error_callback,
1137
+ :ssl => true
1138
+ )
1139
+
1140
+ @pubnub.uuid = 'tester'
1141
+ end
1142
+
1143
+ context 'gets status 200 response' do
1144
+ context 'with valid json' do
1145
+ context 'its asynchronous' do
1146
+ it 'publishes valid message' do
1147
+ VCR.use_cassette('new_ones/publish/publish-encrypted-https-auth_key-200-valid', :record => :none) do
1148
+
1149
+ @pubnub.publish(
1150
+ :message => {:text => 'sometext'},
1151
+ :channel => 'ruby_demo_channel',
1152
+ :callback => @callback
1153
+ )
1154
+
1155
+ eventually do
1156
+ @envelopes.size.should eq 1
1157
+ @envelopes.first.response_message.should eq 'Sent'
1158
+ @envelopes.first.status.should eq 200
1159
+ @envelopes.first.channel.should eq 'ruby_demo_channel'
1160
+ @envelopes.first.message.should eq({:text => 'sometext'})
1161
+ @envelopes.first.timetoken.blank?.should eq false
1162
+ end
1163
+
1164
+ end
1165
+ end
1166
+ end
1167
+
1168
+ context 'its synchronous' do
1169
+ it 'publishes valid message' do
1170
+ VCR.use_cassette('new_ones/publish/publish-encrypted-https-auth_key-200-valid', :record => :none) do
1171
+
1172
+ @pubnub.publish(
1173
+ :message => {:text => 'sometext'},
1174
+ :channel => 'ruby_demo_channel',
1175
+ :callback => @callback,
1176
+ :http_sync => true
1177
+ )
1178
+
1179
+ @envelopes.size.should eq 1
1180
+ @envelopes.first.response_message.should eq 'Sent'
1181
+ @envelopes.first.status.should eq 200
1182
+ @envelopes.first.channel.should eq 'ruby_demo_channel'
1183
+ @envelopes.first.message.should eq({:text => 'sometext'})
1184
+ @envelopes.first.timetoken.blank?.should eq false
1185
+
1186
+ end
1187
+ end
1188
+ end
1189
+ end
1190
+
1191
+ context 'with invalid json' do
1192
+ context 'its asynchronous' do
1193
+ it 'handles invalid json gracefully' do
1194
+ VCR.use_cassette('new_ones/publish/publish-encrypted-https-auth_key-200-invalid', :record => :none) do
1195
+
1196
+ @pubnub.publish(
1197
+ :message => {:text => 'sometext'},
1198
+ :channel => 'ruby_demo_channel',
1199
+ :callback => @callback
1200
+ )
1201
+
1202
+ eventually do
1203
+ @envelopes.size.should eq 0
1204
+ @error_envelopes.size.should eq 1
1205
+ @error_envelopes.first.response_message.should eq nil
1206
+ @error_envelopes.first.response.should eq('[1,"Sent","13937904716672898"')
1207
+ @error_envelopes.first.status.should eq 200
1208
+ @error_envelopes.first.channel.should eq('ruby_demo_channel')
1209
+ @error_envelopes.first.message.should eq('[0,"Invalid JSON in response."]')
1210
+ @error_envelopes.first.timetoken.blank?.should eq true
1211
+ end
1212
+
1213
+ end
1214
+ end
1215
+ end
1216
+
1217
+ context 'its synchronous' do
1218
+ it 'handles invalid json gracefully' do
1219
+ VCR.use_cassette('new_ones/publish/publish-encrypted-https-auth_key-200-invalid', :record => :none) do
1220
+
1221
+ @pubnub.publish(
1222
+ :message => {:text => 'sometext'},
1223
+ :channel => 'ruby_demo_channel',
1224
+ :callback => @callback,
1225
+ :http_sync => true
1226
+ )
1227
+
1228
+ @envelopes.size.should eq 0
1229
+ @error_envelopes.size.should eq 1
1230
+ @error_envelopes.first.response_message.should eq nil
1231
+ @error_envelopes.first.response.should eq('[1,"Sent","13937904716672898"')
1232
+ @error_envelopes.first.status.should eq 200
1233
+ @error_envelopes.first.channel.should eq('ruby_demo_channel')
1234
+ @error_envelopes.first.message.should eq('[0,"Invalid JSON in response."]')
1235
+ @error_envelopes.first.timetoken.blank?.should eq true
1236
+
1237
+ end
1238
+ end
1239
+ end
1240
+ end
1241
+ end
1242
+
1243
+ context 'gets status non200 response' do
1244
+ context 'with valid json' do
1245
+ context 'its asynchronous' do
1246
+ it 'handles non200 response gracefully' do
1247
+ VCR.use_cassette('new_ones/publish/publish-encrypted-https-auth_key-non200-valid', :record => :none) do
1248
+
1249
+ @pubnub.publish(
1250
+ :message => {:text => 'sometext'},
1251
+ :channel => 'ruby_demo_channel',
1252
+ :callback => @callback
1253
+ )
1254
+
1255
+ eventually do
1256
+ @envelopes.size.should eq 0
1257
+ @error_envelopes.size.should eq 1
1258
+ @error_envelopes.first.response_message.should eq 'Sent'
1259
+ @error_envelopes.first.response.should eq('[1,"Sent","13937904716672898"]')
1260
+ @error_envelopes.first.status.should eq 500
1261
+ @error_envelopes.first.channel.should eq('ruby_demo_channel')
1262
+ @error_envelopes.first.message.should eq('[0,"Non 2xx server response."]')
1263
+ @error_envelopes.first.timetoken.blank?.should eq false
1264
+ end
1265
+
1266
+ end
1267
+ end
1268
+ end
1269
+
1270
+ context 'its synchronous' do
1271
+ it 'handles non200 response gracefully' do
1272
+ VCR.use_cassette('new_ones/publish/publish-encrypted-https-auth_key-non200-valid', :record => :none) do
1273
+
1274
+ @pubnub.publish(
1275
+ :message => {:text => 'sometext'},
1276
+ :channel => 'ruby_demo_channel',
1277
+ :callback => @callback,
1278
+ :http_sync => true
1279
+ )
1280
+
1281
+ @envelopes.size.should eq 0
1282
+ @error_envelopes.size.should eq 1
1283
+ @error_envelopes.first.response_message.should eq 'Sent'
1284
+ @error_envelopes.first.response.should eq('[1,"Sent","13937904716672898"]')
1285
+ @error_envelopes.first.status.should eq 500
1286
+ @error_envelopes.first.channel.should eq('ruby_demo_channel')
1287
+ @error_envelopes.first.message.should eq('[0,"Non 2xx server response."]')
1288
+ @error_envelopes.first.timetoken.blank?.should eq false
1289
+
1290
+ end
1291
+ end
1292
+ end
1293
+ end
1294
+
1295
+ context 'with invalid json' do
1296
+ context 'its asynchronous' do
1297
+ it 'handles invalid json and non200 response gracefully' do
1298
+ VCR.use_cassette('new_ones/publish/publish-encrypted-https-auth_key-non200-invalid', :record => :none) do
1299
+
1300
+ @pubnub.publish(
1301
+ :message => {:text => 'sometext'},
1302
+ :channel => 'ruby_demo_channel',
1303
+ :callback => @callback
1304
+ )
1305
+
1306
+ eventually do
1307
+ @envelopes.size.should eq 0
1308
+ @error_envelopes.size.should eq 1
1309
+ @error_envelopes.first.response_message.should eq nil
1310
+ @error_envelopes.first.response.should eq('[1,"Sent","13937904716672898"')
1311
+ @error_envelopes.first.status.should eq 500
1312
+ @error_envelopes.first.channel.should eq('ruby_demo_channel')
1313
+ @error_envelopes.first.message.should eq('[0,"Invalid JSON in response."]')
1314
+ @error_envelopes.first.timetoken.blank?.should eq true
1315
+ end
1316
+
1317
+ end
1318
+ end
1319
+ end
1320
+
1321
+ context 'its synchronous' do
1322
+ it 'handles invalid json and non200 response gracefully' do
1323
+ VCR.use_cassette('new_ones/publish/publish-encrypted-https-auth_key-non200-invalid', :record => :none) do
1324
+
1325
+ @pubnub.publish(
1326
+ :message => {:text => 'sometext'},
1327
+ :channel => 'ruby_demo_channel',
1328
+ :callback => @callback,
1329
+ :http_sync => true
1330
+ )
1331
+
1332
+ @envelopes.size.should eq 0
1333
+ @error_envelopes.size.should eq 1
1334
+ @error_envelopes.first.response_message.should eq nil
1335
+ @error_envelopes.first.response.should eq('[1,"Sent","13937904716672898"')
1336
+ @error_envelopes.first.status.should eq 500
1337
+ @error_envelopes.first.channel.should eq('ruby_demo_channel')
1338
+ @error_envelopes.first.message.should eq('[0,"Invalid JSON in response."]')
1339
+ @error_envelopes.first.timetoken.blank?.should eq true
1340
+
1341
+ end
1342
+ end
1343
+ end
1344
+ end
1345
+ end
1346
+ end
1347
+ end
1348
+
1349
+ context 'without auth_key provided' do
1350
+ context 'without encrypting message' do
1351
+
1352
+ before(:each) do
1353
+ @pubnub = Pubnub.new(
1354
+ :max_retries => 0,
1355
+ :subscribe_key => :demo,
1356
+ :publish_key => :demo,
1357
+ :secret_key => 'some_secret_key',
1358
+ :error_callback => @error_callback,
1359
+ :ssl => true
1360
+ )
1361
+
1362
+ @pubnub.uuid = 'tester'
1363
+ end
1364
+
1365
+ context 'gets status 200 response' do
1366
+ context 'with valid json' do
1367
+ context 'its asynchronous' do
1368
+ it 'publishes valid message' do
1369
+ VCR.use_cassette('new_ones/publish/publish-https-200-valid', :record => :none) do
1370
+
1371
+ @pubnub.publish(
1372
+ :message => {:text => 'sometext'},
1373
+ :channel => 'ruby_demo_channel',
1374
+ :callback => @callback
1375
+ )
1376
+
1377
+ eventually do
1378
+ @envelopes.size.should eq 1
1379
+ @envelopes.first.response_message.should eq 'Sent'
1380
+ @envelopes.first.status.should eq 200
1381
+ @envelopes.first.channel.should eq 'ruby_demo_channel'
1382
+ @envelopes.first.message.should eq({:text => 'sometext'})
1383
+ @envelopes.first.timetoken.blank?.should eq false
1384
+ end
1385
+
1386
+ end
1387
+ end
1388
+ end
1389
+
1390
+ context 'its synchronous' do
1391
+ it 'publishes valid message' do
1392
+ VCR.use_cassette('new_ones/publish/publish-https-200-valid', :record => :none) do
1393
+
1394
+ @pubnub.publish(
1395
+ :message => {:text => 'sometext'},
1396
+ :channel => 'ruby_demo_channel',
1397
+ :callback => @callback,
1398
+ :http_sync => true
1399
+ )
1400
+
1401
+ @envelopes.size.should eq 1
1402
+ @envelopes.first.response_message.should eq 'Sent'
1403
+ @envelopes.first.status.should eq 200
1404
+ @envelopes.first.channel.should eq 'ruby_demo_channel'
1405
+ @envelopes.first.message.should eq({:text => 'sometext'})
1406
+ @envelopes.first.timetoken.blank?.should eq false
1407
+
1408
+ end
1409
+ end
1410
+ end
1411
+ end
1412
+
1413
+ context 'with invalid json' do
1414
+ context 'its asynchronous' do
1415
+ it 'handles invalid json gracefully' do
1416
+ VCR.use_cassette('new_ones/publish/publish-https-200-invalid', :record => :none) do
1417
+
1418
+ @pubnub.publish(
1419
+ :message => {:text => 'sometext'},
1420
+ :channel => 'ruby_demo_channel',
1421
+ :callback => @callback
1422
+ )
1423
+
1424
+ eventually do
1425
+ @envelopes.size.should eq 0
1426
+ @error_envelopes.size.should eq 1
1427
+ @error_envelopes.first.response_message.should eq nil
1428
+ @error_envelopes.first.response.should eq('[1,"Sent","13936818988607190"')
1429
+ @error_envelopes.first.status.should eq 200
1430
+ @error_envelopes.first.channel.should eq('ruby_demo_channel')
1431
+ @error_envelopes.first.message.should eq('[0,"Invalid JSON in response."]')
1432
+ @error_envelopes.first.timetoken.blank?.should eq true
1433
+ end
1434
+
1435
+ end
1436
+ end
1437
+ end
1438
+
1439
+ context 'its synchronous' do
1440
+ it 'handles invalid json gracefully' do
1441
+ VCR.use_cassette('new_ones/publish/publish-https-200-invalid', :record => :none) do
1442
+
1443
+ @pubnub.publish(
1444
+ :message => {:text => 'sometext'},
1445
+ :channel => 'ruby_demo_channel',
1446
+ :callback => @callback,
1447
+ :http_sync => true
1448
+ )
1449
+
1450
+ @envelopes.size.should eq 0
1451
+ @error_envelopes.size.should eq 1
1452
+ @error_envelopes.first.response_message.should eq nil
1453
+ @error_envelopes.first.response.should eq('[1,"Sent","13936818988607190"')
1454
+ @error_envelopes.first.status.should eq 200
1455
+ @error_envelopes.first.channel.should eq('ruby_demo_channel')
1456
+ @error_envelopes.first.message.should eq('[0,"Invalid JSON in response."]')
1457
+ @error_envelopes.first.timetoken.blank?.should eq true
1458
+
1459
+ end
1460
+ end
1461
+ end
1462
+ end
1463
+ end
1464
+
1465
+ context 'gets status non200 response' do
1466
+ context 'with valid json' do
1467
+ context 'its asynchronous' do
1468
+ it 'handles non200 response gracefully' do
1469
+ VCR.use_cassette('new_ones/publish/publish-https-non200-valid', :record => :none) do
1470
+
1471
+ @pubnub.publish(
1472
+ :message => {:text => 'sometext'},
1473
+ :channel => 'ruby_demo_channel',
1474
+ :callback => @callback
1475
+ )
1476
+
1477
+ eventually do
1478
+ @envelopes.size.should eq 0
1479
+ @error_envelopes.size.should eq 1
1480
+ @error_envelopes.first.response_message.should eq 'Sent'
1481
+ @error_envelopes.first.response.should eq('[1,"Sent","13936818988607190"]')
1482
+ @error_envelopes.first.status.should eq 500
1483
+ @error_envelopes.first.channel.should eq('ruby_demo_channel')
1484
+ @error_envelopes.first.message.should eq('[0,"Non 2xx server response."]')
1485
+ @error_envelopes.first.timetoken.blank?.should eq false
1486
+ end
1487
+
1488
+ end
1489
+ end
1490
+ end
1491
+
1492
+ context 'its synchronous' do
1493
+ it 'handles non200 response gracefully' do
1494
+ VCR.use_cassette('new_ones/publish/publish-https-non200-valid', :record => :none) do
1495
+
1496
+ @pubnub.publish(
1497
+ :message => {:text => 'sometext'},
1498
+ :channel => 'ruby_demo_channel',
1499
+ :callback => @callback,
1500
+ :http_sync => true
1501
+ )
1502
+
1503
+ @envelopes.size.should eq 0
1504
+ @error_envelopes.size.should eq 1
1505
+ @error_envelopes.first.response_message.should eq 'Sent'
1506
+ @error_envelopes.first.response.should eq('[1,"Sent","13936818988607190"]')
1507
+ @error_envelopes.first.status.should eq 500
1508
+ @error_envelopes.first.channel.should eq('ruby_demo_channel')
1509
+ @error_envelopes.first.message.should eq('[0,"Non 2xx server response."]')
1510
+ @error_envelopes.first.timetoken.blank?.should eq false
1511
+
1512
+ end
1513
+ end
1514
+ end
1515
+ end
1516
+
1517
+ context 'with invalid json' do
1518
+ context 'its asynchronous' do
1519
+ it 'handles invalid json and non200 response gracefully' do
1520
+ VCR.use_cassette('new_ones/publish/publish-https-non200-invalid', :record => :none) do
1521
+
1522
+ @pubnub.publish(
1523
+ :message => {:text => 'sometext'},
1524
+ :channel => 'ruby_demo_channel',
1525
+ :callback => @callback
1526
+ )
1527
+
1528
+ eventually do
1529
+ @envelopes.size.should eq 0
1530
+ @error_envelopes.size.should eq 1
1531
+ @error_envelopes.first.response_message.should eq nil
1532
+ @error_envelopes.first.response.should eq('[1,"Sent","13936818988607190"')
1533
+ @error_envelopes.first.status.should eq 500
1534
+ @error_envelopes.first.channel.should eq('ruby_demo_channel')
1535
+ @error_envelopes.first.message.should eq('[0,"Invalid JSON in response."]')
1536
+ @error_envelopes.first.timetoken.blank?.should eq true
1537
+ end
1538
+
1539
+ end
1540
+ end
1541
+ end
1542
+
1543
+ context 'its synchronous' do
1544
+ it 'handles invalid json and non200 response gracefully' do
1545
+ VCR.use_cassette('new_ones/publish/publish-https-non200-invalid', :record => :none) do
1546
+
1547
+ @pubnub.publish(
1548
+ :message => {:text => 'sometext'},
1549
+ :channel => 'ruby_demo_channel',
1550
+ :callback => @callback,
1551
+ :http_sync => true
1552
+ )
1553
+
1554
+ @envelopes.size.should eq 0
1555
+ @error_envelopes.size.should eq 1
1556
+ @error_envelopes.first.response_message.should eq nil
1557
+ @error_envelopes.first.response.should eq('[1,"Sent","13936818988607190"')
1558
+ @error_envelopes.first.status.should eq 500
1559
+ @error_envelopes.first.channel.should eq('ruby_demo_channel')
1560
+ @error_envelopes.first.message.should eq('[0,"Invalid JSON in response."]')
1561
+ @error_envelopes.first.timetoken.blank?.should eq true
1562
+
1563
+ end
1564
+ end
1565
+ end
1566
+ end
1567
+ end
1568
+ end
1569
+
1570
+ context 'with encrypting message' do
1571
+
1572
+ before(:each) do
1573
+ @pubnub = Pubnub.new(
1574
+ :max_retries => 0,
1575
+ :subscribe_key => :demo,
1576
+ :publish_key => :demo,
1577
+ :secret_key => 'some_secret_key',
1578
+ :cipher_key => 'secret',
1579
+ :error_callback => @error_callback,
1580
+ :ssl => true
1581
+ )
1582
+
1583
+ @pubnub.uuid = 'tester'
1584
+ end
1585
+
1586
+ context 'gets status 200 response' do
1587
+ context 'with valid json' do
1588
+ context 'its asynchronous' do
1589
+ it 'publishes valid message' do
1590
+ VCR.use_cassette('new_ones/publish/publish-encrypted-https-200-valid', :record => :none) do
1591
+
1592
+ @pubnub.publish(
1593
+ :message => {:text => 'sometext'},
1594
+ :channel => 'ruby_demo_channel',
1595
+ :callback => @callback
1596
+ )
1597
+
1598
+ eventually do
1599
+ @envelopes.size.should eq 1
1600
+ @envelopes.first.response_message.should eq 'Sent'
1601
+ @envelopes.first.status.should eq 200
1602
+ @envelopes.first.channel.should eq 'ruby_demo_channel'
1603
+ @envelopes.first.message.should eq({:text => 'sometext'})
1604
+ @envelopes.first.timetoken.blank?.should eq false
1605
+ end
1606
+
1607
+ end
1608
+ end
1609
+ end
1610
+
1611
+ context 'its synchronous' do
1612
+ it 'publishes valid message' do
1613
+ VCR.use_cassette('new_ones/publish/publish-encrypted-https-200-valid', :record => :none) do
1614
+
1615
+ @pubnub.publish(
1616
+ :message => {:text => 'sometext'},
1617
+ :channel => 'ruby_demo_channel',
1618
+ :callback => @callback,
1619
+ :http_sync => true
1620
+ )
1621
+
1622
+ @envelopes.size.should eq 1
1623
+ @envelopes.first.response_message.should eq 'Sent'
1624
+ @envelopes.first.status.should eq 200
1625
+ @envelopes.first.channel.should eq 'ruby_demo_channel'
1626
+ @envelopes.first.message.should eq({:text => 'sometext'})
1627
+ @envelopes.first.timetoken.blank?.should eq false
1628
+
1629
+ end
1630
+ end
1631
+ end
1632
+ end
1633
+
1634
+ context 'with invalid json' do
1635
+ context 'its asynchronous' do
1636
+ it 'handles invalid json gracefully' do
1637
+ VCR.use_cassette('new_ones/publish/publish-encrypted-https-200-invalid', :record => :none) do
1638
+
1639
+ @pubnub.publish(
1640
+ :message => {:text => 'sometext'},
1641
+ :channel => 'ruby_demo_channel',
1642
+ :callback => @callback
1643
+ )
1644
+
1645
+ eventually do
1646
+ @envelopes.size.should eq 0
1647
+ @error_envelopes.size.should eq 1
1648
+ @error_envelopes.first.response_message.should eq nil
1649
+ @error_envelopes.first.response.should eq('[1,"Sent","13937904716672898"')
1650
+ @error_envelopes.first.status.should eq 200
1651
+ @error_envelopes.first.channel.should eq('ruby_demo_channel')
1652
+ @error_envelopes.first.message.should eq('[0,"Invalid JSON in response."]')
1653
+ @error_envelopes.first.timetoken.blank?.should eq true
1654
+ end
1655
+
1656
+ end
1657
+ end
1658
+ end
1659
+
1660
+ context 'its synchronous' do
1661
+ it 'handles invalid json gracefully' do
1662
+ VCR.use_cassette('new_ones/publish/publish-encrypted-https-200-invalid', :record => :none) do
1663
+
1664
+ @pubnub.publish(
1665
+ :message => {:text => 'sometext'},
1666
+ :channel => 'ruby_demo_channel',
1667
+ :callback => @callback,
1668
+ :http_sync => true
1669
+ )
1670
+
1671
+ @envelopes.size.should eq 0
1672
+ @error_envelopes.size.should eq 1
1673
+ @error_envelopes.first.response_message.should eq nil
1674
+ @error_envelopes.first.response.should eq('[1,"Sent","13937904716672898"')
1675
+ @error_envelopes.first.status.should eq 200
1676
+ @error_envelopes.first.channel.should eq('ruby_demo_channel')
1677
+ @error_envelopes.first.message.should eq('[0,"Invalid JSON in response."]')
1678
+ @error_envelopes.first.timetoken.blank?.should eq true
1679
+
1680
+ end
1681
+ end
1682
+ end
1683
+ end
1684
+ end
1685
+
1686
+ context 'gets status non200 response' do
1687
+ context 'with valid json' do
1688
+ context 'its asynchronous' do
1689
+ it 'handles non200 response gracefully' do
1690
+ VCR.use_cassette('new_ones/publish/publish-encrypted-https-non200-valid', :record => :none) do
1691
+
1692
+ @pubnub.publish(
1693
+ :message => {:text => 'sometext'},
1694
+ :channel => 'ruby_demo_channel',
1695
+ :callback => @callback
1696
+ )
1697
+
1698
+ eventually do
1699
+ @envelopes.size.should eq 0
1700
+ @error_envelopes.size.should eq 1
1701
+ @error_envelopes.first.response_message.should eq 'Sent'
1702
+ @error_envelopes.first.response.should eq('[1,"Sent","13937904716672898"]')
1703
+ @error_envelopes.first.status.should eq 500
1704
+ @error_envelopes.first.channel.should eq('ruby_demo_channel')
1705
+ @error_envelopes.first.message.should eq('[0,"Non 2xx server response."]')
1706
+ @error_envelopes.first.timetoken.blank?.should eq false
1707
+ end
1708
+
1709
+ end
1710
+ end
1711
+ end
1712
+
1713
+ context 'its synchronous' do
1714
+ it 'handles non200 response gracefully' do
1715
+ VCR.use_cassette('new_ones/publish/publish-encrypted-https-non200-valid', :record => :none) do
1716
+
1717
+ @pubnub.publish(
1718
+ :message => {:text => 'sometext'},
1719
+ :channel => 'ruby_demo_channel',
1720
+ :callback => @callback,
1721
+ :http_sync => true
1722
+ )
1723
+
1724
+ @envelopes.size.should eq 0
1725
+ @error_envelopes.size.should eq 1
1726
+ @error_envelopes.first.response_message.should eq 'Sent'
1727
+ @error_envelopes.first.response.should eq('[1,"Sent","13937904716672898"]')
1728
+ @error_envelopes.first.status.should eq 500
1729
+ @error_envelopes.first.channel.should eq('ruby_demo_channel')
1730
+ @error_envelopes.first.message.should eq('[0,"Non 2xx server response."]')
1731
+ @error_envelopes.first.timetoken.blank?.should eq false
1732
+
1733
+ end
1734
+ end
1735
+ end
1736
+ end
1737
+
1738
+ context 'with invalid json' do
1739
+ context 'its asynchronous' do
1740
+ it 'handles invalid json and non200 response gracefully' do
1741
+ VCR.use_cassette('new_ones/publish/publish-encrypted-https-non200-invalid', :record => :none) do
1742
+
1743
+ @pubnub.publish(
1744
+ :message => {:text => 'sometext'},
1745
+ :channel => 'ruby_demo_channel',
1746
+ :callback => @callback
1747
+ )
1748
+
1749
+ eventually do
1750
+ @envelopes.size.should eq 0
1751
+ @error_envelopes.size.should eq 1
1752
+ @error_envelopes.first.response_message.should eq nil
1753
+ @error_envelopes.first.response.should eq('[1,"Sent","13937904716672898"')
1754
+ @error_envelopes.first.status.should eq 500
1755
+ @error_envelopes.first.channel.should eq('ruby_demo_channel')
1756
+ @error_envelopes.first.message.should eq('[0,"Invalid JSON in response."]')
1757
+ @error_envelopes.first.timetoken.blank?.should eq true
1758
+ end
1759
+
1760
+ end
1761
+ end
1762
+ end
1763
+
1764
+ context 'its synchronous' do
1765
+ it 'handles invalid json and non200 response gracefully' do
1766
+ VCR.use_cassette('new_ones/publish/publish-encrypted-https-non200-invalid', :record => :none) do
1767
+
1768
+ @pubnub.publish(
1769
+ :message => {:text => 'sometext'},
1770
+ :channel => 'ruby_demo_channel',
1771
+ :callback => @callback,
1772
+ :http_sync => true
1773
+ )
1774
+
1775
+ @envelopes.size.should eq 0
1776
+ @error_envelopes.size.should eq 1
1777
+ @error_envelopes.first.response_message.should eq nil
1778
+ @error_envelopes.first.response.should eq('[1,"Sent","13937904716672898"')
1779
+ @error_envelopes.first.status.should eq 500
1780
+ @error_envelopes.first.channel.should eq('ruby_demo_channel')
1781
+ @error_envelopes.first.message.should eq('[0,"Invalid JSON in response."]')
1782
+ @error_envelopes.first.timetoken.blank?.should eq true
1783
+
1784
+ end
1785
+ end
1786
+ end
1787
+ end
1788
+ end
1789
+ end
1790
+ end
1791
+ end
1792
+
1793
+ context 'when gets message as' do
1794
+ context 'array of hashes' do
1795
+ context 'and its plain' do
1796
+ it 'publishes it correctly' do
1797
+ @pubnub = Pubnub.new(
1798
+ :max_retries => 0,
1799
+ :subscribe_key => :demo,
1800
+ :publish_key => :demo,
1801
+ :secret_key => 'some_secret_key',
1802
+ :error_callback => @error_callback
1803
+ )
1804
+
1805
+ @pubnub.uuid = 'tester'
1806
+
1807
+ msg = [{:a => 1}, {:b => 2}, :c => [1,2,3]]
1808
+
1809
+ VCR.use_cassette('new_ones/publish/publish-plain-array-of-hashes', :record => :none) do
1810
+
1811
+ @pubnub.publish(
1812
+ :message => msg,
1813
+ :channel => 'ruby_demo_channel',
1814
+ :callback => @callback
1815
+ )
1816
+
1817
+ eventually do
1818
+ @envelopes.size.should eq 1
1819
+ @envelopes.first.response_message.should eq 'Sent'
1820
+ @envelopes.first.status.should eq 200
1821
+ @envelopes.first.channel.should eq 'ruby_demo_channel'
1822
+ @envelopes.first.message.should eq(msg)
1823
+ @envelopes.first.timetoken.blank?.should eq false
1824
+ end
1825
+ end
1826
+
1827
+ end
1828
+ end
1829
+
1830
+ context 'and its encrypted' do
1831
+ it 'publishes it correctly' do
1832
+ @pubnub = Pubnub.new(
1833
+ :max_retries => 0,
1834
+ :subscribe_key => :demo,
1835
+ :publish_key => :demo,
1836
+ :secret_key => 'some_secret_key',
1837
+ :cipher_key => 'secret',
1838
+ :error_callback => @error_callback,
1839
+ :ssl => true
1840
+ )
1841
+
1842
+ @pubnub.uuid = 'tester'
1843
+
1844
+ msg = [{:a => 1}, {:b => 2}, :c => [1,2,3]]
1845
+
1846
+ VCR.use_cassette('new_ones/publish/publish-encrypted-array-of-hashes', :record => :none) do
1847
+
1848
+ @pubnub.publish(
1849
+ :message => msg,
1850
+ :channel => 'ruby_demo_channel',
1851
+ :callback => @callback
1852
+ )
1853
+
1854
+ eventually do
1855
+ @envelopes.size.should eq 1
1856
+ @envelopes.first.response_message.should eq 'Sent'
1857
+ @envelopes.first.status.should eq 200
1858
+ @envelopes.first.channel.should eq 'ruby_demo_channel'
1859
+ @envelopes.first.message.should eq(msg)
1860
+ @envelopes.first.timetoken.blank?.should eq false
1861
+ end
1862
+ end
1863
+ end
1864
+ end
1865
+ end
1866
+ end
1867
+ end