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
2 changes: 1 addition & 1 deletion lib/method_source.rb
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def class_comment
class_inst_or_module = class_inst_or_module.class
end

location = class_inst_or_module.const_source_location(const_name)
location = class_inst_or_module.const_source_location("::#{const_name}")

MethodSource.comment_helper(location, defined?(name) ? name : inspect)
end
Expand Down
11 changes: 11 additions & 0 deletions spec/method_source_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
require 'spec_helper'

# Documentation for the outer class.
class MethodSourceShadowedClass
MethodSourceShadowedClass = Module.new
def work; end
end

describe MethodSource do

describe "source_location (testing 1.8 implementation)" do
Expand Down Expand Up @@ -96,6 +102,11 @@

# if RUBY_VERSION =~ /1.9/ || is_rbx?
describe "Lambdas and Procs" do
it "uses the absolute class name when a nested constant shadows it" do
comment = MethodSourceShadowedClass.new.method(:work).class_comment
expect(comment).to eq("# Documentation for the outer class.\n")
end

it 'should return source for proc' do
expect(MyProc.source).to eq(@proc_source)
end
Expand Down