forked from slack-ruby/slack-ruby-bot
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Do not respond to messages from self, override with allow_message_loo…
…ps, closes slack-ruby#17.
- Loading branch information
Showing
6 changed files
with
62 additions
and
12 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
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,34 @@ | ||
require 'spec_helper' | ||
|
||
describe SlackRubyBot::App do | ||
def app | ||
SlackRubyBot::App.new | ||
end | ||
let(:client) { subject.send(:client) } | ||
before do | ||
allow(client).to receive(:self).and_return('id' => 'UDEADBEEF') | ||
allow(Giphy).to receive(:random) | ||
end | ||
context 'default' do | ||
it 'does not respond to self' do | ||
expect(SlackRubyBot::Commands::Base).to_not receive(:send_client_message) | ||
subject.send(:message, client, text: "#{SlackRubyBot.config.user} hi", channel: 'channel', user: 'UDEADBEEF') | ||
end | ||
end | ||
context 'with allow_message_loops=true' do | ||
before do | ||
SlackRubyBot.configure do |config| | ||
config.allow_message_loops = true | ||
end | ||
end | ||
after do | ||
SlackRubyBot.configure do |config| | ||
config.allow_message_loops = nil | ||
end | ||
end | ||
it 'responds to self' do | ||
expect(SlackRubyBot::Commands::Base).to receive(:send_client_message) | ||
subject.send(:message, client, text: "#{SlackRubyBot.config.user} hi", channel: 'channel', user: 'UDEADBEEF') | ||
end | ||
end | ||
end |