Sha256: ac49e4613b24368adbbb04006148d34e8175c8f1ae55f0ff3b7c5a3e92b368a6

Contents?: true

Size: 1.46 KB

Versions: 8

Compression:

Stored size: 1.46 KB

Contents

require 'spec_helper'

begin
  RSpec.describe Slack::RealTime::Concurrency::Eventmachine::Socket do
    context 'with url' do
      let(:url) { 'wss://ms174.slack-msgs.com/websocket/xyz' }
      let(:socket) { described_class.new(url, ping: 42) }
      let(:ws) { double(Faye::WebSocket::Client) }
      describe '#initialize' do
        it 'sets url' do
          expect(socket.url).to eq url
        end
      end
      describe '#connect!' do
        before do
          allow(ws).to receive(:on).with(:close)
        end
        it 'connects' do
          allow(Faye::WebSocket::Client).to receive(:new).and_return(ws)
          socket.connect!
          expect(socket.instance_variable_get('@driver')).to eq ws
        end
        it 'pings every 30s' do
          expect(Faye::WebSocket::Client).to receive(:new).with(url, nil, ping: 42).and_return(ws)
          socket.connect!
        end
      end
      describe '#disconnect!' do
        it 'closes and nils the websocket' do
          socket.instance_variable_set('@driver', ws)
          expect(ws).to receive(:close)
          socket.disconnect!
        end
      end
      describe 'send_data' do
        before do
          allow(Faye::WebSocket::Client).to receive(:new).and_return(ws)
          allow(ws).to receive(:on)
          socket.connect!
        end
        it 'sends data' do
          expect(ws).to receive(:send).with('data')
          socket.send_data('data')
        end
      end
    end
  end
rescue LoadError
end

Version data entries

8 entries across 8 versions & 2 rubygems

Version Path
slack-ruby-client-bhe-0.5.5 spec/slack/real_time/concurrency/eventmachine_spec.rb
slack-ruby-client-bhe-0.5.4 spec/slack/real_time/concurrency/eventmachine_spec.rb
slack-ruby-client-0.6.0 spec/slack/real_time/concurrency/eventmachine_spec.rb
slack-ruby-client-0.5.4 spec/slack/real_time/concurrency/eventmachine_spec.rb
slack-ruby-client-0.5.3 spec/slack/real_time/concurrency/eventmachine_spec.rb
slack-ruby-client-0.5.2 spec/slack/real_time/concurrency/eventmachine_spec.rb
slack-ruby-client-0.5.1 spec/slack/real_time/concurrency/eventmachine_spec.rb
slack-ruby-client-0.5.0 spec/slack/real_time/concurrency/eventmachine_spec.rb