slack-ruby-client 0.16.0 → 0.17.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +11 -3
  3. data/LICENSE.md +1 -1
  4. data/README.md +8 -8
  5. data/bin/commands.rb +0 -1
  6. data/bin/commands/admin_analytics.rb +2 -1
  7. data/bin/commands/admin_conversations.rb +0 -10
  8. data/bin/commands/admin_teams.rb +1 -1
  9. data/bin/commands/channels.rb +0 -157
  10. data/bin/commands/chat.rb +8 -6
  11. data/bin/commands/conversations.rb +2 -2
  12. data/bin/commands/dnd.rb +2 -0
  13. data/bin/commands/groups.rb +0 -163
  14. data/bin/commands/im.rb +0 -62
  15. data/bin/commands/mpim.rb +0 -60
  16. data/lib/slack/events/request.rb +2 -2
  17. data/lib/slack/real_time/config.rb +3 -13
  18. data/lib/slack/version.rb +1 -1
  19. data/lib/slack/web/api/endpoints.rb +0 -2
  20. data/lib/slack/web/api/endpoints/admin_analytics.rb +3 -1
  21. data/lib/slack/web/api/endpoints/admin_conversations.rb +0 -14
  22. data/lib/slack/web/api/endpoints/admin_teams.rb +1 -1
  23. data/lib/slack/web/api/endpoints/channels.rb +0 -265
  24. data/lib/slack/web/api/endpoints/chat.rb +11 -7
  25. data/lib/slack/web/api/endpoints/conversations.rb +2 -2
  26. data/lib/slack/web/api/endpoints/dnd.rb +4 -0
  27. data/lib/slack/web/api/endpoints/groups.rb +0 -273
  28. data/lib/slack/web/api/endpoints/im.rb +0 -107
  29. data/lib/slack/web/api/endpoints/mpim.rb +0 -102
  30. data/lib/slack/web/api/errors.rb +14 -16
  31. data/lib/slack/web/api/patches/chat.1.patch +5 -6
  32. data/lib/slack/web/faraday/connection.rb +1 -1
  33. data/lib/slack/web/faraday/response/raise_error.rb +0 -4
  34. data/lib/slack/web/faraday/response/wrap_error.rb +11 -5
  35. data/lib/tasks/web.rake +4 -0
  36. data/spec/fixtures/slack/web/{groups_info.yml → conversations_info.yml} +4 -4
  37. data/spec/slack/events/request_spec.rb +6 -5
  38. data/spec/slack/real_time/concurrency/with_concurrency_spec.rb +10 -0
  39. data/spec/slack/real_time/concurrency/without_concurrency_spec.rb +10 -0
  40. data/spec/slack/real_time/rtm_connect_spec.rb +1 -1
  41. data/spec/slack/real_time/rtm_start_spec.rb +1 -1
  42. data/spec/slack/web/api/endpoints/admin_conversations_spec.rb +0 -5
  43. data/spec/slack/web/api/endpoints/custom_specs/conversations_spec.rb +13 -0
  44. data/spec/slack/web/api/endpoints/im_spec.rb +0 -31
  45. data/spec/slack/web/api/endpoints/mpim_spec.rb +0 -31
  46. data/spec/slack/web/client_spec.rb +15 -20
  47. metadata +10 -12
  48. data/spec/slack/web/api/endpoints/admin_conversations_whitelist_spec.rb +0 -32
  49. data/spec/slack/web/api/endpoints/custom_specs/channels_spec.rb +0 -13
  50. data/spec/slack/web/api/endpoints/custom_specs/groups_spec.rb +0 -13
  51. data/spec/slack/web/api/endpoints/views_spec.rb +0 -29
@@ -3,7 +3,7 @@
3
3
 
4
4
  #
5
5
  # to re-record a rtm_connect fixture run with
