Sha256: d02364572b62475fc3110439d9fd1e58bf1e9ebf973c80f02426f0814095a0be

Contents?: true

Size: 1.33 KB

Versions: 5

Compression:

Stored size: 1.33 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'

  context 'bot' do
    it 'bot_added' do
      expect do
        event = Slack::RealTime::Event.new(
          'type' => 'bot_added',
          'bot' => {
            'id' => 'B024BE7LH',
            'name' => 'hugbot',
            'icons' => {
              'image_48' => 'https:\/\/slack.com\/path\/to\/hugbot_48.png'
            }
          }
        )
        client.send(:dispatch, event)
      end.to change(client.bots, :count).by(1)
      bot = client.bots['B024BE7LH']
      expect(bot['id']).to eq 'B024BE7LH'
      expect(bot['name']).to eq 'hugbot'
      expect(bot['icons']['image_48']).to eq 'https:\/\/slack.com\/path\/to\/hugbot_48.png'
    end

    context 'with bot loaded in the store' do
      include_context 'loaded client'

      it 'bot_changed' do
        expect do
          event = Slack::RealTime::Event.new(
            'type' => 'bot_changed',
            'bot' => {
              'id' => 'B0751JU2H',
              'name' => 'hugbot'
            }
          )
          client.send(:dispatch, event)
        end.not_to change(client.bots, :count)
        bot = client.bots['B0751JU2H']
        expect(bot['name']).to eq 'hugbot'
      end
    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/bot_spec.rb
slack-ruby-client-2.3.0 spec/slack/real_time/event_handlers/bot_spec.rb
slack-ruby-client-2.2.0 spec/slack/real_time/event_handlers/bot_spec.rb
slack-ruby-client-2.1.0 spec/slack/real_time/event_handlers/bot_spec.rb
slack-ruby-client-2.0.0 spec/slack/real_time/event_handlers/bot_spec.rb