Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Joshua Wood
committed
Apr 24, 2015
1 parent
e59037e
commit c47af25
Showing
3 changed files
with
51 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
class UniformNotifier | ||
class HoneybadgerNotifier < Base | ||
def self.active? | ||
!!UniformNotifier.honeybadger | ||
end | ||
|
||
protected | ||
|
||
def self._out_of_channel_notify(data) | ||
message = data.values.compact.join("\n") | ||
|
||
opt = {} | ||
if UniformNotifier.honeybadger.is_a?(Hash) | ||
opt = UniformNotifier.honeybadger | ||
end | ||
|
||
exception = Exception.new(message) | ||
Honeybadger.notify(exception, opt) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
require "spec_helper" | ||
|
||
class Honeybadger | ||
# mock Honeybadger | ||
end | ||
|
||
describe UniformNotifier::HoneybadgerNotifier do | ||
it "should not notify honeybadger" do | ||
expect(UniformNotifier::HoneybadgerNotifier.out_of_channel_notify(:title => "notify honeybadger")).to be_nil | ||
end | ||
|
||
it "should notify honeybadger" do | ||
expect(Honeybadger).to receive(:notify).with(UniformNotifier::Exception.new("notify honeybadger"), {}) | ||
|
||
UniformNotifier.honeybadger = true | ||
UniformNotifier::HoneybadgerNotifier.out_of_channel_notify(:title => "notify honeybadger") | ||
end | ||
|
||
it "should notify honeybadger" do | ||
expect(Honeybadger).to receive(:notify).with(UniformNotifier::Exception.new("notify honeybadger"), :foo => :bar) | ||
|
||
UniformNotifier.honeybadger = { :foo => :bar } | ||
UniformNotifier::HoneybadgerNotifier.out_of_channel_notify("notify honeybadger") | ||
end | ||
end |