1
0
Fork 0
mirror of https://github.com/pry/pry.git synced 2022-11-09 12:35:05 -05:00
Commit graph

20 commits

Author SHA1 Message Date
John Mair
c95c25e4d8 Allow show-source --super
Fixing this just required refactoring Pry::CodeObject#empty_lookup
so it respected the 'super_level' parameter
2013-05-18 02:23:01 +02:00
Kyrylo Silin
7a6a6164fe CodeObject: special case super keyword
Fix issue #917 (`$ super` should work (so should `$ -s`))

This is applies to both `show-source` and `show-doc`.
2013-05-04 00:33:38 +03:00
Kyrylo Silin
3546a3acd5 Show{Source,Doc}: assume super definitions from the context
Fix issue #877 (show-source -s doesn't work (when no method arg is
given))

This behaviour is shared between `show-source` and `show-doc`. So with
one fix I kill two bugs.

Add tests and rewrite some of the existing ones (related to the
`--super` switch).
2013-03-27 23:47:32 +02:00
Kyrylo Silin
175c0e950b 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:
d05233ecd3
2013-03-14 17:51:05 +02:00
Kyrylo Silin
d05233ecd3 ShowDocSpec: add another random comment to the definition
This commit is rather interesting. Well, maybe not the commit, but the
issue it is aimed to fix. So what's the aim? The aim is to eliminate an
error in the test for the following Ruby implementations: rbx-18mode,
jruby-18mode, jruby-19mode.

See that build for details: https://travis-ci.org/pry/pry/builds/5478834

You may be wondering now: "Kyrylo, what is so interesting in it?".
Heh-heh, sit down right beside me, my covey.

I have a screenshot for you:
http://img-fotki.yandex.ru/get/4125/98991937.11/0_911d2_acdd6798_orig

The screenshot demonstrates the difference between `show-doc` finding
monkey-patches on different Ruby implementations (JRuby and MRI 1.9.3).
Take a closer look at the order of the candidates. It is different in
the abovementioned implementations. That is the reason why the test is
failing. Unfortunately, I couldn't figure out why that is happening.

The fix is simple and it doesn't ruin the idea of the test. However,
I'm leaving that order issue to the greater minds of our civilization.

Uh! Don't forget to check out the description of that commit, because it
is related to this topic:
e926d8c944
2013-03-14 14:49:34 +02:00
Kyrylo Silin
e926d8c944 ShowDocSpec: add a random comment to the definition
This commit fixes the failing test. Internally, Pry raises
`CommandError`, when cannot find a definition (this is the new
behaviour), so the test needs to be updated.
2013-03-12 21:15:26 +02:00
Kyrylo Silin
c4254d84a6 ShowDocSpec: fix indentation
"The snake which cannot cast its skin has to die.
As well the minds which are prevented from changing
their opinions; they cease to be mind."

  - Friedrich Nietzsche
2013-03-12 20:52:24 +02:00
John Mair
342648f61f show-source: Indicate all monkeypatches can be shown with -a
Fixes #849
2013-03-12 20:52:10 +02:00
John Mair
7c8f9be176 Show error when no docs found 2013-03-10 00:19:10 +01:00
John Mair
8f4b11d70d Fix failing tests on rbx
The failures were due to Rbx recovering more source than expected (compared to MRI)

For example, the following fails in MRI:
module M
end

module N
  include M
end

show-source N

but on rbx it succeeds and shows the source of N

How does rbx do it? It appears to create a secret method called __module_init__ on a module whenever you include another module.
This method has its source_location set to the `include` line.
2013-02-08 03:11:42 +01:00
John Mair
4ca59800f2 Make show-source/show-doc fall-back to superclass
When performing show-source/show-doc on a class whose code
cannot be extracted we now fall-back to its first accessible superclass
and show its code together with a warning.

Example:

class Model < ActiveRecord::Base
end

show-source Model #=> shows ActiveRecord::Base code
2013-02-07 15:57:46 +01:00
John Mair
b7e70db004 show-source/show-doc: Show the first module candidate with source/docs
Prior to this change `show-source ActiveRecord::Base` would fail, as the highest ranked
candidate couldn't be discovered.
2013-01-29 15:25:05 +01:00
John Mair
c786862875 alliteration 2012-12-27 23:20:41 +01:00
John Mair
92c345aa12 module_candidate.rb improved class lookup regex
Bug prevented lookup of Deeply::Nested::Class::Definitions.

Also properly differentiate when looking up docs/source for *commands* and for the class that represents the command, i.e:
show-doc show-source #=> displays show-source --help
show-doc Pry::Command::ShowSource #=> comments above class definition (as with any other class)
2012-12-27 23:02:53 +01:00
John Mair
37b9fce976 show-source / show-doc: ensure _file_ and _line_ are set
Also cleaned up some OCD edge cases for show-doc, totally unnecessary & kind of silly
2012-12-22 22:59:03 +01:00
John Mair
d19aef516e show-doc: Removed the horror of ModuleInstrospectionHelpers and method_options
show-doc should be a lot easier to grok now there are no hidden modules adding methods and doing spooky things
behind the scenes.
2012-12-21 16:41:52 +01:00
John Mair
3663559291 fix tests on ruby 2.0 2012-12-19 12:28:29 +01:00
John Mair
9a279461c1 PryTestHelpers methods are now module_functions, included into Bacon::Context by default 2012-12-07 23:08:49 +01:00
John Mair
31a9578228 cleaned up lib/pry/test/helper.rb
* removed most historicla junk from lib/pry/test/helper.rb
* relocated recalcitrant junk to the local spec/helper.rb (this isn't exposed to 3rd parties)
2012-12-07 21:41:05 +01:00
☈king
848b6bdbeb Rename for tabcompletion-friendliness. 2012-11-15 18:59:51 -06:00
Renamed from test/test_commands/test_show_doc.rb (Browse further)