pry 0.10.2-i386-mingw32 → 1.0.0.pre1-i386-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (189) hide show
  1. data/.document +2 -0
  2. data/.gitignore +16 -0
  3. data/.travis.yml +21 -0
  4. data/.yardopts +3 -0
  5. data/CHANGELOG +503 -0
  6. data/CONTRIBUTORS +55 -0
  7. data/Gemfile +9 -0
  8. data/Guardfile +62 -0
  9. data/LICENSE +2 -2
  10. data/{README.md → README.markdown} +31 -37
  11. data/Rakefile +144 -0
  12. data/TODO +117 -0
  13. data/lib/pry.rb +146 -33
  14. data/lib/pry/cli.rb +13 -35
  15. data/lib/pry/code.rb +63 -24
  16. data/lib/pry/code/loc.rb +2 -2
  17. data/lib/pry/code_object.rb +21 -40
  18. data/lib/pry/command.rb +6 -9
  19. data/lib/pry/command_set.rb +37 -80
  20. data/lib/pry/commands.rb +1 -1
  21. data/lib/pry/commands/amend_line.rb +1 -1
  22. data/lib/pry/commands/bang.rb +1 -1
  23. data/lib/pry/commands/cat.rb +2 -11
  24. data/lib/pry/commands/cat/abstract_formatter.rb +1 -1
  25. data/lib/pry/commands/cat/exception_formatter.rb +7 -6
  26. data/lib/pry/commands/cat/file_formatter.rb +32 -15
  27. data/lib/pry/commands/cat/input_expression_formatter.rb +1 -1
  28. data/lib/pry/commands/cd.rb +3 -14
  29. data/lib/pry/commands/code_collector.rb +4 -4
  30. data/lib/pry/commands/easter_eggs.rb +3 -3
  31. data/lib/pry/commands/edit.rb +22 -10
  32. data/lib/pry/commands/edit/exception_patcher.rb +1 -1
  33. data/lib/pry/commands/edit/file_and_line_locator.rb +2 -0
  34. data/lib/pry/{method/patcher.rb → commands/edit/method_patcher.rb} +37 -40
  35. data/lib/pry/commands/find_method.rb +22 -16
  36. data/lib/pry/commands/gem_install.rb +2 -5
  37. data/lib/pry/commands/gem_open.rb +1 -1
  38. data/lib/pry/commands/gist.rb +11 -10
  39. data/lib/pry/commands/help.rb +14 -14
  40. data/lib/pry/commands/hist.rb +5 -24
  41. data/lib/pry/commands/ls.rb +287 -56
  42. data/lib/pry/commands/play.rb +10 -44
  43. data/lib/pry/commands/pry_backtrace.rb +2 -1
  44. data/lib/pry/commands/raise_up.rb +1 -1
  45. data/lib/pry/commands/reload_code.rb +15 -31
  46. data/lib/pry/commands/ri.rb +3 -7
  47. data/lib/pry/commands/shell_command.rb +12 -17
  48. data/lib/pry/commands/shell_mode.rb +2 -2
  49. data/lib/pry/commands/show_doc.rb +0 -5
  50. data/lib/pry/commands/show_info.rb +10 -11
  51. data/lib/pry/commands/show_source.rb +3 -15
  52. data/lib/pry/commands/simple_prompt.rb +1 -1
  53. data/lib/pry/commands/toggle_color.rb +4 -8
  54. data/lib/pry/commands/whereami.rb +10 -18
  55. data/lib/pry/completion.rb +293 -0
  56. data/lib/pry/config.rb +233 -20
  57. data/lib/pry/core_extensions.rb +19 -29
  58. data/lib/pry/custom_completions.rb +6 -0
  59. data/lib/pry/editor.rb +103 -109
  60. data/lib/pry/helpers/base_helpers.rb +109 -22
  61. data/lib/pry/helpers/command_helpers.rb +8 -10
  62. data/lib/pry/helpers/documentation_helpers.rb +2 -1
  63. data/lib/pry/helpers/text.rb +5 -4
  64. data/lib/pry/history.rb +10 -21
  65. data/lib/pry/history_array.rb +0 -5
  66. data/lib/pry/hooks.rb +29 -9
  67. data/lib/pry/indent.rb +10 -5
  68. data/lib/pry/method.rb +86 -81
  69. data/lib/pry/method/weird_method_locator.rb +2 -4
  70. data/lib/pry/module_candidate.rb +14 -5
  71. data/lib/pry/pager.rb +48 -193
  72. data/lib/pry/plugins.rb +2 -2
  73. data/lib/pry/pry_class.rb +193 -104
  74. data/lib/pry/pry_instance.rb +154 -152
  75. data/lib/pry/rbx_method.rb +13 -0
  76. data/lib/pry/rbx_path.rb +1 -1
  77. data/lib/pry/repl.rb +14 -17
  78. data/lib/pry/repl_file_loader.rb +3 -8
  79. data/lib/pry/rubygem.rb +3 -3
  80. data/lib/pry/terminal.rb +3 -4
  81. data/lib/pry/test/helper.rb +11 -6
  82. data/lib/pry/version.rb +1 -1
  83. data/lib/pry/wrapped_module.rb +56 -49
  84. data/man/pry.1 +195 -0
  85. data/man/pry.1.html +204 -0
  86. data/man/pry.1.ronn +141 -0
  87. data/pry.gemspec +31 -0
  88. data/spec/Procfile +3 -0
  89. data/spec/cli_spec.rb +78 -0
  90. data/spec/code_object_spec.rb +277 -0
  91. data/spec/code_spec.rb +219 -0
  92. data/spec/command_helpers_spec.rb +29 -0
  93. data/spec/command_integration_spec.rb +562 -0
  94. data/spec/command_set_spec.rb +627 -0
  95. data/spec/command_spec.rb +821 -0
  96. data/spec/commands/amend_line_spec.rb +247 -0
  97. data/spec/commands/bang_spec.rb +18 -0
  98. data/spec/commands/cat_spec.rb +164 -0
  99. data/spec/commands/cd_spec.rb +250 -0
  100. data/spec/commands/disable_pry_spec.rb +25 -0
  101. data/spec/commands/edit_spec.rb +725 -0
  102. data/spec/commands/exit_all_spec.rb +27 -0
  103. data/spec/commands/exit_program_spec.rb +19 -0
  104. data/spec/commands/exit_spec.rb +28 -0
  105. data/spec/commands/find_method_spec.rb +70 -0
  106. data/spec/commands/gem_list_spec.rb +26 -0
  107. data/spec/commands/gist_spec.rb +79 -0
  108. data/spec/commands/help_spec.rb +56 -0
  109. data/spec/commands/hist_spec.rb +172 -0
  110. data/spec/commands/jump_to_spec.rb +15 -0
  111. data/spec/commands/ls_spec.rb +189 -0
  112. data/spec/commands/play_spec.rb +136 -0
  113. data/spec/commands/raise_up_spec.rb +56 -0
  114. data/spec/commands/save_file_spec.rb +177 -0
  115. data/spec/commands/show_doc_spec.rb +488 -0
  116. data/spec/commands/show_input_spec.rb +17 -0
  117. data/spec/commands/show_source_spec.rb +760 -0
  118. data/spec/commands/whereami_spec.rb +203 -0
  119. data/spec/completion_spec.rb +221 -0
  120. data/spec/control_d_handler_spec.rb +62 -0
  121. data/spec/documentation_helper_spec.rb +73 -0
  122. data/spec/editor_spec.rb +79 -0
  123. data/spec/exception_whitelist_spec.rb +21 -0
  124. data/spec/fixtures/candidate_helper1.rb +11 -0
  125. data/spec/fixtures/candidate_helper2.rb +8 -0
  126. data/spec/fixtures/example.erb +5 -0
  127. data/spec/fixtures/example_nesting.rb +33 -0
  128. data/spec/fixtures/show_source_doc_examples.rb +15 -0
  129. data/spec/fixtures/testlinkrc +2 -0
  130. data/spec/fixtures/testrc +2 -0
  131. data/spec/fixtures/testrcbad +2 -0
  132. data/spec/fixtures/whereami_helper.rb +6 -0
  133. data/spec/helper.rb +35 -0
  134. data/spec/helpers/bacon.rb +86 -0
  135. data/spec/helpers/mock_pry.rb +44 -0
  136. data/spec/helpers/repl_tester.rb +112 -0
  137. data/spec/helpers/table_spec.rb +105 -0
  138. data/spec/history_array_spec.rb +67 -0
  139. data/spec/hooks_spec.rb +522 -0
  140. data/spec/indent_spec.rb +301 -0
  141. data/spec/method_spec.rb +482 -0
  142. data/spec/prompt_spec.rb +61 -0
  143. data/spec/pry_defaults_spec.rb +420 -0
  144. data/spec/pry_history_spec.rb +69 -0
  145. data/spec/pry_output_spec.rb +95 -0
  146. data/spec/pry_repl_spec.rb +86 -0
  147. data/spec/pry_spec.rb +394 -0
  148. data/spec/pryrc_spec.rb +97 -0
  149. data/spec/run_command_spec.rb +25 -0
  150. data/spec/sticky_locals_spec.rb +147 -0
  151. data/spec/syntax_checking_spec.rb +81 -0
  152. data/spec/wrapped_module_spec.rb +261 -0
  153. data/wiki/Customizing-pry.md +397 -0
  154. data/wiki/Home.md +4 -0
  155. metadata +272 -61
  156. checksums.yaml +0 -7
  157. data/CHANGELOG.md +0 -714
  158. data/lib/pry/code/code_file.rb +0 -103
  159. data/lib/pry/color_printer.rb +0 -55
  160. data/lib/pry/commands/change_inspector.rb +0 -27
  161. data/lib/pry/commands/change_prompt.rb +0 -26
  162. data/lib/pry/commands/list_inspectors.rb +0 -35
  163. data/lib/pry/commands/list_prompts.rb +0 -35
  164. data/lib/pry/commands/ls/constants.rb +0 -47
  165. data/lib/pry/commands/ls/formatter.rb +0 -49
  166. data/lib/pry/commands/ls/globals.rb +0 -48
  167. data/lib/pry/commands/ls/grep.rb +0 -21
  168. data/lib/pry/commands/ls/instance_vars.rb +0 -39
  169. data/lib/pry/commands/ls/interrogatable.rb +0 -18
  170. data/lib/pry/commands/ls/jruby_hacks.rb +0 -49
  171. data/lib/pry/commands/ls/local_names.rb +0 -35
  172. data/lib/pry/commands/ls/local_vars.rb +0 -39
  173. data/lib/pry/commands/ls/ls_entity.rb +0 -70
  174. data/lib/pry/commands/ls/methods.rb +0 -57
  175. data/lib/pry/commands/ls/methods_helper.rb +0 -46
  176. data/lib/pry/commands/ls/self_methods.rb +0 -32
  177. data/lib/pry/commands/watch_expression.rb +0 -105
  178. data/lib/pry/commands/watch_expression/expression.rb +0 -38
  179. data/lib/pry/config/behavior.rb +0 -139
  180. data/lib/pry/config/convenience.rb +0 -25
  181. data/lib/pry/config/default.rb +0 -161
  182. data/lib/pry/exceptions.rb +0 -78
  183. data/lib/pry/input_completer.rb +0 -242
  184. data/lib/pry/input_lock.rb +0 -132
  185. data/lib/pry/inspector.rb +0 -27
  186. data/lib/pry/last_exception.rb +0 -61
  187. data/lib/pry/object_path.rb +0 -82
  188. data/lib/pry/output.rb +0 -50
  189. data/lib/pry/prompt.rb +0 -26