6
- # SLACK_API_TOKEN=... CONCURRENCY=faye-websocket rspec spec/slack/real_time/rtm_connect_spec.rb
6
+ # SLACK_API_TOKEN=... CONCURRENCY=async-websocket rspec spec/slack/real_time/rtm_connect_spec.rb
7
7
  # edit rtm_connect.yml and remove the token, fix wss:// path (run specs, fix failures)
8
8
  #
9
9
 
@@ -3,7 +3,7 @@
3
3
 
4
4
  #
5
5
  # to re-record a rtm_start fixture run with
6
- # SLACK_API_TOKEN=... CONCURRENCY=faye-websocket rspec spec/slack/real_time/rtm_start_spec.rb
6
+ # SLACK_API_TOKEN=... CONCURRENCY=async-websocket rspec spec/slack/real_time/rtm_start_spec.rb
7
7
  # edit rtm_start.yml and remove the token, fix wss:// path (run specs, fix failures)
8
8
  #
9
9
 
@@ -28,11 +28,6 @@ RSpec.describe Slack::Web::Api::Endpoints::AdminConversations do
28
28
  expect { client.admin_conversations_delete }.to raise_error ArgumentError, /Required arguments :channel_id missing/
29
29
  end
30
30
  end
31
- context 'admin.conversations_disconnectShared' do
32
- it 'requires channel_id' do
33
- expect { client.admin_conversations_disconnectShared }.to raise_error ArgumentError, /Required arguments :channel_id missing/
34
- end
35
- end
36
31
  context 'admin.conversations_getConversationPrefs' do
37
32
  it 'requires channel_id' do
38
33
  expect { client.admin_conversations_getConversationPrefs }.to raise_error ArgumentError, /Required arguments :channel_id missing/
@@ -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
@@ -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: %q[1234567890.123456]) }.to raise_error ArgumentError, /Required arguments :channel missing/
21
- end
22
- it 'requires ts' do
23
- expect { client.im_mark(channel: %q[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: %q[1234567890.123456]) }.to raise_error ArgumentError, /Required arguments :channel missing/
34
- end
35
- it 'requires thread_ts' do
36
- expect { client.im_replies(channel: %q[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: %q[1593473566.000200]) }.to raise_error ArgumentError, /Required arguments :channel missing/
21
- end
22
- it 'requires ts' do
23
- expect { client.mpim_mark(channel: %q[C012345678]) }.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: %q[1234567890.123456]) }.to raise_error ArgumentError, /Required arguments :channel missing/
34
- end
35
- it 'requires thread_ts' do
36
- expect { client.mpim_replies(channel: %q[C1234567890]) }.to raise_error ArgumentError, /Required arguments :thread_ts missing/
37
- end
38
- end
39
8
  end
@@ -250,21 +250,6 @@ RSpec.describe Slack::Web::Client do
250
250
  end
251
251
  end
252
252
 
253
- context 'when calling deprecated methods' do
254
- let(:client) { described_class.new }
255
-
256
- it 'produces a warning' do
257
- expect(client.logger).to receive(:warn).with(/
258
- ^channels\.archive:\ This\ method\ is\ deprecated
259
- .+
260
- Alternative\ methods:\ conversations\.archive\.
261
- /x)
262
-
263
- expect(client).to receive(:post)
264
- client.channels_archive(channel: 'test')
265
- end
266
- end
267
-
268
253
  context 'persistent capability' do
269
254
  describe '#initialize' do
270
255
  it 'caches the Faraday connection to allow persistent adapters' do
@@ -322,12 +307,22 @@ RSpec.describe Slack::Web::Client do
322
307
  end
323
308
 
324
309
  context '5xx response' do
325
- before { stub_slack_request.to_return(status: 500, body: '{}') }
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>') }
326
321
 
327
- it 'raises UnavailableError' do
328
- expect { request }.to raise_error(Slack::Web::Api::Errors::UnavailableError).with_message('unavailable_error')
329
- expect(exception.cause).to be_a(Faraday::ServerError)
330
- expect(exception.response.status).to eq(500)
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
331
326
  end
