From: "R. Bernstein" Date: 2008-01-19T00:14:54+09:00 Subject: Avoiding Copy errors in Test::Unit (PATCH to Test::Unit::TestCase) --WQzuzlFMhi Content-Type: text/plain; charset=us-ascii Content-Description: message body text Content-Transfer-Encoding: 7bit I use Test::Unit a lot, and a lot of the times I create a new test by taking an old test, copy that to a new file and start modifying it. The problem is that I sometimes forget to change the class name. When this happens, tests still work but one class of tests has silently been discarded. A colleague, Martin Davis, came up with this simple, short monkeypatch to hook onto method_added to check for this condition. It works very well. I think this would be a great addition to Test::Unit::TestCase in test/unit/testcase.rb Until then, here's a little file you can load/require: --WQzuzlFMhi Content-Type: application/octet-stream Content-Description: Alert when Test::Unit test methods have been redefined. Content-Disposition: attachment; filename="test_helper.rb" Content-Transfer-Encoding: base64 IyBSZWFsbHkgY29vbCBjb2RlIGZyb20gTWFydGluIERhdmlzLgpjbGFzcyBUZXN0OjpVbml0OjpU ZXN0Q2FzZQogICMgVGhpcyBjYXVzZXMgYW4gZXhjZXB0aW9uIHRvIGJlIHRocm93biB3aGVuIGEg dGVzdCBjbGFzcyBkZWZpbmVzIHRoZSBzYW1lIG1ldGhvZCB0d2ljZQogIGNsYXNzIDw8IHNlbGYK ICAgIGFsaWFzIDpvbGRfbWV0aG9kX2FkZGVkIDptZXRob2RfYWRkZWQKICAgIGRlZiBtZXRob2Rf YWRkZWQobWV0aCkKICAgICAgb2xkX21ldGhvZF9hZGRlZChtZXRoKQogICAgICBpZiBtZXRoLnRv X3MgPX4gL150ZXN0Xy8KICAgICAgICBAQHRlc3RfbWV0aG9kcyB8fD0ge30KICAgICAgICBAQHRl c3RfbWV0aG9kc1tzZWxmXSB8fD0ge30KICAgICAgICBpZiBAQHRlc3RfbWV0aG9kc1tzZWxmXS5o YXNfa2V5PyhtZXRoKQogICAgICAgICAgbGluZSA9ICcqJyAqIDgwCiAgICAgICAgICB3YXJuICJc biN7bGluZX1cbllvdSBoYXZlIHJlZGVmaW5lZCAje3NlbGZ9XCMje21ldGh9IG11bHRpcGxlIHRp bWVzLlxuI3tsaW5lfSIKICAgICAgICBlbHNlCiAgICAgICAgICBAQHRlc3RfbWV0aG9kc1tzZWxm XVttZXRoXSA9IHRydWUKICAgICAgICBlbmQKICAgICAgZW5kCiAgICBlbmQKICBlbmQKZW5kCg== --WQzuzlFMhi--