slack-ruby-client 0.12.0 → 0.14.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (301) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/.rubocop.yml +21 -9
  4. data/.rubocop_todo.yml +64 -56
  5. data/.travis.yml +5 -3
  6. data/CHANGELOG.md +90 -32
  7. data/Dangerfile +2 -0
  8. data/Gemfile +10 -4
  9. data/LICENSE.md +1 -1
  10. data/README.md +176 -32
  11. data/Rakefile +2 -1
  12. data/UPGRADING.md +27 -1
  13. data/bin/commands.rb +21 -0
  14. data/bin/commands/admin_apps.rb +27 -0
  15. data/bin/commands/admin_apps_approved.rb +17 -0
  16. data/bin/commands/admin_apps_requests.rb +16 -0
  17. data/bin/commands/admin_apps_restricted.rb +17 -0
  18. data/bin/commands/admin_conversations.rb +17 -0
  19. data/bin/commands/admin_emoji.rb +54 -0
  20. data/bin/commands/admin_inviteRequests.rb +36 -0
  21. data/bin/commands/admin_inviteRequests_approved.rb +16 -0
  22. data/bin/commands/admin_inviteRequests_denied.rb +16 -0
  23. data/bin/commands/admin_teams.rb +27 -0
  24. data/bin/commands/admin_teams_admins.rb +16 -0
  25. data/bin/commands/admin_teams_owners.rb +16 -0
  26. data/bin/commands/admin_teams_settings.rb +64 -0
  27. data/bin/commands/admin_users.rb +97 -0
  28. data/bin/commands/admin_users_session.rb +16 -0
  29. data/bin/commands/api.rb +1 -0
  30. data/bin/commands/apps.rb +15 -0
  31. data/bin/commands/apps_permissions.rb +1 -0
  32. data/bin/commands/apps_permissions_resources.rb +1 -0
  33. data/bin/commands/apps_permissions_scopes.rb +1 -0
  34. data/bin/commands/apps_permissions_users.rb +1 -0
  35. data/bin/commands/auth.rb +1 -0
  36. data/bin/commands/bots.rb +1 -0
  37. data/bin/commands/channels.rb +3 -1
  38. data/bin/commands/chat.rb +48 -9
  39. data/bin/commands/chat_scheduledMessages.rb +18 -0
  40. data/bin/commands/conversations.rb +4 -2
  41. data/bin/commands/dialog.rb +1 -0
  42. data/bin/commands/dnd.rb +4 -3
  43. data/bin/commands/emoji.rb +1 -0
  44. data/bin/commands/files.rb +4 -14
  45. data/bin/commands/files_comments.rb +1 -21
  46. data/bin/commands/files_remote.rb +78 -0
  47. data/bin/commands/groups.rb +2 -1
  48. data/bin/commands/im.rb +2 -1
  49. data/bin/commands/migration.rb +1 -0
  50. data/bin/commands/mpim.rb +2 -1
  51. data/bin/commands/oauth.rb +2 -1
  52. data/bin/commands/oauth_v2.rb +17 -0
  53. data/bin/commands/pins.rb +1 -2
  54. data/bin/commands/reactions.rb +2 -3
  55. data/bin/commands/reminders.rb +1 -0
  56. data/bin/commands/rtm.rb +1 -0
  57. data/bin/commands/search.rb +2 -1
  58. data/bin/commands/stars.rb +1 -0
  59. data/bin/commands/team.rb +2 -0
  60. data/bin/commands/team_profile.rb +1 -0
  61. data/bin/commands/usergroups.rb +2 -1
  62. data/bin/commands/usergroups_users.rb +1 -0
  63. data/bin/commands/users.rb +2 -2
  64. data/bin/commands/users_admin.rb +1 -0
  65. data/bin/commands/users_prefs.rb +1 -0
  66. data/bin/commands/users_profile.rb +1 -0
  67. data/bin/commands/views.rb +48 -0
  68. data/bin/slack +2 -3
  69. data/examples/hi_real_time/Gemfile +1 -0
  70. data/examples/hi_real_time/hi.rb +7 -3
  71. data/examples/hi_real_time_and_web/Gemfile +1 -0
  72. data/examples/hi_real_time_and_web/hi.rb +7 -3
  73. data/examples/hi_real_time_async_async/Gemfile +7 -0
  74. data/examples/hi_real_time_async_async/Procfile +2 -0
  75. data/examples/hi_real_time_async_async/hi.rb +41 -0
  76. data/examples/hi_real_time_async_celluloid/Gemfile +1 -0
  77. data/examples/hi_real_time_async_celluloid/hi.rb +7 -3
  78. data/examples/hi_real_time_async_eventmachine/Gemfile +1 -0
  79. data/examples/hi_real_time_async_eventmachine/hi.rb +7 -3
  80. data/examples/hi_web/Gemfile +1 -0
  81. data/examples/hi_web/hi.rb +1 -0
  82. data/examples/new_ticket/Gemfile +1 -0
  83. data/examples/new_ticket/new_ticket.rb +1 -0
  84. data/lib/slack-ruby-client.rb +8 -2
  85. data/lib/slack.rb +1 -0
  86. data/lib/slack/config.rb +1 -0
  87. data/lib/slack/events/config.rb +32 -0
  88. data/lib/slack/events/request.rb +66 -0
  89. data/lib/slack/logger.rb +6 -5
  90. data/lib/slack/messages/formatting.rb +1 -0
  91. data/lib/slack/messages/message.rb +1 -0
  92. data/lib/slack/real_time/api/message.rb +3 -1
  93. data/lib/slack/real_time/api/message_id.rb +1 -0
  94. data/lib/slack/real_time/api/ping.rb +5 -2
  95. data/lib/slack/real_time/api/typing.rb +3 -1
  96. data/lib/slack/real_time/client.rb +97 -28
  97. data/lib/slack/real_time/concurrency.rb +2 -0
  98. data/lib/slack/real_time/concurrency/async.rb +142 -0
  99. data/lib/slack/real_time/concurrency/celluloid.rb +33 -9
  100. data/lib/slack/real_time/concurrency/eventmachine.rb +32 -7
  101. data/lib/slack/real_time/config.rb +7 -2
  102. data/lib/slack/real_time/models.rb +1 -0
  103. data/lib/slack/real_time/models/base.rb +1 -0
  104. data/lib/slack/real_time/models/bot.rb +1 -0
  105. data/lib/slack/real_time/models/channel.rb +1 -0
  106. data/lib/slack/real_time/models/group.rb +1 -0
  107. data/lib/slack/real_time/models/im.rb +1 -0
  108. data/lib/slack/real_time/models/team.rb +1 -0
  109. data/lib/slack/real_time/models/user.rb +1 -0
  110. data/lib/slack/real_time/socket.rb +42 -13
  111. data/lib/slack/real_time/stores.rb +1 -0
  112. data/lib/slack/real_time/stores/base.rb +1 -0
  113. data/lib/slack/real_time/stores/starter.rb +11 -0
  114. data/lib/slack/real_time/stores/store.rb +28 -25
  115. data/lib/slack/version.rb +2 -1
  116. data/lib/slack/web/api/endpoints.rb +41 -0
  117. data/lib/slack/web/api/endpoints/admin_apps.rb +42 -0
  118. data/lib/slack/web/api/endpoints/admin_apps_approved.rb +35 -0
  119. data/lib/slack/web/api/endpoints/admin_apps_requests.rb +33 -0
  120. data/lib/slack/web/api/endpoints/admin_apps_restricted.rb +35 -0
  121. data/lib/slack/web/api/endpoints/admin_conversations.rb +30 -0
  122. data/lib/slack/web/api/endpoints/admin_emoji.rb +88 -0
  123. data/lib/slack/web/api/endpoints/admin_inviteRequests.rb +61 -0
  124. data/lib/slack/web/api/endpoints/admin_inviteRequests_approved.rb +33 -0
  125. data/lib/slack/web/api/endpoints/admin_inviteRequests_denied.rb +33 -0
  126. data/lib/slack/web/api/endpoints/admin_teams.rb +50 -0
  127. data/lib/slack/web/api/endpoints/admin_teams_admins.rb +34 -0
  128. data/lib/slack/web/api/endpoints/admin_teams_owners.rb +34 -0
  129. data/lib/slack/web/api/endpoints/admin_teams_settings.rb +99 -0
  130. data/lib/slack/web/api/endpoints/admin_users.rb +163 -0
  131. data/lib/slack/web/api/endpoints/admin_users_session.rb +28 -0
  132. data/lib/slack/web/api/endpoints/api.rb +1 -0
  133. data/lib/slack/web/api/endpoints/apps.rb +27 -0
  134. data/lib/slack/web/api/endpoints/apps_permissions.rb +1 -0
  135. data/lib/slack/web/api/endpoints/apps_permissions_resources.rb +1 -0
  136. data/lib/slack/web/api/endpoints/apps_permissions_scopes.rb +1 -0
  137. data/lib/slack/web/api/endpoints/apps_permissions_users.rb +1 -0
  138. data/lib/slack/web/api/endpoints/auth.rb +1 -0
  139. data/lib/slack/web/api/endpoints/bots.rb +1 -0
  140. data/lib/slack/web/api/endpoints/channels.rb +3 -0
  141. data/lib/slack/web/api/endpoints/chat.rb +99 -12
  142. data/lib/slack/web/api/endpoints/chat_scheduledMessages.rb +38 -0
  143. data/lib/slack/web/api/endpoints/conversations.rb +4 -1
  144. data/lib/slack/web/api/endpoints/dialog.rb +1 -0
  145. data/lib/slack/web/api/endpoints/dnd.rb +3 -1
  146. data/lib/slack/web/api/endpoints/emoji.rb +1 -0
  147. data/lib/slack/web/api/endpoints/files.rb +4 -13
  148. data/lib/slack/web/api/endpoints/files_comments.rb +1 -33
  149. data/lib/slack/web/api/endpoints/files_remote.rb +127 -0
  150. data/lib/slack/web/api/endpoints/groups.rb +1 -0
  151. data/lib/slack/web/api/endpoints/im.rb +1 -0
  152. data/lib/slack/web/api/endpoints/migration.rb +1 -0
  153. data/lib/slack/web/api/endpoints/mpim.rb +1 -0
  154. data/lib/slack/web/api/endpoints/oauth.rb +2 -1
  155. data/lib/slack/web/api/endpoints/oauth_v2.rb +30 -0
  156. data/lib/slack/web/api/endpoints/pins.rb +2 -4
  157. data/lib/slack/web/api/endpoints/reactions.rb +5 -6
  158. data/lib/slack/web/api/endpoints/reminders.rb +1 -0
  159. data/lib/slack/web/api/endpoints/rtm.rb +1 -0
  160. data/lib/slack/web/api/endpoints/search.rb +1 -0
  161. data/lib/slack/web/api/endpoints/stars.rb +1 -0
  162. data/lib/slack/web/api/endpoints/team.rb +3 -0
  163. data/lib/slack/web/api/endpoints/team_profile.rb +1 -0
  164. data/lib/slack/web/api/endpoints/usergroups.rb +1 -0
  165. data/lib/slack/web/api/endpoints/usergroups_users.rb +1 -0
  166. data/lib/slack/web/api/endpoints/users.rb +1 -2
  167. data/lib/slack/web/api/endpoints/users_admin.rb +1 -0
  168. data/lib/slack/web/api/endpoints/users_prefs.rb +1 -0
  169. data/lib/slack/web/api/endpoints/users_profile.rb +1 -0
  170. data/lib/slack/web/api/endpoints/views.rb +97 -0
  171. data/lib/slack/web/api/error.rb +1 -0
  172. data/lib/slack/web/api/errors.rb +566 -0
  173. data/lib/slack/web/api/errors/slack_error.rb +14 -1
  174. data/lib/slack/web/api/errors/too_many_requests_error.rb +1 -0
  175. data/lib/slack/web/api/mixins.rb +1 -0
  176. data/lib/slack/web/api/mixins/channels.id.rb +1 -0
  177. data/lib/slack/web/api/mixins/groups.id.rb +1 -0
  178. data/lib/slack/web/api/mixins/ids.id.rb +4 -1
  179. data/lib/slack/web/api/mixins/users.id.rb +1 -0
  180. data/lib/slack/web/api/mixins/users.search.rb +1 -0
  181. data/lib/slack/web/api/patches/chat.5.postEphemeral-text-or-attachments.patch +5 -3
  182. data/lib/slack/web/api/patches/chat.6.block-kit-support.patch +69 -0
  183. data/lib/slack/web/api/patches/views.1.view-json.patch +40 -0
  184. data/lib/slack/web/api/patches/views.1.views-published.patch +16 -0
  185. data/lib/slack/web/api/templates/command.erb +1 -0
  186. data/lib/slack/web/api/templates/commands.erb +1 -0
  187. data/lib/slack/web/api/templates/endpoints.erb +1 -0
  188. data/lib/slack/web/api/templates/errors.erb +20 -0
  189. data/lib/slack/web/api/templates/method.erb +1 -0
  190. data/lib/slack/web/api/templates/method_spec.erb +1 -0
  191. data/lib/slack/web/client.rb +2 -1
  192. data/lib/slack/web/config.rb +1 -0
  193. data/lib/slack/web/faraday/connection.rb +1 -0
  194. data/lib/slack/web/faraday/request.rb +1 -0
  195. data/lib/slack/web/faraday/response/raise_error.rb +10 -6
  196. data/lib/slack/web/pagination/cursor.rb +4 -0
  197. data/lib/slack_ruby_client.rb +1 -0
  198. data/lib/tasks/git.rake +1 -0
  199. data/lib/tasks/real_time.rake +15 -5
  200. data/lib/tasks/update.rake +1 -0
  201. data/lib/tasks/web.rake +28 -7
  202. data/screenshots/create-app.png +0 -0
  203. data/slack-ruby-client.gemspec +6 -2
  204. data/spec/fixtures/slack/web/views_open_error.yml +76 -0
  205. data/spec/integration/integration_spec.rb +116 -48
  206. data/spec/slack/config_spec.rb +2 -0
  207. data/spec/slack/events/config_spec.rb +33 -0
  208. data/spec/slack/events/request_spec.rb +179 -0
  209. data/spec/slack/messages/formatting_spec.rb +25 -13
  210. data/spec/slack/real_time/api/message_spec.rb +6 -1
  211. data/spec/slack/real_time/api/ping_spec.rb +2 -0
  212. data/spec/slack/real_time/api/typing_spec.rb +5 -1
  213. data/spec/slack/real_time/client_spec.rb +212 -31
  214. data/spec/slack/real_time/concurrency/celluloid_spec.rb +15 -5
  215. data/spec/slack/real_time/concurrency/eventmachine_spec.rb +11 -1
  216. data/spec/slack/real_time/concurrency/it_behaves_like_a_realtime_socket.rb +2 -0
  217. data/spec/slack/real_time/event_handlers/bot_spec.rb +2 -1
  218. data/spec/slack/real_time/event_handlers/channel_spec.rb +9 -6
  219. data/spec/slack/real_time/event_handlers/event_handlers_spec.rb +2 -1
  220. data/spec/slack/real_time/event_handlers/group_spec.rb +5 -4
  221. data/spec/slack/real_time/event_handlers/im_spec.rb +4 -3
  222. data/spec/slack/real_time/event_handlers/team_spec.rb +3 -1
  223. data/spec/slack/real_time/event_handlers/user_spec.rb +1 -0
  224. data/spec/slack/real_time/rtm_connect_spec.rb +1 -0
  225. data/spec/slack/real_time/rtm_start_spec.rb +1 -0
  226. data/spec/slack/real_time/store_spec.rb +2 -1
  227. data/spec/slack/slack_spec.rb +37 -5
  228. data/spec/slack/version_spec.rb +2 -1
  229. data/spec/slack/web/api/endpoints/admin_apps_approved_spec.rb +8 -0
  230. data/spec/slack/web/api/endpoints/admin_apps_requests_spec.rb +8 -0
  231. data/spec/slack/web/api/endpoints/admin_apps_restricted_spec.rb +8 -0
  232. data/spec/slack/web/api/endpoints/admin_apps_spec.rb +8 -0
  233. data/spec/slack/web/api/endpoints/admin_conversations_spec.rb +13 -0
  234. data/spec/slack/web/api/endpoints/admin_emoji_spec.rb +37 -0
  235. data/spec/slack/web/api/endpoints/admin_inviteRequests_approved_spec.rb +8 -0
  236. data/spec/slack/web/api/endpoints/admin_inviteRequests_denied_spec.rb +8 -0
  237. data/spec/slack/web/api/endpoints/admin_inviteRequests_spec.rb +18 -0
  238. data/spec/slack/web/api/endpoints/admin_teams_admins_spec.rb +13 -0
  239. data/spec/slack/web/api/endpoints/admin_teams_owners_spec.rb +13 -0
  240. data/spec/slack/web/api/endpoints/admin_teams_settings_spec.rb +53 -0
  241. data/spec/slack/web/api/endpoints/admin_teams_spec.rb +16 -0
  242. data/spec/slack/web/api/endpoints/admin_users_session_spec.rb +13 -0
  243. data/spec/slack/web/api/endpoints/admin_users_spec.rb +75 -0
  244. data/spec/slack/web/api/endpoints/api_spec.rb +1 -0
  245. data/spec/slack/web/api/endpoints/apps_permissions_resources_spec.rb +1 -0
  246. data/spec/slack/web/api/endpoints/apps_permissions_scopes_spec.rb +1 -0
  247. data/spec/slack/web/api/endpoints/apps_permissions_spec.rb +3 -2
  248. data/spec/slack/web/api/endpoints/apps_permissions_users_spec.rb +4 -3
  249. data/spec/slack/web/api/endpoints/apps_spec.rb +16 -0
  250. data/spec/slack/web/api/endpoints/bots_spec.rb +1 -0
  251. data/spec/slack/web/api/endpoints/chat_scheduledMessages_spec.rb +8 -0
  252. data/spec/slack/web/api/endpoints/conversations_spec.rb +2 -1
  253. data/spec/slack/web/api/endpoints/custom_specs/auth_spec.rb +5 -1
  254. data/spec/slack/web/api/endpoints/custom_specs/channels_spec.rb +2 -0
  255. data/spec/slack/web/api/endpoints/custom_specs/chat_spec.rb +112 -36
  256. data/spec/slack/web/api/endpoints/custom_specs/dialog_spec.rb +12 -4
  257. data/spec/slack/web/api/endpoints/custom_specs/groups_spec.rb +2 -0
  258. data/spec/slack/web/api/endpoints/custom_specs/users_spec.rb +6 -1
  259. data/spec/slack/web/api/endpoints/custom_specs/views_spec.rb +95 -0
  260. data/spec/slack/web/api/endpoints/dnd_spec.rb +6 -0
  261. data/spec/slack/web/api/endpoints/emoji_spec.rb +1 -0
  262. data/spec/slack/web/api/endpoints/files_comments_spec.rb +1 -19
  263. data/spec/slack/web/api/endpoints/files_remote_spec.rb +24 -0
  264. data/spec/slack/web/api/endpoints/files_spec.rb +1 -0
  265. data/spec/slack/web/api/endpoints/im_spec.rb +1 -0
  266. data/spec/slack/web/api/endpoints/migration_spec.rb +1 -0
  267. data/spec/slack/web/api/endpoints/mpim_spec.rb +1 -0
  268. data/spec/slack/web/api/endpoints/oauth_spec.rb +1 -0
  269. data/spec/slack/web/api/endpoints/oauth_v2_spec.rb +13 -0
  270. data/spec/slack/web/api/endpoints/pins_spec.rb +5 -1
  271. data/spec/slack/web/api/endpoints/reactions_spec.rb +8 -1
  272. data/spec/slack/web/api/endpoints/reminders_spec.rb +1 -0
  273. data/spec/slack/web/api/endpoints/rtm_spec.rb +1 -0
  274. data/spec/slack/web/api/endpoints/search_spec.rb +1 -0
  275. data/spec/slack/web/api/endpoints/stars_spec.rb +1 -0
  276. data/spec/slack/web/api/endpoints/team_profile_spec.rb +1 -0
  277. data/spec/slack/web/api/endpoints/team_spec.rb +1 -0
  278. data/spec/slack/web/api/endpoints/usergroups_spec.rb +1 -0
  279. data/spec/slack/web/api/endpoints/usergroups_users_spec.rb +1 -0
  280. data/spec/slack/web/api/endpoints/users_admin_spec.rb +1 -0
  281. data/spec/slack/web/api/endpoints/users_prefs_spec.rb +1 -0
  282. data/spec/slack/web/api/endpoints/users_profile_spec.rb +1 -0
  283. data/spec/slack/web/api/endpoints/views_spec.rb +29 -0
  284. data/spec/slack/web/api/error_spec.rb +4 -2
  285. data/spec/slack/web/api/errors/service_unavailable_spec.rb +6 -3
  286. data/spec/slack/web/api/errors/slack_error_spec.rb +26 -2
  287. data/spec/slack/web/api/mixins/channels_spec.rb +17 -7
  288. data/spec/slack/web/api/mixins/groups_spec.rb +17 -7
  289. data/spec/slack/web/api/mixins/users_spec.rb +17 -8
  290. data/spec/slack/web/api/pagination/cursor_spec.rb +40 -10
  291. data/spec/slack/web/client_spec.rb +45 -18
  292. data/spec/slack/web/faraday/response/raise_error_spec.rb +41 -7
  293. data/spec/spec_helper.rb +8 -1
  294. data/spec/support/queue_with_timeout.rb +5 -4
  295. data/spec/support/real_time/concurrency/mock.rb +1 -0
  296. data/spec/support/real_time/connected_client.rb +9 -3
  297. data/spec/support/real_time/event.rb +1 -0
  298. data/spec/support/token.rb +1 -0
  299. data/spec/support/vcr.rb +1 -0
  300. metadata +149 -9
  301. data/screenshots/register-bot.png +0 -0