332
327
  end
333
328
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: slack-ruby-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.16.0
4
+ version: 0.17.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Doubrovkine
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-01-24 00:00:00.000000000 Z
11
+ date: 2021-03-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -484,10 +484,10 @@ files:
484
484
  - spec/fixtures/slack/web/auth_test_error.yml
485
485
  - spec/fixtures/slack/web/auth_test_success.yml
486
486
  - spec/fixtures/slack/web/channels_info.yml
487
+ - spec/fixtures/slack/web/conversations_info.yml
487
488
  - spec/fixtures/slack/web/conversations_setTopic.yml
488
489
  - spec/fixtures/slack/web/conversations_setTopic_one_page.yml
489
490
  - spec/fixtures/slack/web/conversations_setTopic_paginated.yml
490
- - spec/fixtures/slack/web/groups_info.yml
491
491
  - spec/fixtures/slack/web/paginated_users_list.yml
492
492
  - spec/fixtures/slack/web/rtm_connect.yml
493
493
  - spec/fixtures/slack/web/rtm_start.yml
@@ -504,6 +504,8 @@ files:
504
504
  - spec/slack/real_time/api/typing_spec.rb
505
505
  - spec/slack/real_time/client_spec.rb
506
506
  - spec/slack/real_time/concurrency/it_behaves_like_a_realtime_socket.rb
507
+ - spec/slack/real_time/concurrency/with_concurrency_spec.rb
508
+ - spec/slack/real_time/concurrency/without_concurrency_spec.rb
507
509
  - spec/slack/real_time/event_handlers/bot_spec.rb
508
510
  - spec/slack/real_time/event_handlers/channel_spec.rb
509
511
  - spec/slack/real_time/event_handlers/event_handlers_spec.rb
@@ -525,7 +527,6 @@ files:
525
527
  - spec/slack/web/api/endpoints/admin_conversations_ekm_spec.rb
526
528
  - spec/slack/web/api/endpoints/admin_conversations_restrictAccess_spec.rb
527
529
  - spec/slack/web/api/endpoints/admin_conversations_spec.rb
528
- - spec/slack/web/api/endpoints/admin_conversations_whitelist_spec.rb
529
530
  - spec/slack/web/api/endpoints/admin_emoji_spec.rb
530
531
  - spec/slack/web/api/endpoints/admin_inviteRequests_approved_spec.rb
531
532
  - spec/slack/web/api/endpoints/admin_inviteRequests_denied_spec.rb
@@ -552,10 +553,9 @@ files:
552
553
  - spec/slack/web/api/endpoints/chat_scheduledMessages_spec.rb
553
554
  - spec/slack/web/api/endpoints/conversations_spec.rb
554
555
  - spec/slack/web/api/endpoints/custom_specs/auth_spec.rb
555
- - spec/slack/web/api/endpoints/custom_specs/channels_spec.rb
556
556
  - spec/slack/web/api/endpoints/custom_specs/chat_spec.rb
557
+ - spec/slack/web/api/endpoints/custom_specs/conversations_spec.rb
557
558
  - spec/slack/web/api/endpoints/custom_specs/dialog_spec.rb
558
- - spec/slack/web/api/endpoints/custom_specs/groups_spec.rb
559
559
  - spec/slack/web/api/endpoints/custom_specs/users_spec.rb
560
560
  - spec/slack/web/api/endpoints/custom_specs/views_spec.rb
561
561
  - spec/slack/web/api/endpoints/dnd_spec.rb
@@ -581,7 +581,6 @@ files:
581
581
  - spec/slack/web/api/endpoints/users_admin_spec.rb
582
582
  - spec/slack/web/api/endpoints/users_prefs_spec.rb
583
583
  - spec/slack/web/api/endpoints/users_profile_spec.rb
