spec/resque/failure/pagerduty_spec.rb in resque-pagerduty-0.1.0 vs spec/resque/failure/pagerduty_spec.rb in resque-pagerduty-0.1.1

- old
+ new

@@ -152,18 +152,47 @@ it 'should call the pagerduty api with the correct exception backtrace in the details' do save a_request(:any, /.*\.pagerduty\.com/).with(:body => /"details":\{.*"exception":\{.*"backtrace":\["dummy_file.rb:23","dummy_file.rb:42"\].*\}.*\}/).should have_been_made end + it 'should trigger an incident with a description and details' do + pagerduty_client = double + Redphone::Pagerduty.stub(:new).with(hash_including( + :service_key => service_key, + :subdomain => '', + :user => '', + :password => '' + )).and_return(pagerduty_client) + + Resque::Failure::GeneratesPagerdutyDesc.stub(:execute). + with(exception, payload).and_return('Generated description') + + pagerduty_client.should_receive(:trigger_incident).with(hash_including( + :description => 'Generated description', + :details => { + :queue => queue, + :worker => worker.to_s, + :payload => payload, + :exception => { + :class => exception.class.name, + :message => exception.message, + :backtrace => exception.backtrace + } + } + )) + + save + end + end context 'when there is no service key' do it 'should not attempt to trigger an incident in pagerduty' do save a_request(:any, /.*.pagerduty.com/).should_not have_been_made end end - end + end # end describe #save it { should respond_to(:log) } end describe 'class methods' do