Skip to content

Commit

Permalink
Write RSpec for manually notify
Browse files Browse the repository at this point in the history
  • Loading branch information
pocke authored and morygonzalez committed Feb 21, 2016
1 parent 7e3147c commit 42a3069
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions spec/exception_notification/slacky_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -93,5 +93,40 @@
it { expect(slack_notifier.notifier.username).to eq('slacky') }
it { expect(slack_notifier.notifier.default_payload[:additional_parameters][:icon_emoji]).to eq(':warning:') }
end

context 'when manually' do
let(:rack_options) do
{
env: {}
}
end


describe 'Notification format' do
before do
fields = fake_notification.last[:attachments][0][:fields]
fields[1][:value] = "" # Request Path
fields[2][:value] = nil # HTTP Method
fields[3][:value] = nil # IP Address
fields[4][:value] = nil # User Agent
end

it {
allow_any_instance_of(Slack::Notifier).to receive(:ping).with(*fake_notification)
slack_notifier.call(exception, rack_options)
}
end

describe 'Options' do
before do
stub_request(:any, options[:webhook_url])
slack_notifier.call(exception, rack_options)
end

it { expect(slack_notifier.notifier.channel).to eq('#general') }
it { expect(slack_notifier.notifier.username).to eq('slacky') }
it { expect(slack_notifier.notifier.default_payload[:additional_parameters][:icon_emoji]).to eq(':warning:') }
end
end
end
end

0 comments on commit 42a3069

Please sign in to comment.