@@ -0,0 +1,37 @@
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::AdminEmoji do
7
+ let(:client) { Slack::Web::Client.new }
8
+ context 'admin.emoji_add' do
9
+ it 'requires name' do
10
+ expect { client.admin_emoji_add(url: '') }.to raise_error ArgumentError, /Required arguments :name missing/
11
+ end
12
+ it 'requires url' do
13
+ expect { client.admin_emoji_add(name: '') }.to raise_error ArgumentError, /Required arguments :url missing/
14
+ end
15
+ end
16
+ context 'admin.emoji_addAlias' do
17
+ it 'requires alias_for' do
18
+ expect { client.admin_emoji_addAlias(name: '') }.to raise_error ArgumentError, /Required arguments :alias_for missing/
19
+ end
20
+ it 'requires name' do
21
+ expect { client.admin_emoji_addAlias(alias_for: '') }.to raise_error ArgumentError, /Required arguments :name missing/
22
+ end
23
+ end
24
+ context 'admin.emoji_remove' do
25
+ it 'requires name' do
26
+ expect { client.admin_emoji_remove }.to raise_error ArgumentError, /Required arguments :name missing/
27
+ end
28
+ end
29
+ context 'admin.emoji_rename' do
30
+ it 'requires name' do
31
+ expect { client.admin_emoji_rename(new_name: '') }.to raise_error ArgumentError, /Required arguments :name missing/
32
+ end
33
+ it 'requires new_name' do
34
+ expect { client.admin_emoji_rename(name: '') }.to raise_error ArgumentError, /Required arguments :new_name missing/
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,8 @@
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::AdminInviterequestsApproved do
7
+ let(:client) { Slack::Web::Client.new }
8
+ end
@@ -0,0 +1,8 @@
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::AdminInviterequestsDenied do
7
+ let(:client) { Slack::Web::Client.new }
8
+ end
@@ -0,0 +1,18 @@
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::AdminInviterequests do
7
+ let(:client) { Slack::Web::Client.new }
8
+ context 'admin.inviteRequests_approve' do
9
+ it 'requires invite_request_id' do
10
+ expect { client.admin_inviteRequests_approve }.to raise_error ArgumentError, /Required arguments :invite_request_id missing/
11
+ end
12
+ end
13
+ context 'admin.inviteRequests_deny' do
14
+ it 'requires invite_request_id' do
15
+ expect { client.admin_inviteRequests_deny }.to raise_error ArgumentError, /Required arguments :invite_request_id missing/
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,13 @@
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::AdminTeamsAdmins do
7
+ let(:client) { Slack::Web::Client.new }
8
+ context 'admin.teams.admins_list' do
9
+ it 'requires team_id' do
10
+ expect { client.admin_teams_admins_list }.to raise_error ArgumentError, /Required arguments :team_id missing/
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,13 @@
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::AdminTeamsOwners do
7
+ let(:client) { Slack::Web::Client.new }
8
+ context 'admin.teams.owners_list' do
9
+ it 'requires team_id' do
10
+ expect { client.admin_teams_owners_list }.to raise_error ArgumentError, /Required arguments :team_id missing/
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,53 @@
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::AdminTeamsSettings do
7
+ let(:client) { Slack::Web::Client.new }
8
+ context 'admin.teams.settings_info' do
9
+ it 'requires team_id' do
10
+ expect { client.admin_teams_settings_info }.to raise_error ArgumentError, /Required arguments :team_id missing/
11
+ end
12
+ end
13
+ context 'admin.teams.settings_setDefaultChannels' do
14
+ it 'requires channel_ids' do
15
+ expect { client.admin_teams_settings_setDefaultChannels(team_id: '') }.to raise_error ArgumentError, /Required arguments :channel_ids missing/
16
+ end
17
+ it 'requires team_id' do
18
+ expect { client.admin_teams_settings_setDefaultChannels(channel_ids: '') }.to raise_error ArgumentError, /Required arguments :team_id missing/
19
+ end
20
+ end
21
+ context 'admin.teams.settings_setDescription' do
22
+ it 'requires description' do
23
+ expect { client.admin_teams_settings_setDescription(team_id: '') }.to raise_error ArgumentError, /Required arguments :description missing/
24
+ end
25
+ it 'requires team_id' do
26
+ expect { client.admin_teams_settings_setDescription(description: '') }.to raise_error ArgumentError, /Required arguments :team_id missing/
27
+ end
28
+ end
29
+ context 'admin.teams.settings_setDiscoverability' do
30
+ it 'requires discoverability' do
31
+ expect { client.admin_teams_settings_setDiscoverability(team_id: '') }.to raise_error ArgumentError, /Required arguments :discoverability missing/
32
+ end
33
+ it 'requires team_id' do
34
+ expect { client.admin_teams_settings_setDiscoverability(discoverability: '') }.to raise_error ArgumentError, /Required arguments :team_id missing/
35
+ end
36
+ end
37
+ context 'admin.teams.settings_setIcon' do
38
+ it 'requires image_url' do
39
+ expect { client.admin_teams_settings_setIcon(team_id: '') }.to raise_error ArgumentError, /Required arguments :image_url missing/
40
+ end
41
+ it 'requires team_id' do
42
+ expect { client.admin_teams_settings_setIcon(image_url: 'http://mysite.com/icon.jpeg') }.to raise_error ArgumentError, /Required arguments :team_id missing/
43
+ end
44
+ end
45
+ context 'admin.teams.settings_setName' do
46
+ it 'requires name' do
47
+ expect { client.admin_teams_settings_setName(team_id: '') }.to raise_error ArgumentError, /Required arguments :name missing/
48
+ end
49
+ it 'requires team_id' do
50
+ expect { client.admin_teams_settings_setName(name: '') }.to raise_error ArgumentError, /Required arguments :team_id missing/
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,16 @@
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::AdminTeams do
7
+ let(:client) { Slack::Web::Client.new }
8
+ context 'admin.teams_create' do
9
+ it 'requires team_domain' do
10
+ expect { client.admin_teams_create(team_name: '') }.to raise_error ArgumentError, /Required arguments :team_domain missing/
11
+ end
12
+ it 'requires team_name' do
13
+ expect { client.admin_teams_create(team_domain: '') }.to raise_error ArgumentError, /Required arguments :team_name missing/
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,13 @@
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::AdminUsersSession do
7
+ let(:client) { Slack::Web::Client.new }
8
+ context 'admin.users.session_reset' do
9
+ it 'requires user_id' do
10
+ expect { client.admin_users_session_reset }.to raise_error ArgumentError, /Required arguments :user_id missing/
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,75 @@
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::AdminUsers do
7
+ let(:client) { Slack::Web::Client.new }
8
+ context 'admin.users_assign' do
9
+ it 'requires team_id' do
10
+ expect { client.admin_users_assign(user_id: '') }.to raise_error ArgumentError, /Required arguments :team_id missing/
11
+ end
12
+ it 'requires user_id' do
13
+ expect { client.admin_users_assign(team_id: '') }.to raise_error ArgumentError, /Required arguments :user_id missing/
14
+ end
15
+ end
16
+ context 'admin.users_invite' do
17
+ it 'requires channel_ids' do
18
+ expect { client.admin_users_invite(email: 'joe@email.com', team_id: '') }.to raise_error ArgumentError, /Required arguments :channel_ids missing/
19
+ end
20
+ it 'requires email' do
21
+ expect { client.admin_users_invite(channel_ids: 'C1A2B3C4D,C26Z25Y24', team_id: '') }.to raise_error ArgumentError, /Required arguments :email missing/
22
+ end
23
+ it 'requires team_id' do
24
+ expect { client.admin_users_invite(channel_ids: 'C1A2B3C4D,C26Z25Y24', email: 'joe@email.com') }.to raise_error ArgumentError, /Required arguments :team_id missing/
25
+ end
26
+ end
27
+ context 'admin.users_list' do
28
+ it 'requires team_id' do
29
+ expect { client.admin_users_list }.to raise_error ArgumentError, /Required arguments :team_id missing/
30
+ end
31
+ end
32
+ context 'admin.users_remove' do
33
+ it 'requires team_id' do
34
+ expect { client.admin_users_remove(user_id: 'W12345678') }.to raise_error ArgumentError, /Required arguments :team_id missing/
35
+ end
36
+ it 'requires user_id' do
37
+ expect { client.admin_users_remove(team_id: '') }.to raise_error ArgumentError, /Required arguments :user_id missing/
38
+ end
39
+ end
40
+ context 'admin.users_setAdmin' do
41
+ it 'requires team_id' do
42
+ expect { client.admin_users_setAdmin(user_id: 'W12345678') }.to raise_error ArgumentError, /Required arguments :team_id missing/
43
+ end
44
+ it 'requires user_id' do
45
+ expect { client.admin_users_setAdmin(team_id: '') }.to raise_error ArgumentError, /Required arguments :user_id missing/
46
+ end
47
+ end
48
+ context 'admin.users_setExpiration' do
49
+ it 'requires expiration_ts' do
50
+ expect { client.admin_users_setExpiration(team_id: '', user_id: 'W12345678') }.to raise_error ArgumentError, /Required arguments :expiration_ts missing/
51
+ end
52
+ it 'requires team_id' do
53
+ expect { client.admin_users_setExpiration(expiration_ts: '1234567890', user_id: 'W12345678') }.to raise_error ArgumentError, /Required arguments :team_id missing/
54
+ end
55
+ it 'requires user_id' do
56
+ expect { client.admin_users_setExpiration(expiration_ts: '1234567890', team_id: '') }.to raise_error ArgumentError, /Required arguments :user_id missing/
57
+ end
58
+ end
59
+ context 'admin.users_setOwner' do
60
+ it 'requires team_id' do
61
+ expect { client.admin_users_setOwner(user_id: '') }.to raise_error ArgumentError, /Required arguments :team_id missing/
62
+ end
63
+ it 'requires user_id' do
64
+ expect { client.admin_users_setOwner(team_id: '') }.to raise_error ArgumentError, /Required arguments :user_id missing/
65
+ end
66
+ end
67
+ context 'admin.users_setRegular' do
68
+ it 'requires team_id' do
69
+ expect { client.admin_users_setRegular(user_id: 'W12345678') }.to raise_error ArgumentError, /Required arguments :team_id missing/
70
+ end
71
+ it 'requires user_id' do
72
+ expect { client.admin_users_setRegular(team_id: '') }.to raise_error ArgumentError, /Required arguments :user_id missing/
73
+ end
74
+ end
75
+ end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  # This file was auto-generated by lib/tasks/web.rake
2
3
 