584
- - spec/slack/web/api/endpoints/views_spec.rb
585
584
  - spec/slack/web/api/endpoints/workflows_spec.rb
586
585
  - spec/slack/web/api/error_spec.rb
587
586
  - spec/slack/web/api/errors/slack_error_spec.rb
@@ -629,10 +628,10 @@ test_files:
629
628
  - spec/fixtures/slack/web/auth_test_error.yml
630
629
  - spec/fixtures/slack/web/auth_test_success.yml
631
630
  - spec/fixtures/slack/web/channels_info.yml
631
+ - spec/fixtures/slack/web/conversations_info.yml
632
632
  - spec/fixtures/slack/web/conversations_setTopic.yml
633
633
  - spec/fixtures/slack/web/conversations_setTopic_one_page.yml
634
634
  - spec/fixtures/slack/web/conversations_setTopic_paginated.yml
635
- - spec/fixtures/slack/web/groups_info.yml
636
635
  - spec/fixtures/slack/web/paginated_users_list.yml
637
636
  - spec/fixtures/slack/web/rtm_connect.yml
638
637
  - spec/fixtures/slack/web/rtm_start.yml
@@ -649,6 +648,8 @@ test_files:
649
648
  - spec/slack/real_time/api/typing_spec.rb
650
649
  - spec/slack/real_time/client_spec.rb
651
650
  - spec/slack/real_time/concurrency/it_behaves_like_a_realtime_socket.rb
651
+ - spec/slack/real_time/concurrency/with_concurrency_spec.rb
652
+ - spec/slack/real_time/concurrency/without_concurrency_spec.rb
652
653
  - spec/slack/real_time/event_handlers/bot_spec.rb
653
654
  - spec/slack/real_time/event_handlers/channel_spec.rb
654
655
  - spec/slack/real_time/event_handlers/event_handlers_spec.rb
@@ -670,7 +671,6 @@ test_files:
670
671
  - spec/slack/web/api/endpoints/admin_conversations_ekm_spec.rb
671
672
  - spec/slack/web/api/endpoints/admin_conversations_restrictAccess_spec.rb
672
673
  - spec/slack/web/api/endpoints/admin_conversations_spec.rb
673
- - spec/slack/web/api/endpoints/admin_conversations_whitelist_spec.rb
674
674
  - spec/slack/web/api/endpoints/admin_emoji_spec.rb
675
675
  - spec/slack/web/api/endpoints/admin_inviteRequests_approved_spec.rb
676
676
  - spec/slack/web/api/endpoints/admin_inviteRequests_denied_spec.rb
@@ -697,10 +697,9 @@ test_files:
697
697
  - spec/slack/web/api/endpoints/chat_scheduledMessages_spec.rb
698
698
  - spec/slack/web/api/endpoints/conversations_spec.rb
699
699
  - spec/slack/web/api/endpoints/custom_specs/auth_spec.rb
700
- - spec/slack/web/api/endpoints/custom_specs/channels_spec.rb
701
700
  - spec/slack/web/api/endpoints/custom_specs/chat_spec.rb
701
+ - spec/slack/web/api/endpoints/custom_specs/conversations_spec.rb
702
702
  - spec/slack/web/api/endpoints/custom_specs/dialog_spec.rb
703
- - spec/slack/web/api/endpoints/custom_specs/groups_spec.rb
704
703
  - spec/slack/web/api/endpoints/custom_specs/users_spec.rb
705
704
  - spec/slack/web/api/endpoints/custom_specs/views_spec.rb
706
705
  - spec/slack/web/api/endpoints/dnd_spec.rb
@@ -726,7 +725,6 @@ test_files:
726
725
  - spec/slack/web/api/endpoints/users_admin_spec.rb
727
726
  - spec/slack/web/api/endpoints/users_prefs_spec.rb
728
727
  - spec/slack/web/api/endpoints/users_profile_spec.rb
