Sha256: 7aae087cf1bf27e37ed6a9cbf03fc914bd86c00193d8944d8d368ba809e5196e
Contents?: true
Size: 1.99 KB
Versions: 3
Compression:
Stored size: 1.99 KB
Contents
require 'spec_helper' describe UniformNotifier::Slack do context 'not enabled' do it 'should not notify slack' do expect_any_instance_of(Slack::Notifier).to_not receive(:ping) expect(UniformNotifier::Slack.out_of_channel_notify(:title => 'notify slack')).to be_nil end end context 'configuration' do context 'no webhook_url is given' do it 'should raise an error' do expect{ UniformNotifier.slack = {} }.to raise_error(UniformNotifier::NotificationError) end it 'should not notify slack' do begin UniformNotifier.slack = {} rescue UniformNotifier::NotificationError ensure expect_any_instance_of(Slack::Notifier).to_not receive(:ping) expect(UniformNotifier::Slack.out_of_channel_notify(:title => 'notify slack')).to be_nil end end end it 'should remove invalid options' do expect(Slack::Notifier).to receive(:new).with('http://some.slack.url', {}).and_return(true) UniformNotifier.slack = { :webhook_url => 'http://some.slack.url', :pizza => 'pepperoni' } expect(UniformNotifier::Slack.active?).to eq true end it 'should allow username and channel config options' do expect(Slack::Notifier).to receive(:new).with('http://some.slack.url', { :username => 'The Dude', :channel => '#carpets' }).and_return(true) UniformNotifier.slack = { :webhook_url => 'http://some.slack.url', :username => 'The Dude', :channel => '#carpets' } expect(UniformNotifier::Slack.active?).to eq true end end context 'properly configured' do before(:each) do @message = 'notify slack' allow_any_instance_of(Slack::Notifier).to receive(:ping).and_return(@message) end it 'should notify slack' do UniformNotifier.slack = { :webhook_url => 'http://some.slack.url' } expect_any_instance_of(Slack::Notifier).to receive(:ping) expect(UniformNotifier::Slack.out_of_channel_notify(:title => @message)).to eq @message end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
uniform_notifier-1.9.0 | spec/uniform_notifier/slack_spec.rb |
uniform_notifier-1.8.0 | spec/uniform_notifier/slack_spec.rb |
uniform_notifier-1.7.0 | spec/uniform_notifier/slack_spec.rb |