Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion lib/rdoc/code_object/method_attr.rb
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,12 @@ def full_name
end

def inspect # :nodoc:
alias_for = @is_alias_for ? " (alias for #{@is_alias_for.name})" : nil
alias_for =
if @is_alias_for.respond_to? :name then
" (alias for #{@is_alias_for.name})"
elsif Array === @is_alias_for then
" (alias for #{@is_alias_for.last})"
end
visibility = self.visibility
visibility = "forced #{visibility}" if force_documentation
"#<%s:0x%x %s (%s)%s>" % [
Expand Down
24 changes: 24 additions & 0 deletions test/rdoc/code_object/method_attr_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,30 @@ def test_pretty_print
end
end

def test_inspect_alias_from_store
temp_dir do |tmpdir|
s = RDoc::RI::Store.new(RDoc::Options.new, path: tmpdir)

top_level = s.add_file 'file.rb'
meth_bang = RDoc::AnyMethod.new 'method!'
meth_bang.record_location top_level

meth_bang_alias = RDoc::Alias.new 'method!', 'method_bang', ''
meth_bang_alias.record_location top_level

klass = top_level.add_class RDoc::NormalClass, 'Object'
klass.add_method meth_bang

meth_bang.add_alias meth_bang_alias, klass

s.save

meth_alias_from_store = s.load_method 'Object', '#method_bang'

assert_includes meth_alias_from_store.inspect, 'alias for method!'
end
end

def test_to_s
assert_equal 'RDoc::AnyMethod: C1#m', @c1_m.to_s
assert_equal 'RDoc::AnyMethod: C2#b', @c2_b.to_s
Expand Down