aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/mauve/configuration_builders/notification_method.rb4
-rw-r--r--lib/mauve/notifiers/debug.rb46
-rw-r--r--lib/mauve/notifiers/email.rb1
-rw-r--r--test/tc_mauve_configuration_builders_notification_method.rb16
4 files changed, 51 insertions, 16 deletions
diff --git a/lib/mauve/configuration_builders/notification_method.rb b/lib/mauve/configuration_builders/notification_method.rb
index 9596587..3f9283e 100644
--- a/lib/mauve/configuration_builders/notification_method.rb
+++ b/lib/mauve/configuration_builders/notification_method.rb
@@ -35,6 +35,10 @@ module Mauve
def result
@result ||= @provider_class.new(@name)
end
+
+ def debug!
+ result.extend(Mauve::Notifiers::Debug)
+ end
# This catches all methods available for a provider, as needed.
#
diff --git a/lib/mauve/notifiers/debug.rb b/lib/mauve/notifiers/debug.rb
index 775364d..417bc94 100644
--- a/lib/mauve/notifiers/debug.rb
+++ b/lib/mauve/notifiers/debug.rb
@@ -12,22 +12,42 @@ module Mauve
base.class_eval do
alias_method :send_alert_without_debug, :send_alert
alias_method :send_alert, :send_alert_to_debug_channels
-
- # Specifying deliver_to_file allows the administrator to ask for alerts
- # to be delivered to a particular file, which is assumed to be perused
- # by a person rather than a machine.
- #
- attr :deliver_to_file, true
-
- # Specifying deliver_to_queue allows a tester to ask for the send_alert
- # parameters to be appended to a Queue object (or anything else that
- # responds to <<).
- #
- attr :deliver_to_queue, true
end
end
+
+ def extended(base)
+ base.instance_eval do
+ alias :send_alert_without_debug :send_alert
+ alias :send_alert :send_alert_to_debug_channels
+ end
+ end
end
-
+
+
+ # Specifying deliver_to_file allows the administrator to ask for alerts
+ # to be delivered to a particular file, which is assumed to be perused
+ # by a person rather than a machine.
+ #
+ def deliver_to_file
+ @deliver_to_file
+ end
+
+ def deliver_to_file=(fn)
+ @deliver_to_file = fn
+ end
+
+ # Specifying deliver_to_queue allows a tester to ask for the send_alert
+ # parameters to be appended to a Queue object (or anything else that
+ # responds to <<).
+ #
+ def deliver_to_queue
+ @deliver_to_queue
+ end
+
+ def deliver_to_queue=(q)
+ @deliver_to_queue = q
+ end
+
def disable_normal_delivery!
@disable_normal_delivery = true
end
diff --git a/lib/mauve/notifiers/email.rb b/lib/mauve/notifiers/email.rb
index 8efdbec..5b8e9a0 100644
--- a/lib/mauve/notifiers/email.rb
+++ b/lib/mauve/notifiers/email.rb
@@ -97,7 +97,6 @@ module Mauve
m.to_s
end
- include Debug
end
end
end
diff --git a/test/tc_mauve_configuration_builders_notification_method.rb b/test/tc_mauve_configuration_builders_notification_method.rb
index e5e8475..80768e8 100644
--- a/test/tc_mauve_configuration_builders_notification_method.rb
+++ b/test/tc_mauve_configuration_builders_notification_method.rb
@@ -1,13 +1,25 @@
$:.unshift "../lib/"
require 'th_mauve'
-require 'pp'
+require 'mauve/configuration_builder'
require 'mauve/configuration_builders/notification_method'
class TcMauveConfigurationBuildersNotificationMethod < Mauve::UnitTest
- def test_load
+ def test_debug_methods
+ config =<<EOF
+notification_method("email") {
+ debug!
+ disable_normal_delivery!
+ deliver_to_queue []
+}
+EOF
+ x = nil
+ assert_nothing_raised { x = Mauve::ConfigurationBuilder.parse(config) }
+ y = x.notification_methods["email"]
+
+ # TODO test delivery
end
end