3
4
  require 'spec_helper'
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  # This file was auto-generated by lib/tasks/web.rake
2
3
 
3
4
  require 'spec_helper'
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  # This file was auto-generated by lib/tasks/web.rake
2
3
 
3
4
  require 'spec_helper'
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  # This file was auto-generated by lib/tasks/web.rake
2
3
 
3
4
  require 'spec_helper'
@@ -6,10 +7,10 @@ RSpec.describe Slack::Web::Api::Endpoints::AppsPermissions do
6
7
  let(:client) { Slack::Web::Client.new }
7
8
  context 'apps.permissions_request' do
8
9
  it 'requires scopes' do
9
- expect { client.apps_permissions_request(trigger_id: ' ') }.to raise_error ArgumentError, /Required arguments :scopes missing/
10
+ expect { client.apps_permissions_request(trigger_id: '') }.to raise_error ArgumentError, /Required arguments :scopes missing/
10
11
  end
11
12
  it 'requires trigger_id' do
12
- expect { client.apps_permissions_request(scopes: ' ') }.to raise_error ArgumentError, /Required arguments :trigger_id missing/
13
+ expect { client.apps_permissions_request(scopes: '') }.to raise_error ArgumentError, /Required arguments :trigger_id missing/
13
14
  end
14
15
  end
