diff options
author | Patrick J Cherry <patrick@bytemark.co.uk> | 2011-08-18 18:11:10 +0100 |
---|---|---|
committer | Patrick J Cherry <patrick@bytemark.co.uk> | 2011-08-18 18:11:10 +0100 |
commit | 6aba0c3d8e2d30797755dc8b968fe338e13b8df4 (patch) | |
tree | a9c3a469146a47fe88e3a56c8bf40c0ed9b66288 /test/th_mauve.rb | |
parent | c30daf56d4aab9e41a993d82406cba947c8efe32 (diff) |
* Fixed up Alert to postpone raises/clears within initial sleep period for old alerts
* Fixed up AlertChanged to do the same
* Added a migration method for the new AlertHistories table
* added singleton cleanup for tests
* moar tests
* cleaned up Alert a bit
Diffstat (limited to 'test/th_mauve.rb')
-rw-r--r-- | test/th_mauve.rb | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/test/th_mauve.rb b/test/th_mauve.rb index a113ad0..76a4933 100644 --- a/test/th_mauve.rb +++ b/test/th_mauve.rb @@ -3,6 +3,27 @@ require 'mauve/datamapper' require 'timecop' require 'log4r' require 'pp' +require 'singleton' + +# Taken from +# +# http://blog.ardes.com/2006/12/11/testing-singletons-with-ruby +# +class <<Singleton + + def included_with_reset(klass) + included_without_reset(klass) + class <<klass + def reset_instance + Singleton.send :__init__, self + self + end + end + end + + alias_method :included_without_reset, :included + alias_method :included, :included_with_reset +end module Mauve class TestOutputter < Log4r::Outputter @@ -33,6 +54,7 @@ module Mauve class UnitTest < Test::Unit::TestCase def setup + reset_all_singletons setup_logger setup_time end @@ -40,6 +62,7 @@ module Mauve def teardown teardown_logger teardown_time + reset_all_singletons end def setup_logger @@ -81,6 +104,13 @@ module Mauve Timecop.return end + def reset_all_singletons + Mauve.constants.collect{|const| Mauve.const_get(const)}.each do |klass| + next unless klass.respond_to?(:instance) + klass.reset_instance + end + end + def default_test # # |