summaryrefslogtreecommitdiff
path: root/lib/custodian/testfactory.rb
diff options
context:
space:
mode:
authorIan Chilton <ian.chilton@bytemark.co.uk>2018-02-28 13:07:54 +0000
committerIan Chilton <ian.chilton@bytemark.co.uk>2018-02-28 13:07:54 +0000
commitc42a0bef7d7194989cdacc317409fa4ac0b802a0 (patch)
treed0c759084b69d6f2220ca0265f34b9979a1c0b80 /lib/custodian/testfactory.rb
parent25b1792c7adca856bedadbeae1fa4de7972c8b5b (diff)
parent1f3d5467758529812601111b8b4fdf2566abd3d4 (diff)
Merge branch '21-allow-custom-subjects' into 'master'
Resolve "Feature: allow specifying `with subject 'foo'` in checks to declare what the Subject should be" Closes #21 See merge request open-source/custodian!15
Diffstat (limited to 'lib/custodian/testfactory.rb')
-rw-r--r--lib/custodian/testfactory.rb27
1 files changed, 26 insertions, 1 deletions
diff --git a/lib/custodian/testfactory.rb b/lib/custodian/testfactory.rb
index db3f339..358e676 100644
--- a/lib/custodian/testfactory.rb
+++ b/lib/custodian/testfactory.rb
@@ -99,10 +99,21 @@ module Custodian
#
# We do this only after we've instantiated the test.
#
- if line =~ /\s+otherwise\s+'([^']+)'/
+ if line =~ /\s+otherwise\s+'([^']+)'/
obj.set_notification_text($1.dup)
end
+
+ #
+ # Some tests will replace their subject.
+ #
+ #
+ if line =~ /\s+with\s+subject\s+'([^']+)'/
+ obj.set_subject($1.dup)
+ else
+ obj.set_subject( nil )
+ end
+
#
# Is the test inverted?
#
@@ -168,6 +179,20 @@ module Custodian
end
+ #
+ # If this test has a custom subject then return it
+ #
+ def get_subject
+ @subject
+ end
+
+
+ #
+ # Setup a custom subject for the (mauve) alert we raise
+ #
+ def set_subject( subject )
+ @subject = subject
+ end
#