slack-ruby-client 0.14.5 → 0.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (231) hide show
  1. checksums.yaml +4 -4
  2. data/.github/FUNDING.yml +1 -0
  3. data/.rubocop.yml +11 -3
  4. data/.rubocop_todo.yml +61 -23
  5. data/.travis.yml +1 -5
  6. data/CHANGELOG.md +43 -4
  7. data/CONTRIBUTING.md +17 -6
  8. data/Dangerfile +1 -1
  9. data/Gemfile +1 -2
  10. data/LICENSE.md +1 -1
  11. data/README.md +86 -52
  12. data/UPGRADING.md +20 -2
  13. data/bin/commands.rb +23 -0
  14. data/bin/commands/admin_analytics.rb +16 -0
  15. data/bin/commands/admin_apps.rb +15 -2
  16. data/bin/commands/admin_apps_approved.rb +17 -0
  17. data/bin/commands/admin_apps_restricted.rb +17 -0
  18. data/bin/commands/admin_barriers.rb +47 -0
  19. data/bin/commands/admin_conversations.rb +159 -0
  20. data/bin/commands/admin_conversations_ekm.rb +17 -0
  21. data/bin/commands/admin_conversations_restrictAccess.rb +37 -0
  22. data/bin/commands/admin_conversations_whitelist.rb +37 -0
  23. data/bin/commands/admin_emoji.rb +54 -0
  24. data/bin/commands/admin_inviteRequests.rb +36 -0
  25. data/bin/commands/admin_inviteRequests_approved.rb +16 -0
  26. data/bin/commands/admin_inviteRequests_denied.rb +16 -0
  27. data/bin/commands/admin_teams.rb +27 -0
  28. data/bin/commands/admin_teams_admins.rb +16 -0
  29. data/bin/commands/admin_teams_owners.rb +16 -0
  30. data/bin/commands/admin_teams_settings.rb +64 -0
  31. data/bin/commands/admin_usergroups.rb +48 -0
  32. data/bin/commands/admin_users.rb +97 -0
  33. data/bin/commands/admin_users_session.rb +22 -0
  34. data/bin/commands/api.rb +0 -1
  35. data/bin/commands/apps_connections.rb +13 -0
  36. data/bin/commands/apps_event_authorizations.rb +16 -0
  37. data/bin/commands/auth_teams.rb +16 -0
  38. data/bin/commands/bots.rb +1 -0
  39. data/bin/commands/calls.rb +52 -0
  40. data/bin/commands/calls_participants.rb +25 -0
  41. data/bin/commands/channels.rb +1 -155
  42. data/bin/commands/chat.rb +14 -12
  43. data/bin/commands/chat_scheduledMessages.rb +1 -0
  44. data/bin/commands/conversations.rb +15 -4
  45. data/bin/commands/dnd.rb +3 -1
  46. data/bin/commands/files.rb +7 -5
  47. data/bin/commands/files_remote.rb +3 -3
  48. data/bin/commands/groups.rb +1 -162
  49. data/bin/commands/im.rb +1 -63
  50. data/bin/commands/migration.rb +1 -0
  51. data/bin/commands/mpim.rb +1 -61
  52. data/bin/commands/oauth.rb +1 -1
  53. data/bin/commands/pins.rb +0 -2
  54. data/bin/commands/reactions.rb +1 -0
  55. data/bin/commands/search.rb +4 -1
  56. data/bin/commands/team.rb +3 -0
  57. data/bin/commands/usergroups.rb +6 -1
  58. data/bin/commands/usergroups_users.rb +2 -0
  59. data/bin/commands/users.rb +5 -3
  60. data/bin/commands/users_profile.rb +5 -5
  61. data/bin/commands/views.rb +1 -1
  62. data/bin/commands/workflows.rb +38 -0
  63. data/lib/slack-ruby-client.rb +5 -4
  64. data/lib/slack/events/request.rb +7 -3
  65. data/lib/slack/messages/message.rb +0 -4
  66. data/lib/slack/real_time/client.rb +2 -1
  67. data/lib/slack/real_time/concurrency.rb +0 -2
  68. data/lib/slack/real_time/concurrency/async.rb +1 -3
  69. data/lib/slack/real_time/config.rb +5 -14
  70. data/lib/slack/real_time/models/base.rb +0 -4
  71. data/lib/slack/real_time/socket.rb +2 -2
  72. data/lib/slack/real_time/stores/base.rb +3 -1
  73. data/lib/slack/version.rb +1 -1
  74. data/lib/slack/web/api/endpoints.rb +47 -0
  75. data/lib/slack/web/api/endpoints/admin_analytics.rb +28 -0
  76. data/lib/slack/web/api/endpoints/admin_apps.rb +22 -2
  77. data/lib/slack/web/api/endpoints/admin_apps_approved.rb +35 -0
  78. data/lib/slack/web/api/endpoints/admin_apps_restricted.rb +35 -0
  79. data/lib/slack/web/api/endpoints/admin_barriers.rb +82 -0
  80. data/lib/slack/web/api/endpoints/admin_conversations.rb +246 -0
  81. data/lib/slack/web/api/endpoints/admin_conversations_ekm.rb +35 -0
  82. data/lib/slack/web/api/endpoints/admin_conversations_restrictAccess.rb +61 -0
  83. data/lib/slack/web/api/endpoints/admin_conversations_whitelist.rb +64 -0
  84. data/lib/slack/web/api/endpoints/admin_emoji.rb +88 -0
  85. data/lib/slack/web/api/endpoints/admin_inviteRequests.rb +61 -0
  86. data/lib/slack/web/api/endpoints/admin_inviteRequests_approved.rb +33 -0
  87. data/lib/slack/web/api/endpoints/admin_inviteRequests_denied.rb +33 -0
  88. data/lib/slack/web/api/endpoints/admin_teams.rb +50 -0
  89. data/lib/slack/web/api/endpoints/admin_teams_admins.rb +34 -0
  90. data/lib/slack/web/api/endpoints/admin_teams_owners.rb +34 -0
  91. data/lib/slack/web/api/endpoints/admin_teams_settings.rb +99 -0
  92. data/lib/slack/web/api/endpoints/admin_usergroups.rb +77 -0
  93. data/lib/slack/web/api/endpoints/admin_users.rb +161 -0
  94. data/lib/slack/web/api/endpoints/admin_users_session.rb +38 -0
  95. data/lib/slack/web/api/endpoints/api.rb +0 -2
  96. data/lib/slack/web/api/endpoints/apps_connections.rb +21 -0
  97. data/lib/slack/web/api/endpoints/apps_event_authorizations.rb +34 -0
  98. data/lib/slack/web/api/endpoints/auth_teams.rb +33 -0
  99. data/lib/slack/web/api/endpoints/bots.rb +2 -0
  100. data/lib/slack/web/api/endpoints/calls.rb +83 -0
  101. data/lib/slack/web/api/endpoints/calls_participants.rb +42 -0
  102. data/lib/slack/web/api/endpoints/channels.rb +1 -245
  103. data/lib/slack/web/api/endpoints/chat.rb +23 -19
  104. data/lib/slack/web/api/endpoints/chat_scheduledMessages.rb +3 -1
  105. data/lib/slack/web/api/endpoints/conversations.rb +37 -19
  106. data/lib/slack/web/api/endpoints/dnd.rb +4 -0
  107. data/lib/slack/web/api/endpoints/files.rb +8 -4
  108. data/lib/slack/web/api/endpoints/files_remote.rb +4 -4
  109. data/lib/slack/web/api/endpoints/groups.rb +0 -253
  110. data/lib/slack/web/api/endpoints/im.rb +0 -101
  111. data/lib/slack/web/api/endpoints/migration.rb +2 -0
  112. data/lib/slack/web/api/endpoints/mpim.rb +0 -96
  113. data/lib/slack/web/api/endpoints/oauth.rb +1 -4
  114. data/lib/slack/web/api/endpoints/pins.rb +3 -8
  115. data/lib/slack/web/api/endpoints/reactions.rb +5 -3
  116. data/lib/slack/web/api/endpoints/search.rb +6 -0
  117. data/lib/slack/web/api/endpoints/stars.rb +2 -2
  118. data/lib/slack/web/api/endpoints/team.rb +6 -0
  119. data/lib/slack/web/api/endpoints/usergroups.rb +10 -0
  120. data/lib/slack/web/api/endpoints/usergroups_users.rb +4 -0
  121. data/lib/slack/web/api/endpoints/users.rb +7 -5
  122. data/lib/slack/web/api/endpoints/users_profile.rb +3 -3
  123. data/lib/slack/web/api/endpoints/views.rb +1 -1
  124. data/lib/slack/web/api/endpoints/workflows.rb +61 -0
  125. data/lib/slack/web/api/errors.rb +848 -0
  126. data/lib/slack/web/api/errors/internal_error.rb +14 -0
  127. data/lib/slack/web/api/errors/slack_error.rb +12 -0
  128. data/lib/slack/web/api/mixins.rb +1 -0
  129. data/lib/slack/web/api/mixins/channels.id.rb +1 -3
  130. data/lib/slack/web/api/mixins/conversations.id.rb +25 -0
  131. data/lib/slack/web/api/mixins/groups.id.rb +1 -3
  132. data/lib/slack/web/api/mixins/ids.id.rb +3 -5
  133. data/lib/slack/web/api/mixins/users.id.rb +1 -3
  134. data/lib/slack/web/api/patches/{chat.6.block-kit-support.patch → chat.1.patch} +26 -24
  135. data/lib/slack/web/api/templates/endpoints.erb +1 -0
  136. data/lib/slack/web/api/templates/errors.erb +20 -0
  137. data/lib/slack/web/api/templates/method.erb +4 -1
  138. data/lib/slack/web/api/templates/method_spec.erb +1 -1
  139. data/lib/slack/web/client.rb +1 -1
  140. data/lib/slack/web/config.rb +2 -0
  141. data/lib/slack/web/faraday/connection.rb +23 -20
  142. data/lib/slack/web/faraday/response/raise_error.rb +16 -2
  143. data/lib/slack/web/faraday/response/wrap_error.rb +24 -0
  144. data/lib/slack/web/pagination/cursor.rb +2 -2
  145. data/lib/tasks/real_time.rake +1 -1
  146. data/lib/tasks/web.rake +21 -4
  147. data/slack-ruby-client.gemspec +5 -5
  148. data/spec/fixtures/slack/web/channels_info.yml +108 -15
  149. data/spec/fixtures/slack/web/{groups_info.yml → conversations_info.yml} +4 -4
  150. data/spec/fixtures/slack/web/conversations_setTopic.yml +69 -0
  151. data/spec/fixtures/slack/web/conversations_setTopic_one_page.yml +142 -0
  152. data/spec/fixtures/slack/web/conversations_setTopic_paginated.yml +208 -0
  153. data/spec/fixtures/slack/web/views_open_error.yml +76 -0
  154. data/spec/slack/events/request_spec.rb +13 -8
  155. data/spec/slack/real_time/client_spec.rb +18 -1
  156. data/spec/slack/real_time/concurrency/with_concurrency_spec.rb +10 -0
  157. data/spec/slack/real_time/concurrency/without_concurrency_spec.rb +10 -0
  158. data/spec/slack/real_time/rtm_connect_spec.rb +1 -1
  159. data/spec/slack/real_time/rtm_start_spec.rb +1 -1
  160. data/spec/slack/web/api/endpoints/admin_analytics_spec.rb +13 -0
  161. data/spec/slack/web/api/endpoints/admin_apps_approved_spec.rb +8 -0
  162. data/spec/slack/web/api/endpoints/admin_apps_restricted_spec.rb +8 -0
  163. data/spec/slack/web/api/endpoints/admin_apps_spec.rb +5 -0
  164. data/spec/slack/web/api/endpoints/admin_barriers_spec.rb +38 -0
  165. data/spec/slack/web/api/endpoints/admin_conversations_ekm_spec.rb +8 -0
  166. data/spec/slack/web/api/endpoints/admin_conversations_restrictAccess_spec.rb +32 -0
  167. data/spec/slack/web/api/endpoints/admin_conversations_spec.rb +93 -0
  168. data/spec/slack/web/api/endpoints/admin_emoji_spec.rb +37 -0
  169. data/spec/slack/web/api/endpoints/admin_inviteRequests_approved_spec.rb +8 -0
  170. data/spec/slack/web/api/endpoints/admin_inviteRequests_denied_spec.rb +8 -0
  171. data/spec/slack/web/api/endpoints/admin_inviteRequests_spec.rb +18 -0
  172. data/spec/slack/web/api/endpoints/admin_teams_admins_spec.rb +13 -0
  173. data/spec/slack/web/api/endpoints/admin_teams_owners_spec.rb +13 -0
  174. data/spec/slack/web/api/endpoints/admin_teams_settings_spec.rb +53 -0
  175. data/spec/slack/web/api/endpoints/admin_teams_spec.rb +16 -0
  176. data/spec/slack/web/api/endpoints/admin_usergroups_spec.rb +37 -0
  177. data/spec/slack/web/api/endpoints/admin_users_session_spec.rb +8 -0
  178. data/spec/slack/web/api/endpoints/admin_users_spec.rb +67 -0
  179. data/spec/slack/web/api/endpoints/apps_connections_spec.rb +8 -0
  180. data/spec/slack/web/api/endpoints/apps_event_authorizations_spec.rb +13 -0
  181. data/spec/slack/web/api/endpoints/apps_permissions_spec.rb +2 -2
  182. data/spec/slack/web/api/endpoints/apps_permissions_users_spec.rb +3 -3
  183. data/spec/slack/web/api/endpoints/apps_spec.rb +2 -2
  184. data/spec/slack/web/api/endpoints/auth_teams_spec.rb +8 -0
  185. data/spec/slack/web/api/endpoints/calls_participants_spec.rb +24 -0
  186. data/spec/slack/web/api/endpoints/calls_spec.rb +31 -0
  187. data/spec/slack/web/api/endpoints/conversations_spec.rb +20 -12
  188. data/spec/slack/web/api/endpoints/custom_specs/conversations_spec.rb +13 -0
  189. data/spec/slack/web/api/endpoints/files_comments_spec.rb +2 -2
  190. data/spec/slack/web/api/endpoints/files_remote_spec.rb +3 -3
  191. data/spec/slack/web/api/endpoints/files_spec.rb +4 -4
  192. data/spec/slack/web/api/endpoints/im_spec.rb +0 -31
  193. data/spec/slack/web/api/endpoints/mpim_spec.rb +0 -31
  194. data/spec/slack/web/api/endpoints/oauth_spec.rb +3 -14
  195. data/spec/slack/web/api/endpoints/pins_spec.rb +1 -4
  196. data/spec/slack/web/api/endpoints/reactions_spec.rb +3 -3
  197. data/spec/slack/web/api/endpoints/reminders_spec.rb +2 -2
  198. data/spec/slack/web/api/endpoints/usergroups_users_spec.rb +2 -2
  199. data/spec/slack/web/api/endpoints/workflows_spec.rb +26 -0
  200. data/spec/slack/web/api/errors/slack_error_spec.rb +22 -0
  201. data/spec/slack/web/api/mixins/channels_spec.rb +1 -1
  202. data/spec/slack/web/api/mixins/conversations_list_spec.rb +21 -0
  203. data/spec/slack/web/api/mixins/conversations_spec.rb +43 -0
  204. data/spec/slack/web/api/mixins/groups_spec.rb +1 -1
  205. data/spec/slack/web/api/mixins/users_spec.rb +1 -1
  206. data/spec/slack/web/client_spec.rb +121 -0
  207. data/spec/slack/web/faraday/response/raise_error_spec.rb +33 -9
  208. data/spec/support/vcr.rb +4 -0
  209. metadata +145 -55
  210. data/examples/hi_real_time/Gemfile +0 -6
  211. data/examples/hi_real_time/hi.gif +0 -0
  212. data/examples/hi_real_time/hi.rb +0 -41
  213. data/examples/hi_real_time_async_celluloid/Gemfile +0 -7
  214. data/examples/hi_real_time_async_celluloid/Procfile +0 -2
  215. data/examples/hi_real_time_async_celluloid/hi.rb +0 -39
  216. data/examples/hi_real_time_async_eventmachine/Gemfile +0 -7
  217. data/examples/hi_real_time_async_eventmachine/Procfile +0 -2
  218. data/examples/hi_real_time_async_eventmachine/hi.rb +0 -39
  219. data/lib/slack/real_time/concurrency/celluloid.rb +0 -142
  220. data/lib/slack/real_time/concurrency/eventmachine.rb +0 -85
  221. data/lib/slack/web/api/patches/chat.1.text-attachments-required.patch +0 -13
  222. data/lib/slack/web/api/patches/chat.2.attachments-json.patch +0 -17
  223. data/lib/slack/web/api/patches/chat.3.update-attachments-support.patch +0 -21
  224. data/lib/slack/web/api/patches/chat.4.postEphemeral-attachments-support.patch +0 -17
  225. data/lib/slack/web/api/patches/chat.5.postEphemeral-text-or-attachments.patch +0 -15
  226. data/spec/slack/real_time/concurrency/celluloid_spec.rb +0 -116
  227. data/spec/slack/real_time/concurrency/eventmachine_spec.rb +0 -57
  228. data/spec/slack/web/api/endpoints/custom_specs/channels_spec.rb +0 -13
  229. data/spec/slack/web/api/endpoints/custom_specs/groups_spec.rb +0 -13
  230. data/spec/slack/web/api/endpoints/views_spec.rb +0 -29
  231. data/spec/slack/web/api/errors/service_unavailable_spec.rb +0 -17
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+ require 'spec_helper'
3
+
4
+ RSpec.describe Slack::Web::Api::Endpoints::Groups do
5
+ let(:client) { Slack::Web::Client.new }
6
+
7
+ context 'groups' do
8
+ it 'info', vcr: { cassette_name: 'web/conversations_info' } do
9
+ json = client.conversations_info(channel: '#mpdm-dblock--rubybot--player1-1')
10
+ expect(json.channel.name).to eq 'mpdm-dblock--rubybot--player1-1'
11
+ end
12
+ end
13
+ end
@@ -7,10 +7,10 @@ RSpec.describe Slack::Web::Api::Endpoints::FilesComments do
7
7
  let(:client) { Slack::Web::Client.new }