15
16
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  # This file was auto-generated by lib/tasks/web.rake
2
3
 
3
4
  require 'spec_helper'
@@ -6,13 +7,13 @@ RSpec.describe Slack::Web::Api::Endpoints::AppsPermissionsUsers do
6
7
  let(:client) { Slack::Web::Client.new }
7
8
  context 'apps.permissions.users_request' do
8
9
  it 'requires scopes' do
9
- expect { client.apps_permissions_users_request(trigger_id: ' ', user: ' ') }.to raise_error ArgumentError, /Required arguments :scopes missing/
10
+ expect { client.apps_permissions_users_request(trigger_id: '', user: '') }.to raise_error ArgumentError, /Required arguments :scopes missing/
10
11
  end
11
12
  it 'requires trigger_id' do
12
- expect { client.apps_permissions_users_request(scopes: ' ', user: ' ') }.to raise_error ArgumentError, /Required arguments :trigger_id missing/
13
+ expect { client.apps_permissions_users_request(scopes: '', user: '') }.to raise_error ArgumentError, /Required arguments :trigger_id missing/
13
14
  end
14
15
  it 'requires user' do
15
- expect { client.apps_permissions_users_request(scopes: ' ', trigger_id: ' ') }.to raise_error ArgumentError, /Required arguments :user missing/
16
+ expect { client.apps_permissions_users_request(scopes: '', trigger_id: '') }.to raise_error ArgumentError, /Required arguments :user missing/
16
17
  end
