why assert_equal() in Ruby on Rails sometimes seem to compare by Identity and sometimes by value?
Posted
by Jian Lin
on Stack Overflow
See other posts from Stack Overflow
or by Jian Lin
Published on 2010-06-08T18:50:13Z
Indexed on
2010/06/08
19:02 UTC
Read the original article
Hit count: 169
it was very weird that yesterday, I was do an integration test in Rails and
assert_equal array_of_obj1, array_of_obj2 # obj1 from db, obj2 created in test
and it failed. The values shown inside the array and objects were identical. If I change the test to
assert array_of_obj1 == array_of_obj2
Then it will pass.
But today, the first test actually passed. What reason could it be? Is assert_equal always using ==
or .equal?
in Rails 2.2 or 2.3.5?
© Stack Overflow or respective owner