From 175c0e950bf65a67fd297f7adad0ea7dd9d77f8a Mon Sep 17 00:00:00 2001 From: Kyrylo Silin Date: Thu, 14 Mar 2013 17:51:05 +0200 Subject: [PATCH] ShowDocSpec: add a test concerning monkeypatching Make sure that `show-doc` displays the comments of the original definition by default. This test *must* fail with current state of things. The goal is to eliminate the oddities in Pry across some Ruby implementations. For more information see: https://github.com/pry/pry/commit/d05233ecd3ea0bba4c6fc0fb5c932631db687383 --- spec/commands/show_doc_spec.rb | 13 ++++++++++++- spec/fixtures/show_source_doc_examples.rb | 8 +++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/spec/commands/show_doc_spec.rb b/spec/commands/show_doc_spec.rb index 67d53402..66ac440a 100644 --- a/spec/commands/show_doc_spec.rb +++ b/spec/commands/show_doc_spec.rb @@ -263,7 +263,18 @@ if !PryTestHelpers.mri18_and_no_real_source_location? end describe "messages relating to -a" do - it 'indicates all available monkeypatches can be shown with -a when' \ + it "displays the original definition by default (not a doc of a monkeypatch)" do + class TestClassForCandidatesOrder + def beta + end + end + + result = pry_eval("show-doc TestClassForCandidatesOrder") + result.should =~ /Number of monkeypatches: 2/ + result.should =~ /The first definition/ + end + + it 'indicates all available monkeypatches can be shown with -a ' \ '(when -a not used and more than one candidate exists for class)' do # Still reading boring tests, eh? class TestClassForShowSource diff --git a/spec/fixtures/show_source_doc_examples.rb b/spec/fixtures/show_source_doc_examples.rb index 6d8cddfc..90efc43c 100644 --- a/spec/fixtures/show_source_doc_examples.rb +++ b/spec/fixtures/show_source_doc_examples.rb @@ -1,4 +1,4 @@ -# used by test_show_source.rb and test_documentation.rb +# used by show_source_spec.rb and show_doc_spec.rb class TestClassForShowSource #doc def alpha @@ -14,3 +14,9 @@ class TestClassForShowSourceInstanceEval def alpha end end + +# The first definition (find the second one in show_doc_spec.rb). +class TestClassForCandidatesOrder + def alpha + end +end