-
-
Notifications
You must be signed in to change notification settings - Fork 187
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
3 changed files
with
68 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
describe SlackRubyBot::Hooks::Hello do | ||
let(:logger) { double(:logger, info: nil) } | ||
let(:hello_hook) { described_class.new(logger) } | ||
|
||
describe '#call' do | ||
let(:team_name) { 'Example Team' } | ||
let(:team_id) { SecureRandom.uuid } | ||
let(:team_domain) { 'example' } | ||
let(:team) { double(:team, name: team_name, id: team_id, domain: team_domain) } | ||
let(:client) { instance_double(SlackRubyBot::Client, team: team) } | ||
|
||
def receive_hello | ||
hello_hook.call(client, double) | ||
end | ||
|
||
it 'logs the connection' do | ||
expect(logger).to receive(:info).with("Successfully connected team #{team_name} (#{team_id}) to https://#{team_domain}.slack.com.") | ||
receive_hello | ||
end | ||
|
||
context 'with no client' do | ||
let(:client) { nil } | ||
it 'does nothing' do | ||
expect(logger).not_to receive(:info) | ||
receive_hello | ||
end | ||
end | ||
|
||
context 'when client has no team' do | ||
let(:team) { nil } | ||
it 'does nothing' do | ||
expect(logger).not_to receive(:info) | ||
receive_hello | ||
end | ||
end | ||
|
||
context 'when hook is received multiple times' do | ||
before do | ||
receive_hello | ||
end | ||
|
||
it 'logs the reconnections' do | ||
expect(logger).to receive(:info).with(/^Successfully reconnected .+ after \S+s\.$/).twice | ||
receive_hello | ||
receive_hello | ||
end | ||
end | ||
end | ||
end |