Sun Jul 29 12:20:31 EST 2007 Matt Palmer * Add a custom assertion, 'assert_no_rbot_errors', so that you can make sure that no calls to error or warning were made during the test run. Also doc needs_mocha a bit better. diff -rN -u old-trac_urls/test/lib/test_helper.rb new-trac_urls/test/lib/test_helper.rb --- old-trac_urls/test/lib/test_helper.rb 2008-10-20 23:31:04.303857622 +1100 +++ new-trac_urls/test/lib/test_helper.rb 2008-10-20 23:31:04.323857047 +1100 @@ -43,6 +43,7 @@ # def load_plugin(plugin) @bot.pluginmanager.load_module(plugin) + assert_no_rbot_errors end # Load a plugin from a string literal. Unlikely to have much of a @@ -59,13 +60,23 @@ File.unlink(tmpfile) end - def self.needs_mocha + # Assert that rbot has not put any errors/warnings into the log file. + def assert_no_rbot_errors + assert_equal [], $rbotlog['error'], "RBot has thrown an error!" + assert_equal [], $rbotlog['warning'], "RBot has thrown a warning!" + end + + # Wraps a block of code such that, if the Mocha mock objects library is + # not available, the block will not be run. Can be used both in test + # classes as well as test methods. + def needs_mocha if defined?(Mocha::Mock) yield if block_given? end end - def needs_mocha + # The class level version + def self.needs_mocha #:nodoc: if defined?(Mocha::Mock) yield if block_given? end