pry 0.10.pre.1-i386-mswin32 → 0.10.0.pre3-i386-mswin32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (214) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +702 -0
  3. data/LICENSE +2 -2
  4. data/{README.markdown → README.md} +41 -35
  5. data/lib/pry.rb +82 -139
  6. data/lib/pry/cli.rb +77 -30
  7. data/lib/pry/code.rb +122 -183
  8. data/lib/pry/code/code_file.rb +103 -0
  9. data/lib/pry/code/code_range.rb +71 -0
  10. data/lib/pry/code/loc.rb +92 -0
  11. data/lib/pry/code_object.rb +172 -0
  12. data/lib/pry/color_printer.rb +55 -0
  13. data/lib/pry/command.rb +184 -28
  14. data/lib/pry/command_set.rb +113 -59
  15. data/lib/pry/commands.rb +4 -27
  16. data/lib/pry/commands/amend_line.rb +99 -0
  17. data/lib/pry/commands/bang.rb +20 -0
  18. data/lib/pry/commands/bang_pry.rb +17 -0
  19. data/lib/pry/commands/cat.rb +62 -0
  20. data/lib/pry/commands/cat/abstract_formatter.rb +27 -0
  21. data/lib/pry/commands/cat/exception_formatter.rb +77 -0
  22. data/lib/pry/commands/cat/file_formatter.rb +67 -0
  23. data/lib/pry/commands/cat/input_expression_formatter.rb +43 -0
  24. data/lib/pry/commands/cd.rb +41 -0
  25. data/lib/pry/commands/change_inspector.rb +27 -0
  26. data/lib/pry/commands/change_prompt.rb +26 -0
  27. data/lib/pry/commands/code_collector.rb +165 -0
  28. data/lib/pry/commands/disable_pry.rb +27 -0
  29. data/lib/pry/commands/disabled_commands.rb +2 -0
  30. data/lib/pry/commands/easter_eggs.rb +112 -0
  31. data/lib/pry/commands/edit.rb +195 -0
  32. data/lib/pry/commands/edit/exception_patcher.rb +25 -0
  33. data/lib/pry/commands/edit/file_and_line_locator.rb +36 -0
  34. data/lib/pry/commands/exit.rb +42 -0
  35. data/lib/pry/commands/exit_all.rb +29 -0
  36. data/lib/pry/commands/exit_program.rb +23 -0
  37. data/lib/pry/commands/find_method.rb +193 -0
  38. data/lib/pry/commands/fix_indent.rb +19 -0
  39. data/lib/pry/commands/gem_cd.rb +26 -0
  40. data/lib/pry/commands/gem_install.rb +32 -0
  41. data/lib/pry/commands/gem_list.rb +33 -0
  42. data/lib/pry/commands/gem_open.rb +29 -0
  43. data/lib/pry/commands/gist.rb +101 -0
  44. data/lib/pry/commands/help.rb +164 -0
  45. data/lib/pry/commands/hist.rb +180 -0
  46. data/lib/pry/commands/import_set.rb +22 -0
  47. data/lib/pry/commands/install_command.rb +53 -0
  48. data/lib/pry/commands/jump_to.rb +29 -0
  49. data/lib/pry/commands/list_inspectors.rb +35 -0
  50. data/lib/pry/commands/list_prompts.rb +35 -0
  51. data/lib/pry/commands/ls.rb +114 -0
  52. data/lib/pry/commands/ls/constants.rb +47 -0
  53. data/lib/pry/commands/ls/formatter.rb +49 -0
  54. data/lib/pry/commands/ls/globals.rb +48 -0
  55. data/lib/pry/commands/ls/grep.rb +21 -0
  56. data/lib/pry/commands/ls/instance_vars.rb +39 -0
  57. data/lib/pry/commands/ls/interrogatable.rb +18 -0
  58. data/lib/pry/commands/ls/jruby_hacks.rb +49 -0
  59. data/lib/pry/commands/ls/local_names.rb +35 -0
  60. data/lib/pry/commands/ls/local_vars.rb +39 -0
  61. data/lib/pry/commands/ls/ls_entity.rb +70 -0
  62. data/lib/pry/commands/ls/methods.rb +57 -0
  63. data/lib/pry/commands/ls/methods_helper.rb +46 -0
  64. data/lib/pry/commands/ls/self_methods.rb +32 -0
  65. data/lib/pry/commands/nesting.rb +25 -0
  66. data/lib/pry/commands/play.rb +103 -0
  67. data/lib/pry/commands/pry_backtrace.rb +25 -0
  68. data/lib/pry/commands/pry_version.rb +17 -0
  69. data/lib/pry/commands/raise_up.rb +32 -0
  70. data/lib/pry/commands/reload_code.rb +62 -0
  71. data/lib/pry/commands/reset.rb +18 -0
  72. data/lib/pry/commands/ri.rb +60 -0
  73. data/lib/pry/commands/save_file.rb +61 -0
  74. data/lib/pry/commands/shell_command.rb +48 -0
  75. data/lib/pry/commands/shell_mode.rb +25 -0
  76. data/lib/pry/commands/show_doc.rb +83 -0
  77. data/lib/pry/commands/show_info.rb +195 -0
  78. data/lib/pry/commands/show_input.rb +17 -0
  79. data/lib/pry/commands/show_source.rb +50 -0
  80. data/lib/pry/commands/simple_prompt.rb +22 -0
  81. data/lib/pry/commands/stat.rb +40 -0
  82. data/lib/pry/commands/switch_to.rb +23 -0
  83. data/lib/pry/commands/toggle_color.rb +24 -0
  84. data/lib/pry/commands/watch_expression.rb +105 -0
  85. data/lib/pry/commands/watch_expression/expression.rb +38 -0
  86. data/lib/pry/commands/whereami.rb +190 -0
  87. data/lib/pry/commands/wtf.rb +57 -0
  88. data/lib/pry/config.rb +20 -229
  89. data/lib/pry/config/behavior.rb +139 -0
  90. data/lib/pry/config/convenience.rb +26 -0
  91. data/lib/pry/config/default.rb +165 -0
  92. data/lib/pry/core_extensions.rb +59 -38
  93. data/lib/pry/editor.rb +133 -0
  94. data/lib/pry/exceptions.rb +77 -0
  95. data/lib/pry/helpers.rb +1 -0
  96. data/lib/pry/helpers/base_helpers.rb +40 -154
  97. data/lib/pry/helpers/command_helpers.rb +19 -130
  98. data/lib/pry/helpers/documentation_helpers.rb +21 -11
  99. data/lib/pry/helpers/table.rb +109 -0
  100. data/lib/pry/helpers/text.rb +8 -9
  101. data/lib/pry/history.rb +61 -45
  102. data/lib/pry/history_array.rb +11 -1
  103. data/lib/pry/hooks.rb +10 -32
  104. data/lib/pry/indent.rb +110 -38
  105. data/lib/pry/input_completer.rb +242 -0
  106. data/lib/pry/input_lock.rb +132 -0
  107. data/lib/pry/inspector.rb +27 -0
  108. data/lib/pry/last_exception.rb +61 -0
  109. data/lib/pry/method.rb +199 -200
  110. data/lib/pry/method/disowned.rb +53 -0
  111. data/lib/pry/method/patcher.rb +125 -0
  112. data/lib/pry/method/weird_method_locator.rb +186 -0
  113. data/lib/pry/module_candidate.rb +39 -33
  114. data/lib/pry/object_path.rb +82 -0
  115. data/lib/pry/output.rb +50 -0
  116. data/lib/pry/pager.rb +234 -0
  117. data/lib/pry/plugins.rb +4 -3
  118. data/lib/pry/prompt.rb +26 -0
  119. data/lib/pry/pry_class.rb +199 -227
  120. data/lib/pry/pry_instance.rb +344 -403
  121. data/lib/pry/rbx_path.rb +1 -1
  122. data/lib/pry/repl.rb +202 -0
  123. data/lib/pry/repl_file_loader.rb +20 -26
  124. data/lib/pry/rubygem.rb +82 -0
  125. data/lib/pry/terminal.rb +79 -0
  126. data/lib/pry/test/helper.rb +170 -0
  127. data/lib/pry/version.rb +1 -1
  128. data/lib/pry/wrapped_module.rb +133 -48
  129. metadata +132 -197
  130. data/.document +0 -2
  131. data/.gemtest +0 -0
  132. data/.gitignore +0 -16
  133. data/.travis.yml +0 -17
  134. data/.yardopts +0 -1
  135. data/CHANGELOG +0 -387
  136. data/CONTRIBUTORS +0 -36
  137. data/Gemfile +0 -2
  138. data/Rakefile +0 -137
  139. data/TODO +0 -117
  140. data/examples/example_basic.rb +0 -15
  141. data/examples/example_command_override.rb +0 -32
  142. data/examples/example_commands.rb +0 -36
  143. data/examples/example_hooks.rb +0 -9
  144. data/examples/example_image_edit.rb +0 -67
  145. data/examples/example_input.rb +0 -7
  146. data/examples/example_input2.rb +0 -29
  147. data/examples/example_output.rb +0 -11
  148. data/examples/example_print.rb +0 -6
  149. data/examples/example_prompt.rb +0 -9
  150. data/examples/helper.rb +0 -6
  151. data/lib/pry/completion.rb +0 -221
  152. data/lib/pry/custom_completions.rb +0 -6
  153. data/lib/pry/default_commands/cd.rb +0 -81
  154. data/lib/pry/default_commands/commands.rb +0 -62
  155. data/lib/pry/default_commands/context.rb +0 -98
  156. data/lib/pry/default_commands/easter_eggs.rb +0 -95
  157. data/lib/pry/default_commands/editing.rb +0 -420
  158. data/lib/pry/default_commands/find_method.rb +0 -169
  159. data/lib/pry/default_commands/gems.rb +0 -84
  160. data/lib/pry/default_commands/gist.rb +0 -187
  161. data/lib/pry/default_commands/help.rb +0 -127
  162. data/lib/pry/default_commands/hist.rb +0 -120
  163. data/lib/pry/default_commands/input_and_output.rb +0 -306
  164. data/lib/pry/default_commands/introspection.rb +0 -410
  165. data/lib/pry/default_commands/ls.rb +0 -272
  166. data/lib/pry/default_commands/misc.rb +0 -38
  167. data/lib/pry/default_commands/navigating_pry.rb +0 -110
  168. data/lib/pry/default_commands/whereami.rb +0 -92
  169. data/lib/pry/extended_commands/experimental.rb +0 -7
  170. data/lib/pry/rbx_method.rb +0 -13
  171. data/man/pry.1 +0 -195
  172. data/man/pry.1.html +0 -204
  173. data/man/pry.1.ronn +0 -141
  174. data/pry.gemspec +0 -46
  175. data/test/candidate_helper1.rb +0 -11
  176. data/test/candidate_helper2.rb +0 -8
  177. data/test/helper.rb +0 -223
  178. data/test/test_cli.rb +0 -78
  179. data/test/test_code.rb +0 -201
  180. data/test/test_command.rb +0 -712
  181. data/test/test_command_helpers.rb +0 -9
  182. data/test/test_command_integration.rb +0 -668
  183. data/test/test_command_set.rb +0 -610
  184. data/test/test_completion.rb +0 -62
  185. data/test/test_control_d_handler.rb +0 -45
  186. data/test/test_default_commands/example.erb +0 -5
  187. data/test/test_default_commands/test_cd.rb +0 -318
  188. data/test/test_default_commands/test_context.rb +0 -280
  189. data/test/test_default_commands/test_documentation.rb +0 -314
  190. data/test/test_default_commands/test_find_method.rb +0 -50
  191. data/test/test_default_commands/test_gems.rb +0 -18
  192. data/test/test_default_commands/test_help.rb +0 -57
  193. data/test/test_default_commands/test_input.rb +0 -428
  194. data/test/test_default_commands/test_introspection.rb +0 -511
  195. data/test/test_default_commands/test_ls.rb +0 -151
  196. data/test/test_default_commands/test_shell.rb +0 -343
  197. data/test/test_default_commands/test_show_source.rb +0 -432
  198. data/test/test_exception_whitelist.rb +0 -21
  199. data/test/test_history_array.rb +0 -65
  200. data/test/test_hooks.rb +0 -521
  201. data/test/test_indent.rb +0 -277
  202. data/test/test_input_stack.rb +0 -86
  203. data/test/test_method.rb +0 -401
  204. data/test/test_pry.rb +0 -463
  205. data/test/test_pry_defaults.rb +0 -419
  206. data/test/test_pry_history.rb +0 -84
  207. data/test/test_pry_output.rb +0 -41
  208. data/test/test_sticky_locals.rb +0 -155
  209. data/test/test_syntax_checking.rb +0 -65
  210. data/test/test_wrapped_module.rb +0 -174
  211. data/test/testrc +0 -2
  212. data/test/testrcbad +0 -2
  213. data/wiki/Customizing-pry.md +0 -397
  214. data/wiki/Home.md +0 -4