@@ -0,0 +1,488 @@
1
+ require 'helper'
2
+ require "fixtures/show_source_doc_examples"
3
+
4
+ if !PryTestHelpers.mri18_and_no_real_source_location?
5
+ describe "show-doc" do
6
+ before do
7
+ @o = Object.new
8
+
9
+ # sample doc
10
+ def @o.sample_method
11
+ :sample
12
+ end
13
+ end
14
+
15
+ it 'should output a method\'s documentation' do
16
+ pry_eval(binding, "show-doc @o.sample_method").should =~ /sample doc/
17
+ end
18
+
19
+ it 'should output a method\'s documentation with line numbers' do
20
+ pry_eval(binding, "show-doc @o.sample_method -l").should =~ /\d: sample doc/
21
+ end
22
+
23
+ it 'should output a method\'s documentation with line numbers (base one)' do
24
+ pry_eval(binding, "show-doc @o.sample_method -b").should =~ /1: sample doc/
25
+ end
26
+
27
+ it 'should output a method\'s documentation if inside method without needing to use method name' do
28
+ # sample comment
29
+ def @o.sample
30
+ pry_eval(binding, 'show-doc').should =~ /sample comment/
31
+ end
32
+ @o.sample
33
+ end
34
+
35
+ it "should be able to find super methods" do
36
+ b = Class.new{
37
+ # daddy initialize!
38
+ def initialize(*args) ;end
39
+ }
40
+
41
+ c = Class.new(b){
42
+ # classy initialize!
43
+ def initialize(*args); end
44
+ }
45
+
46
+ d = Class.new(c){
47
+ # grungy initialize??
48
+ def initialize(*args, &block); end
49
+ }
50
+
51
+ o = d.new
52
+
53
+ # instancey initialize!
54
+ def o.initialize; end
55
+
56
+ t = pry_tester(binding)
57
+
58
+ t.eval("show-doc o.initialize").should =~ /instancey initialize/
59
+ t.eval("show-doc --super o.initialize").should =~ /grungy initialize/
60
+ t.eval("show-doc o.initialize -ss").should =~ /classy initialize/
61
+ t.eval("show-doc o.initialize -sss").should =~ /daddy initialize/
62
+ end
63
+
64
+ describe "rdoc highlighting" do
65
+ it "should syntax highlight code in rdoc" do
66
+ c = Class.new{
67
+ # This can initialize your class:
68
+ #
69
+ # a = c.new :foo
70
+ #
71
+ # @param foo
72
+ def initialize(foo); end
73
+ }
74
+
75
+ begin
76
+ t = pry_tester(binding)
77
+ t.eval("show-doc c#initialize").should =~ /c.new :foo/
78
+ Pry.config.color = true
79
+ # I don't want the test to rely on which colour codes are there, just to
80
+ # assert that "something" is being colourized.
81
+ t.eval("show-doc c#initialize").should.not =~ /c.new :foo/
82
+ ensure
83
+ Pry.config.color = false
84
+ end
85
+ end
86
+
87
+ it "should syntax highlight `code` in rdoc" do
88
+ c = Class.new{
89
+ # After initializing your class with `c.new(:foo)`, go have fun!
90
+ #
91
+ # @param foo
92
+ def initialize(foo); end
93
+ }
94
+
95
+ begin
96
+ t = pry_tester(binding)
97
+ t.eval("show-doc c#initialize").should =~ /c.new\(:foo\)/
98
+ Pry.config.color = true
99
+ # I don't want the test to rely on which colour codes are there, just to
100
+ # assert that "something" is being colourized.
101
+ t.eval("show-doc c#initialize").should.not =~ /c.new\(:foo\)/
102
+ ensure
103
+ Pry.config.color = false
104
+ end
105
+
106
+ end
107
+
108
+ it "should not syntax highlight `` inside code" do
109
+ c = Class.new{
110
+ # Convert aligned output (from many shell commands) into nested arrays:
111
+ #
112
+ # a = decolumnize `ls -l $HOME`
113
+ #
114
+ # @param output
115
+ def decolumnize(output); end
116
+ }
117
+
118
+ begin
119
+ t = pry_tester(binding)
120
+ Pry.config.color = true
121
+ t.eval("show-doc c#decolumnize").should =~ /ls -l \$HOME/
122
+ t.eval("show-doc c#decolumnize").should.not =~ /`ls -l \$HOME`/
123
+ ensure
124
+ Pry.config.color = false
125
+ end
126
+ end
127
+ end
128
+
129
+ describe "on sourcable objects" do
130
+ it "should show documentation for object" do
131
+ # this is a documentation
132
+ hello = proc { puts 'hello world!' }
133
+ mock_pry(binding, "show-doc hello").should =~ /this is a documentation/
134
+ end
135
+ end
136
+
137
+ describe "on modules" do
138
+ before do
139
+ # god this is boring1
140
+ class ShowSourceTestClass
141
+ def alpha
142
+ end
143
+ end
144
+
145
+ # god this is boring2
146
+ module ShowSourceTestModule
147
+ def alpha
148
+ end
149
+ end
150
+
151
+ # god this is boring3
152
+ ShowSourceTestClassWeirdSyntax = Class.new do
153
+ def beta
154
+ end
155
+ end
156
+
157
+ # god this is boring4
158
+ ShowSourceTestModuleWeirdSyntax = Module.new do
159
+ def beta
160
+ end
161
+ end
162
+ end
163
+
164
+ after do
165
+ Object.remove_const :ShowSourceTestClass
166
+ Object.remove_const :ShowSourceTestClassWeirdSyntax
167
+ Object.remove_const :ShowSourceTestModule
168
+ Object.remove_const :ShowSourceTestModuleWeirdSyntax
169
+ end
170
+
171
+ describe "basic functionality, should show docs for top-level module definitions" do
172
+ it 'should show docs for a class' do
173
+ pry_eval("show-doc ShowSourceTestClass").should =~
174
+ /god this is boring1/
175
+ end
176
+
177
+ it 'should show docs for a module' do
178
+ pry_eval("show-doc ShowSourceTestModule").should =~
179
+ /god this is boring2/
180
+ end
181
+
182
+ it 'should show docs for a class when Const = Class.new syntax is used' do
183
+ pry_eval("show-doc ShowSourceTestClassWeirdSyntax").should =~
184
+ /god this is boring3/
185
+ end
186
+
187
+ it 'should show docs for a module when Const = Module.new syntax is used' do
188
+ pry_eval("show-doc ShowSourceTestModuleWeirdSyntax").should =~
189
+ /god this is boring4/
190
+ end
191
+ end
192
+
193
+ if !Pry::Helpers::BaseHelpers.mri_18?
194
+ describe "in REPL" do
195
+ it 'should find class defined in repl' do
196
+ t = pry_tester
197
+ t.eval <<-RUBY
198
+ # hello tobina
199
+ class TobinaMyDog
200
+ def woof
201
+ end
202
+ end
203
+ RUBY
204
+ t.eval('show-doc TobinaMyDog').should =~ /hello tobina/
205
+ Object.remove_const :TobinaMyDog
206
+ end
207
+ end
208
+ end
209
+
210
+ it 'should lookup module name with respect to current context' do
211
+ constant_scope(:AlphaClass, :BetaClass) do
212
+ # top-level beta
213
+ class BetaClass
214
+ def alpha
215
+ end
216
+ end
217
+
218
+ class AlphaClass
219
+ # nested beta
220
+ class BetaClass
221
+ def beta
222
+ end
223
+ end
224
+ end
225
+
226
+ pry_eval(AlphaClass, "show-doc BetaClass").should =~ /nested beta/
227
+ end
228
+ end
229
+
230
+ it 'should look up nested modules' do
231
+ constant_scope(:AlphaClass) do
232
+ class AlphaClass
233
+ # nested beta
234
+ class BetaClass
235
+ def beta
236
+ end
237
+ end
238
+ end
239
+
240
+ pry_eval("show-doc AlphaClass::BetaClass").should =~
241
+ /nested beta/
242
+ end
243
+ end
244
+
245
+ describe "show-doc -a" do
246
+ it 'should show the docs for all monkeypatches defined in different files' do
247
+ # local monkeypatch
248
+ class TestClassForShowSource
249
+ def beta
250
+ end
251
+ end
252
+
253
+ result = pry_eval("show-doc TestClassForShowSource -a")
254
+ result.should =~ /used by/
255
+ result.should =~ /local monkeypatch/
256
+ end
257
+ end
258
+
259
+ describe "when no class/module arg is given" do
260
+ before do
261
+ module TestHost
262
+
263
+ # hello there froggy
264
+ module M
265
+ def d; end
266
+ def e; end
267
+ end
268
+ end
269
+ end
270
+
271
+ after do
272
+ Object.remove_const(:TestHost)
273
+ end
274
+
275
+ it 'should return doc for current module' do
276
+ pry_eval(TestHost::M, "show-doc").should =~ /hello there froggy/
277
+ end
278
+ end
279
+
280
+ # FIXME: THis is nto a good spec anyway, because i dont think it
281
+ # SHOULD skip!
282
+ describe "should skip over broken modules" do
283
+ before do
284
+ module TestHost
285
+ # hello
286
+ module M
287
+ binding.eval("def a; end", "dummy.rb", 1)
288
+ binding.eval("def b; end", "dummy.rb", 2)
289
+ binding.eval("def c; end", "dummy.rb", 3)
290
+ end
291
+
292
+ # goodbye
293
+ module M
294
+ def d; end
295
+ def e; end
296
+ end
297
+ end
298
+ end
299
+
300
+ after do
301
+ Object.remove_const(:TestHost)
302
+ end
303
+
304
+ it 'should return doc for first valid module' do
305
+ result = pry_eval("show-doc TestHost::M")
306
+ result.should =~ /goodbye/
307
+ result.should.not =~ /hello/
308
+ end
309
+ end
310
+ end
311
+
312
+ describe "on commands" do
313
+ # mostly copied & modified from test_help.rb
314
+ before do
315
+ @oldset = Pry.config.commands
316
+ @set = Pry.config.commands = Pry::CommandSet.new do
317
+ import Pry::Commands
318
+ end
319
+ end
320
+
321
+ after do
322
+ Pry.config.commands = @oldset
323
+ end
324
+
325
+ it 'should display help for a specific command' do
326
+ pry_eval('show-doc ls').should =~ /Usage: ls/
327
+ end
328
+
329
+ it 'should display help for a regex command with a "listing"' do
330
+ @set.command /bar(.*)/, "Test listing", :listing => "foo" do; end
331
+ pry_eval('show-doc foo').should =~ /Test listing/
332
+ end
333
+
334
+ it 'should display help for a command with a spaces in its name' do
335
+ @set.command "command with spaces", "description of a command with spaces" do; end
336
+ pry_eval('show-doc command with spaces').should =~ /description of a command with spaces/
337
+ end
338
+
339
+ describe "class commands" do
340
+ before do
341
+ # pretty pink pincers
342
+ class LobsterLady < Pry::ClassCommand
343
+ match "lobster-lady"
344
+ description "nada."
345
+ def process
346
+ "lobster"
347
+ end
348
+ end
349
+
350
+ Pry.commands.add_command(LobsterLady)
351
+ end
352
+
353
+ after do
354
+ Object.remove_const(:LobsterLady)
355
+ end
356
+
357
+ it 'should display "help" when looking up by command name' do
358
+ pry_eval('show-doc lobster-lady').should =~ /nada/
359
+ Pry.commands.delete("lobster-lady")
360
+ end
361
+
362
+ it 'should display actual preceding comment for a class command, when class is used (rather than command name) when looking up' do
363
+ pry_eval('show-doc LobsterLady').should =~ /pretty pink pincers/
364
+ Pry.commands.delete("lobster-lady")
365
+ end
366
+ end
367
+ end
368
+
369
+ describe "should set _file_ and _dir_" do
370
+ it 'should set _file_ and _dir_ to file containing method source' do
371
+ t = pry_tester
372
+ t.process_command "show-doc TestClassForShowSource#alpha"
373
+ t.pry.last_file.should =~ /show_source_doc_examples/
374
+ t.pry.last_dir.should =~ /fixtures/
375
+ end
376
+ end
377
+
378
+ unless Pry::Helpers::BaseHelpers.rbx?
379
+ describe "can't find class docs" do
380
+ describe "for classes" do
381
+ before do
382
+ module Jesus
383
+ class Brian; end
384
+
385
+ # doink-doc
386
+ class Jingle
387
+ def a; :doink; end
388
+ end
389
+
390
+ class Jangle < Jingle; end
391
+ class Bangle < Jangle; end
392
+ end
393
+ end
394
+
395
+ after do
396
+ Object.remove_const(:Jesus)
397
+ end
398
+
399
+ it 'shows superclass doc' do
400
+ t = pry_tester
401
+ t.process_command "show-doc Jesus::Jangle"
402
+ t.last_output.should =~ /doink-doc/
403
+ end
404
+
405
+ it 'errors when class has no superclass to show' do
406
+ t = pry_tester
407
+ lambda { t.process_command "show-doc Jesus::Brian" }.should.raise(Pry::CommandError).message.
408
+ should =~ /Couldn't locate/
409
+ end
410
+
411
+ it 'shows warning when reverting to superclass docs' do
412
+ t = pry_tester
413
+ t.process_command "show-doc Jesus::Jangle"
414
+ t.last_output.should =~ /Warning.*?Cannot find.*?Jesus::Jangle.*Showing.*Jesus::Jingle instead/
415
+ end
416
+
417
+ it 'shows nth level superclass docs (when no intermediary superclasses have code either)' do
418
+ t = pry_tester
419
+ t.process_command "show-doc Jesus::Bangle"
420
+ t.last_output.should =~ /doink-doc/
421
+ end
422
+
423
+ it 'shows correct warning when reverting to nth level superclass' do
424
+ t = pry_tester
425
+ t.process_command "show-doc Jesus::Bangle"
426
+ t.last_output.should =~ /Warning.*?Cannot find.*?Jesus::Bangle.*Showing.*Jesus::Jingle instead/
427
+ end
428
+ end
429
+
430
+ describe "for modules" do
431
+ before do
432
+ module Jesus
433
+
434
+ # alpha-doc
435
+ module Alpha
436
+ def alpha; :alpha; end
437
+ end
438
+
439
+ module Zeta; end
440
+
441
+ module Beta
442
+ include Alpha
443
+ end
444
+
445
+ module Gamma
446
+ include Beta
447
+ end
448
+ end
449
+ end
450
+
451
+ after do
452
+ Object.remove_const(:Jesus)
453
+ end
454
+
455
+ it 'shows included module doc' do
456
+ t = pry_tester
457
+ t.process_command "show-doc Jesus::Beta"
458
+ t.last_output.should =~ /alpha-doc/
459
+ end
460
+
461
+ it 'shows warning when reverting to included module doc' do
462
+ t = pry_tester
463
+ t.process_command "show-doc Jesus::Beta"
464
+ t.last_output.should =~ /Warning.*?Cannot find.*?Jesus::Beta.*Showing.*Jesus::Alpha instead/
465
+ end
466
+
467
+ it 'errors when module has no included module to show' do
468
+ t = pry_tester
469
+ lambda { t.process_command "show-source Jesus::Zeta" }.should.raise(Pry::CommandError).message.
470
+ should =~ /Couldn't locate/
471
+ end
472
+
473
+ it 'shows nth level included module doc (when no intermediary modules have code either)' do
474
+ t = pry_tester
475
+ t.process_command "show-doc Jesus::Gamma"
476
+ t.last_output.should =~ /alpha-doc/
477
+ end
478
+
479
+ it 'shows correct warning when reverting to nth level included module' do
480
+ t = pry_tester
481
+ t.process_command "show-source Jesus::Gamma"
482
+ t.last_output.should =~ /Warning.*?Cannot find.*?Jesus::Gamma.*Showing.*Jesus::Alpha instead/
483
+ end
484
+ end
485
+ end
486
+ end
487
+ end
488
+ end