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,544 @@
1
+ require 'spec_helper'
2
+
3
+ describe "#grant" do
4
+ before(:each) do
5
+
6
+ EM.stop if EM.reactor_running?
7
+ while EM.reactor_running? do end
8
+ sleep(0.1)
9
+
10
+ @response_output = StringIO.new
11
+ @message_output = StringIO.new
12
+
13
+ @callback = lambda { |envelope|
14
+ $logger.debug 'FIRING CALLBACK FROM TEST'
15
+ @response_output.write envelope.response
16
+ @message_output.write envelope.msg
17
+ @after_callback = true
18
+ }
19
+
20
+ @error_callback = lambda { |envelope|
21
+ $logger.debug 'FIRING ERROR CALLBACK FROM TEST'
22
+ @response_output.write envelope.response
23
+ @message_output.write envelope.msg
24
+ @after_error_callback = true
25
+ }
26
+
27
+ @pn = Pubnub.new(:max_retries => 0, :subscribe_key => 'sub-c-53c3d30a-4135-11e3-9970-02ee2ddab7fe', :publish_key => 'pub-c-15d6fd3c-05de-4abc-8eba-6595a441959d', :secret_key => 'sec-c-ZWYwMGJiZTYtMTQwMC00NDQ5LWI0NmEtMzZiM2M5NThlOTJh', :error_callback => @error_callback)
28
+ @pn.uuid = 'f0ac67ef-912f-4797-be67-a59745107306'
29
+
30
+ Pubnub::Grant.any_instance.stub(:current_time).and_return 1234567890
31
+ Pubnub::Grant.any_instance.stub(:signature).and_return 'kdDh/sFC3rSR%2Bt5AEymIc57d1velIr562V7usa5M4k0='
32
+
33
+ end
34
+ context "uses ssl" do
35
+ before(:each) { @ssl = true }
36
+ context "passess callback as block" do
37
+ context "gets valid json in response" do
38
+ context "gets status 200 in response" do
39
+ context "uses sync connection" do
40
+ it 'works fine' do
41
+ VCR.use_cassette("grant-ssl-block-valid-200-sync", :record => :none) do
42
+ @pn.grant(:ssl => true, :http_sync => true, :channel => "demo", :auth_key => "authkey", :write => true, :read => true, &@callback)
43
+
44
+ @after_callback.should eq true
45
+ @response_output.seek 0
46
+ @response_output.read.should eq '{"status":200,"message":"Success","payload":{"auths":{"authkey":{"r":1,"w":1}},"subscribe_key":"sub-c-53c3d30a-4135-11e3-9970-02ee2ddab7fe","ttl":3600,"channel":"demo","level":"user"},"service":"Access Manager"}'
47
+ @message_output.seek 0
48
+ @message_output.read.should eq 'Success'
49
+ end
50
+ end
51
+ end
52
+ context "uses async connection" do
53
+ it 'works fine' do
54
+ VCR.use_cassette("grant-ssl-block-valid-200-async", :record => :none) do
55
+ @pn.grant(:ssl => true, :http_sync => false, :channel => "demo", :auth_key => "authkey", :write => true, :read => true, &@callback)
56
+
57
+ eventually do
58
+ @after_callback.should eq true
59
+ @response_output.seek 0
60
+ @response_output.read.should eq '{"status":200,"message":"Success","payload":{"auths":{"authkey":{"r":1,"w":1}},"subscribe_key":"sub-c-53c3d30a-4135-11e3-9970-02ee2ddab7fe","ttl":3600,"channel":"demo","level":"user"},"service":"Access Manager"}'
61
+ @message_output.seek 0
62
+ @message_output.read.should eq 'Success'
63
+ end
64
+ end
65
+ end
66
+ end
67
+ end
68
+ context "gets status non-200 in response" do
69
+ context "uses sync connection" do
70
+ it 'works fine' do
71
+ VCR.use_cassette("grant-ssl-block-valid-non-200-sync", :record => :none) do
72
+ @pn.grant(:ssl => true, :http_sync => true, :channel => "demo", :auth_key => "authkey", :write => true, :read => true, &@callback)
73
+
74
+ @after_error_callback.should eq true
75
+ @response_output.seek 0
76
+ @response_output.read.should eq '{"status":200,"message":"Success","payload":{"auths":{"authkey":{"r":1,"w":1}},"subscribe_key":"sub-c-53c3d30a-4135-11e3-9970-02ee2ddab7fe","ttl":3600,"channel":"demo","level":"user"},"service":"Access Manager"}'
77
+ @message_output.seek 0
78
+ @message_output.read.should eq '[0,"Non 2xx server response."]'
79
+ end
80
+ end
81
+ end
82
+ context "uses async connection" do
83
+ it 'works fine' do
84
+ VCR.use_cassette("grant-ssl-block-valid-non-200-async", :record => :none) do
85
+ @pn.grant(:ssl => true, :http_sync => false, :channel => "demo", :auth_key => "authkey", :write => true, :read => true, &@callback)
86
+
87
+ eventually do
88
+ @after_error_callback.should eq true
89
+ @response_output.seek 0
90
+ @response_output.read.should eq '{"status":200,"message":"Success","payload":{"auths":{"authkey":{"r":1,"w":1}},"subscribe_key":"sub-c-53c3d30a-4135-11e3-9970-02ee2ddab7fe","ttl":3600,"channel":"demo","level":"user"},"service":"Access Manager"}'
91
+ @message_output.seek 0
92
+ @message_output.read.should eq '[0,"Non 2xx server response."]'
93
+ end
94
+ end
95
+ end
96
+ end
97
+ end
98
+ end
99
+ context "gets invalid json in response" do
100
+ context "gets status 200 in response" do
101
+ context "uses sync connection" do
102
+ it 'works fine' do
103
+ VCR.use_cassette("grant-ssl-block-invalid-200-sync", :record => :none) do
104
+ @pn.grant(:ssl => true, :http_sync => true, :channel => "demo", :auth_key => "authkey", :write => true, :read => true, &@callback)
105
+
106
+ @after_error_callback.should eq true
107
+ @response_output.seek 0
108
+ @response_output.read.should eq '{"status":200,'
109
+ @message_output.seek 0
110
+ @message_output.read.should eq '[0,"Invalid JSON in response."]'
111
+ end
112
+ end
113
+ end
114
+ context "uses async connection" do
115
+ it 'works fine' do
116
+ VCR.use_cassette("grant-ssl-block-invalid-200-async", :record => :none) do
117
+ @pn.grant(:ssl => true, :http_sync => false, :channel => "demo", :auth_key => "authkey", :write => true, :read => true, &@callback)
118
+
119
+ eventually do
120
+ @after_error_callback.should eq true
121
+ @response_output.seek 0
122
+ @response_output.read.should eq '{"status":200,'
123
+ @message_output.seek 0
124
+ @message_output.read.should eq '[0,"Invalid JSON in response."]'
125
+ end
126
+ end
127
+ end
128
+ end
129
+ end
130
+ context "gets status non-200 in response" do
131
+ context "uses sync connection" do
132
+ it 'works fine' do
133
+ VCR.use_cassette("grant-ssl-block-invalid-non-200-sync", :record => :none) do
134
+ @pn.grant(:ssl => true, :http_sync => true, :channel => "demo", :auth_key => "authkey", :write => true, :read => true, &@callback)
135
+
136
+ @after_error_callback.should eq true
137
+ @response_output.seek 0
138
+ @response_output.read.should eq '{"status":200,'
139
+ @message_output.seek 0
140
+ @message_output.read.should eq '[0,"Invalid JSON in response."]'
141
+ end
142
+ end
143
+ end
144
+ context "uses async connection" do
145
+ it 'works fine' do
146
+ VCR.use_cassette("grant-ssl-block-invalid-non-200-async", :record => :none) do
147
+ @pn.grant(:ssl => true, :http_sync => false, :channel => "demo", :auth_key => "authkey", :write => true, :read => true, &@callback)
148
+
149
+ eventually do
150
+ @after_error_callback.should eq true
151
+ @response_output.seek 0
152
+ @response_output.read.should eq '{"status":200,'
153
+ @message_output.seek 0
154
+ @message_output.read.should eq '[0,"Invalid JSON in response."]'
155
+ end
156
+ end
157
+ end
158
+ end
159
+ end
160
+ end
161
+ end
162
+ context "passess callback as parameter" do
163
+ context "gets valid json in response" do
164
+ context "gets status 200 in response" do
165
+ context "uses sync connection" do
166
+ it 'works fine' do
167
+ VCR.use_cassette("grant-ssl-parameter-valid-200-sync", :record => :none) do
168
+ @pn.grant(:ssl => true, :http_sync => true, :channel => "demo", :auth_key => "authkey", :write => true, :read => true, :callback => @callback)
169
+
170
+ @after_callback.should eq true
171
+ @response_output.seek 0
172
+ @response_output.read.should eq '{"status":200,"message":"Success","payload":{"auths":{"authkey":{"r":1,"w":1}},"subscribe_key":"sub-c-53c3d30a-4135-11e3-9970-02ee2ddab7fe","ttl":3600,"channel":"demo","level":"user"},"service":"Access Manager"}'
173
+ @message_output.seek 0
174
+ @message_output.read.should eq 'Success'
175
+ end
176
+ end
177
+ end
178
+ context "uses async connection" do
179
+ it 'works fine' do
180
+ VCR.use_cassette("grant-ssl-parameter-valid-200-async", :record => :none) do
181
+ @pn.grant(:ssl => true, :http_sync => false, :channel => "demo", :auth_key => "authkey", :write => true, :read => true, :callback => @callback)
182
+
183
+ eventually do
184
+ @after_callback.should eq true
185
+ @response_output.seek 0
186
+ @response_output.read.should eq '{"status":200,"message":"Success","payload":{"auths":{"authkey":{"r":1,"w":1}},"subscribe_key":"sub-c-53c3d30a-4135-11e3-9970-02ee2ddab7fe","ttl":3600,"channel":"demo","level":"user"},"service":"Access Manager"}'
187
+ @message_output.seek 0
188
+ @message_output.read.should eq 'Success'
189
+ end
190
+ end
191
+ end
192
+ end
193
+ end
194
+ context "gets status non-200 in response" do
195
+ context "uses sync connection" do
196
+ it 'works fine' do
197
+ VCR.use_cassette("grant-ssl-parameter-valid-non-200-sync", :record => :none) do
198
+ @pn.grant(:ssl => true, :http_sync => true, :channel => "demo", :auth_key => "authkey", :write => true, :read => true, :callback => @callback)
199
+
200
+ @after_error_callback.should eq true
201
+ @response_output.seek 0
202
+ @response_output.read.should eq '{"status":200,"message":"Success","payload":{"auths":{"authkey":{"r":1,"w":1}},"subscribe_key":"sub-c-53c3d30a-4135-11e3-9970-02ee2ddab7fe","ttl":3600,"channel":"demo","level":"user"},"service":"Access Manager"}'
203
+ @message_output.seek 0
204
+ @message_output.read.should eq '[0,"Non 2xx server response."]'
205
+ end
206
+ end
207
+ end
208
+ context "uses async connection" do
209
+ it 'works fine' do
210
+ VCR.use_cassette("grant-ssl-parameter-valid-non-200-async", :record => :none) do
211
+ @pn.grant(:ssl => true, :http_sync => false, :channel => "demo", :auth_key => "authkey", :write => true, :read => true, :callback => @callback)
212
+
213
+ eventually do
214
+ @after_error_callback.should eq true
215
+ @response_output.seek 0
216
+ @response_output.read.should eq '{"status":200,"message":"Success","payload":{"auths":{"authkey":{"r":1,"w":1}},"subscribe_key":"sub-c-53c3d30a-4135-11e3-9970-02ee2ddab7fe","ttl":3600,"channel":"demo","level":"user"},"service":"Access Manager"}'
217
+ @message_output.seek 0
218
+ @message_output.read.should eq '[0,"Non 2xx server response."]'
219
+ end
220
+ end
221
+ end
222
+ end
223
+ end
224
+ end
225
+ context "gets invalid json in response" do
226
+ context "gets status 200 in response" do
227
+ context "uses sync connection" do
228
+ it 'works fine' do
229
+ VCR.use_cassette("grant-ssl-parameter-invalid-200-sync", :record => :none) do
230
+ @pn.grant(:ssl => true, :http_sync => true, :channel => "demo", :auth_key => "authkey", :write => true, :read => true, :callback => @callback)
231
+
232
+ @after_error_callback.should eq true
233
+ @response_output.seek 0
234
+ @response_output.read.should eq '{"status":200,'
235
+ @message_output.seek 0
236
+ @message_output.read.should eq '[0,"Invalid JSON in response."]'
237
+ end
238
+ end
239
+ end
240
+ context "uses async connection" do
241
+ it 'works fine' do
242
+ VCR.use_cassette("grant-ssl-parameter-invalid-200-async", :record => :none) do
243
+ @pn.grant(:ssl => true, :http_sync => false, :channel => "demo", :auth_key => "authkey", :write => true, :read => true, :callback => @callback)
244
+
245
+ eventually do
246
+ @after_error_callback.should eq true
247
+ @response_output.seek 0
248
+ @response_output.read.should eq '{"status":200,'
249
+ @message_output.seek 0
250
+ @message_output.read.should eq '[0,"Invalid JSON in response."]'
251
+ end
252
+ end
253
+ end
254
+ end
255
+ end
256
+ context "gets status non-200 in response" do
257
+ context "uses sync connection" do
258
+ it 'works fine' do
259
+ VCR.use_cassette("grant-ssl-parameter-invalid-non-200-sync", :record => :none) do
260
+ @pn.grant(:ssl => true, :http_sync => true, :channel => "demo", :auth_key => "authkey", :write => true, :read => true, :callback => @callback)
261
+
262
+ @after_error_callback.should eq true
263
+ @response_output.seek 0
264
+ @response_output.read.should eq '{"status":200,'
265
+ @message_output.seek 0
266
+ @message_output.read.should eq '[0,"Invalid JSON in response."]'
267
+ end
268
+ end
269
+ end
270
+ context "uses async connection" do
271
+ it 'works fine' do
272
+ VCR.use_cassette("grant-ssl-parameter-invalid-non-200-async", :record => :none) do
273
+ @pn.grant(:ssl => true, :http_sync => false, :channel => "demo", :auth_key => "authkey", :write => true, :read => true, :callback => @callback)
274
+
275
+ eventually do
276
+ @after_error_callback.should eq true
277
+ @response_output.seek 0
278
+ @response_output.read.should eq '{"status":200,'
279
+ @message_output.seek 0
280
+ @message_output.read.should eq '[0,"Invalid JSON in response."]'
281
+ end
282
+ end
283
+ end
284
+ end
285
+ end
286
+ end
287
+ end
288
+ end
289
+ context "uses non-ssl" do
290
+ before(:each) { @ssl = false }
291
+ context "passess callback as block" do
292
+ context "gets valid json in response" do
293
+ context "gets status 200 in response" do
294
+ context "uses sync connection" do
295
+ it 'works fine' do
296
+ VCR.use_cassette("grant-nonssl-block-valid-200-sync", :record => :none) do
297
+ @pn.grant(:ssl => false, :http_sync => true, :channel => "demo", :auth_key => "authkey", :write => true, :read => true, &@callback)
298
+
299
+ @after_callback.should eq true
300
+ @response_output.seek 0
301
+ @response_output.read.should eq '{"status":200,"message":"Success","payload":{"auths":{"authkey":{"r":1,"w":1}},"subscribe_key":"sub-c-53c3d30a-4135-11e3-9970-02ee2ddab7fe","ttl":3600,"channel":"demo","level":"user"},"service":"Access Manager"}'
302
+ @message_output.seek 0
303
+ @message_output.read.should eq 'Success'
304
+ end
305
+ end
306
+ end
307
+ context "uses async connection" do
308
+ it 'works fine' do
309
+ VCR.use_cassette("grant-nonssl-block-valid-200-async", :record => :none) do
310
+ @pn.grant(:ssl => false, :http_sync => false, :channel => "demo", :auth_key => "authkey", :write => true, :read => true, &@callback)
311
+
312
+ eventually do
313
+ @after_callback.should eq true
314
+ @response_output.seek 0
315
+ @response_output.read.should eq '{"status":200,"message":"Success","payload":{"auths":{"authkey":{"r":1,"w":1}},"subscribe_key":"sub-c-53c3d30a-4135-11e3-9970-02ee2ddab7fe","ttl":3600,"channel":"demo","level":"user"},"service":"Access Manager"}'
316
+ @message_output.seek 0
317
+ @message_output.read.should eq 'Success'
318
+ end
319
+ end
320
+ end
321
+ end
322
+ end
323
+ context "gets status non-200 in response" do
324
+ context "uses sync connection" do
325
+ it 'works fine' do
326
+ VCR.use_cassette("grant-nonssl-block-valid-non-200-sync", :record => :none) do
327
+ @pn.grant(:ssl => false, :http_sync => true, :channel => "demo", :auth_key => "authkey", :write => true, :read => true, &@callback)
328
+
329
+ @after_error_callback.should eq true
330
+ @response_output.seek 0
331
+ @response_output.read.should eq '{"status":200,"message":"Success","payload":{"auths":{"authkey":{"r":1,"w":1}},"subscribe_key":"sub-c-53c3d30a-4135-11e3-9970-02ee2ddab7fe","ttl":3600,"channel":"demo","level":"user"},"service":"Access Manager"}'
332
+ @message_output.seek 0
333
+ @message_output.read.should eq '[0,"Non 2xx server response."]'
334
+ end
335
+ end
336
+ end
337
+ context "uses async connection" do
338
+ it 'works fine' do
339
+ VCR.use_cassette("grant-nonssl-block-valid-non-200-async", :record => :none) do
340
+ @pn.grant(:ssl => false, :http_sync => false, :channel => "demo", :auth_key => "authkey", :write => true, :read => true, &@callback)
341
+
342
+ eventually do
343
+ @after_error_callback.should eq true
344
+ @response_output.seek 0
345
+ @response_output.read.should eq '{"status":200,"message":"Success","payload":{"auths":{"authkey":{"r":1,"w":1}},"subscribe_key":"sub-c-53c3d30a-4135-11e3-9970-02ee2ddab7fe","ttl":3600,"channel":"demo","level":"user"},"service":"Access Manager"}'
346
+ @message_output.seek 0
347
+ @message_output.read.should eq '[0,"Non 2xx server response."]'
348
+ end
349
+ end
350
+ end
351
+ end
352
+ end
353
+ end
354
+ context "gets invalid json in response" do
355
+ context "gets status 200 in response" do
356
+ context "uses sync connection" do
357
+ it 'works fine' do
358
+ VCR.use_cassette("grant-nonssl-block-invalid-200-sync", :record => :none) do
359
+ @pn.grant(:ssl => false, :http_sync => true, :channel => "demo", :auth_key => "authkey", :write => true, :read => true, &@callback)
360
+
361
+ @after_error_callback.should eq true
362
+ @response_output.seek 0
363
+ @response_output.read.should eq '{"status":200,'
364
+ @message_output.seek 0
365
+ @message_output.read.should eq '[0,"Invalid JSON in response."]'
366
+ end
367
+ end
368
+ end
369
+ context "uses async connection" do
370
+ it 'works fine' do
371
+ VCR.use_cassette("grant-nonssl-block-invalid-200-async", :record => :none) do
372
+ @pn.grant(:ssl => false, :http_sync => false, :channel => "demo", :auth_key => "authkey", :write => true, :read => true, &@callback)
373
+
374
+ eventually do
375
+ @after_error_callback.should eq true
376
+ @response_output.seek 0
377
+ @response_output.read.should eq '{"status":200,'
378
+ @message_output.seek 0
379
+ @message_output.read.should eq '[0,"Invalid JSON in response."]'
380
+ end
381
+ end
382
+ end
383
+ end
384
+ end
385
+ context "gets status non-200 in response" do
386
+ context "uses sync connection" do
387
+ it 'works fine' do
388
+ VCR.use_cassette("grant-nonssl-block-invalid-non-200-sync", :record => :none) do
389
+ @pn.grant(:ssl => false, :http_sync => true, :channel => "demo", :auth_key => "authkey", :write => true, :read => true, &@callback)
390
+
391
+ @after_error_callback.should eq true
392
+ @response_output.seek 0
393
+ @response_output.read.should eq '{"status":200,'
394
+ @message_output.seek 0
395
+ @message_output.read.should eq '[0,"Invalid JSON in response."]'
396
+ end
397
+ end
398
+ end
399
+ context "uses async connection" do
400
+ it 'works fine' do
401
+ VCR.use_cassette("grant-nonssl-block-invalid-non-200-async", :record => :none) do
402
+ @pn.grant(:ssl => false, :http_sync => false, :channel => "demo", :auth_key => "authkey", :write => true, :read => true, &@callback)
403
+
404
+ eventually do
405
+ @after_error_callback.should eq true
406
+ @response_output.seek 0
407
+ @response_output.read.should eq '{"status":200,'
408
+ @message_output.seek 0
409
+ @message_output.read.should eq '[0,"Invalid JSON in response."]'
410
+ end
411
+ end
412
+ end
413
+ end
414
+ end
415
+ end
416
+ end
417
+ context "passess callback as parameter" do
418
+ context "gets valid json in response" do
419
+ context "gets status 200 in response" do
420
+ context "uses sync connection" do
421
+ it 'works fine' do
422
+ VCR.use_cassette("grant-nonssl-parameter-valid-200-sync", :record => :none) do
423
+ @pn.grant(:ssl => false, :http_sync => true, :channel => "demo", :auth_key => "authkey", :write => true, :read => true, :callback => @callback)
424
+
425
+ @after_callback.should eq true
426
+ @response_output.seek 0
427
+ @response_output.read.should eq '{"status":200,"message":"Success","payload":{"auths":{"authkey":{"r":1,"w":1}},"subscribe_key":"sub-c-53c3d30a-4135-11e3-9970-02ee2ddab7fe","ttl":3600,"channel":"demo","level":"user"},"service":"Access Manager"}'
428
+ @message_output.seek 0
429
+ @message_output.read.should eq 'Success'
430
+ end
431
+ end
432
+ end
433
+ context "uses async connection" do
434
+ it 'works fine' do
435
+ VCR.use_cassette("grant-nonssl-parameter-valid-200-async", :record => :none) do
436
+ @pn.grant(:ssl => false, :http_sync => false, :channel => "demo", :auth_key => "authkey", :write => true, :read => true, :callback => @callback)
437
+
438
+ eventually do
439
+ @after_callback.should eq true
440
+ @response_output.seek 0
441
+ @response_output.read.should eq '{"status":200,"message":"Success","payload":{"auths":{"authkey":{"r":1,"w":1}},"subscribe_key":"sub-c-53c3d30a-4135-11e3-9970-02ee2ddab7fe","ttl":3600,"channel":"demo","level":"user"},"service":"Access Manager"}'
442
+ @message_output.seek 0
443
+ @message_output.read.should eq 'Success'
444
+ end
445
+ end
446
+ end
447
+ end
448
+ end
449
+ context "gets status non-200 in response" do
450
+ context "uses sync connection" do
451
+ it 'works fine' do
452
+ VCR.use_cassette("grant-nonssl-parameter-valid-non-200-sync", :record => :none) do
453
+ @pn.grant(:ssl => false, :http_sync => true, :channel => "demo", :auth_key => "authkey", :write => true, :read => true, :callback => @callback)
454
+
455
+ @after_error_callback.should eq true
456
+ @response_output.seek 0
457
+ @response_output.read.should eq '{"status":200,"message":"Success","payload":{"auths":{"authkey":{"r":1,"w":1}},"subscribe_key":"sub-c-53c3d30a-4135-11e3-9970-02ee2ddab7fe","ttl":3600,"channel":"demo","level":"user"},"service":"Access Manager"}'
458
+ @message_output.seek 0
459
+ @message_output.read.should eq '[0,"Non 2xx server response."]'
460
+ end
461
+ end
462
+ end
463
+ context "uses async connection" do
464
+ it 'works fine' do
465
+ VCR.use_cassette("grant-nonssl-parameter-valid-non-200-async", :record => :none) do
466
+ @pn.grant(:ssl => false, :http_sync => false, :channel => "demo", :auth_key => "authkey", :write => true, :read => true, :callback => @callback)
467
+
468
+ eventually do
469
+ @after_error_callback.should eq true
470
+ @response_output.seek 0
471
+ @response_output.read.should eq '{"status":200,"message":"Success","payload":{"auths":{"authkey":{"r":1,"w":1}},"subscribe_key":"sub-c-53c3d30a-4135-11e3-9970-02ee2ddab7fe","ttl":3600,"channel":"demo","level":"user"},"service":"Access Manager"}'
472
+ @message_output.seek 0
473
+ @message_output.read.should eq '[0,"Non 2xx server response."]'
474
+ end
475
+ end
476
+ end
477
+ end
478
+ end
479
+ end
480
+ context "gets invalid json in response" do
481
+ context "gets status 200 in response" do
482
+ context "uses sync connection" do
483
+ it 'works fine' do
484
+ VCR.use_cassette("grant-nonssl-parameter-invalid-200-sync", :record => :none) do
485
+ @pn.grant(:ssl => false, :http_sync => true, :channel => "demo", :auth_key => "authkey", :write => true, :read => true, :callback => @callback)
486
+
487
+ @after_error_callback.should eq true
488
+ @response_output.seek 0
489
+ @response_output.read.should eq '{"status":200,'
490
+ @message_output.seek 0
491
+ @message_output.read.should eq '[0,"Invalid JSON in response."]'
492
+ end
493
+ end
494
+ end
495
+ context "uses async connection" do
496
+ it 'works fine' do
497
+ VCR.use_cassette("grant-nonssl-parameter-invalid-200-async", :record => :none) do
498
+ @pn.grant(:ssl => false, :http_sync => false, :channel => "demo", :auth_key => "authkey", :write => true, :read => true, :callback => @callback)
499
+
500
+ eventually do
501
+ @after_error_callback.should eq true
502
+ @response_output.seek 0
503
+ @response_output.read.should eq '{"status":200,'
504
+ @message_output.seek 0
505
+ @message_output.read.should eq '[0,"Invalid JSON in response."]'
506
+ end
507
+ end
508
+ end
509
+ end
510
+ end
511
+ context "gets status non-200 in response" do
512
+ context "uses sync connection" do
513
+ it 'works fine' do
514
+ VCR.use_cassette("grant-nonssl-parameter-invalid-non-200-sync", :record => :none) do
515
+ @pn.grant(:ssl => false, :http_sync => true, :channel => "demo", :auth_key => "authkey", :write => true, :read => true, :callback => @callback)
516
+
517
+ @after_error_callback.should eq true
518
+ @response_output.seek 0
519
+ @response_output.read.should eq '{"status":200,'
520
+ @message_output.seek 0
521
+ @message_output.read.should eq '[0,"Invalid JSON in response."]'
522
+ end
523
+ end
524
+ end
525
+ context "uses async connection" do
526
+ it 'works fine' do
527
+ VCR.use_cassette("grant-nonssl-parameter-invalid-non-200-async", :record => :none) do
528
+ @pn.grant(:ssl => false, :http_sync => false, :channel => "demo", :auth_key => "authkey", :write => true, :read => true, :callback => @callback)
529
+
530
+ eventually do
531
+ @after_error_callback.should eq true
532
+ @response_output.seek 0
533
+ @response_output.read.should eq '{"status":200,'
534
+ @message_output.seek 0
535
+ @message_output.read.should eq '[0,"Invalid JSON in response."]'
536
+ end
537
+ end
538
+ end
539
+ end
540
+ end
541
+ end
542
+ end
543
+ end
544
+ end