17
18
  end
18
19
  end
@@ -0,0 +1,16 @@
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::Apps do
7
+ let(:client) { Slack::Web::Client.new }
8
+ context 'apps_uninstall' do
9
+ it 'requires client_id' do
10
+ expect { client.apps_uninstall(client_secret: 'f25b5ceaf8a3c2a2c4f52bb4f0b0499e') }.to raise_error ArgumentError, /Required arguments :client_id missing/
11
+ end
12
+ it 'requires client_secret' do
13
+ expect { client.apps_uninstall(client_id: '56579136444.26251006572') }.to raise_error ArgumentError, /Required arguments :client_secret missing/
14
+ end
15
+ end
16
+ end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  # This file was auto-generated by lib/tasks/web.rake
2
3
 
3
4
  require 'spec_helper'
@@ -0,0 +1,8 @@
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::ChatScheduledmessages do
7
+ let(:client) { Slack::Web::Client.new }
8
+ end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  # This file was auto-generated by lib/tasks/web.rake
2
3
 
3
4
  require 'spec_helper'
@@ -62,7 +63,7 @@ RSpec.describe Slack::Web::Api::Endpoints::Conversations do
62
63
  end
63
64
  context 'conversations_rename' do
64
65
  it 'requires channel' do
65
- expect { client.conversations_rename(name: ' ') }.to raise_error ArgumentError, /Required arguments :channel missing/
66
+ expect { client.conversations_rename(name: '') }.to raise_error ArgumentError, /Required arguments :channel missing/
66
67
  end
