Sha256: 36b4e38d8bc8c878866241cf60653797b4eb2f61829ac0491024a94f8b6b27f5

Contents?: true

Size: 1.85 KB

Versions: 5

Compression:

Stored size: 1.85 KB

Contents

# frozen_string_literal: true
require 'spec_helper'

RSpec.describe Slack::RealTime::Client, vcr: { cassette_name: 'web/rtm_connect' } do
  include_context 'connected client'
  include_context 'loaded client'

  context 'user' do
    it 'user_change' do
      expect(client.users['U07KECJ77'].name).to eq 'aws'
      event = Slack::RealTime::Event.new(
        'type' => 'user_change',
        'user' => {
          'id' => 'U07KECJ77', 'name' => 'renamed'
        }
      )
      client.send(:dispatch, event)
      expect(client.users['U07KECJ77'].name).to eq 'renamed'
    end

    it 'team_join' do
      expect do
        event = Slack::RealTime::Event.new(
          'type' => 'team_join',
          'user' => {
            'id' => 'DEADBEEF', 'name' => 'added'
          }
        )
        client.send(:dispatch, event)
      end.to change(client.users, :count).by(1)
      expect(client.users['DEADBEEF'].name).to eq 'added'
    end

    it 'pref_change' do
      event = Slack::RealTime::Event.new(
        'type' => 'pref_change',
        'name' => 'push_sound',
        'value' => 'updated.mp3'
      )
      client.send(:dispatch, event)
      expect(client.self.prefs['push_sound']).to eq 'updated.mp3'
    end

    it 'presence_change' do
      expect(client.users['U07KECJ77'].presence).to eq 'away'
      event = Slack::RealTime::Event.new(
        'type' => 'presence_change',
        'user' => 'U07KECJ77',
        'presence' => 'updated'
      )
      client.send(:dispatch, event)
      expect(client.users['U07KECJ77'].presence).to eq 'updated'
    end

    it 'manual_presence_change' do
      expect(client.self['presence']).to eq 'away'
      event = Slack::RealTime::Event.new(
        'type' => 'manual_presence_change',
        'presence' => 'updated'
      )
      client.send(:dispatch, event)
      expect(client.self.presence).to eq 'updated'
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
slack-ruby-client-2.4.0 spec/slack/real_time/event_handlers/user_spec.rb
slack-ruby-client-2.3.0 spec/slack/real_time/event_handlers/user_spec.rb
slack-ruby-client-2.2.0 spec/slack/real_time/event_handlers/user_spec.rb
slack-ruby-client-2.1.0 spec/slack/real_time/event_handlers/user_spec.rb
slack-ruby-client-2.0.0 spec/slack/real_time/event_handlers/user_spec.rb