Sha256: 6c15809939ca445f2c4f53429c33196f4a1aeab8fb0b00d72fcea5e9011ab6a1
Contents?: true
Size: 1.72 KB
Versions: 5
Compression:
Stored size: 1.72 KB
Contents
require 'spec_helper' require 'honeybadger/monitor' begin require 'delayed_job' DELAYED_JOB_INSTALLED = true rescue LoadError DELAYED_JOB_INSTALLED = false nil end if DELAYED_JOB_INSTALLED # Prepend the load path with delayed_job's spec directory so that we can take # advantage of their test backend: # https://github.com/collectiveidea/delayed_job/blob/master/spec/delayed/backend/test.rb $:.unshift(File.join(Gem::Specification.find_by_name('delayed_job').full_gem_path, 'spec')) Delayed::Worker.backend = :test class ExceptionTester def null_method end def will_raise raise "raised from will_raise" end end describe "DelayedJob integration" do let(:worker) { Delayed::Worker.new } before { Honeybadger::Dependency.inject! } after { Delayed::Job.delete_all } context "when a method is delayed" do let(:method_name) { :null_method } before { ExceptionTester.new.delay.send(method_name) } specify { expect(Delayed::Job.count).to eq 1 } it "queues a new trace" do trace_id = nil Honeybadger::Monitor.worker.should_receive(:queue_trace).once.and_return do # This ensures that Honeybadger::Monitor.worker.trace is not nil when # it's queued from the worker. There may still be an edge case where # that's possible. (see #84) trace_id = Thread.current[:hb_trace_id] end worker.work_off expect(trace_id).not_to be_nil end context "and an exception occurs" do let(:method_name) { :will_raise } after { worker.work_off } it "notifies Honeybadger" do Honeybadger.should_receive(:notify_or_ignore).once end end end end end
Version data entries
5 entries across 5 versions & 1 rubygems