67
68
  it 'requires name' do
68
69
  expect { client.conversations_rename(channel: 'C1234567890') }.to raise_error ArgumentError, /Required arguments :name missing/
@@ -1,17 +1,21 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  RSpec.describe Slack::Web::Api::Endpoints::Auth do
4
5
  let(:client) { Slack::Web::Client.new }
6
+
5
7
  context 'without auth', vcr: { cassette_name: 'web/auth_test_error' } do
6
8
  it 'fails with an exception' do
7
9
  expect { client.auth_test }.to raise_error Slack::Web::Api::Errors::SlackError, 'not_authed'
8
10
  end
9
11
  end
12
+
10
13
  context 'with auth', vcr: { cassette_name: 'web/auth_test_success' } do
11
14
  it 'succeeds' do
12
- expect { client.auth_test }.to_not raise_error
15
+ expect { client.auth_test }.not_to raise_error
13
16
  end
14
17
  end
18
+
15
19
  context '429 error', vcr: { cassette_name: 'web/429_error' } do
16
20
  it 'fails with an specific exception' do
17
21
  begin
@@ -1,7 +1,9 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  RSpec.describe Slack::Web::Api::Endpoints::Channels do
4
5
  let(:client) { Slack::Web::Client.new }
6
+
5
7
  context 'channels' do
