Sha256: d1f9cb1ec9a62df3cc636203596e2d5b8c9b88f0af4ad7486b4cd65f79be88cb
Contents?: true
Size: 2 KB
Versions: 2
Compression:
Stored size: 2 KB
Contents
require 'spec_helper' RSpec.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(:example) 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
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
uniform_notifier-1.11.0 | spec/uniform_notifier/slack_spec.rb |
uniform_notifier-1.10.0 | spec/uniform_notifier/slack_spec.rb |