From: Daniel Berger Date: 2007-06-22T06:01:15+09:00 Subject: Re: Performing $SAFE checks with test-unit On Jun 21, 2:50 pm, Nobuyoshi Nakada wrote: > Hi, > > At Fri, 22 Jun 2007 00:44:37 +0900, > Daniel Berger wrote in [ruby-talk:256413]: > > > Is there a way to perform $SAFE checks with test-unit? I tried this > > with Ruby 1.8.6: > > def test_replace_in_safe_mode > o = {1,2,3,4} > assert_raise(SecurityError) do > proc do > $SAFE = 4 > o.replace({'a', 'b'}) > end.call > end > end Nice, thanks Nobu. Perhaps all assertions should run in anonymous blocks? It's probably slower, but then I've never cared about the speed of my unit tests. Or is there some other downside to doing that? Regards, Dan