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

With reference to the previous thread
http://groups.google.com/group/comp.lang.ruby/browse_thread/thread/0402853c3617e243#
(“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
to_s
end
end

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?

Thanks
MM

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