Sha256: 034efdf0f8dc6db5c0059b67c7a87e5ed6c5113399296e19fbcf25da274780b1

Contents?: true

Size: 1.3 KB

Versions: 2

Compression:

Stored size: 1.3 KB

Contents

# frozen_string_literal: true
require 'spec_helper'

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

  context 'bot' do
    it 'sets bot data on rtm.start' do
      expect(client.bots.count).to eq 83
    end
    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
    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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
slack-ruby-client-1.1.0 spec/slack/real_time/event_handlers/bot_spec.rb
slack-ruby-client-1.0.0 spec/slack/real_time/event_handlers/bot_spec.rb