Skip to content

Commit

Permalink
Fix test incorrectly failing under Rubinius 1.0.
Browse files Browse the repository at this point in the history
This test imposed too many constraints. It appears that
Object#inspect legitimately calls Object#object_id in Rubinius.
But we're only interested in what 'id' methods
Mocha::ObjectMethods#mocha_inspect calls. By stubbing
Object#inspect we can relax the constraints imposed by the test.
  • Loading branch information
floehopper committed May 15, 2010
1 parent eed5ff3 commit 668b358
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions test/unit/object_inspect_test.rb
Expand Up @@ -23,15 +23,16 @@ class << object
end

def test_should_use_underscored_id_instead_of_object_id_or_id_so_that_they_can_be_stubbed
calls = []
object = Object.new
object.define_instance_accessor(:called)
object.called = false
object.replace_instance_method(:object_id) { self.called = true; 1 }
if RUBY_VERSION < '1.9'
object.replace_instance_method(:id) { self.called = true; 1 }
end
object.replace_instance_method(:id) { calls << :id; return 1 } if RUBY_VERSION < '1.9'
object.replace_instance_method(:object_id) { calls << :object_id; return 1 }
object.replace_instance_method(:__id__) { calls << :__id__; return 1 }
object.replace_instance_method(:inspect) { "object-description" }

object.mocha_inspect
assert_equal false, object.called

assert_equal [:__id__], calls.uniq
end

end

0 comments on commit 668b358

Please sign in to comment.