6
8
  it 'info', vcr: { cassette_name: 'web/channels_info' } do
7
9
  json = client.channels_info(channel: '#general')
@@ -1,108 +1,184 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  RSpec.describe Slack::Web::Api::Endpoints::Chat do
4
5
  let(:client) { Slack::Web::Client.new }
6
+
5
7
  context 'chat_postEphemeral' do
6
8
  let(:user) { OpenStruct.new(user: { id: '123' }) }
7
- before(:each) do
9
+
10
+ before do
8
11
  allow(described_class).to receive(:users_id).and_return(user)
9
12
  end
10
13
 
11
- it 'automatically converts attachments into JSON' do
14
+ it 'automatically converts attachments and blocks into JSON' do
12
15
  expect(client).to receive(:post).with(
13
16
  'chat.postEphemeral',
14
17
  channel: 'channel',
15
18
  text: 'text',
16
19
  user: '123',
17
- attachments: '[]'
20
+ attachments: '[]',
21
+ blocks: '[]'
22
+ )
23
+ client.chat_postEphemeral(
24
+ channel: 'channel',
25
+ text: 'text',
26
+ user: '123',
27
+ attachments: [],
28
+ blocks: []
18
29
  )
19
- client.chat_postEphemeral(channel: 'channel', text: 'text', user: '123', attachments: [])
20
30
  end
21
31
  context 'text and user arguments' do
22
32
  it 'requires text or attachments' do
23
- expect { client.chat_postEphemeral(channel: 'channel') }.to raise_error ArgumentError, /Required arguments :text or :attachments missing/
33
+ expect { client.chat_postEphemeral(channel: 'channel') }.to(
34
+ raise_error(ArgumentError, /Required arguments :text, :attachments or :blocks missing/)
35
+ )
24
36
  end
25
37
  it 'requires user' do
26
- expect { client.chat_postEphemeral(channel: 'channel', text: 'text') }.to raise_error ArgumentError, /Required arguments :user missing/
38
+ expect { client.chat_postEphemeral(channel: 'channel', text: 'text') }.to(
39
+ raise_error(ArgumentError, /Required arguments :user missing/)
40
+ )
27
41
  end
28
42
  it 'both text and user' do
29
- expect(client).to receive(:post).with('chat.postEphemeral', hash_including(text: 'text', user: '123'))
30
- expect { client.chat_postEphemeral(channel: 'channel', text: 'text', user: '123') }.to_not raise_error
43
+ expect(client).to(
44
+ receive(:post).with('chat.postEphemeral', hash_including(text: 'text', user: '123'))
45
+ )
46
+ expect do
47
+ client.chat_postEphemeral(channel: 'channel', text: 'text', user: '123')
48
+ end.not_to raise_error
31
49
  end
32
50
  end
51
+
33
52
  context 'attachments argument' do
34
53
  it 'optional attachments' do
35
- expect(client).to receive(:post).with('chat.postEphemeral', hash_including(attachments: '[]'))
36
- expect { client.chat_postEphemeral(channel: 'channel', text: 'text', user: '123', attachments: []) }.to_not raise_error
54
+ expect(client).to(
55
+ receive(:post).with('chat.postEphemeral', hash_including(attachments: '[]'))
56
+ )
57
+ expect do
58
+ client.chat_postEphemeral(channel: 'channel', text: 'text', user: '123', attachments: [])
59
+ end.not_to raise_error
37
60
  end
38
61
  it 'attachments without text' do
39
- expect(client).to receive(:post).with('chat.postEphemeral', hash_including(attachments: '[]'))
40
- expect { client.chat_postEphemeral(channel: 'channel', attachments: [], user: '123') }.to_not raise_error
62
+ expect(client).to(
63
+ receive(:post).with('chat.postEphemeral', hash_including(attachments: '[]'))
64
+ )
65
+ expect do
66
+ client.chat_postEphemeral(channel: 'channel', attachments: [], user: '123')
67
+ end.not_to raise_error
68
+ end
69
+ end
70
+
71
+ context 'blocks argument' do
72
+ it 'optional blocks' do
73
+ expect(client).to receive(:post).with('chat.postEphemeral', hash_including(blocks: '[]'))
74
+ expect do
75
+ client.chat_postEphemeral(channel: 'channel', text: 'text', user: '123', blocks: [])
76
+ end.not_to raise_error
77
+ end
78
+ it 'blocks without text' do
79
+ expect(client).to receive(:post).with('chat.postEphemeral', hash_including(blocks: '[]'))
80
+ expect do
81
+ client.chat_postEphemeral(channel: 'channel', blocks: [], user: '123')
82
+ end.not_to raise_error
41
83
  end
42
84
  end
43
85
  end
44
86
 
45
87
  context 'chat_postMessage' do
