mirror of
https://github.com/pry/pry.git
synced 2022-11-09 12:35:05 -05:00
Show error when no docs found
This commit is contained in:
parent
0256eaa35d
commit
7c8f9be176
4 changed files with 9 additions and 2 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
1
spec/fixtures/show_source_doc_examples.rb
vendored
1
spec/fixtures/show_source_doc_examples.rb
vendored
|
@ -1,5 +1,6 @@
|
|||
# used by test_show_source.rb and test_documentation.rb
|
||||
class TestClassForShowSource
|
||||
#doc
|
||||
def alpha
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue