slack-ruby-client 0.11.0 → 2.7.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 +5 -5
- data/.coveralls.yml +2 -0
- data/.github/FUNDING.yml +2 -0
- data/.github/dependabot.yml +6 -0
- data/.github/workflows/integration_test.yml +45 -0
- data/.github/workflows/lint.yml +14 -0
- data/.github/workflows/pr_lint.yml +21 -0
- data/.github/workflows/test.yml +56 -0
- data/.github/workflows/update_api.yml +81 -0
- data/.gitignore +7 -3
- data/.rubocop.yml +40 -2
- data/.rubocop_todo.yml +209 -55
- data/.ruby-version +1 -0
- data/CHANGELOG.md +257 -30
- data/CONTRIBUTING.md +44 -29
- data/Dangerfile +2 -0
- data/Gemfile +28 -6
- data/Gemfile.danger +6 -0
- data/LICENSE.md +1 -1
- data/README.md +473 -134
- data/RELEASING.md +2 -2
- data/Rakefile +2 -1
- data/SECURITY.md +9 -0
- data/UPGRADING.md +117 -3
- data/bin/commands/admin_analytics.rb +22 -0
- data/bin/commands/admin_apps.rb +57 -0
- data/bin/commands/admin_apps_activities.rb +32 -0
- data/bin/commands/admin_apps_approved.rb +24 -0
- data/bin/commands/admin_apps_config.rb +31 -0
- data/bin/commands/admin_apps_requests.rb +35 -0
- data/bin/commands/admin_apps_restricted.rb +24 -0
- data/bin/commands/admin_audit_anomaly_allow.rb +29 -0
- data/bin/commands/admin_auth_policy.rb +45 -0
- data/bin/commands/admin_barriers.rb +53 -0
- data/bin/commands/admin_conversations.rb +260 -0
- data/bin/commands/admin_conversations_ekm.rb +23 -0
- data/bin/commands/admin_conversations_restrictAccess.rb +43 -0
- data/bin/commands/admin_emoji.rb +60 -0
- data/bin/commands/admin_functions.rb +23 -0
- data/bin/commands/admin_functions_permissions.rb +31 -0
- data/bin/commands/admin_inviteRequests.rb +42 -0
- data/bin/commands/admin_inviteRequests_approved.rb +22 -0
- data/bin/commands/admin_inviteRequests_denied.rb +22 -0
- data/bin/commands/admin_roles.rb +46 -0
- data/bin/commands/admin_teams.rb +33 -0
- data/bin/commands/admin_teams_admins.rb +22 -0
- data/bin/commands/admin_teams_owners.rb +22 -0
- data/bin/commands/admin_teams_settings.rb +70 -0
- data/bin/commands/admin_usergroups.rb +54 -0
- data/bin/commands/admin_users.rb +106 -0
- data/bin/commands/admin_users_session.rb +84 -0
- data/bin/commands/admin_users_unsupportedVersions.rb +21 -0
- data/bin/commands/admin_workflows.rb +42 -0
- data/bin/commands/admin_workflows_collaborators.rb +31 -0
- data/bin/commands/admin_workflows_permissions.rb +21 -0
- data/bin/commands/admin_workflows_triggers_types_permissions.rb +31 -0
- data/bin/commands/api.rb +15 -9
- data/bin/commands/apps.rb +21 -0
- data/bin/commands/apps_activities.rb +32 -0
- data/bin/commands/apps_auth_external.rb +32 -0
- data/bin/commands/apps_connections.rb +19 -0
- data/bin/commands/apps_datastore.rb +116 -0
- data/bin/commands/apps_event_authorizations.rb +22 -0
- data/bin/commands/apps_manifest.rb +58 -0
- data/bin/commands/assistant_search.rb +27 -0
- data/bin/commands/assistant_threads.rb +45 -0
- data/bin/commands/auth.rb +22 -15
- data/bin/commands/auth_teams.rb +22 -0
- data/bin/commands/bookmarks.rb +60 -0
- data/bin/commands/bots.rb +16 -8
- data/bin/commands/calls.rb +58 -0
- data/bin/commands/calls_participants.rb +31 -0
- data/bin/commands/canvases.rb +41 -0
- data/bin/commands/canvases_access.rb +34 -0
- data/bin/commands/canvases_sections.rb +21 -0
- data/bin/commands/chat.rb +158 -99
- data/bin/commands/chat_scheduledMessages.rb +25 -0
- data/bin/commands/conversations.rb +241 -157
- data/bin/commands/conversations_canvases.rb +22 -0
- data/bin/commands/conversations_externalInvitePermissions.rb +22 -0
- data/bin/commands/conversations_requestSharedInvite.rb +48 -0
- data/bin/commands/dialog.rb +16 -9
- data/bin/commands/dnd.rb +47 -38
- data/bin/commands/emoji.rb +15 -7
- data/bin/commands/files.rb +113 -87
- data/bin/commands/files_comments.rb +16 -30
- data/bin/commands/files_remote.rb +84 -0
- data/bin/commands/functions.rb +31 -0
- data/bin/commands/functions_distributions_permissions.rb +61 -0
- data/bin/commands/functions_workflows_steps.rb +23 -0
- data/bin/commands/functions_workflows_steps_responses.rb +23 -0
- data/bin/commands/migration.rb +17 -9
- data/bin/commands/oauth.rb +19 -24
- data/bin/commands/oauth_v2.rb +35 -0
- data/bin/commands/openid_connect.rb +33 -0
- data/bin/commands/pins.rb +33 -30
- data/bin/commands/reactions.rb +53 -45
- data/bin/commands/reminders.rb +54 -41
- data/bin/commands/rtm.rb +16 -22
- data/bin/commands/search.rb +44 -33
- data/bin/commands/stars.rb +39 -29
- data/bin/commands/team.rb +50 -34
- data/bin/commands/team_billing.rb +19 -0
- data/bin/commands/team_externalTeams.rb +35 -0
- data/bin/commands/team_preferences.rb +19 -0
- data/bin/commands/team_profile.rb +15 -8
- data/bin/commands/tooling_tokens.rb +20 -0
- data/bin/commands/usergroups.rb +69 -53
- data/bin/commands/usergroups_users.rb +30 -19
- data/bin/commands/users.rb +114 -84
- data/bin/commands/users_admin.rb +29 -22
- data/bin/commands/users_discoverableContacts.rb +20 -0
- data/bin/commands/users_prefs.rb +14 -7
- data/bin/commands/users_profile.rb +27 -20
- data/bin/commands/views.rb +56 -0
- data/bin/commands/workflows.rb +44 -0
- data/bin/commands/workflows_triggers_permissions.rb +60 -0
- data/bin/slack +50 -46
- data/examples/files_upload_v2/.env.example +1 -0
- data/examples/{hi_real_time → files_upload_v2}/Gemfile +2 -2
- data/examples/files_upload_v2/README.md +13 -0
- data/examples/files_upload_v2/files_upload_v2.rb +45 -0
- data/examples/hi_real_time_and_web/Gemfile +1 -0
- data/examples/hi_real_time_and_web/hi.rb +7 -3
- data/examples/{hi_real_time_async_eventmachine → hi_real_time_async_async}/Gemfile +2 -1
- data/examples/{hi_real_time_async_eventmachine → hi_real_time_async_async}/hi.rb +12 -7
- data/examples/hi_web/Gemfile +1 -0
- data/examples/hi_web/hi.rb +1 -0
- data/examples/new_ticket/Gemfile +1 -0
- data/examples/new_ticket/new_ticket.rb +1 -0
- data/examples/oauth_v2/.env.example +4 -0
- data/examples/oauth_v2/Gemfile +7 -0
- data/examples/oauth_v2/README.md +33 -0
- data/examples/oauth_v2/oauth_v2.rb +60 -0
- data/lib/slack/config.rb +2 -2
- data/lib/slack/events/config.rb +32 -0
- data/lib/slack/events/request.rb +76 -0
- data/lib/slack/logger.rb +6 -5
- data/lib/slack/messages/formatting.rb +66 -1
- data/lib/slack/messages/message.rb +1 -4
- data/lib/slack/real_time/api/message.rb +6 -3
- data/lib/slack/real_time/api/message_id.rb +1 -0
- data/lib/slack/real_time/api/ping.rb +5 -2
- data/lib/slack/real_time/api/templates/event_handler.erb +5 -1
- data/lib/slack/real_time/api/typing.rb +5 -2
- data/lib/slack/real_time/client.rb +117 -54
- data/lib/slack/real_time/concurrency/async.rb +142 -0
- data/lib/slack/real_time/concurrency.rb +2 -2
- data/lib/slack/real_time/config.rb +12 -13
- data/lib/slack/real_time/models/base.rb +1 -4
- data/lib/slack/real_time/models/bot.rb +1 -0
- data/lib/slack/real_time/models/channel.rb +5 -0
- data/lib/slack/real_time/models/im.rb +1 -0
- data/lib/slack/real_time/models/{group.rb → mpim.rb} +2 -1
- data/lib/slack/real_time/models/team.rb +1 -0
- data/lib/slack/real_time/models/user.rb +1 -0
- data/lib/slack/real_time/models.rb +3 -1
- data/lib/slack/real_time/socket.rb +49 -17
- data/lib/slack/real_time/stores/base.rb +28 -14
- data/lib/slack/real_time/stores/starter.rb +325 -287
- data/lib/slack/real_time/stores/store.rb +271 -186
- data/lib/slack/real_time/stores.rb +2 -7
- data/lib/slack/utils/security.rb +44 -0
- data/lib/slack/version.rb +2 -1
- data/lib/slack/web/api/endpoints/admin_analytics.rb +28 -0
- data/lib/slack/web/api/endpoints/admin_apps.rb +78 -0
- data/lib/slack/web/api/endpoints/admin_apps_activities.rb +53 -0
- data/lib/slack/web/api/endpoints/admin_apps_approved.rb +37 -0
- data/lib/slack/web/api/endpoints/admin_apps_config.rb +40 -0
- data/lib/slack/web/api/endpoints/admin_apps_requests.rb +53 -0
- data/lib/slack/web/api/endpoints/admin_apps_restricted.rb +37 -0
- data/lib/slack/web/api/endpoints/admin_audit_anomaly_allow.rb +34 -0
- data/lib/slack/web/api/endpoints/admin_auth_policy.rb +72 -0
- data/lib/slack/web/api/endpoints/admin_barriers.rb +82 -0
- data/lib/slack/web/api/endpoints/admin_conversations.rb +397 -0
- data/lib/slack/web/api/endpoints/admin_conversations_ekm.rb +35 -0
- data/lib/slack/web/api/endpoints/admin_conversations_restrictAccess.rb +61 -0
- data/lib/slack/web/api/endpoints/admin_emoji.rb +88 -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_inviteRequests.rb +61 -0
- data/lib/slack/web/api/endpoints/admin_inviteRequests_approved.rb +33 -0
- data/lib/slack/web/api/endpoints/admin_inviteRequests_denied.rb +33 -0
- data/lib/slack/web/api/endpoints/admin_roles.rb +73 -0
- data/lib/slack/web/api/endpoints/admin_teams.rb +50 -0
- data/lib/slack/web/api/endpoints/admin_teams_admins.rb +34 -0
- data/lib/slack/web/api/endpoints/admin_teams_owners.rb +34 -0
- data/lib/slack/web/api/endpoints/admin_teams_settings.rb +99 -0
- data/lib/slack/web/api/endpoints/admin_usergroups.rb +77 -0
- data/lib/slack/web/api/endpoints/admin_users.rb +167 -0
- data/lib/slack/web/api/endpoints/admin_users_session.rb +121 -0
- data/lib/slack/web/api/endpoints/admin_users_unsupportedVersions.rb +25 -0
- data/lib/slack/web/api/endpoints/admin_workflows.rb +67 -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/admin_workflows_triggers_types_permissions.rb +41 -0
- data/lib/slack/web/api/endpoints/api.rb +2 -3
- data/lib/slack/web/api/endpoints/apps.rb +27 -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_connections.rb +21 -0
- data/lib/slack/web/api/endpoints/apps_datastore.rb +181 -0
- data/lib/slack/web/api/endpoints/apps_event_authorizations.rb +34 -0
- data/lib/slack/web/api/endpoints/apps_manifest.rb +79 -0
- data/lib/slack/web/api/endpoints/assistant_search.rb +44 -0
- data/lib/slack/web/api/endpoints/assistant_threads.rb +68 -0
- data/lib/slack/web/api/endpoints/auth.rb +2 -1
- data/lib/slack/web/api/endpoints/auth_teams.rb +33 -0
- data/lib/slack/web/api/endpoints/bookmarks.rb +90 -0
- data/lib/slack/web/api/endpoints/bots.rb +4 -1
- data/lib/slack/web/api/endpoints/calls.rb +83 -0
- data/lib/slack/web/api/endpoints/calls_participants.rb +42 -0
- data/lib/slack/web/api/endpoints/canvases.rb +54 -0
- data/lib/slack/web/api/endpoints/canvases_access.rb +47 -0
- data/lib/slack/web/api/endpoints/canvases_sections.rb +27 -0
- data/lib/slack/web/api/endpoints/chat.rb +172 -87
- data/lib/slack/web/api/endpoints/chat_scheduledMessages.rb +40 -0
- data/lib/slack/web/api/endpoints/conversations.rb +190 -64
- data/lib/slack/web/api/endpoints/conversations_canvases.rb +28 -0
- data/lib/slack/web/api/endpoints/conversations_externalInvitePermissions.rb +31 -0
- data/lib/slack/web/api/endpoints/conversations_requestSharedInvite.rb +73 -0
- data/lib/slack/web/api/endpoints/dialog.rb +6 -10
- data/lib/slack/web/api/endpoints/dnd.rb +11 -5
- data/lib/slack/web/api/endpoints/emoji.rb +3 -0
- data/lib/slack/web/api/endpoints/files.rb +85 -36
- data/lib/slack/web/api/endpoints/files_comments.rb +4 -36
- data/lib/slack/web/api/endpoints/files_remote.rb +127 -0
- data/lib/slack/web/api/endpoints/functions.rb +43 -0
- data/lib/slack/web/api/endpoints/functions_distributions_permissions.rb +84 -0
- data/lib/slack/web/api/endpoints/functions_workflows_steps.rb +30 -0
- data/lib/slack/web/api/endpoints/functions_workflows_steps_responses.rb +30 -0
- data/lib/slack/web/api/endpoints/migration.rb +6 -3
- data/lib/slack/web/api/endpoints/oauth.rb +10 -32
- data/lib/slack/web/api/endpoints/oauth_v2.rb +48 -0
- data/lib/slack/web/api/endpoints/openid_connect.rb +42 -0
- data/lib/slack/web/api/endpoints/pins.rb +11 -18
- data/lib/slack/web/api/endpoints/reactions.rb +31 -20
- data/lib/slack/web/api/endpoints/reminders.rb +25 -12
- data/lib/slack/web/api/endpoints/rtm.rb +4 -22
- data/lib/slack/web/api/endpoints/search.rb +33 -18
- data/lib/slack/web/api/endpoints/stars.rb +23 -10
- data/lib/slack/web/api/endpoints/team.rb +38 -7
- data/lib/slack/web/api/endpoints/team_billing.rb +21 -0
- data/lib/slack/web/api/endpoints/team_externalTeams.rb +53 -0
- data/lib/slack/web/api/endpoints/team_preferences.rb +21 -0
- data/lib/slack/web/api/endpoints/team_profile.rb +2 -1
- data/lib/slack/web/api/endpoints/tooling_tokens.rb +24 -0
- data/lib/slack/web/api/endpoints/usergroups.rb +44 -25
- data/lib/slack/web/api/endpoints/usergroups_users.rb +23 -14
- data/lib/slack/web/api/endpoints/users.rb +57 -18
- data/lib/slack/web/api/endpoints/users_admin.rb +5 -2
- data/lib/slack/web/api/endpoints/users_discoverableContacts.rb +24 -0
- data/lib/slack/web/api/endpoints/users_prefs.rb +2 -0
- data/lib/slack/web/api/endpoints/users_profile.rb +11 -9
- data/lib/slack/web/api/endpoints/views.rb +86 -0
- data/lib/slack/web/api/endpoints/workflows.rb +63 -0
- data/lib/slack/web/api/endpoints/workflows_triggers_permissions.rb +87 -0
- data/lib/slack/web/api/endpoints.rb +136 -12
- data/lib/slack/web/api/error.rb +1 -0
- data/lib/slack/web/api/errors/server_error.rb +37 -0
- data/lib/slack/web/api/errors/slack_error.rb +14 -1
- data/lib/slack/web/api/errors/too_many_requests_error.rb +2 -4
- data/lib/slack/web/api/errors.rb +1396 -0
- data/lib/slack/web/api/helpers/files.rb +97 -0
- data/lib/slack/web/api/helpers.rb +13 -0
- data/lib/slack/web/api/mixins/conversations.id.rb +47 -0
- data/lib/slack/web/api/mixins/ids.id.rb +4 -3
- data/lib/slack/web/api/mixins/users.id.rb +18 -4
- data/lib/slack/web/api/mixins/users.search.rb +3 -1
- data/lib/slack/web/api/mixins.rb +2 -2
- data/lib/slack/web/api/options.rb +26 -0
- data/lib/slack/web/api/patches/.gitkeep +0 -0
- data/lib/slack/web/api/templates/command.erb +19 -12
- data/lib/slack/web/api/templates/endpoints.erb +2 -2
- data/lib/slack/web/api/templates/errors.erb +20 -0
- data/lib/slack/web/api/templates/method.erb +23 -3
- data/lib/slack/web/api/templates/method_spec.erb +40 -3
- data/lib/slack/web/client.rb +4 -1
- data/lib/slack/web/config.rb +9 -2
- data/lib/slack/web/faraday/connection.rb +11 -20
- data/lib/slack/web/faraday/options.rb +24 -0
- data/lib/slack/web/faraday/request.rb +6 -1
- data/lib/slack/web/faraday/response/raise_error.rb +14 -8
- data/lib/slack/web/faraday/response/wrap_error.rb +24 -0
- data/lib/slack/web/pagination/cursor.rb +7 -7
- data/lib/slack-ruby-client.rb +18 -6
- data/lib/slack.rb +1 -0
- data/lib/slack_ruby_client.rb +1 -0
- data/lib/tasks/git.rake +1 -0
- data/lib/tasks/real_time.rake +51 -21
- data/lib/tasks/update.rake +1 -0
- data/lib/tasks/web.rake +43 -17
- data/slack-ruby-client.gemspec +10 -14
- metadata +191 -307
- data/.travis.yml +0 -30
- data/bin/commands/apps_permissions.rb +0 -22
- data/bin/commands/channels.rb +0 -175
- data/bin/commands/groups.rb +0 -172
- data/bin/commands/im.rb +0 -67
- data/bin/commands/mpim.rb +0 -63
- data/bin/commands.rb +0 -33
- data/examples/hi_real_time/hi.gif +0 -0
- data/examples/hi_real_time/hi.rb +0 -37
- data/examples/hi_real_time_async_celluloid/Gemfile +0 -6
- data/examples/hi_real_time_async_celluloid/hi.rb +0 -36
- data/examples/hi_real_time_async_eventmachine/Procfile +0 -2
- data/lib/slack/real_time/concurrency/celluloid.rb +0 -117
- data/lib/slack/real_time/concurrency/eventmachine.rb +0 -60
- data/lib/slack/web/api/endpoints/apps_permissions.rb +0 -35
- data/lib/slack/web/api/endpoints/channels.rb +0 -265
- data/lib/slack/web/api/endpoints/groups.rb +0 -255
- data/lib/slack/web/api/endpoints/im.rb +0 -113
- data/lib/slack/web/api/endpoints/mpim.rb +0 -98
- data/lib/slack/web/api/endpoints/presence.rb +0 -23
- data/lib/slack/web/api/mixins/channels.id.json +0 -20
- data/lib/slack/web/api/mixins/channels.id.rb +0 -26
- data/lib/slack/web/api/mixins/groups.id.json +0 -20
- data/lib/slack/web/api/mixins/groups.id.rb +0 -26
- data/lib/slack/web/api/patches/chat.1.text-attachments-required.patch +0 -13
- data/lib/slack/web/api/patches/chat.2.attachments-json.patch +0 -17
- data/lib/slack/web/api/patches/chat.3.update-attachments-support.patch +0 -21
- data/lib/slack/web/api/patches/chat.4.postEphemeral-attachments-support.patch +0 -17
- data/lib/slack/web/api/patches/dialog.1.open-json-support.patch +0 -17
- data/lib/slack/web/api/templates/commands.erb +0 -5
- data/screenshots/register-bot.png +0 -0
- data/spec/fixtures/slack/web/429_error.yml +0 -85
- data/spec/fixtures/slack/web/auth_test_error.yml +0 -48
- data/spec/fixtures/slack/web/auth_test_success.yml +0 -57
- data/spec/fixtures/slack/web/channels_info.yml +0 -46
- data/spec/fixtures/slack/web/groups_info.yml +0 -43
- data/spec/fixtures/slack/web/paginated_users_list.yml +0 -181
- data/spec/fixtures/slack/web/rtm_connect.yml +0 -70
- data/spec/fixtures/slack/web/rtm_start.yml +0 -104
- data/spec/fixtures/slack/web/users_info.yml +0 -130
- data/spec/fixtures/slack/web/users_list.yml +0 -72
- data/spec/integration/integration_spec.rb +0 -139
- data/spec/slack/config_spec.rb +0 -14
- data/spec/slack/messages/formatting_spec.rb +0 -43
- data/spec/slack/real_time/api/message_spec.rb +0 -15
- data/spec/slack/real_time/api/ping_spec.rb +0 -15
- data/spec/slack/real_time/api/typing_spec.rb +0 -15
- data/spec/slack/real_time/client_spec.rb +0 -425
- data/spec/slack/real_time/concurrency/celluloid_spec.rb +0 -62
- data/spec/slack/real_time/concurrency/eventmachine_spec.rb +0 -47
- data/spec/slack/real_time/concurrency/it_behaves_like_a_realtime_socket.rb +0 -19
- data/spec/slack/real_time/event_handlers/bot_spec.rb +0 -44
- data/spec/slack/real_time/event_handlers/channel_spec.rb +0 -116
- data/spec/slack/real_time/event_handlers/event_handlers_spec.rb +0 -15
- data/spec/slack/real_time/event_handlers/group_spec.rb +0 -90
- data/spec/slack/real_time/event_handlers/im_spec.rb +0 -47
- data/spec/slack/real_time/event_handlers/team_spec.rb +0 -62
- data/spec/slack/real_time/event_handlers/user_spec.rb +0 -63
- data/spec/slack/real_time/rtm_connect_spec.rb +0 -13
- data/spec/slack/real_time/rtm_start_spec.rb +0 -13
- data/spec/slack/real_time/store_spec.rb +0 -11
- data/spec/slack/slack_spec.rb +0 -58
- data/spec/slack/version_spec.rb +0 -7
- data/spec/slack/web/api/endpoints/api_spec.rb +0 -7
- data/spec/slack/web/api/endpoints/apps_permissions_spec.rb +0 -15
- data/spec/slack/web/api/endpoints/bots_spec.rb +0 -7
- data/spec/slack/web/api/endpoints/conversations_spec.rb +0 -100
- data/spec/slack/web/api/endpoints/custom_specs/auth_spec.rb +0 -25
- data/spec/slack/web/api/endpoints/custom_specs/channels_spec.rb +0 -11
- data/spec/slack/web/api/endpoints/custom_specs/chat_spec.rb +0 -105
- data/spec/slack/web/api/endpoints/custom_specs/dialog_spec.rb +0 -28
- data/spec/slack/web/api/endpoints/custom_specs/groups_spec.rb +0 -11
- data/spec/slack/web/api/endpoints/custom_specs/users_spec.rb +0 -33
- data/spec/slack/web/api/endpoints/dnd_spec.rb +0 -12
- data/spec/slack/web/api/endpoints/emoji_spec.rb +0 -7
- data/spec/slack/web/api/endpoints/files_comments_spec.rb +0 -34
- data/spec/slack/web/api/endpoints/files_spec.rb +0 -43
- data/spec/slack/web/api/endpoints/im_spec.rb +0 -38
- data/spec/slack/web/api/endpoints/migration_spec.rb +0 -12
- data/spec/slack/web/api/endpoints/mpim_spec.rb +0 -38
- data/spec/slack/web/api/endpoints/oauth_spec.rb +0 -29
- data/spec/slack/web/api/endpoints/pins_spec.rb +0 -22
- data/spec/slack/web/api/endpoints/reactions_spec.rb +0 -17
- data/spec/slack/web/api/endpoints/reminders_spec.rb +0 -30
- data/spec/slack/web/api/endpoints/rtm_spec.rb +0 -7
- data/spec/slack/web/api/endpoints/search_spec.rb +0 -22
- data/spec/slack/web/api/endpoints/stars_spec.rb +0 -7
- data/spec/slack/web/api/endpoints/team_profile_spec.rb +0 -7
- data/spec/slack/web/api/endpoints/team_spec.rb +0 -7
- data/spec/slack/web/api/endpoints/usergroups_spec.rb +0 -27
- data/spec/slack/web/api/endpoints/usergroups_users_spec.rb +0 -20
- data/spec/slack/web/api/endpoints/users_admin_spec.rb +0 -17
- data/spec/slack/web/api/endpoints/users_prefs_spec.rb +0 -7
- data/spec/slack/web/api/endpoints/users_profile_spec.rb +0 -7
- data/spec/slack/web/api/error_spec.rb +0 -14
- data/spec/slack/web/api/errors/slack_error_spec.rb +0 -14
- data/spec/slack/web/api/mixins/channels_spec.rb +0 -31
- data/spec/slack/web/api/mixins/groups_spec.rb +0 -31
- data/spec/slack/web/api/mixins/users_spec.rb +0 -39
- data/spec/slack/web/api/pagination/cursor_spec.rb +0 -70
- data/spec/slack/web/client_spec.rb +0 -174
- data/spec/spec_helper.rb +0 -14
- data/spec/support/queue_with_timeout.rb +0 -34
- data/spec/support/real_time/concurrency/mock.rb +0 -30
- data/spec/support/real_time/connected_client.rb +0 -21
- data/spec/support/real_time/event.rb +0 -11
- data/spec/support/token.rb +0 -10
- data/spec/support/vcr.rb +0 -9
- /data/examples/{hi_real_time_async_celluloid → hi_real_time_async_async}/Procfile +0 -0
data/spec/slack/config_spec.rb
DELETED
@@ -1,43 +0,0 @@
|
|
1
|
-
|
2
|
-
require 'spec_helper'
|
3
|
-
|
4
|
-
describe Slack::Messages::Formatting do
|
5
|
-
subject do
|
6
|
-
Slack::Messages::Formatting
|
7
|
-
end
|
8
|
-
context '#unescape' do
|
9
|
-
it 'plain text' do
|
10
|
-
expect(subject.unescape('plain text')).to eq 'plain text'
|
11
|
-
end
|
12
|
-
it 'decodes an HTML-encoded message' do
|
13
|
-
expect(subject.unescape('Hello & <world>')).to eq 'Hello & <world>'
|
14
|
-
end
|
15
|
-
it 'unescapes a user reference' do
|
16
|
-
expect(subject.unescape('Hey <@U024BE7LH|bob>, did you see my file?')).to eq 'Hey @bob, did you see my file?'
|
17
|
-
end
|
18
|
-
it 'unescapes a user reference without a name' do
|
19
|
-
expect(subject.unescape('<@U02BEFY4U> ^^^')).to eq '@U02BEFY4U ^^^'
|
20
|
-
end
|
21
|
-
it 'unescapes a URL without text' do
|
22
|
-
expect(subject.unescape('This message contains a URL <http://foo.com/>')).to eq 'This message contains a URL http://foo.com/'
|
23
|
-
end
|
24
|
-
it 'unescapes a URL with text' do
|
25
|
-
expect(subject.unescape('So does this one: <http://www.foo.com|www.foo.com>')).to eq 'So does this one: www.foo.com'
|
26
|
-
end
|
27
|
-
it 'removes mailto' do
|
28
|
-
expect(subject.unescape('<mailto:bob@example.com|Bob>')).to eq 'Bob'
|
29
|
-
end
|
30
|
-
it 'unlinkifies references' do
|
31
|
-
expect(subject.unescape('Hello <@U123|bob>, say hi to <!everyone> in <#C1234|general>')).to eq 'Hello @bob, say hi to @everyone in #general'
|
32
|
-
end
|
33
|
-
it 'can handle a lone >' do
|
34
|
-
expect(subject.unescape('Hello <@U123|bob> > file.txt')).to eq 'Hello @bob > file.txt'
|
35
|
-
end
|
36
|
-
it 'unescapes a double smart quote' do
|
37
|
-
expect(subject.unescape('“hello”')).to eq '"hello"'
|
38
|
-
end
|
39
|
-
it 'unescapes a single smart quote' do
|
40
|
-
expect(subject.unescape('‘hello’')).to eq "'hello'"
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
@@ -1,15 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
RSpec.describe Slack::RealTime::Client, vcr: { cassette_name: 'web/rtm_start' } do
|
4
|
-
include_context 'connected client'
|
5
|
-
|
6
|
-
describe '#message' do
|
7
|
-
before do
|
8
|
-
allow(client).to receive(:next_id).and_return(42)
|
9
|
-
end
|
10
|
-
it 'sends message' do
|
11
|
-
expect(socket).to receive(:send_data).with({ type: 'message', id: 42, text: 'hello world', channel: 'channel' }.to_json)
|
12
|
-
client.message(text: 'hello world', channel: 'channel')
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
@@ -1,15 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
RSpec.describe Slack::RealTime::Client, vcr: { cassette_name: 'web/rtm_start' } do
|
4
|
-
include_context 'connected client'
|
5
|
-
|
6
|
-
describe '#ping' do
|
7
|
-
before do
|
8
|
-
allow(client).to receive(:next_id).and_return(42)
|
9
|
-
end
|
10
|
-
it 'sends message' do
|
11
|
-
expect(socket).to receive(:send_data).with({ type: 'ping', id: 42 }.to_json)
|
12
|
-
client.ping
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
@@ -1,15 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
RSpec.describe Slack::RealTime::Client, vcr: { cassette_name: 'web/rtm_start' } do
|
4
|
-
include_context 'connected client'
|
5
|
-
|
6
|
-
describe '#typing' do
|
7
|
-
before do
|
8
|
-
allow(client).to receive(:next_id).and_return(42)
|
9
|
-
end
|
10
|
-
it 'sends a typing indicator' do
|
11
|
-
expect(socket).to receive(:send_data).with({ type: 'typing', id: 42, channel: 'channel' }.to_json)
|
12
|
-
client.typing(channel: 'channel')
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
@@ -1,425 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
RSpec.describe Slack::RealTime::Client do
|
4
|
-
let(:ws) { double(Slack::RealTime::Concurrency::Mock::WebSocket, on: true) }
|
5
|
-
before do
|
6
|
-
@token = ENV.delete('SLACK_API_TOKEN')
|
7
|
-
Slack::Config.reset
|
8
|
-
Slack::RealTime::Config.reset
|
9
|
-
Slack::RealTime.configure do |config|
|
10
|
-
config.concurrency = Slack::RealTime::Concurrency::Mock
|
11
|
-
end
|
12
|
-
end
|
13
|
-
after do
|
14
|
-
ENV['SLACK_API_TOKEN'] = @token if @token
|
15
|
-
end
|
16
|
-
context 'token' do
|
17
|
-
before do
|
18
|
-
Slack.configure do |config|
|
19
|
-
config.token = 'global default'
|
20
|
-
end
|
21
|
-
end
|
22
|
-
it 'defaults token to global default' do
|
23
|
-
client = Slack::RealTime::Client.new
|
24
|
-
expect(client.token).to eq 'global default'
|
25
|
-
expect(client.web_client.token).to eq 'global default'
|
26
|
-
end
|
27
|
-
context 'with real time config' do
|
28
|
-
before do
|
29
|
-
Slack::RealTime::Client.configure do |config|
|
30
|
-
config.token = 'custom real time token'
|
31
|
-
end
|
32
|
-
end
|
33
|
-
it 'overrides token to real time config' do
|
34
|
-
client = Slack::RealTime::Client.new
|
35
|
-
expect(client.token).to eq 'custom real time token'
|
36
|
-
expect(client.web_client.token).to eq 'custom real time token'
|
37
|
-
end
|
38
|
-
it 'overrides token to specific token' do
|
39
|
-
client = Slack::RealTime::Client.new(token: 'local token')
|
40
|
-
expect(client.token).to eq 'local token'
|
41
|
-
expect(client.web_client.token).to eq 'local token'
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
context 'client with a full store', vcr: { cassette_name: 'web/rtm_start' } do
|
46
|
-
let(:client) { Slack::RealTime::Client.new(store_class: Slack::RealTime::Stores::Store) }
|
47
|
-
let(:url) { 'wss://ms173.slack-msgs.com/websocket/lqcUiAvrKTP-uuid=' }
|
48
|
-
describe '#start!' do
|
49
|
-
let(:socket) { double(Slack::RealTime::Socket, connected?: true) }
|
50
|
-
before do
|
51
|
-
allow(Slack::RealTime::Socket).to receive(:new).with(url, ping: 30, logger: Slack::Logger.default).and_return(socket)
|
52
|
-
allow(socket).to receive(:connect!)
|
53
|
-
allow(socket).to receive(:start_sync)
|
54
|
-
client.start!
|
55
|
-
end
|
56
|
-
describe 'properties provided upon connection' do
|
57
|
-
it 'sets url' do
|
58
|
-
expect(client.url).to eq url
|
59
|
-
end
|
60
|
-
it 'sets team' do
|
61
|
-
expect(client.team.domain).to eq 'dblockdotorg'
|
62
|
-
end
|
63
|
-
it 'sets teams' do
|
64
|
-
expect(client.teams.count).to eq 1
|
65
|
-
expect(client.teams.values.first).to eq client.team
|
66
|
-
end
|
67
|
-
it 'sets self' do
|
68
|
-
expect(client.self.id).to eq 'U07518DTL'
|
69
|
-
end
|
70
|
-
it 'sets users' do
|
71
|
-
expect(client.users.count).to eq 18
|
72
|
-
expect(client.users.values.first['id']).to eq 'U07518DTL'
|
73
|
-
end
|
74
|
-
it 'sets channels' do
|
75
|
-
expect(client.channels.count).to eq 37
|
76
|
-
expect(client.channels.values.first['name']).to eq 'a1'
|
77
|
-
end
|
78
|
-
it 'sets ims' do
|
79
|
-
expect(client.ims.count).to eq 2
|
80
|
-
expect(client.ims.values.first['user']).to eq 'USLACKBOT'
|
81
|
-
end
|
82
|
-
it 'sets bots' do
|
83
|
-
expect(client.bots.count).to eq 16
|
84
|
-
expect(client.bots.values.first['name']).to eq 'bot'
|
85
|
-
end
|
86
|
-
it 'sets groups' do
|
87
|
-
expect(client.groups.count).to eq 1
|
88
|
-
end
|
89
|
-
end
|
90
|
-
it 'uses web client to fetch url' do
|
91
|
-
expect(client.web_client).to be_a Slack::Web::Client
|
92
|
-
end
|
93
|
-
it 'remembers socket' do
|
94
|
-
expect(client.instance_variable_get('@socket')).to eq socket
|
95
|
-
end
|
96
|
-
it 'cannot be invoked twice' do
|
97
|
-
expect do
|
98
|
-
client.start!
|
99
|
-
end.to raise_error Slack::RealTime::Client::ClientAlreadyStartedError
|
100
|
-
end
|
101
|
-
describe '#stop!' do
|
102
|
-
before do
|
103
|
-
expect(socket).to receive(:disconnect!)
|
104
|
-
client.stop!
|
105
|
-
end
|
106
|
-
it 'cannot be invoked twice' do
|
107
|
-
client.instance_variable_set('@socket', nil) # caused by a :close callback
|
108
|
-
expect do
|
109
|
-
client.stop!
|
110
|
-
end.to raise_error Slack::RealTime::Client::ClientNotStartedError
|
111
|
-
end
|
112
|
-
end
|
113
|
-
describe '#next_id' do
|
114
|
-
it 'increments' do
|
115
|
-
previous_id = client.send(:next_id)
|
116
|
-
expect(client.send(:next_id)).to eq previous_id + 1
|
117
|
-
end
|
118
|
-
end
|
119
|
-
context 'subclassed' do
|
120
|
-
it 'runs event handlers' do
|
121
|
-
event = Slack::RealTime::Event.new(
|
122
|
-
'type' => 'team_rename',
|
123
|
-
'name' => 'New Team Name Inc.'
|
124
|
-
)
|
125
|
-
client.send(:dispatch, event)
|
126
|
-
expect(client.store.team.name).to eq 'New Team Name Inc.'
|
127
|
-
end
|
128
|
-
end
|
129
|
-
end
|
130
|
-
end
|
131
|
-
context 'client with starter store', vcr: { cassette_name: 'web/rtm_connect' } do
|
132
|
-
let(:client) { Slack::RealTime::Client.new(store_class: Slack::RealTime::Stores::Starter) }
|
133
|
-
let(:url) { 'wss://mpmulti-w5tz.slack-msgs.com/websocket/uid' }
|
134
|
-
describe '#start!' do
|
135
|
-
let(:socket) { double(Slack::RealTime::Socket, connected?: true) }
|
136
|
-
before do
|
137
|
-
allow(Slack::RealTime::Socket).to receive(:new).with(url, ping: 30, logger: Slack::Logger.default).and_return(socket)
|
138
|
-
allow(socket).to receive(:connect!)
|
139
|
-
allow(socket).to receive(:start_sync)
|
140
|
-
client.start!
|
141
|
-
end
|
142
|
-
describe 'properties provided upon connection' do
|
143
|
-
it 'sets url' do
|
144
|
-
expect(client.url).to eq url
|
145
|
-
end
|
146
|
-
it 'sets team' do
|
147
|
-
expect(client.team.domain).to eq 'dblockdotorg'
|
148
|
-
end
|
149
|
-
it 'sets self' do
|
150
|
-
expect(client.self.id).to eq 'U07518DTL'
|
151
|
-
end
|
152
|
-
it 'no users' do
|
153
|
-
expect(client.users).to be_nil
|
154
|
-
end
|
155
|
-
it 'no teams' do
|
156
|
-
expect(client.teams).to be_nil
|
157
|
-
end
|
158
|
-
it 'no channels' do
|
159
|
-
expect(client.channels).to be_nil
|
160
|
-
end
|
161
|
-
it 'no ims' do
|
162
|
-
expect(client.ims).to be_nil
|
163
|
-
end
|
164
|
-
it 'no bots' do
|
165
|
-
expect(client.bots).to be_nil
|
166
|
-
end
|
167
|
-
it 'no groups' do
|
168
|
-
expect(client.groups).to be_nil
|
169
|
-
end
|
170
|
-
end
|
171
|
-
it 'uses web client to fetch url' do
|
172
|
-
expect(client.web_client).to be_a Slack::Web::Client
|
173
|
-
end
|
174
|
-
it 'remembers socket' do
|
175
|
-
expect(client.instance_variable_get('@socket')).to eq socket
|
176
|
-
end
|
177
|
-
it 'cannot be invoked twice' do
|
178
|
-
expect do
|
179
|
-
client.start!
|
180
|
-
end.to raise_error Slack::RealTime::Client::ClientAlreadyStartedError
|
181
|
-
end
|
182
|
-
describe '#stop!' do
|
183
|
-
before do
|
184
|
-
expect(socket).to receive(:disconnect!)
|
185
|
-
client.stop!
|
186
|
-
end
|
187
|
-
it 'cannot be invoked twice' do
|
188
|
-
client.instance_variable_set('@socket', nil) # caused by a :close callback
|
189
|
-
expect do
|
190
|
-
client.stop!
|
191
|
-
end.to raise_error Slack::RealTime::Client::ClientNotStartedError
|
192
|
-
end
|
193
|
-
end
|
194
|
-
describe '#next_id' do
|
195
|
-
it 'increments' do
|
196
|
-
previous_id = client.send(:next_id)
|
197
|
-
expect(client.send(:next_id)).to eq previous_id + 1
|
198
|
-
end
|
199
|
-
end
|
200
|
-
end
|
201
|
-
end
|
202
|
-
context 'client with nil store', vcr: { cassette_name: 'web/rtm_connect' } do
|
203
|
-
let(:client) { Slack::RealTime::Client.new(store_class: nil) }
|
204
|
-
let(:url) { 'wss://mpmulti-w5tz.slack-msgs.com/websocket/uid' }
|
205
|
-
it 'sets store to nil' do
|
206
|
-
expect(client.store).to be nil
|
207
|
-
end
|
208
|
-
it "doesn't handle events" do
|
209
|
-
event = Slack::RealTime::Event.new(
|
210
|
-
'type' => 'team_rename',
|
211
|
-
'name' => 'New Team Name Inc.'
|
212
|
-
)
|
213
|
-
expect(client).to_not receive(:run_handlers)
|
214
|
-
client.send(:dispatch, event)
|
215
|
-
end
|
216
|
-
it 'self' do
|
217
|
-
expect(client.self).to be nil
|
218
|
-
end
|
219
|
-
it 'team' do
|
220
|
-
expect(client.team).to be nil
|
221
|
-
end
|
222
|
-
end
|
223
|
-
context 'client with defaults' do
|
224
|
-
let(:client) { Slack::RealTime::Client.new }
|
225
|
-
describe '#initialize' do
|
226
|
-
it 'sets ping' do
|
227
|
-
expect(client.websocket_ping).to eq 30
|
228
|
-
end
|
229
|
-
it "doesn't set proxy" do
|
230
|
-
expect(client.websocket_proxy).to be nil
|
231
|
-
end
|
232
|
-
it 'defaults logger' do
|
233
|
-
expect(client.send(:logger)).to be_a ::Logger
|
234
|
-
end
|
235
|
-
it 'sets default store_class' do
|
236
|
-
expect(client.send(:store_class)).to eq Slack::RealTime::Store
|
237
|
-
end
|
238
|
-
(Slack::RealTime::Config::ATTRIBUTES - %i[logger store_class]).each do |key|
|
239
|
-
it "sets #{key}" do
|
240
|
-
expect(client.send(key)).to eq Slack::RealTime::Config.send(key)
|
241
|
-
end
|
242
|
-
end
|
243
|
-
end
|
244
|
-
end
|
245
|
-
context 'with custom settings' do
|
246
|
-
describe '#initialize' do
|
247
|
-
Slack::RealTime::Config::ATTRIBUTES.each do |key|
|
248
|
-
context key do
|
249
|
-
let(:client) { Slack::RealTime::Client.new(key => 'custom') }
|
250
|
-
it "sets #{key}" do
|
251
|
-
expect(client.send(key)).to_not eq Slack::RealTime::Config.send(key)
|
252
|
-
expect(client.send(key)).to eq 'custom'
|
253
|
-
end
|
254
|
-
end
|
255
|
-
end
|
256
|
-
end
|
257
|
-
end
|
258
|
-
context 'global config' do
|
259
|
-
after do
|
260
|
-
Slack::RealTime::Client.config.reset
|
261
|
-
end
|
262
|
-
let(:url) { 'wss://ms173.slack-msgs.com/websocket/lqcUiAvrKTP-uuid=' }
|
263
|
-
let(:client) { Slack::RealTime::Client.new }
|
264
|
-
context 'ping' do
|
265
|
-
before do
|
266
|
-
Slack::RealTime::Client.configure do |config|
|
267
|
-
config.websocket_ping = 15
|
268
|
-
end
|
269
|
-
end
|
270
|
-
describe '#initialize' do
|
271
|
-
it 'sets ping' do
|
272
|
-
expect(client.websocket_ping).to eq 15
|
273
|
-
end
|
274
|
-
it 'creates a connection with custom ping', vcr: { cassette_name: 'web/rtm_start' } do
|
275
|
-
expect(Slack::RealTime::Concurrency::Mock::WebSocket).to receive(:new).with(url, nil, ping: 15).and_return(ws)
|
276
|
-
client.start!
|
277
|
-
end
|
278
|
-
it 'sets start_options' do
|
279
|
-
expect(client.start_options).to eq(request: { timeout: 180 })
|
280
|
-
end
|
281
|
-
end
|
282
|
-
end
|
283
|
-
context 'proxy' do
|
284
|
-
before do
|
285
|
-
Slack::RealTime::Client.configure do |config|
|
286
|
-
config.websocket_proxy = {
|
287
|
-
origin: 'http://username:password@proxy.example.com',
|
288
|
-
headers: { 'User-Agent' => 'ruby' }
|
289
|
-
}
|
290
|
-
end
|
291
|
-
end
|
292
|
-
describe '#initialize' do
|
293
|
-
it 'sets proxy' do
|
294
|
-
expect(client.websocket_proxy).to eq(
|
295
|
-
origin: 'http://username:password@proxy.example.com',
|
296
|
-
headers: { 'User-Agent' => 'ruby' }
|
297
|
-
)
|
298
|
-
end
|
299
|
-
it 'creates a connection with custom proxy', vcr: { cassette_name: 'web/rtm_start' } do
|
300
|
-
expect(Slack::RealTime::Concurrency::Mock::WebSocket).to receive(:new).with(
|
301
|
-
url,
|
302
|
-
nil,
|
303
|
-
ping: 30,
|
304
|
-
proxy: {
|
305
|
-
origin: 'http://username:password@proxy.example.com',
|
306
|
-
headers: { 'User-Agent' => 'ruby' }
|
307
|
-
}
|
308
|
-
).and_return(ws)
|
309
|
-
client.start!
|
310
|
-
end
|
311
|
-
end
|
312
|
-
end
|
313
|
-
context 'start_options' do
|
314
|
-
before do
|
315
|
-
Slack::RealTime::Client.configure do |config|
|
316
|
-
config.start_options = { simple_latest: true }
|
317
|
-
end
|
318
|
-
end
|
319
|
-
describe '#initialize' do
|
320
|
-
it 'sets start_options' do
|
321
|
-
expect(client.start_options).to eq(simple_latest: true)
|
322
|
-
end
|
323
|
-
context 'start!' do
|
324
|
-
let(:socket) { double(Slack::RealTime::Socket, connected?: true) }
|
325
|
-
before do
|
326
|
-
allow(Slack::RealTime::Socket).to receive(:new).and_return(socket)
|
327
|
-
allow(socket).to receive(:connect!)
|
328
|
-
allow(socket).to receive(:start_sync)
|
329
|
-
end
|
330
|
-
it 'calls rtm_start with start options', vcr: { cassette_name: 'web/rtm_start' } do
|
331
|
-
expect(client.web_client).to receive(:rtm_start).with(simple_latest: true).and_call_original
|
332
|
-
client.start!
|
333
|
-
end
|
334
|
-
end
|
335
|
-
end
|
336
|
-
end
|
337
|
-
context 'store_class' do
|
338
|
-
context 'starter' do
|
339
|
-
before do
|
340
|
-
Slack::RealTime::Client.configure do |config|
|
341
|
-
config.store_class = Slack::RealTime::Stores::Starter
|
342
|
-
end
|
343
|
-
end
|
344
|
-
describe '#initialize' do
|
345
|
-
it 'can be overriden explicitly' do
|
346
|
-
client = Slack::RealTime::Client.new(store_class: Slack::RealTime::Store)
|
347
|
-
expect(client.send(:store_class)).to eq Slack::RealTime::Store
|
348
|
-
end
|
349
|
-
it 'sets store_class' do
|
350
|
-
expect(client.send(:store_class)).to eq(Slack::RealTime::Stores::Starter)
|
351
|
-
end
|
352
|
-
context 'start!' do
|
353
|
-
let(:socket) { double(Slack::RealTime::Socket, connected?: true) }
|
354
|
-
before do
|
355
|
-
allow(Slack::RealTime::Socket).to receive(:new).and_return(socket)
|
356
|
-
allow(socket).to receive(:connect!)
|
357
|
-
allow(socket).to receive(:start_sync)
|
358
|
-
end
|
359
|
-
it 'instantiates the correct store class', vcr: { cassette_name: 'web/rtm_connect' } do
|
360
|
-
client.start!
|
361
|
-
expect(client.store).to be_a Slack::RealTime::Stores::Starter
|
362
|
-
end
|
363
|
-
end
|
364
|
-
end
|
365
|
-
end
|
366
|
-
context 'store' do
|
367
|
-
before do
|
368
|
-
Slack::RealTime::Client.configure do |config|
|
369
|
-
config.store_class = Slack::RealTime::Stores::Store
|
370
|
-
end
|
371
|
-
end
|
372
|
-
describe '#initialize' do
|
373
|
-
context 'start!' do
|
374
|
-
let(:socket) { double(Slack::RealTime::Socket, connected?: true) }
|
375
|
-
before do
|
376
|
-
allow(Slack::RealTime::Socket).to receive(:new).and_return(socket)
|
377
|
-
allow(socket).to receive(:connect!)
|
378
|
-
allow(socket).to receive(:start_sync)
|
379
|
-
end
|
380
|
-
it 'calls rtm_start and not rtm_connect', vcr: { cassette_name: 'web/rtm_start' } do
|
381
|
-
expect(client.web_client).to receive(:rtm_start).and_call_original
|
382
|
-
client.start!
|
383
|
-
end
|
384
|
-
end
|
385
|
-
end
|
386
|
-
end
|
387
|
-
end
|
388
|
-
context 'start_method' do
|
389
|
-
describe '#initialize' do
|
390
|
-
it 'can be overriden explicitly' do
|
391
|
-
client = Slack::RealTime::Client.new(start_method: :overriden)
|
392
|
-
expect(client.send(:start_method)).to eq :overriden
|
393
|
-
end
|
394
|
-
context 'with start_method' do
|
395
|
-
before do
|
396
|
-
Slack::RealTime::Client.configure do |config|
|
397
|
-
config.start_method = :overriden
|
398
|
-
end
|
399
|
-
end
|
400
|
-
it 'sets start_method' do
|
401
|
-
expect(client.send(:start_method)).to eq :overriden
|
402
|
-
end
|
403
|
-
it 'calls the overriden method' do
|
404
|
-
expect(client.web_client).to receive(:overriden).and_raise('overriden')
|
405
|
-
expect do
|
406
|
-
client.start!
|
407
|
-
end.to raise_error RuntimeError, 'overriden'
|
408
|
-
end
|
409
|
-
end
|
410
|
-
context 'start!' do
|
411
|
-
let(:socket) { double(Slack::RealTime::Socket, connected?: true) }
|
412
|
-
before do
|
413
|
-
allow(Slack::RealTime::Socket).to receive(:new).and_return(socket)
|
414
|
-
allow(socket).to receive(:connect!)
|
415
|
-
allow(socket).to receive(:start_sync)
|
416
|
-
end
|
417
|
-
it 'defaults to :rtm_start when using full store', vcr: { cassette_name: 'web/rtm_start' } do
|
418
|
-
expect(client.web_client).to receive(:rtm_start).and_call_original
|
419
|
-
client.start!
|
420
|
-
end
|
421
|
-
end
|
422
|
-
end
|
423
|
-
end
|
424
|
-
end
|
425
|
-
end
|
@@ -1,62 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require_relative './it_behaves_like_a_realtime_socket'
|
3
|
-
|
4
|
-
begin
|
5
|
-
RSpec.describe Slack::RealTime::Concurrency::Celluloid::Socket do
|
6
|
-
it_behaves_like 'a realtime socket'
|
7
|
-
context 'with url' do
|
8
|
-
let(:url) { 'wss://echo.websocket.org/websocket/xyz' }
|
9
|
-
let(:logger) { ::Logger.new(STDOUT) }
|
10
|
-
|
11
|
-
[EOFError, Errno::EPIPE].each do |err|
|
12
|
-
context "finishing run_loop with #{err}" do
|
13
|
-
let(:test_socket) do
|
14
|
-
Class.new(described_class) do
|
15
|
-
def read
|
16
|
-
raise options[:err]
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
let(:socket) do
|
22
|
-
test_socket.new(url, ping: 42, logger: logger, err: err)
|
23
|
-
end
|
24
|
-
|
25
|
-
let(:driver) { WebSocket::Driver::Client }
|
26
|
-
let(:ws) { double(driver) }
|
27
|
-
subject { socket }
|
28
|
-
|
29
|
-
describe '#connect!' do
|
30
|
-
pending 'connects'
|
31
|
-
pending 'pings every 30s'
|
32
|
-
end
|
33
|
-
|
34
|
-
context 'with a driver' do
|
35
|
-
before do
|
36
|
-
socket.instance_variable_set('@driver', ws)
|
37
|
-
end
|
38
|
-
|
39
|
-
describe '#disconnect!' do
|
40
|
-
it 'closes and nils the websocket' do
|
41
|
-
expect(ws).to receive(:close)
|
42
|
-
socket.disconnect!
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
context 'consumes data' do
|
47
|
-
it 'runs' do
|
48
|
-
expect(ws).to receive(:emit)
|
49
|
-
expect(ws).to receive(:start)
|
50
|
-
expect(logger).to receive(:debug).with("#{test_socket}#run_loop")
|
51
|
-
socket.run_loop
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
pending 'send_data'
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|
61
|
-
rescue LoadError
|
62
|
-
end
|
@@ -1,47 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require_relative './it_behaves_like_a_realtime_socket'
|
3
|
-
|
4
|
-
begin
|
5
|
-
RSpec.describe Slack::RealTime::Concurrency::Eventmachine::Socket do
|
6
|
-
it_behaves_like 'a realtime socket'
|
7
|
-
context 'with url' do
|
8
|
-
let(:url) { 'wss://ms174.slack-msgs.com/websocket/xyz' }
|
9
|
-
let(:logger) { ::Logger.new($stdout) }
|
10
|
-
let(:socket) { described_class.new(url, ping: 42, logger: logger) }
|
11
|
-
let(:ws) { double(Faye::WebSocket::Client) }
|
12
|
-
describe '#connect!' do
|
13
|
-
before do
|
14
|
-
allow(ws).to receive(:on).with(:close)
|
15
|
-
end
|
16
|
-
it 'connects' do
|
17
|
-
allow(Faye::WebSocket::Client).to receive(:new).and_return(ws)
|
18
|
-
socket.connect!
|
19
|
-
expect(socket.instance_variable_get('@driver')).to eq ws
|
20
|
-
end
|
21
|
-
it 'pings every 30s' do
|
22
|
-
expect(Faye::WebSocket::Client).to receive(:new).with(url, nil, ping: 42, logger: logger).and_return(ws)
|
23
|
-
socket.connect!
|
24
|
-
end
|
25
|
-
end
|
26
|
-
describe '#disconnect!' do
|
27
|
-
it 'closes and nils the websocket' do
|
28
|
-
socket.instance_variable_set('@driver', ws)
|
29
|
-
expect(ws).to receive(:close)
|
30
|
-
socket.disconnect!
|
31
|
-
end
|
32
|
-
end
|
33
|
-
describe 'send_data' do
|
34
|
-
before do
|
35
|
-
allow(Faye::WebSocket::Client).to receive(:new).and_return(ws)
|
36
|
-
allow(ws).to receive(:on)
|
37
|
-
socket.connect!
|
38
|
-
end
|
39
|
-
it 'sends data' do
|
40
|
-
expect(ws).to receive(:send).with('data')
|
41
|
-
socket.send_data('data')
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
46
|
-
rescue LoadError
|
47
|
-
end
|
@@ -1,19 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
RSpec.shared_examples_for 'a realtime socket' do
|
4
|
-
let(:url) { 'wss://ms174.slack-msgs.com/websocket/xyz' }
|
5
|
-
let(:logger) { ::Logger.new($stdout) }
|
6
|
-
let(:socket) { described_class.new(url, ping: 42, logger: logger) }
|
7
|
-
describe '#initialize' do
|
8
|
-
it 'sets url' do
|
9
|
-
expect(socket.url).to eq url
|
10
|
-
end
|
11
|
-
end
|
12
|
-
describe 'api' do
|
13
|
-
%i[start_sync start_sync disconnect! connect! connected? send_data close].each do |m|
|
14
|
-
it m do
|
15
|
-
expect(socket).to respond_to(m)
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|