mirror of
https://github.com/jimeh/airbrake-statsd.git
synced 2026-02-19 10:56:43 +00:00
hook into the airbrake gem in a cleaner and simpler way
This commit is contained in:
@@ -4,58 +4,33 @@ describe Airbrake do
|
||||
|
||||
subject { Airbrake }
|
||||
|
||||
it '#notify is an alias to #notify_with_statsd' do
|
||||
subject.method(:notify).should == subject.method(:notify_with_statds)
|
||||
let(:notice) { mock('Notice', :to_xml => '') }
|
||||
let(:configuration) { mock('Configuration', :public? => true) }
|
||||
|
||||
let(:sender) do
|
||||
sender = mock('Sender')
|
||||
sender.stub(:send_to_airbrake)
|
||||
sender
|
||||
end
|
||||
|
||||
it '#notify_or_ignore is an alias to #notify_or_ignore_with_statsd' do
|
||||
subject.method(:notify_or_ignore).
|
||||
should == subject.method(:notify_or_ignore_with_statsd)
|
||||
end
|
||||
describe '#send_notice_without_statsd' do
|
||||
before do
|
||||
Airbrake.stub(:configuration).and_return(configuration)
|
||||
Airbrake.stub(:sender).and_return(sender)
|
||||
end
|
||||
|
||||
describe '#notify_without_statsd' do
|
||||
it 'does not call Airbrake::Statsd.increment' do
|
||||
Airbrake.stub(:send_notice).and_return(nil)
|
||||
|
||||
Airbrake.should_receive(:build_notice_for).with('oops', {})
|
||||
Airbrake::Statsd.should_not_receive(:increment)
|
||||
|
||||
Airbrake.notify_without_statsd('oops', {})
|
||||
Airbrake.send(:send_notice_without_statsd, notice)
|
||||
end
|
||||
end
|
||||
|
||||
describe '#notify' do
|
||||
describe '#send_notice' do
|
||||
it 'calls Airbrake::Statsd.increment' do
|
||||
Airbrake.stub(:send_notice).and_return(nil)
|
||||
|
||||
Airbrake.should_receive(:build_notice_for).with('oops', {})
|
||||
Airbrake::Statsd.should_receive(:increment)
|
||||
Airbrake.should_receive(:send_notice_without_statsd)
|
||||
|
||||
Airbrake.notify('oops', {})
|
||||
end
|
||||
end
|
||||
|
||||
describe '#notify_or_ignore_without_statsd' do
|
||||
it 'does not call Airbrake::Statsd.increment' do
|
||||
Airbrake.stub(:send_notice).and_return(nil)
|
||||
|
||||
Airbrake.should_receive(:build_notice_for).with('oops', {}).
|
||||
and_return(mock('Notice', :ignore? => false))
|
||||
Airbrake::Statsd.should_not_receive(:increment)
|
||||
|
||||
Airbrake.notify_or_ignore_without_statsd('oops', {})
|
||||
end
|
||||
end
|
||||
|
||||
describe '#notify_or_ignore' do
|
||||
it 'calls Airbrake::Statsd.increment' do
|
||||
Airbrake.stub(:send_notice).and_return(nil)
|
||||
|
||||
Airbrake.should_receive(:build_notice_for).with('oops', {}).
|
||||
and_return(mock('Notice', :ignore? => false))
|
||||
Airbrake::Statsd.should_receive(:increment)
|
||||
|
||||
Airbrake.notify_or_ignore('oops', {})
|
||||
Airbrake.send(:send_notice, notice)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user