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

  • SEARCH
  • Home
  • 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 7896461
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T07:54:02+00:00 2026-06-03T07:54:02+00:00

I have a test in Ruby as follows def testSomeObjectsAreEqual assert_equal( object1, object2 )

  • 0

I have a test in Ruby as follows

def testSomeObjectsAreEqual
  assert_equal( object1, object2 )
end

When this test fails I get an error message which states that the two objects are not equal and gives the following style of message for the expected and actual values:

<#<Java:com.mynamespace.MyClass:0x1232b3e12>> expected but was
<#<Java:com.mynamespace.MyClass:0x489654ebd>>.

As you can see I am using JRuby to instantiate a Java class and that is the object being compared. I’ve trying printing object.to_s in Ruby and that prints a sensible looking message, it seems to map directly to the Java declared toString() method for MyClass, however to_s does not seem to be used for the failure message of the assertion. Is there anyway I can get Ruby test/unit to use the to_s value of the objects as this would make the failure messages much more useful for me?

  • 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-06-03T07:54:03+00:00Added an answer on June 3, 2026 at 7:54 am

    Test::Unit (I presume that is what you are using) uses #pretty_inspect to convert objects into printable form. You can override/monkeypatch this for your class; you only need to do so in the test script.

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

Sidebar

Related Questions

Say I have this Ruby code in test.rb module MyModule class TestClassA end class
so i have ruby script that simply writes to a test.txt file with hello
I have a test winforms app with ThreadExceptionHandler that displays a message box when
I have a test which looks a bit like this (I'm simplifying a bit
I have installed rvm (mutiuser option) and ruby using rvm install on my test
I'm new to ruby so forgive me if this is simple or I get
my Ruby On Rails unit-test fails in a simple string comparison and I can't
I have a test environment that uses Ruby to drive a server over an
I have the following files in this directory: ~/test/lib/liblost.dylib ~/test/include/lost.h I am trying to
I have the following test Ruby script: require 'tempfile' tempfile = Tempfile.new 'test' $stderr.reopen

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.