mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Report the correct value of nil.id in the exception message
as different ruby implementations may have different values, for example Rubinius returns 53 for nil.id. [#6444 state:resolved]
This commit is contained in:
parent
31f09f9dbc
commit
5e7ce47fb9
2 changed files with 3 additions and 1 deletions
|
@ -37,7 +37,7 @@ class NilClass
|
|||
|
||||
# Raises a RuntimeError when you attempt to call +id+ on +nil+.
|
||||
def id
|
||||
raise RuntimeError, "Called id for nil, which would mistakenly be 4 -- if you really wanted the id of nil, use object_id", caller
|
||||
raise RuntimeError, "Called id for nil, which would mistakenly be #{object_id} -- if you really wanted the id of nil, use object_id", caller
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
@ -33,9 +33,11 @@ class WhinyNilTest < Test::Unit::TestCase
|
|||
end
|
||||
|
||||
def test_id
|
||||
nil.stubs(:object_id).returns(999)
|
||||
nil.id
|
||||
rescue RuntimeError => nme
|
||||
assert_no_match(/nil:NilClass/, nme.message)
|
||||
assert_match(/999/, nme.message)
|
||||
end
|
||||
|
||||
def test_no_to_ary_coercion
|
||||
|
|
Loading…
Reference in a new issue