spec/slack/real_time/client_spec.rb in slack-ruby-client-0.14.2 vs spec/slack/real_time/client_spec.rb in slack-ruby-client-0.14.3
- old
+ new
@@ -84,10 +84,13 @@
expect(client.bots.values.first['name']).to eq 'bot'
end
it 'sets groups' do
expect(client.groups.count).to eq 1
end
+ it 'includes team name in to_s' do
+ expect(client.to_s).to eq "id=#{client.team.id}, name=#{client.team.name}, domain=#{client.team.domain}"
+ end
end
it 'uses web client to fetch url' do
expect(client.web_client).to be_a Slack::Web::Client
end
it 'remembers socket' do
@@ -146,12 +149,26 @@
allow(socket).to receive(:connected?).and_return(true)
expect(socket).to receive(:close)
expect(socket).to receive(:restart_async)
client.run_ping!
end
+ [EOFError, Errno::ECONNRESET, Errno::EPIPE, Faraday::ClientError].each do |err|
+ context "raising #{err}" do
+ it 'does not terminate the ping worker' do
+ allow(socket).to receive(:time_since_last_message) { raise err }
+ expect(socket).to_not receive(:send_data)
+ client.run_ping!
+ end
+ end
+ end
end
end
+ describe 'to_s' do
+ it 'defaults to class instance' do
+ expect(client.to_s).to match(/^#<Slack::RealTime::Client:0x\h+>$/)
+ end
+ end
end
context 'client with starter store', vcr: { cassette_name: 'web/rtm_connect' } do
let(:client) { Slack::RealTime::Client.new(store_class: Slack::RealTime::Stores::Starter) }
let(:url) { 'wss://mpmulti-w5tz.slack-msgs.com/websocket/uid' }
describe '#start!' do
@@ -188,10 +205,13 @@
expect(client.bots).to be_nil
end
it 'no groups' do
expect(client.groups).to be_nil
end
+ it 'includes team name in to_s' do
+ expect(client.to_s).to eq "id=#{client.team.id}, name=#{client.team.name}, domain=#{client.team.domain}"
+ end
end
it 'uses web client to fetch url' do
expect(client.web_client).to be_a Slack::Web::Client
end
it 'remembers socket' do
@@ -239,9 +259,14 @@
it 'self' do
expect(client.self).to be nil
end
it 'team' do
expect(client.team).to be nil
+ end
+ describe 'to_s' do
+ it 'defaults to class instance' do
+ expect(client.to_s).to match(/^#<Slack::RealTime::Client:0x\h+>$/)
+ end
end
end
context 'client with defaults' do
let(:client) { Slack::RealTime::Client.new }
describe '#initialize' do