-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathreporter_spec.rb
More file actions
76 lines (62 loc) · 2.28 KB
/
Copy pathreporter_spec.rb
File metadata and controls
76 lines (62 loc) · 2.28 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
require 'spec_helper'
describe Adhearsion::Reporter do
EventClass = Class.new
ExceptionClass = Class.new StandardError
context "with a DummyNotifier" do
class DummyNotifier
include Singleton
attr_reader :initialized, :notified
def init
@initialized = true
end
def notify(ex)
@notified = ex
end
end
before(:each) do
Adhearsion::Reporter.config.notifier = DummyNotifier
Adhearsion::Plugin.init_plugins
Adhearsion::Events.trigger_immediately :exception, ExceptionClass.new
end
it "calls init on the notifier instance" do
Adhearsion::Reporter.config.notifier.instance.initialized.should == true
end
it "logs an exception event" do
sleep 0.25
Adhearsion::Reporter.config.notifier.instance.notified.class.should == ExceptionClass
end
end
context "with a HoptoadNotifier" do
before(:each) do
Adhearsion::Reporter.config.notifier = Adhearsion::Reporter::HoptoadNotifier
end
it "should initialize correctly" do
Toadhopper.should_receive(:new).with(Adhearsion::Reporter.config.api_key, notify_host: Adhearsion::Reporter.config.url)
Adhearsion::Plugin.init_plugins
end
it "should notify Airbrake" do
mock_notifier = double('notifier')
Toadhopper.should_receive(:new).and_return(mock_notifier)
event_error = ExceptionClass.new
mock_notifier.should_receive(:post!).at_least(:once).with(event_error).and_return(double('response').as_null_object)
Adhearsion::Plugin.init_plugins
Adhearsion::Events.trigger_immediately :exception, event_error
end
end
context "with a NewrelicNotifier" do
before(:each) do
Adhearsion::Reporter.config.notifier = Adhearsion::Reporter::NewrelicNotifier
end
it "should initialize correctly" do
NewRelic::Agent.should_receive(:manual_start).with(Adhearsion::Reporter.config.newrelic.to_hash)
Adhearsion::Plugin.init_plugins
end
it "should notify Newrelic" do
NewRelic::Agent.should_receive(:manual_start)
event_error = ExceptionClass.new
NewRelic::Agent.should_receive(:notice_error).at_least(:once).with(event_error)
Adhearsion::Plugin.init_plugins
Adhearsion::Events.trigger_immediately :exception, event_error
end
end
end