Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid calling Kernel#format from ObjectMethods#mocha_inspect #345

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/mocha/inspect.rb
100644 → 100755
Expand Up @@ -5,7 +5,7 @@ module ObjectMethods
def mocha_inspect
address = __id__ * 2
address += 0x100000000 if address < 0
inspect =~ /#</ ? "#<#{self.class}:0x#{format('%x', address)}>" : inspect
inspect =~ /#</ ? "#<#{self.class}:0x#{Kernel.format('%x', address)}>" : inspect
end
end

Expand Down
10 changes: 10 additions & 0 deletions test/unit/object_inspect_test.rb
100644 → 100755
Expand Up @@ -45,4 +45,14 @@ def test_should_use_underscored_id_instead_of_object_id_or_id_so_that_they_can_b

assert_equal [:__id__], calls.uniq
end

def test_should_not_call_object_instance_format_method
object = Object.new
class << object
def format(*)
'internal_format'
end
end
assert_no_match(/internal_format/, object.mocha_inspect)
end
end