Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

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.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1958002
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T07:57:29+00:00 2026-05-17T07:57:29+00:00

Can you execute assert_equal from within irb? This does not work. require ‘test/unit’ assert_equal(5,5)

  • 0

Can you execute assert_equal from within irb? This does not work.

require 'test/unit'
assert_equal(5,5)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T07:57:29+00:00Added an answer on May 17, 2026 at 7:57 am

    Sure you can!

    require 'test/unit'
    extend Test::Unit::Assertions
    assert_equal 5, 5                # <= nil
    assert_equal 5, 6                # <= raises AssertionFailedError
    

    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, calling extend SomeModule in any context will put the methods in that module somewhere you can call them from the same context – main just 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.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In the unit tests that I wrote, I provide a test fixture for each
Can JPQL execute LIKE expressions against enums? If I have an entity Foo with
I know you can execute a Job in SQL Server 2005/2008 by sending a
I would like to know how I can execute a Python (or Lua etc)
As I understand, with JUnit 4.x and its annotation org.junit.runners.Parameterized I can make my
I'm in troubles with TransactionPropagation.NotSupported. I believed that this propagation causes that the code
How do I ensure in a JUnit test case, that all the the threads
Consider the following test snippet: // act AutoResetEvent workDoneEvent = new AutoResetEvent(false); ThreadPool.QueueUserWorkItem(delegate {
I'm wondering how to best implement a property (here, LatestRequest ) which is read-only,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.