Forum: Ruby Test::Unit mixup

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Warren S. (Guest)
on 2006-03-13 21:21
(Received via mailing list)
Suddenly test::unit is failing for me.  The following 2-line script
comes up with

"testu.rb:2: undefined method `assert' for main:Object (NoMethodError)"

testu.rb contains:

 1: require 'test/unit'
 2: assert(1==1)

What have I broken or forgot?
ruby 1.8.2 (2004-12-25) [i386-mswin32]

It fails the same way under irb.

Warren
Pit C. (Guest)
on 2006-03-13 21:46
(Received via mailing list)
Warren S. schrieb:
> ruby 1.8.2 (2004-12-25) [i386-mswin32]
Hi Warren,

normally the assert methods are accessible in subclasses of
Test::Unit::TestCase. You could change your code to

   require 'test/unit'
   class AssertionTest < Test::Unit::TestCase
     def test_assert
       assert(1==1)
     end
   end

If you want to use assertions outside of testcases, look at module
Test::Unit::Assertions.

Regards,
Pit
This topic is locked and can not be replied to.