summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/pry/commands/show_doc.rb1
-rw-r--r--lib/pry/commands/show_source.rb2
-rw-r--r--spec/commands/show_doc_spec.rb7
-rw-r--r--spec/fixtures/show_source_doc_examples.rb1
4 files changed, 9 insertions, 2 deletions
diff --git a/lib/pry/commands/show_doc.rb b/lib/pry/commands/show_doc.rb
index 9d55ffd7..86f74624 100644
--- a/lib/pry/commands/show_doc.rb
+++ b/lib/pry/commands/show_doc.rb
@@ -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
diff --git a/lib/pry/commands/show_source.rb b/lib/pry/commands/show_source.rb
index e5477658..73356d2e 100644
--- a/lib/pry/commands/show_source.rb
+++ b/lib/pry/commands/show_source.rb
@@ -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
diff --git a/spec/commands/show_doc_spec.rb b/spec/commands/show_doc_spec.rb
index d530b70f..b69eee43 100644
--- a/spec/commands/show_doc_spec.rb
+++ b/spec/commands/show_doc_spec.rb
@@ -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
diff --git a/spec/fixtures/show_source_doc_examples.rb b/spec/fixtures/show_source_doc_examples.rb
index 53804baa..6d8cddfc 100644
--- a/spec/fixtures/show_source_doc_examples.rb
+++ b/spec/fixtures/show_source_doc_examples.rb
@@ -1,5 +1,6 @@
# used by test_show_source.rb and test_documentation.rb
class TestClassForShowSource
+ #doc
def alpha
end
end