Problems overriding Date#inspect in a file required in a test

With reference to the previous thread
(“change usage of pp in Test::Unit assertions”), I’m finding something
that I consider very odd.

Basically, I wanted to override Date#inspect in one place only, a
small and nice common.rb file that I include anywhere else. For the
same reasons, I wanted to say use_pp=false there only.

This is the content of common.rb file:
class Date
def inspect

Test::Unit::Assertions.use_pp = false

It seems that if I require this file in my test, nothing changes, Date
instances are still printed using PP. The only way to make it work is
through overriding inspect directly in the test file.

Is there something obvious about require and test/unit that I’m
missing here?


This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs