Show error when no docs found

This commit is contained in:
John Mair 2013-03-10 00:19:10 +01:00
parent 0256eaa35d
commit 7c8f9be176
4 changed files with 9 additions and 2 deletions

View File

@ -35,6 +35,7 @@ class Pry
# command '--help' shouldn't use markup highlighting
docs
else
raise CommandError, "No docs found for: #{obj_name}" if docs.empty?
process_comment_markup(docs)
end
end

View File

@ -25,8 +25,6 @@ class Pry
# The source for code_object prepared for display.
def content_for(code_object)
cannot_locate_source_error if !code_object.source
Code.new(code_object.source, start_line_for(code_object)).
with_line_numbers(use_line_numbers?).to_s
end

View File

@ -10,12 +10,19 @@ if !PryTestHelpers.mri18_and_no_real_source_location?
def @o.sample_method
:sample
end
def @o.no_docs;end
end
it 'should output a method\'s documentation' do
pry_eval(binding, "show-doc @o.sample_method").should =~ /sample doc/
end
it 'should raise exception when cannot find docs' do
lambda { pry_eval(binding, "show-doc @o.no_docs") }.should.raise(Pry::CommandError)
end
it 'should output a method\'s documentation with line numbers' do
pry_eval(binding, "show-doc @o.sample_method -l").should =~ /\d: sample doc/
end

View File

@ -1,5 +1,6 @@
# used by test_show_source.rb and test_documentation.rb
class TestClassForShowSource
#doc
def alpha
end
end