Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why 'undefined method `assert_equal' ' is thrown even after requiring 'test/unit'

Tags:

I opened irb & entered:

require 'test/unit'

but when I used the assert_equal method, I got following error: NoMethodError: undefined method 'assert_equal' for main:Object. Why is this happening even after requiring 'test/unit' ?

like image 424
Alpha Avatar asked Sep 07 '12 12:09

Alpha


1 Answers

assert_equal is defined on subclasses of Test::Unit::TestCase, so are only available in that class. You may have some success with include Test::Unit::TestCase to load those methods onto the current scope.

More likely you could be better writing your tests in a short file, and running them with ruby ./my_file.rb

like image 181
Lee Hambley Avatar answered Sep 27 '22 16:09

Lee Hambley