@@ -1,432 +0,0 @@
1
- require 'helper'
2
-
3
- if !mri18_and_no_real_source_location?
4
- describe "show-source" do
5
- before do
6
- @str_output = StringIO.new
7
- end
8
-
9
- it 'should output a method\'s source' do
10
- redirect_pry_io(InputTester.new("show-source sample_method", "exit-all"), @str_output) do
11
- pry
12
- end
13
-
14
- @str_output.string.should =~ /def sample/
15
- end
16
-
17
- it 'should output help' do
18
- mock_pry('show-source -h').should =~ /Usage: show-source/
19
- end
20
-
21
- it 'should output a method\'s source with line numbers' do
22
- redirect_pry_io(InputTester.new("show-source -l sample_method", "exit-all"), @str_output) do
23
- pry
24
- end
25
-
26
- @str_output.string.should =~ /\d+: def sample/
27
- end
28
-
29
- it 'should output a method\'s source with line numbers starting at 1' do
30
- redirect_pry_io(InputTester.new("show-source -b sample_method", "exit-all"), @str_output) do
31
- pry
32
- end
33
-
34
- @str_output.string.should =~ /1: def sample/
35
- end
36
-
37
- it 'should output a method\'s source if inside method without needing to use method name' do
38
- $str_output = StringIO.new
39
-
40
- o = Object.new
41
- def o.sample
42
- redirect_pry_io(InputTester.new("show-source", "exit-all"), $str_output) do
43
- binding.pry
44
- end
45
- end
46
- o.sample
47
-
48
- $str_output.string.should =~ /def o.sample/
49
- $str_output = nil
50
- end
51
-
52
- it 'should output a method\'s source if inside method without needing to use method name, and using the -l switch' do
53
- $str_output = StringIO.new
54
-
55
- o = Object.new
56
- def o.sample
57
- redirect_pry_io(InputTester.new("show-source -l", "exit-all"), $str_output) do
58
- binding.pry
59
- end
60
- end
61
- o.sample
62
-
63
- $str_output.string.should =~ /\d+: def o.sample/
64
- $str_output = nil
65
- end
66
-
67
- it "should find methods even if there are spaces in the arguments" do
68
- o = Object.new
69
- def o.foo(*bars);
70
- "Mr flibble"
71
- self;
72
- end
73
-
74
- redirect_pry_io(InputTester.new("show-source o.foo('bar', 'baz bam').foo", "exit-all"), @str_output) do
75
- binding.pry
76
- end
77
-
78
- @str_output.string.should =~ /Mr flibble/
79
- end
80
-
81
- it "should find methods even if the object has an overridden method method" do
82
- c = Class.new{
83
- def method;
84
- 98
85
- end
86
- }
87
-
88
- mock_pry(binding, "show-source c.new.method").should =~ /98/
89
- end
90
-
91
- it "should find instance_methods even if the class has an override instance_method method" do
92
- c = Class.new{
93
- def method;
94
- 98
95
- end
96
-
97
- def self.instance_method; 789; end
98
- }
99
-
100
- mock_pry(binding, "show-source c#method").should =~ /98/
101
- end
102
-
103
- it "should find instance methods with -M" do
104
- c = Class.new{ def moo; "ve over!"; end }
105
- mock_pry(binding, "cd c","show-source -M moo").should =~ /ve over/
106
- end
107
-
108
- it "should not find instance methods with -m" do
109
- c = Class.new{ def moo; "ve over!"; end }
110
- mock_pry(binding, "cd c", "show-source -m moo").should =~ /could not be found/
111
- end
112
-
113
- it "should find normal methods with -m" do
114
- c = Class.new{ def self.moo; "ve over!"; end }
115
- mock_pry(binding, "cd c", "show-source -m moo").should =~ /ve over/
116
- end
117
-
118
- it "should not find normal methods with -M" do
119
- c = Class.new{ def self.moo; "ve over!"; end }
120
- mock_pry(binding, "cd c", "show-source -M moo").should =~ /could not be found/
121
- end
122
-
123
- it "should find normal methods with no -M or -m" do
124
- c = Class.new{ def self.moo; "ve over!"; end }
125
- mock_pry(binding, "cd c", "show-source moo").should =~ /ve over/
126
- end
127
-
128
- it "should find instance methods with no -M or -m" do
129
- c = Class.new{ def moo; "ve over!"; end }
130
- mock_pry(binding, "cd c", "show-source moo").should =~ /ve over/
131
- end
132
-
133
- it "should find super methods" do
134
- class Foo
135
- def foo(*bars)
136
- :super_wibble
137
- end
138
- end
139
- o = Foo.new
140
- Object.remove_const(:Foo)
141
- def o.foo(*bars)
142
- :wibble
143
- end
144
-
145
- mock_pry(binding, "show-source --super o.foo").should =~ /:super_wibble/
146
- end
147
-
148
- it "should not raise an exception when a non-extant super method is requested" do
149
- o = Object.new
150
- def o.foo(*bars); end
151
-
152
- mock_pry(binding, "show-source --super o.foo").should =~ /'self.foo' has no super method/
153
- end
154
-
155
- # dynamically defined method source retrieval is only supported in
156
- # 1.9 - where Method#source_location is native
157
- if RUBY_VERSION =~ /1.9/
158
- it 'should output a method\'s source for a method defined inside pry' do
159
- redirect_pry_io(InputTester.new("def dyna_method", ":testing", "end", "show-source dyna_method"), @str_output) do
160
- TOPLEVEL_BINDING.pry
161
- end
162
-
163
- @str_output.string.should =~ /def dyna_method/
164
- Object.remove_method :dyna_method
165
- end
166
-
167
- it 'should output a method\'s source for a method defined inside pry, even if exceptions raised before hand' do
168
- redirect_pry_io(InputTester.new("bad code", "123", "bad code 2", "1 + 2", "def dyna_method", ":testing", "end", "show-source dyna_method"), @str_output) do
169
- TOPLEVEL_BINDING.pry
170
- end
171
-
172
- @str_output.string.should =~ /def dyna_method/
173
- Object.remove_method :dyna_method
174
- end
175
-
176
- it 'should output an instance method\'s source for a method defined inside pry' do
177
- Object.remove_const :A if defined?(A)
178
- redirect_pry_io(InputTester.new("class A", "def yo", "end", "end", "show-source A#yo"), @str_output) do
179
- TOPLEVEL_BINDING.pry
180
- end
181
-
182
- @str_output.string.should =~ /def yo/
183
- Object.remove_const :A
184
- end
185
-
186
- it 'should output an instance method\'s source for a method defined inside pry using define_method' do
187
- Object.remove_const :A if defined?(A)
188
- redirect_pry_io(InputTester.new("class A", "define_method(:yup) {}", "end", "show-source A#yup"), @str_output) do
189
- TOPLEVEL_BINDING.pry
190
- end
191
-
192
- @str_output.string.should =~ /define_method\(:yup\)/
193
- Object.remove_const :A
194
- end
195
- end
196
-
197
- describe "on modules" do
198
- before do
199
- class ShowSourceTestClass
200
- def alpha
201
- end
202
- end
203
-
204
- module ShowSourceTestModule
205
- def alpha
206
- end
207
- end
208
-
209
- ShowSourceTestClassWeirdSyntax = Class.new do
210
- def beta
211
- end
212
- end
213
-
214
- ShowSourceTestModuleWeirdSyntax = Module.new do
215
- def beta
216
- end
217
- end
218
- end
219
-
220
- after do
221
- Object.remove_const :ShowSourceTestClass
222
- Object.remove_const :ShowSourceTestClassWeirdSyntax
223
- Object.remove_const :ShowSourceTestModule
224
- Object.remove_const :ShowSourceTestModuleWeirdSyntax
225
- end
226
-
227
- describe "basic functionality, should find top-level module definitions" do
228
- it 'should show source for a class' do
229
- mock_pry("show-source ShowSourceTestClass").should =~ /class ShowSourceTest.*?def alpha/m
230
- end
231
-
232
- it 'should show source for a module' do
233
- mock_pry("show-source ShowSourceTestModule").should =~ /module ShowSourceTestModule/
234
- end
235
-
236
- it 'should show source for a class when Const = Class.new syntax is used' do
237
- mock_pry("show-source ShowSourceTestClassWeirdSyntax").should =~ /ShowSourceTestClassWeirdSyntax = Class.new/
238
- end
239
-
240
- it 'should show source for a module when Const = Module.new syntax is used' do
241
- mock_pry("show-source ShowSourceTestModuleWeirdSyntax").should =~ /ShowSourceTestModuleWeirdSyntax = Module.new/
242
- end
243
- end
244
-
245
- if !Pry::Helpers::BaseHelpers.mri_18?
246
- describe "in REPL" do
247
- it 'should find class defined in repl' do
248
- mock_pry("class TobinaMyDog", "def woof", "end", "end", "show-source TobinaMyDog").should =~ /class TobinaMyDog/
249
- Object.remove_const :TobinaMyDog
250
- end
251
- end
252
- end
253
-
254
- it 'should lookup module name with respect to current context' do
255
- constant_scope(:AlphaClass, :BetaClass) do
256
- class BetaClass
257
- def alpha
258
- end
259
- end
260
-
261
- class AlphaClass
262
- class BetaClass
263
- def beta
264
- end
265
- end
266
- end
267
-
268
- redirect_pry_io(InputTester.new("show-source BetaClass", "exit-all"), out=StringIO.new) do
269
- AlphaClass.pry
270
- end
271
-
272
- out.string.should =~ /def beta/
273
- end
274
- end
275
-
276
- it 'should lookup nested modules' do
277
- constant_scope(:AlphaClass) do
278
- class AlphaClass
279
- class BetaClass
280
- def beta
281
- end
282
- end
283
- end
284
-
285
- mock_pry("show-source AlphaClass::BetaClass").should =~ /class BetaClass/
286
- end
287
- end
288
-
289
- # note that pry assumes a class is only monkey-patched at most
290
- # ONCE per file, so will not find multiple monkeypatches in the
291
- # SAME file.
292
- describe "show-source -a" do
293
- it 'should show the source for all monkeypatches defined in different files' do
294
- class TestClassForShowSource
295
- def beta
296
- end
297
- end
298
-
299
- result = mock_pry("show-source TestClassForShowSource -a")
300
- result.should =~ /def alpha/
301
- result.should =~ /def beta/
302
- end
303
-
304
- it 'should show the source for a class_eval-based monkeypatch' do
305
- TestClassForShowSourceClassEval.class_eval do
306
- def class_eval_method
307
- end
308
- end
309
-
310
- result = mock_pry("show-source TestClassForShowSourceClassEval -a")
311
- result.should =~ /def class_eval_method/
312
- end
313
-
314
- it 'should show the source for an instance_eval-based monkeypatch' do
315
- TestClassForShowSourceInstanceEval.instance_eval do
316
- def instance_eval_method
317
- end
318
- end
319
-
320
- result = mock_pry("show-source TestClassForShowSourceInstanceEval -a")
321
- result.should =~ /def instance_eval_method/
322
- end
323
- end
324
-
325
- describe "when show-source is invoked without a method or class argument" do
326
- before do
327
- module TestHost
328
- class M
329
- def alpha; end
330
- def beta; end
331
- end
332
-
333
- module C
334
- end
335
-
336
- module D
337
- def self.invoked_in_method
338
- redirect_pry_io(InputTester.new("show-source", "exit-all"), out = StringIO.new) do
339
- Pry.start(binding)
340
- end
341
- out.string
342
- end
343
- end
344
- end
345
- end
346
-
347
- after do
348
- Object.remove_const(:TestHost)
349
- end
350
-
351
- describe "inside a module" do
352
- it 'should display module source by default' do
353
- redirect_pry_io(InputTester.new("show-source", "exit-all"), out = StringIO.new) do
354
- Pry.start(TestHost::M)
355
- end
356
-
357
- out.string.should =~ /class M/
358
- out.string.should =~ /def alpha/
359
- out.string.should =~ /def beta/
360
- end
361
-
362
- it 'should be unable to find module source if no methods defined' do
363
- redirect_pry_io(InputTester.new("show-source", "exit-all"), out = StringIO.new) do
364
- Pry.start(TestHost::C)
365
- end
366
-
367
- out.string.should.should =~ /Cannot find a definition for/
368
- end
369
-
370
- it 'should display method code (rather than class) if Pry started inside method binding' do
371
- string = TestHost::D.invoked_in_method
372
- string.should =~ /invoked_in_method/
373
- string.should.not =~ /module D/
374
- end
375
-
376
- it 'should display class source when inside instance' do
377
- redirect_pry_io(InputTester.new("show-source", "exit-all"), out = StringIO.new) do
378
- Pry.start(TestHost::M.new)
379
- end
380
-
381
- out.string.should =~ /class M/
382
- out.string.should =~ /def alpha/
383
- out.string.should =~ /def beta/
384
- end
385
-
386
- it 'should allow options to be passed' do
387
- redirect_pry_io(InputTester.new("show-source -b", "exit-all"), out = StringIO.new) do
388
- Pry.start(TestHost::M)
389
- end
390
-
391
- out.string.should =~ /\d:\s*class M/
392
- out.string.should =~ /\d:\s*def alpha/
393
- out.string.should =~ /\d:\s*def beta/
394
- end
395
-
396
- describe "should skip over broken modules" do
397
- before do
398
- module BabyDuck
399
-
400
- module Muesli
401
- binding.eval("def a; end", "dummy.rb", 1)
402
- binding.eval("def b; end", "dummy.rb", 2)
403
- binding.eval("def c; end", "dummy.rb", 3)
404
- end
405
-
406
- module Muesli
407
- def d; end
408
- def e; end
409
- end
410
- end
411
- end
412
-
413
- after do
414
- Object.remove_const(:BabyDuck)
415
- end
416
-
417
- it 'should return source for first valid module' do
418
- redirect_pry_io(InputTester.new("show-source BabyDuck::Muesli"), out = StringIO.new) do
419
- Pry.start
420
- end
421
-
422
- out.string.should =~ /def d; end/
423
- out.string.should.not =~ /def a; end/
424
- end
425
-
426
- end
427
- end
428
- end
429
- end
430
- end
431
- end
432
-
@@ -1,21 +0,0 @@
1
- require 'helper'
2
-
3
- describe "Pry.config.exception_whitelist" do
4
- before do
5
- @str_output = StringIO.new
6
- end
7
-
8
- it 'should rescue all exceptions NOT specified on whitelist' do
9
- Pry.config.exception_whitelist.include?(NameError).should == false
10
- lambda { Pry.start(self, :input => StringIO.new("raise NameError\nexit"), :output => @str_output) }.should.not.raise NameError
11
- end
12
-
13
- it 'should NOT rescue exceptions specified on whitelist' do
14
- old_whitelist = Pry.config.exception_whitelist
15
- Pry.config.exception_whitelist = [NameError]
16
- lambda { Pry.start(self, :input => StringIO.new("raise NameError"), :output => @str_output) }.should.raise NameError
17
- Pry.config.exception_whitelist = old_whitelist
18
- end
19
- end
20
-
21
-