-
-
Save addisonj/107b80bb8cd02437dff8 to your computer and use it in GitHub Desktop.
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
diff --git a/lib/uniform_notifier.rb b/lib/uniform_notifier.rb | |
index f362948..41e4022 100644 | |
--- a/lib/uniform_notifier.rb | |
+++ b/lib/uniform_notifier.rb | |
@@ -42,5 +42,13 @@ module UniformNotifier | |
def raise=(exception_class) | |
UniformNotifier::Raise.setup_connection(exception_class) | |
end | |
+ | |
+ def add_notifier(logger) | |
+ NOTIFIERS << logger | |
+ end | |
+ | |
+ def notifiers | |
+ NOTIFIERS | |
+ end | |
end | |
end | |
diff --git a/spec/uniform_notifier/base_spec.rb b/spec/uniform_notifier/base_spec.rb | |
index 1c1adad..8820983 100644 | |
--- a/spec/uniform_notifier/base_spec.rb | |
+++ b/spec/uniform_notifier/base_spec.rb | |
@@ -19,4 +19,31 @@ describe UniformNotifier::Base do | |
UniformNotifier::Base.out_of_channel_notify("something") | |
end | |
end | |
+ context "#add_notifier" do | |
+ class MyNotifier < UniformNotifier::Base | |
+ | |
+ def self.active? | |
+ true | |
+ end | |
+ | |
+ protected | |
+ | |
+ def self._out_of_channel_notify(data) | |
+ end | |
+ end | |
+ before do | |
+ UniformNotifier::add_notifier(MyNotifier) | |
+ end | |
+ it "should have added a new notifier to the list of notifiers" do | |
+ expect(UniformNotifier.notifiers).to include(MyNotifier) | |
+ end | |
+ it "should have the custom notifier be called" do | |
+ data = { | |
+ title: 'test', | |
+ body: 'hello' | |
+ } | |
+ MyNotifier.should_receive(:_out_of_channel_notify).once.with(data) | |
+ MyNotifier.out_of_channel_notify(data) | |
+ end | |
+ end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment