forked from exceptional/exceptional
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdj_integration_spec.rb
More file actions
51 lines (47 loc) · 1.81 KB
/
dj_integration_spec.rb
File metadata and controls
51 lines (47 loc) · 1.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
require File.dirname(__FILE__) + '/spec_helper'
describe "Delayed Job integration for DJ < 1.8.5" do
before do
module Delayed
class Worker
end
end
end
it "should report the lack of support to STDERR" do
STDERR.should_receive(:puts).with("\n\n\nThe Exceptional gem does not support Delayed Job 1.8.4 or earlier.\n\n\n")
load File.join(File.dirname(__FILE__), '..', 'lib', 'exceptional', 'integration', 'dj.rb')
end
it "should report the lack of support to Exceptional.logger" do
STDERR.stub(:puts)
Exceptional.logger.should_receive(:error).with("\n\n\nThe Exceptional gem does not support Delayed Job 1.8.4 or earlier.\n\n\n")
load File.join(File.dirname(__FILE__), '..', 'lib', 'exceptional', 'integration', 'dj.rb')
end
end
describe 'Delayed Job integration' do
before :each do
Exceptional::Config.stub!(:should_send_to_api?).and_return(true)
Exceptional.stub(:handle)
module Delayed
class Worker
def handle_failed_job(job, exception); end
end
end
load File.join(File.dirname(__FILE__), '..', 'lib', 'exceptional', 'integration', 'dj.rb')
@worker = Delayed::Worker.new
@exception = StandardError.new
@job = mock(:name => "My delayed job")
end
describe "For Delayed Job > 1.8.5" do
it "should handle exceptions with Exceptional" do
Exceptional.should_receive(:handle).with(@exception, 'Delayed::Job My delayed job')
@worker.handle_failed_job(@job, @exception)
end
it "should clear context" do
Exceptional.should_receive(:clear!)
@worker.handle_failed_job(@job, @exception)
end
it "should invoke the original handle_failed_job" do
@worker.should_receive(:handle_failed_job_without_exceptional).with(@job, @exception)
@worker.handle_failed_job(@job, @exception)
end
end
end