729
- - spec/slack/web/api/endpoints/views_spec.rb
730
728
  - spec/slack/web/api/endpoints/workflows_spec.rb
731
729
  - spec/slack/web/api/error_spec.rb
732
730
  - spec/slack/web/api/errors/slack_error_spec.rb
@@ -1,32 +0,0 @@
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::AdminConversationsWhitelist do
7
- let(:client) { Slack::Web::Client.new }
8
- context 'admin.conversations.whitelist_add' do
9
- it 'requires channel_id' do
10
- expect { client.admin_conversations_whitelist_add(group_id: %q[]) }.to raise_error ArgumentError, /Required arguments :channel_id missing/
11
- end
12
- it 'requires group_id' do
13
- expect { client.admin_conversations_whitelist_add(channel_id: %q[]) }.to raise_error ArgumentError, /Required arguments :group_id missing/
14
- end
15
- end
16
- context 'admin.conversations.whitelist_listGroupsLinkedToChannel' do
17
- it 'requires channel_id' do
18
- expect { client.admin_conversations_whitelist_listGroupsLinkedToChannel }.to raise_error ArgumentError, /Required arguments :channel_id missing/
19
- end
20
- end
21
- context 'admin.conversations.whitelist_remove' do
22
- it 'requires channel_id' do
23
- expect { client.admin_conversations_whitelist_remove(group_id: %q[], team_id: %q[]) }.to raise_error ArgumentError, /Required arguments :channel_id missing/
24
- end
25
- it 'requires group_id' do
26
- expect { client.admin_conversations_whitelist_remove(channel_id: %q[], team_id: %q[]) }.to raise_error ArgumentError, /Required arguments :group_id missing/
27
- end
28
- it 'requires team_id' do
29
- expect { client.admin_conversations_whitelist_remove(channel_id: %q[], group_id: %q[]) }.to raise_error ArgumentError, /Required arguments :team_id missing/
30
- end
31
- end
32
- end
@@ -1,13 +0,0 @@
1
- # frozen_string_literal: true
2
- require 'spec_helper'
3
-
4
- RSpec.describe Slack::Web::Api::Endpoints::Channels do
5
- let(:client) { Slack::Web::Client.new }
6
-
7
- context 'channels' do
8
- it 'raises deprecation error', vcr: { cassette_name: 'web/channels_info' } do
9
- expect { client.channels_info(channel: '#general') }
10
- .to raise_error(Slack::Web::Api::Errors::MethodDeprecated, 'method_deprecated')
11
- end
12
- end
13
- end
@@ -1,13 +0,0 @@
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/groups_info' } do
9
- json = client.groups_info(channel: '#mpdm-dblock--rubybot--player1-1')
10
- expect(json.group.name).to eq 'mpdm-dblock--rubybot--player1-1'
11
- end
12
- end
13
- end
@@ -1,29 +0,0 @@
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::Views do
7
- let(:client) { Slack::Web::Client.new }
8
- context 'views_open' do
9
- it 'requires trigger_id' do
10
- expect { client.views_open(view: ' ') }.to raise_error ArgumentError, /Required arguments :trigger_id missing/
11
- end
12
- it 'requires view' do
13
- expect { client.views_open(trigger_id: '12345.98765.abcd2358fdea') }.to raise_error ArgumentError, /Required arguments :view missing/
14
- end
15
- end
16
- context 'views_push' do
17
- it 'requires trigger_id' do
18
- expect { client.views_push(view: ' ') }.to raise_error ArgumentError, /Required arguments :trigger_id missing/
19
- end
20
- it 'requires view' do
21
- expect { client.views_push(trigger_id: '12345.98765.abcd2358fdea') }.to raise_error ArgumentError, /Required arguments :view missing/
22
- end
23
- end
24
- context 'views_update' do
25
- it 'requires view' do
26
- expect { client.views_update }.to raise_error ArgumentError, /Required arguments :view missing/
27
- end
28
- end
29
- end