new
obj2 = obj1
obj3 = Artest.new
assert_same obj1, obj2
assert_same obj1, obj3
end
end
assert_not_same
This method is simply the inverse of the assert_same method.
Again, the important thing to remember with this method is that you are really comparing
object_id values. It??™s also important to remember that in this case, you are checking that
the objects do not have the same object_id value??”only when the IDs are different does the
test actually pass.
In our example, our first assertion should pass, because our first and third objects are, in
fact, associated to different object_id values. However, our second assertion will fail, because
our first and second objects are associated to the same object_id value.
# test_artest.rb Unit Test example
require 'artest'
require 'test/unit'
class TestArtest < Test::Unit::TestCase
def test_simple
obj1 = Artest.new
obj2 = obj1
obj3 = Artest.new
assert_same obj1, obj3
assert_same obj1, obj2
end
end
assert_operator
The assert_operator method compares two given objects using the given operator.
Pages:
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316