8
8
  context 'files.comments_delete' do
9
9
  it 'requires file' do
10
- expect { client.files_comments_delete(id: 'Fc1234567890') }.to raise_error ArgumentError, /Required arguments :file missing/
10
+ expect { client.files_comments_delete(id: %q[Fc1234567890]) }.to raise_error ArgumentError, /Required arguments :file missing/
11
11
  end
12
12
  it 'requires id' do
13
- expect { client.files_comments_delete(file: 'F1234567890') }.to raise_error ArgumentError, /Required arguments :id missing/
13
+ expect { client.files_comments_delete(file: %q[F1234567890]) }.to raise_error ArgumentError, /Required arguments :id missing/
14
14
  end
15
15
  end
16
16
  end
@@ -7,13 +7,13 @@ RSpec.describe Slack::Web::Api::Endpoints::FilesRemote do
7
7
  let(:client) { Slack::Web::Client.new }
8
8
  context 'files.remote_add' do
9
9
  it 'requires external_id' do
10
- expect { client.files_remote_add(external_url: 'http://example.com/my_cloud_service_file/abc123', title: 'Danger, High Voltage!') }.to raise_error ArgumentError, /Required arguments :external_id missing/
10
+ expect { client.files_remote_add(external_url: %q[http://example.com/my_cloud_service_file/abc123], title: %q[Danger, High Voltage!]) }.to raise_error ArgumentError, /Required arguments :external_id missing/
11
11
  end
12
12
  it 'requires external_url' do
13
- expect { client.files_remote_add(external_id: '123456', title: 'Danger, High Voltage!') }.to raise_error ArgumentError, /Required arguments :external_url missing/
13
+ expect { client.files_remote_add(external_id: %q[123456], title: %q[Danger, High Voltage!]) }.to raise_error ArgumentError, /Required arguments :external_url missing/
14
14
  end
15
15
  it 'requires title' do
16
- expect { client.files_remote_add(external_id: '123456', external_url: 'http://example.com/my_cloud_service_file/abc123') }.to raise_error ArgumentError, /Required arguments :title missing/
16
+ expect { client.files_remote_add(external_id: %q[123456], external_url: %q[http://example.com/my_cloud_service_file/abc123]) }.to raise_error ArgumentError, /Required arguments :title missing/
17
17
  end
18
18
  end
19
19
  context 'files.remote_share' do
@@ -12,10 +12,10 @@ RSpec.describe Slack::Web::Api::Endpoints::Files do
12
12
  end
13
13
  context 'files_edit' do
14
14
  it 'requires file' do
15
- expect { client.files_edit(title: 'Brand new title') }.to raise_error ArgumentError, /Required arguments :file missing/
15
+ expect { client.files_edit(title: %q[Brand new title]) }.to raise_error ArgumentError, /Required arguments :file missing/
16
16
  end
17
17
  it 'requires title' do
18
- expect { client.files_edit(file: 'F2147483862') }.to raise_error ArgumentError, /Required arguments :title missing/
18
+ expect { client.files_edit(file: %q[F2147483862]) }.to raise_error ArgumentError, /Required arguments :title missing/
19
19
  end
20
20
  end
21
21
  context 'files_info' do
@@ -30,10 +30,10 @@ RSpec.describe Slack::Web::Api::Endpoints::Files do
30
30
  end
31
31
  context 'files_share' do
32
32
  it 'requires file' do
33
- expect { client.files_share(channel: 'C1234567890') }.to raise_error ArgumentError, /Required arguments :file missing/
33
+ expect { client.files_share(channel: %q[C1234567890]) }.to raise_error ArgumentError, /Required arguments :file missing/
34
34
  end
35
35
  it 'requires channel' do
36
- expect { client.files_share(file: 'F2147483862') }.to raise_error ArgumentError, /Required arguments :channel missing/
36
+ expect { client.files_share(file: %q[F2147483862]) }.to raise_error ArgumentError, /Required arguments :channel missing/
37
37
  end
38
38
  end
39
39
  context 'files_sharedPublicURL' do
@@ -5,35 +5,4 @@ require 'spec_helper'
5
5
 
6
6
  RSpec.describe Slack::Web::Api::Endpoints::Im do
7
7
  let(:client) { Slack::Web::Client.new }
8
- context 'im_close' do
9
- it 'requires channel' do
10
- expect { client.im_close }.to raise_error ArgumentError, /Required arguments :channel missing/
11
- end
12
- end
13
- context 'im_history' do
14
- it 'requires channel' do
15
- expect { client.im_history }.to raise_error ArgumentError, /Required arguments :channel missing/
16
- end
17
- end
18
- context 'im_mark' do
19
- it 'requires channel' do
20
- expect { client.im_mark(ts: '1234567890.123456') }.to raise_error ArgumentError, /Required arguments :channel missing/
21
- end
22
- it 'requires ts' do
23
- expect { client.im_mark(channel: 'D1234567890') }.to raise_error ArgumentError, /Required arguments :ts missing/
24
- end
25
- end
26
- context 'im_open' do
27
- it 'requires user' do
28
- expect { client.im_open }.to raise_error ArgumentError, /Required arguments :user missing/
29
- end
30
- end
31
- context 'im_replies' do
32
- it 'requires channel' do
33
- expect { client.im_replies(thread_ts: '1234567890.123456') }.to raise_error ArgumentError, /Required arguments :channel missing/
34
- end
35
- it 'requires thread_ts' do
36
- expect { client.im_replies(channel: 'C1234567890') }.to raise_error ArgumentError, /Required arguments :thread_ts missing/
37
- end
38
- end
39
8
  end
@@ -5,35 +5,4 @@ require 'spec_helper'
5
5
 
6
6
  RSpec.describe Slack::Web::Api::Endpoints::Mpim do
7
7
  let(:client) { Slack::Web::Client.new }
8
- context 'mpim_close' do
9
- it 'requires channel' do
10
- expect { client.mpim_close }.to raise_error ArgumentError, /Required arguments :channel missing/
11
- end
12
- end
13
- context 'mpim_history' do
14
- it 'requires channel' do
15
- expect { client.mpim_history }.to raise_error ArgumentError, /Required arguments :channel missing/
16
- end
17
- end
18
- context 'mpim_mark' do
19
- it 'requires channel' do
20
- expect { client.mpim_mark(ts: '1234567890.123456') }.to raise_error ArgumentError, /Required arguments :channel missing/
21
- end
22
- it 'requires ts' do
23
- expect { client.mpim_mark(channel: 'G1234567890') }.to raise_error ArgumentError, /Required arguments :ts missing/
24
- end
25
- end
26
- context 'mpim_open' do
27
- it 'requires users' do
28
- expect { client.mpim_open }.to raise_error ArgumentError, /Required arguments :users missing/
29
- end
30
- end
31
- context 'mpim_replies' do
32
- it 'requires channel' do
33
- expect { client.mpim_replies(thread_ts: '1234567890.123456') }.to raise_error ArgumentError, /Required arguments :channel missing/
34
- end
35
- it 'requires thread_ts' do
36
- expect { client.mpim_replies(channel: 'C1234567890') }.to raise_error ArgumentError, /Required arguments :thread_ts missing/
37
- end
38
- end
39
8
  end
@@ -5,26 +5,15 @@ require 'spec_helper'
5
5
 
6
6
  RSpec.describe Slack::Web::Api::Endpoints::Oauth do
7
7
  let(:client) { Slack::Web::Client.new }
8
- context 'oauth_access' do
9
- it 'requires client_id' do
10
- expect { client.oauth_access(client_secret: '33fea0113f5b1', code: 'ccdaa72ad') }.to raise_error ArgumentError, /Required arguments :client_id missing/
11
- end
12
- it 'requires client_secret' do
13
- expect { client.oauth_access(client_id: '4b39e9-752c4', code: 'ccdaa72ad') }.to raise_error ArgumentError, /Required arguments :client_secret missing/
14
- end
15
- it 'requires code' do
16
- expect { client.oauth_access(client_id: '4b39e9-752c4', client_secret: '33fea0113f5b1') }.to raise_error ArgumentError, /Required arguments :code missing/
17
- end
18
- end
19
8
  context 'oauth_token' do
20
9
  it 'requires client_id' do
21
- expect { client.oauth_token(client_secret: '33fea0113f5b1', code: 'ccdaa72ad') }.to raise_error ArgumentError, /Required arguments :client_id missing/
10
+ expect { client.oauth_token(client_secret: %q[33fea0113f5b1], code: %q[ccdaa72ad]) }.to raise_error ArgumentError, /Required arguments :client_id missing/
22
11
  end
23
12
  it 'requires client_secret' do
24
- expect { client.oauth_token(client_id: '4b39e9-752c4', code: 'ccdaa72ad') }.to raise_error ArgumentError, /Required arguments :client_secret missing/
13
+ expect { client.oauth_token(client_id: %q[4b39e9-752c4], code: %q[ccdaa72ad]) }.to raise_error ArgumentError, /Required arguments :client_secret missing/
25
14
  end
26
15
  it 'requires code' do
27
- expect { client.oauth_token(client_id: '4b39e9-752c4', client_secret: '33fea0113f5b1') }.to raise_error ArgumentError, /Required arguments :code missing/
16
+ expect { client.oauth_token(client_id: %q[4b39e9-752c4], client_secret: %q[33fea0113f5b1]) }.to raise_error ArgumentError, /Required arguments :code missing/
28
17
  end
29
18
  end
30
19
  end
@@ -7,10 +7,7 @@ RSpec.describe Slack::Web::Api::Endpoints::Pins do
7
7
  let(:client) { Slack::Web::Client.new }
8
8
  context 'pins_add' do
9
9
  it 'requires channel' do
10
- expect { client.pins_add(timestamp: '1234567890.123456') }.to raise_error ArgumentError, /Required arguments :channel missing/
11
- end
12
- it 'requires timestamp' do
13
- expect { client.pins_add(channel: 'C1234567890') }.to raise_error ArgumentError, /Required arguments :timestamp missing/
10
+ expect { client.pins_add }.to raise_error ArgumentError, /Required arguments :channel missing/
14
11
  end
15
12
  end
16
13
  context 'pins_list' do
@@ -7,13 +7,13 @@ RSpec.describe Slack::Web::Api::Endpoints::Reactions do
7
7
  let(:client) { Slack::Web::Client.new }
8
8
  context 'reactions_add' do
9
9
  it 'requires channel' do
10
- expect { client.reactions_add(name: 'thumbsup', timestamp: '1234567890.123456') }.to raise_error ArgumentError, /Required arguments :channel missing/
10
+ expect { client.reactions_add(name: %q[thumbsup], timestamp: %q[1234567890.123456]) }.to raise_error ArgumentError, /Required arguments :channel missing/
11
11
  end
12
12
  it 'requires name' do
13
- expect { client.reactions_add(channel: 'C1234567890', timestamp: '1234567890.123456') }.to raise_error ArgumentError, /Required arguments :name missing/
13
+ expect { client.reactions_add(channel: %q[C1234567890], timestamp: %q[1234567890.123456]) }.to raise_error ArgumentError, /Required arguments :name missing/
14
14
  end
15
15
  it 'requires timestamp' do
16
- expect { client.reactions_add(channel: 'C1234567890', name: 'thumbsup') }.to raise_error ArgumentError, /Required arguments :timestamp missing/
16
+ expect { client.reactions_add(channel: %q[C1234567890], name: %q[thumbsup]) }.to raise_error ArgumentError, /Required arguments :timestamp missing/
17
17
  end
18
18
  end
19
19
  context 'reactions_remove' do
@@ -7,10 +7,10 @@ RSpec.describe Slack::Web::Api::Endpoints::Reminders do
7
7
  let(:client) { Slack::Web::Client.new }
8
8
  context 'reminders_add' do
9
9
  it 'requires text' do
10
- expect { client.reminders_add(time: '1602288000') }.to raise_error ArgumentError, /Required arguments :text missing/
10
+ expect { client.reminders_add(time: %q[1602288000]) }.to raise_error ArgumentError, /Required arguments :text missing/
11
11
  end
12
12
  it 'requires time' do
13
- expect { client.reminders_add(text: 'eat a banana') }.to raise_error ArgumentError, /Required arguments :time missing/
13
+ expect { client.reminders_add(text: %q[eat a banana]) }.to raise_error ArgumentError, /Required arguments :time missing/
14
14
  end
15
15
  end
16
16
  context 'reminders_complete' do
@@ -12,10 +12,10 @@ RSpec.describe Slack::Web::Api::Endpoints::UsergroupsUsers do
12
12
  end
13
13
  context 'usergroups.users_update' do
14
14
  it 'requires usergroup' do
15
- expect { client.usergroups_users_update(users: 'U060R4BJ4,U060RNRCZ') }.to raise_error ArgumentError, /Required arguments :usergroup missing/
15
+ expect { client.usergroups_users_update(users: %q[U060R4BJ4,U060RNRCZ]) }.to raise_error ArgumentError, /Required arguments :usergroup missing/
16
16
  end
17
17
  it 'requires users' do
18
- expect { client.usergroups_users_update(usergroup: 'S0604QSJC') }.to raise_error ArgumentError, /Required arguments :users missing/
18
+ expect { client.usergroups_users_update(usergroup: %q[S0604QSJC]) }.to raise_error ArgumentError, /Required arguments :users missing/
19
19
  end
20
20
  end
21
21
  end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+ # This file was auto-generated by lib/tasks/web.rake
3
+
4
+ require 'spec_helper'
5
+
6
+ RSpec.describe Slack::Web::Api::Endpoints::Workflows do
7
+ let(:client) { Slack::Web::Client.new }
8
+ context 'workflows_stepCompleted' do
9
+ it 'requires workflow_step_execute_id' do
10
+ expect { client.workflows_stepCompleted }.to raise_error ArgumentError, /Required arguments :workflow_step_execute_id missing/
11
+ end
12
+ end
13
+ context 'workflows_stepFailed' do
14
+ it 'requires error' do
15
+ expect { client.workflows_stepFailed(workflow_step_execute_id: %q[]) }.to raise_error ArgumentError, /Required arguments :error missing/
16
+ end
17
+ it 'requires workflow_step_execute_id' do
18
+ expect { client.workflows_stepFailed(error: %q[]) }.to raise_error ArgumentError, /Required arguments :workflow_step_execute_id missing/
19
+ end
20
+ end
21
+ context 'workflows_updateStep' do
22
+ it 'requires workflow_step_edit_id' do
23
+ expect { client.workflows_updateStep }.to raise_error ArgumentError, /Required arguments :workflow_step_edit_id missing/
24
+ end
25
+ end
26
+ end
@@ -11,6 +11,28 @@ RSpec.describe Slack::Web::Api::Errors::SlackError do
11
11
  rescue described_class => e
12
12
  expect(e.response).not_to be_nil
13
13
  expect(e.response.status).to eq 200
14
+ expect(e.message).to eql 'not_authed'
15
+ expect(e.error).to eql 'not_authed'
16
+ expect(e.response_metadata).to be_nil
17
+ end
18
+ end
19
+
20
+ it 'provides access to any response_metadata', vcr: { cassette_name: 'web/views_open_error' } do
21
+ begin
22
+ client.views_open(trigger_id: 'trigger_id', view: {})
23
+ raise 'Expected to receive Slack::Web::Api::Errors::SlackError.'
24
+ rescue described_class => e
25
+ expect(e.response).not_to be_nil
26
+ expect(e.response.status).to eq 200
27
+ expect(e.message).to eql 'invalid_arguments'
28
+ expect(e.error).to eql 'invalid_arguments'
29
+ expect(e.response_metadata).to eq(
30
+ 'messages' => [
31
+ "[ERROR] missing required field: title [json-pointer:\/view]",
32
+ "[ERROR] missing required field: blocks [json-pointer:\/view]",
33
+ "[ERROR] missing required field: type [json-pointer:\/view]"
34
+ ]
35
+ )
14
36
  end
15
37
  end
16
38
  end
@@ -13,7 +13,7 @@ RSpec.describe Slack::Web::Api::Mixins::Channels do
13
13
  end
14
14
 
15
15
  before do
16
- allow(channels).to receive(:channels_list).and_return(
16
+ allow(channels).to receive(:channels_list).and_yield(
17
17
  Slack::Messages::Message.new(
18
18
  'channels' => [{
19
19
  'id' => 'CDEADBEEF',
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+ require 'spec_helper'
3
+
4
+ RSpec.describe Slack::Web::Client do
5
+ context 'conversations_setTopic' do
6
+ it 'does not invoke conversations_list', vcr: { cassette_name: 'web/conversations_setTopic' } do
7
+ rc = subject.conversations_setTopic({ channel: 'C018Y6VH39D', topic: 'new topic' })
8
+ expect(rc.channel.topic.value).to eq 'new topic'
9
+ end
10
+
11
+ it 'resolves IDs via conversations_list', vcr: { cassette_name: 'web/conversations_setTopic_one_page' } do
12
+ rc = subject.conversations_setTopic({ channel: '#1', topic: 'new topic' })
13
+ expect(rc.channel.topic.value).to eq 'new topic'
14
+ end
15
+
16
+ it 'paginates to resolve IDs', vcr: { cassette_name: 'web/conversations_setTopic_paginated' } do
17
+ rc = subject.conversations_setTopic({ channel: '#topic', topic: 'new topic' })
18
+ expect(rc.channel.topic.value).to eq 'new topic'
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,43 @@
1
+ # frozen_string_literal: true
2
+ require 'spec_helper'
3
+
4
+ RSpec.describe Slack::Web::Api::Mixins::Conversations do
5
+ subject(:conversations) do
6
+ klass.new
7
+ end
8
+
9
+ let(:klass) do
10
+ Class.new do
11
+ include Slack::Web::Api::Mixins::Conversations
12
+ end
13
+ end
14
+
15
+ before do
16
+ allow(conversations).to receive(:conversations_list).and_yield(
17
+ Slack::Messages::Message.new(
18
+ 'channels' => [{
19
+ 'id' => 'CDEADBEEF',
20
+ 'name' => 'general'
21
+ }]
22
+ )
23
+ )
24
+ end
25
+
26
+ describe '#conversations_id' do
27
+ it 'leaves channels specified by ID alone' do
28
+ expect(conversations.conversations_id(channel: 'C123456')).to(
29
+ eq('ok' => true, 'channel' => { 'id' => 'C123456' })
30
+ )
31
+ end
32
+ it 'translates a channel that starts with a #' do
33
+ expect(conversations.conversations_id(channel: '#general')).to(
34
+ eq('ok' => true, 'channel' => { 'id' => 'CDEADBEEF' })
35
+ )
36
+ end
37
+ it 'fails with an exception' do
38
+ expect { conversations.conversations_id(channel: '#invalid') }.to(
39
+ raise_error(Slack::Web::Api::Errors::SlackError, 'channel_not_found')
40
+ )
41
+ end
42
+ end
43
+ end
@@ -13,7 +13,7 @@ RSpec.describe Slack::Web::Api::Mixins::Groups do
13
13
  end
14
14
 
15
15
  before do
16
- allow(groups).to receive(:groups_list).and_return(
16
+ allow(groups).to receive(:groups_list).and_yield(
17
17
  Slack::Messages::Message.new(
18
18
  'groups' => [{
19
19
  'id' => 'CDEADBEEF',
@@ -13,7 +13,7 @@ RSpec.describe Slack::Web::Api::Mixins::Users do
13
13
  end
14
14
 
15
15
  before do
16
- allow(users).to receive(:users_list).and_return(
16
+ allow(users).to receive(:users_list).and_yield(
17
17
  Slack::Messages::Message.new(
18
18
  'members' => [{
19
19
  'id' => 'UDEADBEEF',
@@ -150,6 +150,50 @@ RSpec.describe Slack::Web::Client do
150
150
  end
151
151
  end
152
152
 
153
+ context 'adapter option' do
154
+ let(:adapter) { Faraday.default_adapter }
155
+ let(:adapter_class) { Faraday::Adapter::NetHttp }
156
+
157
+ around do |ex|
158
+ previous_adapter = Faraday.default_adapter
159
+ # ensure default adapter is set for this spec
160
+ Faraday.default_adapter = :net_http
161
+ ex.run
162
+ Faraday.default_adapter = previous_adapter
163
+ end
164
+
165
+ context 'default adapter' do
166
+ describe '#initialize' do
167
+ it 'sets adapter' do
168
+ expect(client.adapter).to eq adapter
169
+ end
170
+ it 'creates a connection with an adapter' do
171
+ expect(client.send(:connection).adapter).to eq adapter_class
172
+ end
173
+ end
174
+ end
175
+
176
+ context 'non default adapter' do
177
+ let(:adapter) { :typhoeus }
178
+ let(:adapter_class) { Faraday::Adapter::Typhoeus }
179
+
180
+ before do
181
+ described_class.configure do |config|
182
+ config.adapter = adapter
183
+ end
184
+ end
185
+
186
+ describe '#initialize' do
187
+ it 'sets adapter' do
188
+ expect(client.adapter).to eq adapter
189
+ end
190
+ it 'creates a connection with an adapter' do
191
+ expect(client.send(:connection).adapter).to eq adapter_class
192
+ end
193
+ end
194
+ end
195
+ end
196
+
153
197
  context 'timeout options' do
154
198
  before do
155
199
  described_class.configure do |config|
@@ -205,5 +249,82 @@ RSpec.describe Slack::Web::Client do
205
249
  client.users_admin_setInactive(user: 'U092BDCLV')
206
250
  end
207
251
  end
252
+
253
+ context 'persistent capability' do
254
+ describe '#initialize' do
255
+ it 'caches the Faraday connection to allow persistent adapters' do
256
+ first = client.send(:connection)
257
+ second = client.send(:connection)
258
+
259
+ expect(first).to equal second
260
+ end
261
+ end
262
+ end
263
+
264
+ context 'server failures' do
265
+ subject(:request) { client.api_test }
266
+
267
+ let(:stub_slack_request) { stub_request(:post, 'https://slack.com/api/api.test') }
268
+ let(:exception) do
269
+ begin
270
+ request
271
+ rescue Slack::Web::Api::Errors::ServerError => e
272
+ return e
273
+ end
274
+ end
275
+
276
+ context 'parsing error' do
277
+ before { stub_slack_request.to_return(body: '<html></html>') }
278
+
279
+ it 'raises ParsingError' do
280
+ expect { request }.to raise_error(Slack::Web::Api::Errors::ParsingError).with_message('parsing_error')
281
+ expect(exception.response.body).to eq('<html></html>')
282
+ expect(exception.cause).to be_a(Faraday::ParsingError)
283
+ expect(exception.cause.cause.cause).to be_a(JSON::ParserError)
284
+ end
285
+ end
286
+
287
+ context 'timeout' do
288
+ context 'open timeout' do
289
+ before { stub_slack_request.to_timeout }
290
+
291
+ it 'raises TimoutError' do
292
+ expect { request }.to raise_error(Slack::Web::Api::Errors::TimeoutError).with_message('timeout_error')
293
+ expect(exception.cause).to be_a(Faraday::ConnectionFailed)
294
+ expect(exception.cause.cause).to be_a(Net::OpenTimeout)
295
+ end
296
+ end
297
+
298
+ context 'read timeout' do
299
+ before { stub_slack_request.to_raise(Net::ReadTimeout) }
300
+
301
+ it 'raises TimeoutError' do
302
+ expect { request }.to raise_error(Slack::Web::Api::Errors::TimeoutError).with_message('timeout_error')
303
+ expect(exception.cause).to be_a(Faraday::TimeoutError)
304
+ expect(exception.cause.cause).to be_a(Net::ReadTimeout)
305
+ end
306
+ end
307
+ end
308
+
309
+ context '5xx response' do
310
+ context 'with a JSON body' do
311
+ before { stub_slack_request.to_return(status: 500, body: '{}') }
312
+
313
+ it 'raises UnavailableError' do
314
+ expect { request }.to raise_error(Slack::Web::Api::Errors::UnavailableError).with_message('unavailable_error')
315
+ expect(exception.response.status).to eq(500)
316
+ end
317
+ end
318
+
319
+ context 'with a HTML response' do
320
+ before { stub_slack_request.to_return(status: 500, body: '<html></html>') }
321
+
322
+ it 'raises UnavailableError' do
323
+ expect { request }.to raise_error(Slack::Web::Api::Errors::UnavailableError).with_message('unavailable_error')
324
+ expect(exception.response.status).to eq(500)
325
+ end
326
+ end
327
+ end
328
+ end
208
329
  end
209
330
  end