On Sat, Aug 30, 2008 at 2:40 PM, Adam Akhtar <adamtemporary / gmail.com> wrote: > hi is it possible to use assert in your actual code i.e. not just in the > unit test but in say your class methods etc. > > I tried to use it but ruby complains its not a recognised method for my > class. (i made sure to write require 'test/unit' at the top of my class > file.) > > Unit testing is great for checking what methods return but Id also like > to check whats going on inside sometimes. Having the program stop and > tell me when something i didnt expect will also help to prevent bugs. > > Is it possible. I googled and checked previous posts here but couldnt > find anything. > -- > Posted via http://www.ruby-forum.com/. > > 508/8 > ruby -rtest/unit/assertions -e 'include Test::Unit::Assertions; assert 41 > 42' /usr/local/lib/ruby/1.8/test/unit/assertions.rb:48:in `assert_block': <false> is not true. (Test::Unit::AssertionFailedError) from /usr/local/lib/ruby/1.8/test/unit/assertions.rb:500:in `_wrap_assertion' from /usr/local/lib/ruby/1.8/test/unit/assertions.rb:46:in `assert_block' from /usr/local/lib/ruby/1.8/test/unit/assertions.rb:63:in `assert' from /usr/local/lib/ruby/1.8/test/unit/assertions.rb:495:in `_wrap_assertion' from /usr/local/lib/ruby/1.8/test/unit/assertions.rb:61:in `assert' from -e:1 HTH Robert -- http://ruby-smalltalk.blogspot.com/ There's no one thing that's true. It's all true. -- Ernest Hemingway