Sha256: b055f38c397e273ed206d016c56319cebc059f2ba44272e32df8560d8e771909

Contents?: true

Size: 1.3 KB

Versions: 6

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 16
    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

6 entries across 6 versions & 1 rubygems

Version Path
slack-ruby-client-0.17.0 spec/slack/real_time/event_handlers/bot_spec.rb
slack-ruby-client-0.16.0 spec/slack/real_time/event_handlers/bot_spec.rb
slack-ruby-client-0.15.1 spec/slack/real_time/event_handlers/bot_spec.rb
slack-ruby-client-0.15.0 spec/slack/real_time/event_handlers/bot_spec.rb
slack-ruby-client-0.14.6 spec/slack/real_time/event_handlers/bot_spec.rb
slack-ruby-client-0.14.5 spec/slack/real_time/event_handlers/bot_spec.rb