Can you execute assert_equal from within irb? This does not work.
require 'test/unit'
assert_equal(5,5)
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Sure you can!
What’s going on is that all the assertions are methods in the Test::Unit::Assertions module. Extending that module from inside irb makes those methods available as class methods on
main, which allows you to call them directly from your irb prompt. (Really, callingextend SomeModulein any context will put the methods in that module somewhere you can call them from the same context –mainjust happens to be where you are by default.)Also, since the assertions were designed to be run from within a
TestCase, the semantics might be a little different than expected: instead of returning true or false, it returns nil or raises an error.