46
- it 'automatically converts attachments into JSON' do
88
+ it 'automatically converts attachments and blocks into JSON' do
47
89
  expect(client).to receive(:post).with(
48
90
  'chat.postMessage',
49
91
  channel: 'channel',
50
92
  text: 'text',
51
- attachments: '[]'
93
+ attachments: '[]',
94
+ blocks: '[]'
52
95
  )
53
- client.chat_postMessage(channel: 'channel', text: 'text', attachments: [])
96
+ client.chat_postMessage(channel: 'channel', text: 'text', attachments: [], blocks: [])
54
97
  end
55
- context 'text and attachment arguments' do
56
- it 'requires text or attachments' do
57
- expect { client.chat_postMessage(channel: 'channel') }.to raise_error ArgumentError, /Required arguments :text or :attachments missing/
98
+ context 'text, attachment and blocks arguments' do
99
+ it 'requires text, attachments or blocks' do
100
+ expect { client.chat_postMessage(channel: 'channel') }.to(
101
+ raise_error(ArgumentError, /Required arguments :text, :attachments or :blocks missing/)
102
+ )
58
103
  end
59
104
  it 'only text' do
60
105
  expect(client).to receive(:post).with('chat.postMessage', hash_including(text: 'text'))
61
- expect { client.chat_postMessage(channel: 'channel', text: 'text') }.to_not raise_error
106
+ expect { client.chat_postMessage(channel: 'channel', text: 'text') }.not_to raise_error
62
107
  end
63
108
  it 'only attachments' do
64
109
  expect(client).to receive(:post).with('chat.postMessage', hash_including(attachments: '[]'))
65
- expect { client.chat_postMessage(channel: 'channel', attachments: []) }.to_not raise_error
110
+ expect { client.chat_postMessage(channel: 'channel', attachments: []) }.not_to raise_error
66
111
  end
67
- it 'both text and attachments' do
68
- expect(client).to receive(:post).with('chat.postMessage', hash_including(text: 'text', attachments: '[]'))
69
- expect { client.chat_postMessage(channel: 'channel', text: 'text', attachments: []) }.to_not raise_error
112
+ it 'only blocks' do
113
+ expect(client).to receive(:post).with('chat.postMessage', hash_including(blocks: '[]'))
114
+ expect { client.chat_postMessage(channel: 'channel', blocks: []) }.not_to raise_error
115
+ end
116
+ it 'all text, attachments and blocks' do
117
+ expect(client).to(
118
+ receive(:post)
119
+ .with('chat.postMessage', hash_including(text: 'text', attachments: '[]', blocks: '[]'))
120
+ )
121
+ expect do
122
+ client.chat_postMessage(channel: 'channel', text: 'text', attachments: [], blocks: [])
123
+ end.not_to raise_error
70
124
  end
71
125
  end
72
126
  end
73
127
 
74
128
  context 'chat_update' do
75
129
  let(:ts) { '1405894322.002768' }
76
- it 'automatically converts attachments into JSON' do
130
+
131
+ it 'automatically converts attachments and blocks into JSON' do
77
132
  expect(client).to receive(:post).with(
78
133
  'chat.update',
79
- attachments: '[]',
80
134
  channel: 'channel',
81
135
  text: 'text',
82
- ts: ts
136
+ ts: ts,
137
+ attachments: '[]',
138
+ blocks: '[]'
83
139
  )
84
- client.chat_update(attachments: [], channel: 'channel', text: 'text', ts: ts)
140
+ client.chat_update(channel: 'channel', text: 'text', ts: ts, attachments: [], blocks: [])
85
141
  end
86
142
  context 'ts arguments' do
87
143
  it 'requires ts' do
88
- expect { client.chat_update(channel: 'channel', text: 'text') }.to raise_error ArgumentError, /Required arguments :ts missing>/
144
+ expect do
145
+ client.chat_update(channel: 'channel', text: 'text')
146
+ end.to raise_error(ArgumentError, /Required arguments :ts missing>/)
89
147
  end
90
148
  end
91
- context 'text and attachment arguments' do
92
- it 'requires text or attachments' do
93
- expect { client.chat_update(channel: 'channel', ts: ts) }.to raise_error ArgumentError, /Required arguments :text or :attachments missing/
149
+
150
+ context 'text, attachment and blocks arguments' do
151
+ it 'requires text, attachments or blocks' do
152
+ expect { client.chat_update(channel: 'channel', ts: ts) }.to(
153
+ raise_error(ArgumentError, /Required arguments :text, :attachments or :blocks missing/)
154
+ )
94
155
  end
95
156
  it 'only text' do
96
157
  expect(client).to receive(:post).with('chat.update', hash_including(text: 'text'))
97
- expect { client.chat_update(channel: 'channel', text: 'text', ts: ts) }.to_not raise_error
158
+ expect do
159
+ client.chat_update(channel: 'channel', text: 'text', ts: ts)
160
+ end.not_to raise_error
98
161
  end
99
162
  it 'only attachments' do
100
163
  expect(client).to receive(:post).with('chat.update', hash_including(attachments: '[]'))
101
- expect { client.chat_update(attachments: [], channel: 'channel', ts: ts) }.to_not raise_error
164
+ expect do
165
+ client.chat_update(channel: 'channel', ts: ts, attachments: [])
166
+ end.not_to raise_error
167
+ end
168
+ it 'only blocks' do
169
+ expect(client).to receive(:post).with('chat.update', hash_including(blocks: '[]'))
170
+ expect do
171
+ client.chat_update(channel: 'channel', ts: ts, blocks: [])
172
+ end.not_to raise_error
102
173
  end
103
- it 'both text and attachments' do
104
- expect(client).to receive(:post).with('chat.update', hash_including(text: 'text', attachments: '[]'))
105
- expect { client.chat_update(attachments: [], channel: 'channel', text: 'text', ts: ts) }.to_not raise_error
174
+ it 'all text, attachments and blocks' do
175
+ expect(client).to(
176
+ receive(:post)
177
+ .with('chat.update', hash_including(text: 'text', attachments: '[]', blocks: '[]'))
178
+ )
179
+ expect do
180
+ client.chat_update(channel: 'channel', text: 'text', ts: ts, attachments: [], blocks: [])
181
+ end.not_to raise_error
106
182
  end
107
183
  end
108
184
  end