Make resque job specs specific about what error should be raised; fix expectation on hoptoad notifier

This commit is contained in:
Raphael Sofaer 2011-08-10 16:36:42 -07:00
parent 091cdd6f94
commit 3431cd94fb

View file

@ -25,18 +25,19 @@ describe ResqueJobLogging do
end end
it 'logs stack traces on failure' do it 'logs stack traces on failure' do
Rails.logger.should_receive(:info).with(/app_backtrace=/) Rails.logger.should_receive(:info).with(/app_backtrace=/)
error = RuntimeError.new("GRAAAAAAAAAGH")
proc { proc {
ResqueJobLoggingDummy.around_perform_log_job("stuff"){raise "GRAAAAAAAAAGH"} ResqueJobLoggingDummy.around_perform_log_job("stuff"){raise error}
}.should raise_error }.should raise_error(Regexp.new(error.message))
end end
it 'notifies hoptoad if the hoptoad api key is set' do it 'notifies hoptoad if the hoptoad api key is set' do
Rails.logger.should_receive(:info) Rails.logger.should_receive(:info)
AppConfig.should_receive(:[]).with(:hoptoad_api_key).and_return("what") AppConfig.should_receive(:[]).with(:hoptoad_api_key).and_return("what")
error = RuntimeError.new("GRAAAAAAAAAGH") error = RuntimeError.new("GRAAAAAAAAAGH")
ResqueJobLoggingDummy.should_receive(:notify_hoptoad).with(error, ["stuff"], anything) ResqueJobLoggingDummy.should_receive(:notify_hoptoad).with(error, ["stuff"])
proc { proc {
ResqueJobLoggingDummy.around_perform_log_job("stuff"){raise error } ResqueJobLoggingDummy.around_perform_log_job("stuff"){raise error }
}.should raise_error }.should raise_error(Regexp.new(error.message))
end end
end end