slack-ruby-client 2.1.0 → 2.2.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.
- checksums.yaml +4 -4
- data/.coveralls.yml +2 -0
- data/.github/workflows/test.yml +6 -0
- data/.github/workflows/update_api.yml +76 -0
- data/.gitignore +1 -0
- data/.rubocop_todo.yml +17 -29
- data/CHANGELOG.md +23 -1
- data/CONTRIBUTING.md +35 -32
- data/Gemfile +2 -0
- data/README.md +123 -14
- data/bin/commands/admin_apps_activities.rb +32 -0
- data/bin/commands/admin_apps_approved.rb +1 -0
- data/bin/commands/admin_apps_config.rb +31 -0
- data/bin/commands/admin_apps_requests.rb +1 -0
- data/bin/commands/admin_apps_restricted.rb +1 -0
- data/bin/commands/admin_functions.rb +23 -0
- data/bin/commands/admin_functions_permissions.rb +31 -0
- data/bin/commands/admin_roles.rb +1 -1
- data/bin/commands/admin_teams.rb +1 -1
- data/bin/commands/admin_users.rb +2 -2
- data/bin/commands/admin_workflows.rb +38 -0
- data/bin/commands/admin_workflows_collaborators.rb +31 -0
- data/bin/commands/admin_workflows_permissions.rb +21 -0
- data/bin/commands/apps_activities.rb +32 -0
- data/bin/commands/apps_auth_external.rb +32 -0
- data/bin/commands/apps_datastore.rb +70 -0
- data/bin/commands/auth_teams.rb +2 -2
- data/bin/commands/calls.rb +1 -1
- data/bin/commands/chat.rb +6 -6
- data/bin/commands/chat_scheduledMessages.rb +2 -2
- data/bin/commands/conversations.rb +3 -3
- data/bin/commands/dnd.rb +1 -1
- data/bin/commands/functions_workflows_steps.rb +2 -1
- data/bin/commands/functions_workflows_steps_responses.rb +2 -1
- data/bin/commands/reminders.rb +1 -1
- data/bin/commands/stars.rb +4 -4
- data/bin/commands/team.rb +3 -1
- data/bin/commands/users.rb +1 -1
- data/lib/slack/messages/formatting.rb +44 -0
- data/lib/slack/real_time/client.rb +14 -2
- data/lib/slack/real_time/concurrency/async.rb +4 -0
- data/lib/slack/real_time/config.rb +3 -0
- data/lib/slack/real_time/socket.rb +4 -0
- data/lib/slack/real_time/stores/starter.rb +2 -2
- data/lib/slack/real_time/stores/store.rb +2 -2
- data/lib/slack/version.rb +1 -1
- data/lib/slack/web/api/endpoints/admin_apps_activities.rb +53 -0
- data/lib/slack/web/api/endpoints/admin_apps_approved.rb +2 -0
- data/lib/slack/web/api/endpoints/admin_apps_config.rb +40 -0
- data/lib/slack/web/api/endpoints/admin_apps_requests.rb +2 -0
- data/lib/slack/web/api/endpoints/admin_apps_restricted.rb +2 -0
- data/lib/slack/web/api/endpoints/admin_conversations.rb +1 -0
- data/lib/slack/web/api/endpoints/admin_functions.rb +36 -0
- data/lib/slack/web/api/endpoints/admin_functions_permissions.rb +41 -0
- data/lib/slack/web/api/endpoints/admin_roles.rb +1 -1
- data/lib/slack/web/api/endpoints/admin_teams.rb +1 -1
- data/lib/slack/web/api/endpoints/admin_users.rb +2 -2
- data/lib/slack/web/api/endpoints/admin_workflows.rb +59 -0
- data/lib/slack/web/api/endpoints/admin_workflows_collaborators.rb +42 -0
- data/lib/slack/web/api/endpoints/admin_workflows_permissions.rb +26 -0
- data/lib/slack/web/api/endpoints/apps_activities.rb +54 -0
- data/lib/slack/web/api/endpoints/apps_auth_external.rb +41 -0
- data/lib/slack/web/api/endpoints/apps_datastore.rb +110 -0
- data/lib/slack/web/api/endpoints/apps_manifest.rb +2 -0
- data/lib/slack/web/api/endpoints/auth_teams.rb +1 -1
- data/lib/slack/web/api/endpoints/calls.rb +1 -1
- data/lib/slack/web/api/endpoints/chat.rb +14 -45
- data/lib/slack/web/api/endpoints/chat_scheduledMessages.rb +2 -2
- data/lib/slack/web/api/endpoints/conversations.rb +3 -3
- data/lib/slack/web/api/endpoints/dialog.rb +1 -6
- data/lib/slack/web/api/endpoints/dnd.rb +1 -1
- data/lib/slack/web/api/endpoints/functions_workflows_steps.rb +3 -1
- data/lib/slack/web/api/endpoints/functions_workflows_steps_responses.rb +3 -1
- data/lib/slack/web/api/endpoints/reminders.rb +1 -1
- data/lib/slack/web/api/endpoints/stars.rb +2 -2
- data/lib/slack/web/api/endpoints/team.rb +12 -2
- data/lib/slack/web/api/endpoints/users.rb +1 -1
- data/lib/slack/web/api/endpoints/users_profile.rb +1 -0
- data/lib/slack/web/api/endpoints/views.rb +7 -23
- data/lib/slack/web/api/endpoints/workflows.rb +2 -0
- data/lib/slack/web/api/endpoints.rb +20 -0
- data/lib/slack/web/api/errors.rb +66 -4
- data/lib/slack/web/api/options.rb +26 -0
- data/lib/slack/web/api/patches/chat.attachments-blocks.patch +7 -55
- data/lib/slack/web/api/templates/method.erb +12 -0
- data/lib/slack/web/api/templates/method_spec.erb +40 -4
- data/lib/slack/web/client.rb +1 -0
- data/lib/slack-ruby-client.rb +1 -0
- data/lib/tasks/web.rake +2 -4
- data/slack-ruby-client.gemspec +1 -0
- data/spec/slack/messages/formatting_spec.rb +60 -0
- data/spec/slack/real_time/client_spec.rb +25 -7
- data/spec/slack/real_time/concurrency/clients/async_spec.rb +16 -0
- data/spec/slack/web/api/endpoints/admin_apps_activities_spec.rb +8 -0
- data/spec/slack/web/api/endpoints/admin_apps_config_spec.rb +18 -0
- data/spec/slack/web/api/endpoints/admin_auth_policy_spec.rb +6 -6
- data/spec/slack/web/api/endpoints/admin_conversations_spec.rb +14 -10
- data/spec/slack/web/api/endpoints/admin_functions_permissions_spec.rb +21 -0
- data/spec/slack/web/api/endpoints/admin_functions_spec.rb +13 -0
- data/spec/slack/web/api/endpoints/admin_roles_spec.rb +6 -6
- data/spec/slack/web/api/endpoints/admin_teams_settings_spec.rb +1 -1
- data/spec/slack/web/api/endpoints/admin_usergroups_spec.rb +6 -6
- data/spec/slack/web/api/endpoints/admin_users_session_spec.rb +2 -2
- data/spec/slack/web/api/endpoints/admin_users_spec.rb +8 -8
- data/spec/slack/web/api/endpoints/admin_workflows_collaborators_spec.rb +24 -0
- data/spec/slack/web/api/endpoints/admin_workflows_permissions_spec.rb +13 -0
- data/spec/slack/web/api/endpoints/admin_workflows_spec.rb +13 -0
- data/spec/slack/web/api/endpoints/apps_activities_spec.rb +13 -0
- data/spec/slack/web/api/endpoints/apps_auth_external_spec.rb +13 -0
- data/spec/slack/web/api/endpoints/apps_datastore_spec.rb +45 -0
- data/spec/slack/web/api/endpoints/apps_manifest_spec.rb +8 -0
- data/spec/slack/web/api/endpoints/apps_spec.rb +2 -2
- data/spec/slack/web/api/endpoints/auth_spec.rb +8 -0
- data/spec/slack/web/api/endpoints/bookmarks_spec.rb +4 -4
- data/spec/slack/web/api/endpoints/calls_participants_spec.rb +4 -4
- data/spec/slack/web/api/endpoints/calls_spec.rb +2 -2
- data/spec/slack/web/api/endpoints/chat_spec.rb +62 -0
- data/spec/slack/web/api/endpoints/conversations_spec.rb +8 -0
- data/spec/slack/web/api/endpoints/custom_specs/chat_spec.rb +3 -3
- data/spec/slack/web/api/endpoints/custom_specs/views_spec.rb +1 -1
- data/spec/slack/web/api/endpoints/dialog_spec.rb +14 -0
- data/spec/slack/web/api/endpoints/files_comments_spec.rb +2 -2
- data/spec/slack/web/api/endpoints/files_remote_spec.rb +3 -3
- data/spec/slack/web/api/endpoints/files_spec.rb +2 -2
- data/spec/slack/web/api/endpoints/oauth_v2_spec.rb +2 -2
- data/spec/slack/web/api/endpoints/reactions_spec.rb +3 -3
- data/spec/slack/web/api/endpoints/reminders_spec.rb +2 -2
- data/spec/slack/web/api/endpoints/usergroups_users_spec.rb +2 -2
- data/spec/slack/web/api/endpoints/users_profile_spec.rb +6 -0
- data/spec/slack/web/api/endpoints/users_spec.rb +8 -0
- data/spec/slack/web/api/endpoints/views_spec.rb +65 -0
- data/spec/slack/web/api/endpoints/workflows_spec.rb +8 -0
- data/spec/slack/web/api/options_spec.rb +69 -0
- data/spec/spec_helper.rb +9 -0
- metadata +45 -5
- data/lib/slack/web/api/patches/dialog.encoded-json.patch +0 -17
- data/lib/slack/web/api/patches/views.view-json.patch +0 -55
|
@@ -7,10 +7,10 @@ RSpec.describe Slack::Web::Api::Endpoints::Apps do
|
|
|
7
7
|
let(:client) { Slack::Web::Client.new }
|
|
8
8
|
context 'apps_uninstall' do
|
|
9
9
|
it 'requires client_id' do
|
|
10
|
-
expect { client.apps_uninstall(client_secret: %q[]) }.to raise_error ArgumentError, /Required arguments :client_id missing/
|
|
10
|
+
expect { client.apps_uninstall(client_secret: %q[f25b5ceaf8a3c2a2c4f52bb4f0b0499e]) }.to raise_error ArgumentError, /Required arguments :client_id missing/
|
|
11
11
|
end
|
|
12
12
|
it 'requires client_secret' do
|
|
13
|
-
expect { client.apps_uninstall(client_id: %q[]) }.to raise_error ArgumentError, /Required arguments :client_secret missing/
|
|
13
|
+
expect { client.apps_uninstall(client_id: %q[56579136444.26251006572]) }.to raise_error ArgumentError, /Required arguments :client_secret missing/
|
|
14
14
|
end
|
|
15
15
|
end
|
|
16
16
|
end
|
|
@@ -10,15 +10,15 @@ RSpec.describe Slack::Web::Api::Endpoints::Bookmarks do
|
|
|
10
10
|
expect { client.bookmarks_add(title: %q[], type: %q[]) }.to raise_error ArgumentError, /Required arguments :channel_id missing/
|
|
11
11
|
end
|
|
12
12
|
it 'requires title' do
|
|
13
|
-
expect { client.bookmarks_add(channel_id: %q[], type: %q[]) }.to raise_error ArgumentError, /Required arguments :title missing/
|
|
13
|
+
expect { client.bookmarks_add(channel_id: %q[C1234567890], type: %q[]) }.to raise_error ArgumentError, /Required arguments :title missing/
|
|
14
14
|
end
|
|
15
15
|
it 'requires type' do
|
|
16
|
-
expect { client.bookmarks_add(channel_id: %q[], title: %q[]) }.to raise_error ArgumentError, /Required arguments :type missing/
|
|
16
|
+
expect { client.bookmarks_add(channel_id: %q[C1234567890], title: %q[]) }.to raise_error ArgumentError, /Required arguments :type missing/
|
|
17
17
|
end
|
|
18
18
|
end
|
|
19
19
|
context 'bookmarks_edit' do
|
|
20
20
|
it 'requires bookmark_id' do
|
|
21
|
-
expect { client.bookmarks_edit(channel_id: %q[]) }.to raise_error ArgumentError, /Required arguments :bookmark_id missing/
|
|
21
|
+
expect { client.bookmarks_edit(channel_id: %q[C1234567890]) }.to raise_error ArgumentError, /Required arguments :bookmark_id missing/
|
|
22
22
|
end
|
|
23
23
|
it 'requires channel_id' do
|
|
24
24
|
expect { client.bookmarks_edit(bookmark_id: %q[]) }.to raise_error ArgumentError, /Required arguments :channel_id missing/
|
|
@@ -31,7 +31,7 @@ RSpec.describe Slack::Web::Api::Endpoints::Bookmarks do
|
|
|
31
31
|
end
|
|
32
32
|
context 'bookmarks_remove' do
|
|
33
33
|
it 'requires bookmark_id' do
|
|
34
|
-
expect { client.bookmarks_remove(channel_id: %q[]) }.to raise_error ArgumentError, /Required arguments :bookmark_id missing/
|
|
34
|
+
expect { client.bookmarks_remove(channel_id: %q[C1234567890]) }.to raise_error ArgumentError, /Required arguments :bookmark_id missing/
|
|
35
35
|
end
|
|
36
36
|
it 'requires channel_id' do
|
|
37
37
|
expect { client.bookmarks_remove(bookmark_id: %q[]) }.to raise_error ArgumentError, /Required arguments :channel_id missing/
|
|
@@ -7,18 +7,18 @@ RSpec.describe Slack::Web::Api::Endpoints::CallsParticipants do
|
|
|
7
7
|
let(:client) { Slack::Web::Client.new }
|
|
8
8
|
context 'calls.participants_add' do
|
|
9
9
|
it 'requires id' do
|
|
10
|
-
expect { client.calls_participants_add(users: %q[]) }.to raise_error ArgumentError, /Required arguments :id missing/
|
|
10
|
+
expect { client.calls_participants_add(users: %q[[{"slack_id": "U1H77"}, {"external_id": "54321678", "display_name": "External User", "avatar_url": "https://example.com/users/avatar1234.jpg"}]]) }.to raise_error ArgumentError, /Required arguments :id missing/
|
|
11
11
|
end
|
|
12
12
|
it 'requires users' do
|
|
13
|
-
expect { client.calls_participants_add(id: %q[]) }.to raise_error ArgumentError, /Required arguments :users missing/
|
|
13
|
+
expect { client.calls_participants_add(id: %q[R0E69JAIF]) }.to raise_error ArgumentError, /Required arguments :users missing/
|
|
14
14
|
end
|
|
15
15
|
end
|
|
16
16
|
context 'calls.participants_remove' do
|
|
17
17
|
it 'requires id' do
|
|
18
|
-
expect { client.calls_participants_remove(users: %q[]) }.to raise_error ArgumentError, /Required arguments :id missing/
|
|
18
|
+
expect { client.calls_participants_remove(users: %q[[{"slack_id": "U1H77"}, {"external_id": "54321678", "display_name": "External User", "avatar_url": "https://example.com/users/avatar1234.jpg"}]]) }.to raise_error ArgumentError, /Required arguments :id missing/
|
|
19
19
|
end
|
|
20
20
|
it 'requires users' do
|
|
21
|
-
expect { client.calls_participants_remove(id: %q[]) }.to raise_error ArgumentError, /Required arguments :users missing/
|
|
21
|
+
expect { client.calls_participants_remove(id: %q[R0E69JAIF]) }.to raise_error ArgumentError, /Required arguments :users missing/
|
|
22
22
|
end
|
|
23
23
|
end
|
|
24
24
|
end
|
|
@@ -7,10 +7,10 @@ RSpec.describe Slack::Web::Api::Endpoints::Calls do
|
|
|
7
7
|
let(:client) { Slack::Web::Client.new }
|
|
8
8
|
context 'calls_add' do
|
|
9
9
|
it 'requires external_unique_id' do
|
|
10
|
-
expect { client.calls_add(join_url: %q[]) }.to raise_error ArgumentError, /Required arguments :external_unique_id missing/
|
|
10
|
+
expect { client.calls_add(join_url: %q[https://example.com/calls/1234567890]) }.to raise_error ArgumentError, /Required arguments :external_unique_id missing/
|
|
11
11
|
end
|
|
12
12
|
it 'requires join_url' do
|
|
13
|
-
expect { client.calls_add(external_unique_id: %q[]) }.to raise_error ArgumentError, /Required arguments :join_url missing/
|
|
13
|
+
expect { client.calls_add(external_unique_id: %q[025169F6-E37A-4E62-BB54-7F93A0FC4C1F]) }.to raise_error ArgumentError, /Required arguments :join_url missing/
|
|
14
14
|
end
|
|
15
15
|
end
|
|
16
16
|
context 'calls_end' do
|
|
@@ -0,0 +1,62 @@
|
|
|
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::Chat do
|
|
7
|
+
let(:client) { Slack::Web::Client.new }
|
|
8
|
+
context 'chat_postEphemeral' do
|
|
9
|
+
it 'encodes attachments, blocks as json' do
|
|
10
|
+
expect(client).to receive(:post).with('chat.postEphemeral', {channel: %q[C1234567890], text: %q[Hello world], user: %q[U0BPQUNTA], attachments: %q[{"data":["data"]}], blocks: %q[{"data":["data"]}]})
|
|
11
|
+
client.chat_postEphemeral(channel: %q[C1234567890], text: %q[Hello world], user: %q[U0BPQUNTA], attachments: {:data=>["data"]}, blocks: {:data=>["data"]})
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
context 'chat_postMessage' do
|
|
15
|
+
it 'requires one of attachments, blocks, text' do
|
|
16
|
+
expect { client.chat_postMessage(channel: %q[C1234567890]) }.to raise_error ArgumentError, /At least one of/
|
|
17
|
+
|
|
18
|
+
expect(client).to receive(:post).with('chat.postMessage', {attachments: %q[[{"pretext": "pre-hello", "text": "text-world"}]], channel: %q[C1234567890]})
|
|
19
|
+
client.chat_postMessage(attachments: %q[[{"pretext": "pre-hello", "text": "text-world"}]], channel: %q[C1234567890])
|
|
20
|
+
|
|
21
|
+
expect(client).to receive(:post).with('chat.postMessage', {blocks: %q[[{"type": "section", "text": {"type": "plain_text", "text": "Hello world"}}]], channel: %q[C1234567890]})
|
|
22
|
+
client.chat_postMessage(blocks: %q[[{"type": "section", "text": {"type": "plain_text", "text": "Hello world"}}]], channel: %q[C1234567890])
|
|
23
|
+
|
|
24
|
+
expect(client).to receive(:post).with('chat.postMessage', {text: %q[Hello world], channel: %q[C1234567890]})
|
|
25
|
+
client.chat_postMessage(text: %q[Hello world], channel: %q[C1234567890])
|
|
26
|
+
|
|
27
|
+
expect(client).to receive(:post).with('chat.postMessage', {attachments: %q[[{"pretext": "pre-hello", "text": "text-world"}]], blocks: %q[[{"type": "section", "text": {"type": "plain_text", "text": "Hello world"}}]], channel: %q[C1234567890]})
|
|
28
|
+
client.chat_postMessage(attachments: %q[[{"pretext": "pre-hello", "text": "text-world"}]], blocks: %q[[{"type": "section", "text": {"type": "plain_text", "text": "Hello world"}}]], channel: %q[C1234567890])
|
|
29
|
+
|
|
30
|
+
expect(client).to receive(:post).with('chat.postMessage', {attachments: %q[[{"pretext": "pre-hello", "text": "text-world"}]], text: %q[Hello world], channel: %q[C1234567890]})
|
|
31
|
+
client.chat_postMessage(attachments: %q[[{"pretext": "pre-hello", "text": "text-world"}]], text: %q[Hello world], channel: %q[C1234567890])
|
|
32
|
+
|
|
33
|
+
expect(client).to receive(:post).with('chat.postMessage', {blocks: %q[[{"type": "section", "text": {"type": "plain_text", "text": "Hello world"}}]], text: %q[Hello world], channel: %q[C1234567890]})
|
|
34
|
+
client.chat_postMessage(blocks: %q[[{"type": "section", "text": {"type": "plain_text", "text": "Hello world"}}]], text: %q[Hello world], channel: %q[C1234567890])
|
|
35
|
+
|
|
36
|
+
expect(client).to receive(:post).with('chat.postMessage', {attachments: %q[[{"pretext": "pre-hello", "text": "text-world"}]], blocks: %q[[{"type": "section", "text": {"type": "plain_text", "text": "Hello world"}}]], text: %q[Hello world], channel: %q[C1234567890]})
|
|
37
|
+
client.chat_postMessage(attachments: %q[[{"pretext": "pre-hello", "text": "text-world"}]], blocks: %q[[{"type": "section", "text": {"type": "plain_text", "text": "Hello world"}}]], text: %q[Hello world], channel: %q[C1234567890])
|
|
38
|
+
end
|
|
39
|
+
it 'encodes attachments, blocks, metadata as json' do
|
|
40
|
+
expect(client).to receive(:post).with('chat.postMessage', {channel: %q[C1234567890], attachments: %q[{"data":["data"]}], blocks: %q[{"data":["data"]}], metadata: %q[{"data":["data"]}]})
|
|
41
|
+
client.chat_postMessage(channel: %q[C1234567890], attachments: {:data=>["data"]}, blocks: {:data=>["data"]}, metadata: {:data=>["data"]})
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
context 'chat_scheduleMessage' do
|
|
45
|
+
it 'encodes attachments, blocks, metadata as json' do
|
|
46
|
+
expect(client).to receive(:post).with('chat.scheduleMessage', {channel: %q[C1234567890], post_at: %q[299876400], text: %q[Hello world], attachments: %q[{"data":["data"]}], blocks: %q[{"data":["data"]}], metadata: %q[{"data":["data"]}]})
|
|
47
|
+
client.chat_scheduleMessage(channel: %q[C1234567890], post_at: %q[299876400], text: %q[Hello world], attachments: {:data=>["data"]}, blocks: {:data=>["data"]}, metadata: {:data=>["data"]})
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
context 'chat_unfurl' do
|
|
51
|
+
it 'encodes unfurls, user_auth_blocks as json' do
|
|
52
|
+
expect(client).to receive(:post).with('chat.unfurl', {channel: %q[C1234567890], ts: %q[], unfurls: %q[{"data":["data"]}], user_auth_blocks: %q[{"data":["data"]}]})
|
|
53
|
+
client.chat_unfurl(channel: %q[C1234567890], ts: %q[], unfurls: {:data=>["data"]}, user_auth_blocks: {:data=>["data"]})
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
context 'chat_update' do
|
|
57
|
+
it 'encodes attachments, blocks, metadata as json' do
|
|
58
|
+
expect(client).to receive(:post).with('chat.update', {channel: %q[C1234567890], ts: %q["1405894322.002768"], attachments: %q[{"data":["data"]}], blocks: %q[{"data":["data"]}], metadata: %q[{"data":["data"]}]})
|
|
59
|
+
client.chat_update(channel: %q[C1234567890], ts: %q["1405894322.002768"], attachments: {:data=>["data"]}, blocks: {:data=>["data"]}, metadata: {:data=>["data"]})
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
end
|
|
@@ -34,7 +34,7 @@ RSpec.describe Slack::Web::Api::Endpoints::Chat do
|
|
|
34
34
|
context 'text and user arguments' do
|
|
35
35
|
it 'requires text or attachments' do
|
|
36
36
|
expect { client.chat_postEphemeral(channel: 'channel') }.to(
|
|
37
|
-
raise_error(ArgumentError, /
|
|
37
|
+
raise_error(ArgumentError, /At least one of :attachments, :blocks, :text is required/)
|
|
38
38
|
)
|
|
39
39
|
end
|
|
40
40
|
|
|
@@ -108,7 +108,7 @@ RSpec.describe Slack::Web::Api::Endpoints::Chat do
|
|
|
108
108
|
context 'text, attachment and blocks arguments' do
|
|
109
109
|
it 'requires text, attachments or blocks' do
|
|
110
110
|
expect { client.chat_postMessage(channel: 'channel') }.to(
|
|
111
|
-
raise_error(ArgumentError, /
|
|
111
|
+
raise_error(ArgumentError, /At least one of :attachments, :blocks, :text is required/)
|
|
112
112
|
)
|
|
113
113
|
end
|
|
114
114
|
|
|
@@ -167,7 +167,7 @@ RSpec.describe Slack::Web::Api::Endpoints::Chat do
|
|
|
167
167
|
context 'text, attachment and blocks arguments' do
|
|
168
168
|
it 'requires text, attachments, blocks or reply_broadcast' do
|
|
169
169
|
expect { client.chat_update(channel: 'channel', ts: ts) }.to(
|
|
170
|
-
raise_error(ArgumentError, /
|
|
170
|
+
raise_error(ArgumentError, /At least one of :attachments, :blocks, :text, :reply_broadcast is required/)
|
|
171
171
|
)
|
|
172
172
|
end
|
|
173
173
|
|
|
@@ -104,7 +104,7 @@ RSpec.describe Slack::Web::Api::Endpoints::Views do
|
|
|
104
104
|
it 'raises error' do
|
|
105
105
|
expect do
|
|
106
106
|
client.views_update(external_id: trigger_id, view_id: view_id, view: 'celery man')
|
|
107
|
-
end.to raise_error ArgumentError, '
|
|
107
|
+
end.to raise_error ArgumentError, 'Exactly one of :external_id, :view_id is required'
|
|
108
108
|
end
|
|
109
109
|
end
|
|
110
110
|
end
|
|
@@ -0,0 +1,14 @@
|
|
|
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::Dialog do
|
|
7
|
+
let(:client) { Slack::Web::Client.new }
|
|
8
|
+
context 'dialog_open' do
|
|
9
|
+
it 'encodes dialog as json' do
|
|
10
|
+
expect(client).to receive(:post).with('dialog.open', {dialog: %q[{"data":["data"]}], trigger_id: %q[12345.98765.abcd2358fdea]})
|
|
11
|
+
client.dialog_open(dialog: {:data=>["data"]}, trigger_id: %q[12345.98765.abcd2358fdea])
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
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: %q[]) }.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: %q[]) }.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: %q[], title: %q[]) }.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: %q[], title: %q[]) }.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: %q[], external_url: %q[]) }.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
|
|
@@ -25,10 +25,10 @@ RSpec.describe Slack::Web::Api::Endpoints::Files do
|
|
|
25
25
|
end
|
|
26
26
|
context 'files_getUploadURLExternal' do
|
|
27
27
|
it 'requires filename' do
|
|
28
|
-
expect { client.files_getUploadURLExternal(length: %q[]) }.to raise_error ArgumentError, /Required arguments :filename missing/
|
|
28
|
+
expect { client.files_getUploadURLExternal(length: %q[53072]) }.to raise_error ArgumentError, /Required arguments :filename missing/
|
|
29
29
|
end
|
|
30
30
|
it 'requires length' do
|
|
31
|
-
expect { client.files_getUploadURLExternal(filename: %q[]) }.to raise_error ArgumentError, /Required arguments :length missing/
|
|
31
|
+
expect { client.files_getUploadURLExternal(filename: %q[laughingoutloudcat.jpg]) }.to raise_error ArgumentError, /Required arguments :length missing/
|
|
32
32
|
end
|
|
33
33
|
end
|
|
34
34
|
context 'files_info' do
|
|
@@ -7,10 +7,10 @@ RSpec.describe Slack::Web::Api::Endpoints::OauthV2 do
|
|
|
7
7
|
let(:client) { Slack::Web::Client.new }
|
|
8
8
|
context 'oauth.v2_exchange' do
|
|
9
9
|
it 'requires client_id' do
|
|
10
|
-
expect { client.oauth_v2_exchange(client_secret: %q[]) }.to raise_error ArgumentError, /Required arguments :client_id missing/
|
|
10
|
+
expect { client.oauth_v2_exchange(client_secret: %q[e1b9e11dfcd19c1982d5de12921e17e8c]) }.to raise_error ArgumentError, /Required arguments :client_id missing/
|
|
11
11
|
end
|
|
12
12
|
it 'requires client_secret' do
|
|
13
|
-
expect { client.oauth_v2_exchange(client_id: %q[]) }.to raise_error ArgumentError, /Required arguments :client_secret missing/
|
|
13
|
+
expect { client.oauth_v2_exchange(client_id: %q[4123121235.9872358710]) }.to raise_error ArgumentError, /Required arguments :client_secret missing/
|
|
14
14
|
end
|
|
15
15
|
end
|
|
16
16
|
end
|
|
@@ -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: %q[], timestamp: %q[]) }.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: %q[], timestamp: %q[]) }.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: %q[], name: %q[]) }.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: %q[]) }.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: %q[]) }.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: %q[]) }.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: %q[]) }.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
|
|
@@ -5,4 +5,10 @@ require 'spec_helper'
|
|
|
5
5
|
|
|
6
6
|
RSpec.describe Slack::Web::Api::Endpoints::UsersProfile do
|
|
7
7
|
let(:client) { Slack::Web::Client.new }
|
|
8
|
+
context 'users.profile_set' do
|
|
9
|
+
it 'encodes profile as json' do
|
|
10
|
+
expect(client).to receive(:post).with('users.profile.set', {profile: %q[{"data":["data"]}]})
|
|
11
|
+
client.users_profile_set(profile: {:data=>["data"]})
|
|
12
|
+
end
|
|
13
|
+
end
|
|
8
14
|
end
|
|
@@ -0,0 +1,65 @@
|
|
|
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 one of trigger_id, interactivity_pointer' do
|
|
10
|
+
expect { client.views_open(view: %q[]) }.to raise_error ArgumentError, /Exactly one of/
|
|
11
|
+
|
|
12
|
+
expect(client).to receive(:post).with('views.open', {trigger_id: %q[12345.98765.abcd2358fdea], view: %q[]})
|
|
13
|
+
client.views_open(trigger_id: %q[12345.98765.abcd2358fdea], view: %q[])
|
|
14
|
+
|
|
15
|
+
expect(client).to receive(:post).with('views.open', {interactivity_pointer: %q[12345.98765.abcd2358fdea], view: %q[]})
|
|
16
|
+
client.views_open(interactivity_pointer: %q[12345.98765.abcd2358fdea], view: %q[])
|
|
17
|
+
|
|
18
|
+
expect { client.views_open(trigger_id: %q[12345.98765.abcd2358fdea], interactivity_pointer: %q[12345.98765.abcd2358fdea], view: %q[]) }.to raise_error ArgumentError, /Exactly one of/
|
|
19
|
+
end
|
|
20
|
+
it 'encodes view as json' do
|
|
21
|
+
expect(client).to receive(:post).with('views.open', {view: %q[{"data":["data"]}], trigger_id: %q[12345.98765.abcd2358fdea]})
|
|
22
|
+
client.views_open(view: {:data=>["data"]}, trigger_id: %q[12345.98765.abcd2358fdea])
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
context 'views_publish' do
|
|
26
|
+
it 'encodes view as json' do
|
|
27
|
+
expect(client).to receive(:post).with('views.publish', {user_id: %q[U0BPQUNTA], view: %q[{"data":["data"]}]})
|
|
28
|
+
client.views_publish(user_id: %q[U0BPQUNTA], view: {:data=>["data"]})
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
context 'views_push' do
|
|
32
|
+
it 'requires one of trigger_id, interactivity_pointer' do
|
|
33
|
+
expect { client.views_push(view: %q[]) }.to raise_error ArgumentError, /Exactly one of/
|
|
34
|
+
|
|
35
|
+
expect(client).to receive(:post).with('views.push', {trigger_id: %q[12345.98765.abcd2358fdea], view: %q[]})
|
|
36
|
+
client.views_push(trigger_id: %q[12345.98765.abcd2358fdea], view: %q[])
|
|
37
|
+
|
|
38
|
+
expect(client).to receive(:post).with('views.push', {interactivity_pointer: %q[12345.98765.abcd2358fdea], view: %q[]})
|
|
39
|
+
client.views_push(interactivity_pointer: %q[12345.98765.abcd2358fdea], view: %q[])
|
|
40
|
+
|
|
41
|
+
expect { client.views_push(trigger_id: %q[12345.98765.abcd2358fdea], interactivity_pointer: %q[12345.98765.abcd2358fdea], view: %q[]) }.to raise_error ArgumentError, /Exactly one of/
|
|
42
|
+
end
|
|
43
|
+
it 'encodes view as json' do
|
|
44
|
+
expect(client).to receive(:post).with('views.push', {view: %q[{"data":["data"]}], trigger_id: %q[12345.98765.abcd2358fdea]})
|
|
45
|
+
client.views_push(view: {:data=>["data"]}, trigger_id: %q[12345.98765.abcd2358fdea])
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
context 'views_update' do
|
|
49
|
+
it 'requires one of external_id, view_id' do
|
|
50
|
+
expect { client.views_update(view: %q[]) }.to raise_error ArgumentError, /Exactly one of/
|
|
51
|
+
|
|
52
|
+
expect(client).to receive(:post).with('views.update', {external_id: %q[bmarley_view2], view: %q[]})
|
|
53
|
+
client.views_update(external_id: %q[bmarley_view2], view: %q[])
|
|
54
|
+
|
|
55
|
+
expect(client).to receive(:post).with('views.update', {view_id: %q[VMM512F2U], view: %q[]})
|
|
56
|
+
client.views_update(view_id: %q[VMM512F2U], view: %q[])
|
|
57
|
+
|
|
58
|
+
expect { client.views_update(external_id: %q[bmarley_view2], view_id: %q[VMM512F2U], view: %q[]) }.to raise_error ArgumentError, /Exactly one of/
|
|
59
|
+
end
|
|
60
|
+
it 'encodes view as json' do
|
|
61
|
+
expect(client).to receive(:post).with('views.update', {view: %q[{"data":["data"]}], external_id: %q[bmarley_view2]})
|
|
62
|
+
client.views_update(view: {:data=>["data"]}, external_id: %q[bmarley_view2])
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
end
|
|
@@ -17,10 +17,18 @@ RSpec.describe Slack::Web::Api::Endpoints::Workflows do
|
|
|
17
17
|
it 'requires workflow_step_execute_id' do
|
|
18
18
|
expect { client.workflows_stepFailed(error: %q[]) }.to raise_error ArgumentError, /Required arguments :workflow_step_execute_id missing/
|
|
19
19
|
end
|
|
20
|
+
it 'encodes error as json' do
|
|
21
|
+
expect(client).to receive(:post).with('workflows.stepFailed', {error: %q[{"data":["data"]}], workflow_step_execute_id: %q[]})
|
|
22
|
+
client.workflows_stepFailed(error: {:data=>["data"]}, workflow_step_execute_id: %q[])
|
|
23
|
+
end
|
|
20
24
|
end
|
|
21
25
|
context 'workflows_updateStep' do
|
|
22
26
|
it 'requires workflow_step_edit_id' do
|
|
23
27
|
expect { client.workflows_updateStep }.to raise_error ArgumentError, /Required arguments :workflow_step_edit_id missing/
|
|
24
28
|
end
|
|
29
|
+
it 'encodes inputs, outputs as json' do
|
|
30
|
+
expect(client).to receive(:post).with('workflows.updateStep', {workflow_step_edit_id: %q[], inputs: %q[{"data":["data"]}], outputs: %q[{"data":["data"]}]})
|
|
31
|
+
client.workflows_updateStep(workflow_step_edit_id: %q[], inputs: {:data=>["data"]}, outputs: {:data=>["data"]})
|
|
32
|
+
end
|
|
25
33
|
end
|
|
26
34
|
end
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
require 'spec_helper'
|
|
3
|
+
|
|
4
|
+
RSpec.describe Slack::Web::Api::Error do
|
|
5
|
+
let(:client) { Slack::Web::Client.new }
|
|
6
|
+
|
|
7
|
+
describe '#encode_options_as_json' do
|
|
8
|
+
let(:encoded_options) { client.encode_options_as_json(options, keys) }
|
|
9
|
+
|
|
10
|
+
let(:keys) { %i[attachments blocks metadata] }
|
|
11
|
+
|
|
12
|
+
context 'with some of the keys present in the options' do
|
|
13
|
+
let(:options) do
|
|
14
|
+
{
|
|
15
|
+
text: 'Hello, world!',
|
|
16
|
+
blocks: blocks,
|
|
17
|
+
metadata: metadata
|
|
18
|
+
}
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
context 'and non-string objects in those keys' do
|
|
22
|
+
let(:blocks) { [{ type: 'section' }, { type: 'actions' }] }
|
|
23
|
+
let(:metadata) { { external_id: SecureRandom.uuid } }
|
|
24
|
+
|
|
25
|
+
it 'encodes the named keys into json' do
|
|
26
|
+
expect(encoded_options).to eql(
|
|
27
|
+
text: 'Hello, world!',
|
|
28
|
+
blocks: JSON.dump(blocks),
|
|
29
|
+
metadata: JSON.dump(metadata)
|
|
30
|
+
)
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
context 'and string objects in those keys' do
|
|
35
|
+
let(:blocks) { JSON.dump([{ type: 'section' }, { type: 'actions' }]) }
|
|
36
|
+
let(:metadata) { JSON.dump({ external_id: SecureRandom.uuid }) }
|
|
37
|
+
|
|
38
|
+
it 'returns the original options' do
|
|
39
|
+
expect(encoded_options).to eql(options)
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
context 'with none of the keys present in the options' do
|
|
45
|
+
let(:options) do
|
|
46
|
+
{
|
|
47
|
+
text: 'Hello, world!'
|
|
48
|
+
}
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
it 'returns the original options' do
|
|
52
|
+
expect(encoded_options).to eql(options)
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
context 'with no keys given' do
|
|
57
|
+
let(:options) do
|
|
58
|
+
{
|
|
59
|
+
text: 'Hello, world!'
|
|
60
|
+
}
|
|
61
|
+
end
|
|
62
|
+
let(:keys) { [] }
|
|
63
|
+
|
|
64
|
+
it 'returns the original options' do
|
|
65
|
+
expect(encoded_options).to eql(options)
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
end
|
data/spec/spec_helper.rb
CHANGED
|
@@ -5,6 +5,15 @@ require 'rubygems'
|
|
|
5
5
|
require 'rspec'
|
|
6
6
|
require 'timecop'
|
|
7
7
|
|
|
8
|
+
require 'simplecov'
|
|
9
|
+
require 'simplecov-lcov'
|
|
10
|
+
SimpleCov::Formatter::LcovFormatter.config do |c|
|
|
11
|
+
c.report_with_single_file = true
|
|
12
|
+
c.single_report_path = 'coverage/lcov.info'
|
|
13
|
+
end
|
|
14
|
+
SimpleCov.formatter = SimpleCov::Formatter::LcovFormatter
|
|
15
|
+
SimpleCov.start
|
|
16
|
+
|
|
8
17
|
require 'slack_ruby_client'
|
|
9
18
|
|
|
10
19
|
Dir[File.join(File.dirname(__FILE__), 'support', '**/*.rb')].each do |file|
|