spec/slack/real_time/client_spec.rb in slack-ruby-client-0.4.0 vs spec/slack/real_time/client_spec.rb in slack-ruby-client-0.5.0
- old
+ new
@@ -1,12 +1,14 @@
require 'spec_helper'
RSpec.describe Slack::RealTime::Client, vcr: { cassette_name: 'web/rtm_start' } do
- let(:ws) { double(Faye::WebSocket::Client, on: true) }
+ let(:ws) { double(Slack::RealTime::Concurrency::Mock::WebSocket, on: true) }
let(:url) { 'wss://ms173.slack-msgs.com/websocket/lqcUiAvrKTP-uuid=' }
before do
- allow(EM).to receive(:run).and_yield
+ Slack::RealTime.configure do |config|
+ config.concurrency = Slack::RealTime::Concurrency::Mock
+ end
end
context 'token' do
before do
Slack.configure do |config|
config.token = 'global default'
@@ -40,11 +42,12 @@
context 'started' do
describe '#start!' do
let(:socket) { double(Slack::RealTime::Socket, connected?: true) }
before do
allow(Slack::RealTime::Socket).to receive(:new).with(url, ping: 30).and_return(socket)
- allow(socket).to receive(:connect!).and_yield(ws)
+ allow(socket).to receive(:connect!)
+ allow(socket).to receive(:start_sync).and_yield
client.start!
end
context 'properties provided upon connection' do
it 'sets url' do
expect(client.url).to eq url
@@ -149,11 +152,11 @@
describe '#initialize' do
it 'sets ping' do
expect(client.websocket_ping).to eq 15
end
it 'creates a connection with custom ping' do
- expect(Faye::WebSocket::Client).to receive(:new).with(url, nil, ping: 15).and_return(ws)
+ expect(Slack::RealTime::Concurrency::Mock::WebSocket).to receive(:new).with(url, nil, ping: 15).and_return(ws)
client.start!
end
end
end
context 'proxy' do
@@ -171,10 +174,10 @@
origin: 'http://username:password@proxy.example.com',
headers: { 'User-Agent' => 'ruby' }
)
end
it 'creates a connection with custom proxy' do
- expect(Faye::WebSocket::Client).to receive(:new).with(
+ expect(Slack::RealTime::Concurrency::Mock::WebSocket).to receive(:new).with(
url,
nil,
ping: 30,
proxy: {
origin: 'http://username:password@proxy.example.com',