pry 0.9.12.2 → 0.14.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (237) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +1141 -0
  3. data/LICENSE +2 -2
  4. data/README.md +466 -0
  5. data/bin/pry +4 -7
  6. data/lib/pry/basic_object.rb +10 -0
  7. data/lib/pry/block_command.rb +22 -0
  8. data/lib/pry/class_command.rb +194 -0
  9. data/lib/pry/cli.rb +97 -92
  10. data/lib/pry/code/code_file.rb +114 -0
  11. data/lib/pry/code/code_range.rb +7 -4
  12. data/lib/pry/code/loc.rb +27 -14
  13. data/lib/pry/code.rb +62 -90
  14. data/lib/pry/code_object.rb +83 -39
  15. data/lib/pry/color_printer.rb +66 -0
  16. data/lib/pry/command.rb +202 -371
  17. data/lib/pry/command_set.rb +151 -133
  18. data/lib/pry/command_state.rb +31 -0
  19. data/lib/pry/commands/amend_line.rb +86 -82
  20. data/lib/pry/commands/bang.rb +18 -14
  21. data/lib/pry/commands/bang_pry.rb +15 -11
  22. data/lib/pry/commands/cat/abstract_formatter.rb +23 -18
  23. data/lib/pry/commands/cat/exception_formatter.rb +85 -73
  24. data/lib/pry/commands/cat/file_formatter.rb +56 -63
  25. data/lib/pry/commands/cat/input_expression_formatter.rb +35 -30
  26. data/lib/pry/commands/cat.rb +64 -47
  27. data/lib/pry/commands/cd.rb +42 -26
  28. data/lib/pry/commands/change_inspector.rb +34 -0
  29. data/lib/pry/commands/change_prompt.rb +51 -0
  30. data/lib/pry/commands/clear_screen.rb +20 -0
  31. data/lib/pry/commands/code_collector.rb +148 -131
  32. data/lib/pry/commands/disable_pry.rb +23 -19
  33. data/lib/pry/commands/easter_eggs.rb +23 -34
  34. data/lib/pry/commands/edit/exception_patcher.rb +21 -17
  35. data/lib/pry/commands/edit/file_and_line_locator.rb +33 -24
  36. data/lib/pry/commands/edit.rb +183 -167
  37. data/lib/pry/commands/exit.rb +40 -35
  38. data/lib/pry/commands/exit_all.rb +24 -20
  39. data/lib/pry/commands/exit_program.rb +20 -17
  40. data/lib/pry/commands/find_method.rb +167 -167
  41. data/lib/pry/commands/fix_indent.rb +16 -12
  42. data/lib/pry/commands/help.rb +140 -133
  43. data/lib/pry/commands/hist.rb +153 -132
  44. data/lib/pry/commands/import_set.rb +20 -15
  45. data/lib/pry/commands/jump_to.rb +25 -21
  46. data/lib/pry/commands/list_inspectors.rb +42 -0
  47. data/lib/pry/commands/ls/constants.rb +75 -0
  48. data/lib/pry/commands/ls/formatter.rb +55 -0
  49. data/lib/pry/commands/ls/globals.rb +50 -0
  50. data/lib/pry/commands/ls/grep.rb +23 -0
  51. data/lib/pry/commands/ls/instance_vars.rb +40 -0
  52. data/lib/pry/commands/ls/interrogatable.rb +24 -0
  53. data/lib/pry/commands/ls/jruby_hacks.rb +55 -0
  54. data/lib/pry/commands/ls/local_names.rb +37 -0
  55. data/lib/pry/commands/ls/local_vars.rb +47 -0
  56. data/lib/pry/commands/ls/ls_entity.rb +65 -0
  57. data/lib/pry/commands/ls/methods.rb +55 -0
  58. data/lib/pry/commands/ls/methods_helper.rb +50 -0
  59. data/lib/pry/commands/ls/self_methods.rb +34 -0
  60. data/lib/pry/commands/ls.rb +100 -303
  61. data/lib/pry/commands/nesting.rb +21 -17
  62. data/lib/pry/commands/play.rb +93 -49
  63. data/lib/pry/commands/pry_backtrace.rb +22 -18
  64. data/lib/pry/commands/pry_version.rb +15 -11
  65. data/lib/pry/commands/raise_up.rb +33 -27
  66. data/lib/pry/commands/reload_code.rb +57 -48
  67. data/lib/pry/commands/reset.rb +16 -12
  68. data/lib/pry/commands/ri.rb +57 -38
  69. data/lib/pry/commands/save_file.rb +45 -43
  70. data/lib/pry/commands/shell_command.rb +66 -34
  71. data/lib/pry/commands/shell_mode.rb +22 -20
  72. data/lib/pry/commands/show_doc.rb +80 -65
  73. data/lib/pry/commands/show_info.rb +193 -159
  74. data/lib/pry/commands/show_input.rb +16 -11
  75. data/lib/pry/commands/show_source.rb +113 -33
  76. data/lib/pry/commands/stat.rb +35 -31
  77. data/lib/pry/commands/switch_to.rb +21 -15
  78. data/lib/pry/commands/toggle_color.rb +21 -13
  79. data/lib/pry/commands/watch_expression/expression.rb +43 -0
  80. data/lib/pry/commands/watch_expression.rb +110 -0
  81. data/lib/pry/commands/whereami.rb +157 -134
  82. data/lib/pry/commands/wtf.rb +78 -40
  83. data/lib/pry/config/attributable.rb +22 -0
  84. data/lib/pry/config/lazy_value.rb +29 -0
  85. data/lib/pry/config/memoized_value.rb +34 -0
  86. data/lib/pry/config/value.rb +24 -0
  87. data/lib/pry/config.rb +290 -220
  88. data/lib/pry/control_d_handler.rb +28 -0
  89. data/lib/pry/core_extensions.rb +50 -27
  90. data/lib/pry/editor.rb +130 -102
  91. data/lib/pry/env.rb +18 -0
  92. data/lib/pry/exception_handler.rb +43 -0
  93. data/lib/pry/exceptions.rb +73 -0
  94. data/lib/pry/forwardable.rb +27 -0
  95. data/lib/pry/helpers/base_helpers.rb +22 -151
  96. data/lib/pry/helpers/command_helpers.rb +55 -63
  97. data/lib/pry/helpers/documentation_helpers.rb +21 -13
  98. data/lib/pry/helpers/options_helpers.rb +15 -8
  99. data/lib/pry/helpers/platform.rb +55 -0
  100. data/lib/pry/helpers/table.rb +44 -32
  101. data/lib/pry/helpers/text.rb +96 -86
  102. data/lib/pry/helpers.rb +3 -0
  103. data/lib/pry/history.rb +101 -70
  104. data/lib/pry/hooks.rb +67 -137
  105. data/lib/pry/indent.rb +79 -73
  106. data/lib/pry/input_completer.rb +283 -0
  107. data/lib/pry/input_lock.rb +129 -0
  108. data/lib/pry/inspector.rb +39 -0
  109. data/lib/pry/last_exception.rb +61 -0
  110. data/lib/pry/method/disowned.rb +19 -5
  111. data/lib/pry/{commands/edit/method_patcher.rb → method/patcher.rb} +51 -42
  112. data/lib/pry/method/weird_method_locator.rb +80 -44
  113. data/lib/pry/method.rb +225 -176
  114. data/lib/pry/object_path.rb +91 -0
  115. data/lib/pry/output.rb +136 -0
  116. data/lib/pry/pager.rb +227 -68
  117. data/lib/pry/prompt.rb +214 -0
  118. data/lib/pry/pry_class.rb +216 -289
  119. data/lib/pry/pry_instance.rb +438 -500
  120. data/lib/pry/repl.rb +256 -0
  121. data/lib/pry/repl_file_loader.rb +34 -35
  122. data/lib/pry/ring.rb +89 -0
  123. data/lib/pry/slop/LICENSE +20 -0
  124. data/lib/pry/slop/commands.rb +190 -0
  125. data/lib/pry/slop/option.rb +210 -0
  126. data/lib/pry/slop.rb +672 -0
  127. data/lib/pry/syntax_highlighter.rb +26 -0
  128. data/lib/pry/system_command_handler.rb +17 -0
  129. data/lib/pry/testable/evalable.rb +24 -0
  130. data/lib/pry/testable/mockable.rb +22 -0
  131. data/lib/pry/testable/pry_tester.rb +88 -0
  132. data/lib/pry/testable/utility.rb +34 -0
  133. data/lib/pry/testable/variables.rb +52 -0
  134. data/lib/pry/testable.rb +68 -0
  135. data/lib/pry/version.rb +3 -1
  136. data/lib/pry/warning.rb +20 -0
  137. data/lib/pry/{module_candidate.rb → wrapped_module/candidate.rb} +36 -43
  138. data/lib/pry/wrapped_module.rb +102 -103
  139. data/lib/pry.rb +135 -261
  140. metadata +94 -283
  141. data/.document +0 -2
  142. data/.gitignore +0 -16
  143. data/.travis.yml +0 -21
  144. data/.yardopts +0 -1
  145. data/CHANGELOG +0 -534
  146. data/CONTRIBUTORS +0 -55
  147. data/Gemfile +0 -9
  148. data/Guardfile +0 -62
  149. data/README.markdown +0 -400
  150. data/Rakefile +0 -140
  151. data/TODO +0 -117
  152. data/lib/pry/commands/disabled_commands.rb +0 -2
  153. data/lib/pry/commands/gem_cd.rb +0 -26
  154. data/lib/pry/commands/gem_install.rb +0 -29
  155. data/lib/pry/commands/gem_list.rb +0 -33
  156. data/lib/pry/commands/gem_open.rb +0 -29
  157. data/lib/pry/commands/gist.rb +0 -102
  158. data/lib/pry/commands/install_command.rb +0 -51
  159. data/lib/pry/commands/simple_prompt.rb +0 -22
  160. data/lib/pry/commands.rb +0 -6
  161. data/lib/pry/completion.rb +0 -304
  162. data/lib/pry/custom_completions.rb +0 -6
  163. data/lib/pry/history_array.rb +0 -116
  164. data/lib/pry/plugins.rb +0 -103
  165. data/lib/pry/rbx_method.rb +0 -13
  166. data/lib/pry/rbx_path.rb +0 -22
  167. data/lib/pry/rubygem.rb +0 -74
  168. data/lib/pry/terminal.rb +0 -78
  169. data/lib/pry/test/helper.rb +0 -185
  170. data/man/pry.1 +0 -195
  171. data/man/pry.1.html +0 -204
  172. data/man/pry.1.ronn +0 -141
  173. data/pry.gemspec +0 -30
  174. data/spec/Procfile +0 -3
  175. data/spec/cli_spec.rb +0 -78
  176. data/spec/code_object_spec.rb +0 -277
  177. data/spec/code_spec.rb +0 -219
  178. data/spec/command_helpers_spec.rb +0 -29
  179. data/spec/command_integration_spec.rb +0 -644
  180. data/spec/command_set_spec.rb +0 -627
  181. data/spec/command_spec.rb +0 -821
  182. data/spec/commands/amend_line_spec.rb +0 -247
  183. data/spec/commands/bang_spec.rb +0 -19
  184. data/spec/commands/cat_spec.rb +0 -164
  185. data/spec/commands/cd_spec.rb +0 -250
  186. data/spec/commands/disable_pry_spec.rb +0 -25
  187. data/spec/commands/edit_spec.rb +0 -727
  188. data/spec/commands/exit_all_spec.rb +0 -34
  189. data/spec/commands/exit_program_spec.rb +0 -19
  190. data/spec/commands/exit_spec.rb +0 -34
  191. data/spec/commands/find_method_spec.rb +0 -70
  192. data/spec/commands/gem_list_spec.rb +0 -26
  193. data/spec/commands/gist_spec.rb +0 -79
  194. data/spec/commands/help_spec.rb +0 -56
  195. data/spec/commands/hist_spec.rb +0 -181
  196. data/spec/commands/jump_to_spec.rb +0 -15
  197. data/spec/commands/ls_spec.rb +0 -181
  198. data/spec/commands/play_spec.rb +0 -140
  199. data/spec/commands/raise_up_spec.rb +0 -56
  200. data/spec/commands/save_file_spec.rb +0 -177
  201. data/spec/commands/show_doc_spec.rb +0 -510
  202. data/spec/commands/show_input_spec.rb +0 -17
  203. data/spec/commands/show_source_spec.rb +0 -782
  204. data/spec/commands/whereami_spec.rb +0 -203
  205. data/spec/completion_spec.rb +0 -239
  206. data/spec/control_d_handler_spec.rb +0 -58
  207. data/spec/documentation_helper_spec.rb +0 -73
  208. data/spec/editor_spec.rb +0 -79
  209. data/spec/exception_whitelist_spec.rb +0 -21
  210. data/spec/fixtures/candidate_helper1.rb +0 -11
  211. data/spec/fixtures/candidate_helper2.rb +0 -8
  212. data/spec/fixtures/example.erb +0 -5
  213. data/spec/fixtures/example_nesting.rb +0 -33
  214. data/spec/fixtures/show_source_doc_examples.rb +0 -15
  215. data/spec/fixtures/testrc +0 -2
  216. data/spec/fixtures/testrcbad +0 -2
  217. data/spec/fixtures/whereami_helper.rb +0 -6
  218. data/spec/helper.rb +0 -34
  219. data/spec/helpers/bacon.rb +0 -86
  220. data/spec/helpers/mock_pry.rb +0 -43
  221. data/spec/helpers/table_spec.rb +0 -105
  222. data/spec/history_array_spec.rb +0 -67
  223. data/spec/hooks_spec.rb +0 -522
  224. data/spec/indent_spec.rb +0 -301
  225. data/spec/input_stack_spec.rb +0 -90
  226. data/spec/method_spec.rb +0 -482
  227. data/spec/prompt_spec.rb +0 -60
  228. data/spec/pry_defaults_spec.rb +0 -419
  229. data/spec/pry_history_spec.rb +0 -99
  230. data/spec/pry_output_spec.rb +0 -95
  231. data/spec/pry_spec.rb +0 -504
  232. data/spec/run_command_spec.rb +0 -25
  233. data/spec/sticky_locals_spec.rb +0 -157
  234. data/spec/syntax_checking_spec.rb +0 -81
  235. data/spec/wrapped_module_spec.rb +0 -261
  236. data/wiki/Customizing-pry.md +0 -397
  237. data/wiki/Home.md +0 -4
@@ -1,203 +0,0 @@
1
- require 'helper'
2
-
3
- describe "whereami" do
4
- it 'should work with methods that have been undefined' do
5
- class Cor
6
- def blimey!
7
- Cor.send :undef_method, :blimey!
8
- Pad.binding = binding
9
- end
10
- end
11
-
12
- Cor.new.blimey!
13
-
14
- # using [.] so the regex doesn't match itself
15
- pry_eval(Pad.binding, 'whereami').should =~ /self[.]blimey!/
16
-
17
- Object.remove_const(:Cor)
18
- end
19
-
20
- it 'should work in objects with no method methods' do
21
- class Cor
22
- def blimey!
23
- pry_eval(binding, 'whereami').should =~ /Cor[#]blimey!/
24
- end
25
-
26
- def method; "moo"; end
27
- end
28
- Cor.new.blimey!
29
- Object.remove_const(:Cor)
30
- end
31
-
32
- it 'should properly set _file_, _line_ and _dir_' do
33
- class Cor
34
- def blimey!
35
- pry_eval(binding, 'whereami', '_file_').
36
- should == File.expand_path(__FILE__)
37
- end
38
- end
39
-
40
- Cor.new.blimey!
41
- Object.remove_const(:Cor)
42
- end
43
-
44
- if defined?(BasicObject)
45
- it 'should work in BasicObjects' do
46
- cor = Class.new(BasicObject) do
47
- def blimey!
48
- ::Kernel.binding # omnom
49
- end
50
- end.new.blimey!
51
-
52
- pry_eval(cor, 'whereami').should =~ /::Kernel.binding [#] omnom/
53
- end
54
- end
55
-
56
- it 'should show description and correct code when __LINE__ and __FILE__ are outside @method.source_location' do
57
- class Cor
58
- def blimey!
59
- eval <<-END, binding, "spec/fixtures/example.erb", 1
60
- pry_eval(binding, 'whereami')
61
- END
62
- end
63
- end
64
-
65
- Cor.instance_method(:blimey!).source.should =~ /pry_eval/
66
- Cor.new.blimey!.should =~ /Cor#blimey!.*Look at me/m
67
- Object.remove_const(:Cor)
68
- end
69
-
70
- it 'should show description and correct code when @method.source_location would raise an error' do
71
- class Cor
72
- eval <<-END, binding, "spec/fixtures/example.erb", 1
73
- def blimey!
74
- pry_eval(binding, 'whereami')
75
- end
76
- END
77
- end
78
-
79
- lambda{
80
- Cor.instance_method(:blimey!).source
81
- }.should.raise(MethodSource::SourceNotFoundError)
82
-
83
- Cor.new.blimey!.should =~ /Cor#blimey!.*Look at me/m
84
- Object.remove_const(:Cor)
85
- end
86
-
87
- # Now that we use stagger_output (paging output) we no longer get
88
- # the "From: " line, as we output everything in one go (not separate output.puts)
89
- # and so the user just gets a single `Error: Cannot open
90
- # "not.found.file.erb" for reading.`
91
- # which is good enough IMO. Unfortunately we can't test for it
92
- # though, as we don't hook stdout.
93
- #
94
- # it 'should display a description and error if reading the file goes wrong' do
95
- # class Cor
96
- # def blimey!
97
- # eval <<-END, binding, "not.found.file.erb", 7
98
- # Pad.tester = pry_tester(binding)
99
- # Pad.tester.eval('whereami')
100
- # END
101
- # end
102
- # end
103
-
104
- # proc { Cor.new.blimey! }.should.raise(MethodSource::SourceNotFoundError)
105
-
106
- # Pad.tester.last_output.should =~
107
- # /From: not.found.file.erb @ line 7 Cor#blimey!:/
108
- # Object.remove_const(:Cor)
109
- # end
110
-
111
- it 'should show code window (not just method source) if parameter passed to whereami' do
112
- class Cor
113
- def blimey!
114
- pry_eval(binding, 'whereami 3').should =~ /class Cor/
115
- end
116
- end
117
- Cor.new.blimey!
118
- Object.remove_const(:Cor)
119
- end
120
-
121
- it 'should show entire method when -m option used' do
122
- old_size, Pry.config.default_window_size = Pry.config.default_window_size, 1
123
- old_cutoff, Pry::Command::Whereami.method_size_cutoff = Pry::Command::Whereami.method_size_cutoff, 1
124
- class Cor
125
- def blimey!
126
- 1
127
- 2
128
- pry_eval(binding, 'whereami -m').should =~ /def blimey/
129
- end
130
- end
131
- Pry::Command::Whereami.method_size_cutoff, Pry.config.default_window_size = old_cutoff, old_size
132
- Cor.new.blimey!
133
- Object.remove_const(:Cor)
134
- end
135
-
136
- it 'should show entire file when -f option used' do
137
- class Cor
138
- def blimey!
139
- 1
140
- 2
141
- pry_eval(binding, 'whereami -f').should =~ /show entire file when -f option used/
142
- end
143
- end
144
- Cor.new.blimey!
145
- Object.remove_const(:Cor)
146
- end
147
-
148
- it 'should show class when -c option used, and locate correct candidate' do
149
- require 'fixtures/whereami_helper'
150
- class Cor
151
- def blimey!
152
- 1
153
- 2
154
- out = pry_eval(binding, 'whereami -c')
155
- out.should =~ /class Cor/
156
- out.should =~ /blimey/
157
- end
158
- end
159
- Cor.new.blimey!
160
- Object.remove_const(:Cor)
161
- end
162
-
163
- it 'should not show line numbers or marker when -n switch is used' do
164
- class Cor
165
- def blimey!
166
- out = pry_eval(binding, 'whereami -n')
167
- out.should =~ /^\s*def/
168
- out.should.not =~ /\=\>/
169
- end
170
- end
171
- Cor.new.blimey!
172
- Object.remove_const(:Cor)
173
- end
174
-
175
- it 'should use Pry.config.default_window_size for window size when outside a method context' do
176
- old_size, Pry.config.default_window_size = Pry.config.default_window_size, 1
177
- :litella
178
- :pig
179
- out = pry_eval(binding, 'whereami')
180
- :punk
181
- :sanders
182
-
183
- out.should.not =~ /:litella/
184
- out.should =~ /:pig/
185
- out.should =~ /:punk/
186
- out.should.not =~ /:sanders/
187
-
188
- Pry.config.default_window_size = old_size
189
- end
190
-
191
- it "should work at the top level" do
192
- pry_eval(Pry.toplevel_binding, 'whereami').should =~
193
- /At the top level/
194
- end
195
-
196
- it "should work inside a class" do
197
- pry_eval(Pry, 'whereami').should =~ /Inside Pry/
198
- end
199
-
200
- it "should work inside an object" do
201
- pry_eval(Object.new, 'whereami').should =~ /Inside #<Object/
202
- end
203
- end
@@ -1,239 +0,0 @@
1
- require 'helper'
2
-
3
- def new_completer(bind, pry=nil)
4
- Pry::InputCompleter.build_completion_proc(Pry.binding_for(bind), pry)
5
- end
6
-
7
- def completer_test(bind, pry=nil, assert_flag=true)
8
- completer = new_completer(bind, pry)
9
- test = proc {|symbol| completer.call(symbol[0..-2]).include?(symbol).should == assert_flag}
10
- return proc {|*symbols| symbols.each(&test) }
11
- end
12
-
13
- if defined?(Bond) && Readline::VERSION !~ /editline/i
14
- describe 'bond-based completion' do
15
- it 'should pull in Bond by default' do
16
- Pry.config.completer.should == Pry::BondCompleter
17
- end
18
- end
19
- end
20
-
21
- describe Pry::InputCompleter do
22
-
23
- before do
24
- # The AMQP gem has some classes like this:
25
- # pry(main)> AMQP::Protocol::Test::ContentOk.name
26
- # => :content_ok
27
- module SymbolyName
28
- def self.name; :symboly_name; end
29
- end
30
-
31
- $default_completer = Pry.config.completer
32
- Pry.config.completer = Pry::InputCompleter
33
- end
34
-
35
- after do
36
- Pry.config.completer = $default_completer
37
- Object.remove_const :SymbolyName
38
- end
39
-
40
- # another jruby hack :((
41
- if !Pry::Helpers::BaseHelpers.jruby?
42
- it "should not crash if there's a Module that has a symbolic name." do
43
- completer = Pry::InputCompleter.build_completion_proc(Pry.binding_for(Object.new))
44
- lambda{ completer.call "a.to_s." }.should.not.raise Exception
45
- end
46
- end
47
-
48
- it 'should take parenthesis and other characters into account for symbols' do
49
- b = Pry.binding_for(Object.new)
50
- completer = Pry::InputCompleter.build_completion_proc(b)
51
-
52
- lambda { completer.call(":class)") }.should.not.raise(RegexpError)
53
- end
54
-
55
- it 'should complete instance variables' do
56
- object = Class.new.new
57
-
58
- # set variables in appropriate scope
59
- object.instance_variable_set(:'@name', 'Pry')
60
- object.class.send(:class_variable_set, :'@@number', 10)
61
-
62
- # check to see if variables are in scope
63
- object.instance_variables.
64
- map { |v| v.to_sym }.
65
- include?(:'@name').should == true
66
-
67
- object.class.class_variables.
68
- map { |v| v.to_sym }.
69
- include?(:'@@number').should == true
70
-
71
- # Complete instance variables.
72
- b = Pry.binding_for(object)
73
- completer_test(b).call('@name', '@name.downcase')
74
-
75
- # Complete class variables.
76
- b = Pry.binding_for(object.class)
77
- completer_test(b).call('@@number', '@@number.class')
78
-
79
- end
80
-
81
-
82
- it 'should complete for stdlib symbols' do
83
-
84
- o = Object.new
85
- # Regexp
86
- completer_test(o).call('/foo/.extend')
87
-
88
- # Array
89
- completer_test(o).call('[1].push')
90
-
91
- # Hash
92
- completer_test(o).call('{"a" => "b"}.keys')
93
-
94
- # Proc
95
- completer_test(o).call('{2}.call')
96
-
97
- # Symbol
98
- completer_test(o).call(':symbol.to_s')
99
-
100
- # Absolute Constant
101
- completer_test(o).call('::IndexError')
102
- end
103
-
104
- it 'should complete for target symbols' do
105
- o = Object.new
106
-
107
- # Constant
108
- module Mod
109
- Con = 'Constant'
110
- module Mod2
111
- end
112
- end
113
-
114
- completer_test(Mod).call('Con')
115
-
116
- # Constants or Class Methods
117
- completer_test(o).call('Mod::Con')
118
-
119
- # Symbol
120
- foo = :symbol
121
- completer_test(o).call(':symbol')
122
-
123
- # Variables
124
- class << o
125
- attr_accessor :foo
126
- end
127
- o.foo = 'bar'
128
- completer_test(binding).call('o.foo')
129
-
130
- # trailing slash
131
- new_completer(Mod).call('Mod2/').include?('Mod2/').should == true
132
- end
133
-
134
- it 'should complete for arbitrary scopes' do
135
- module Bar
136
- @barvar = :bar
137
- end
138
-
139
- module Baz
140
- @bar = Bar
141
- @bazvar = :baz
142
- Con = :constant
143
- end
144
-
145
- pry = Pry.new()
146
- stack = pry.binding_stack
147
- stack.push(Pry.binding_for(Baz))
148
- stack.push(Pry.binding_for(Bar))
149
-
150
- b = Pry.binding_for(Bar)
151
- completer_test(b, pry).call("../@bazvar")
152
- completer_test(b, pry).call('/Con')
153
- end
154
-
155
- it 'should complete for stdlib symbols' do
156
-
157
- o = Object.new
158
- # Regexp
159
- completer_test(o).call('/foo/.extend')
160
-
161
- # Array
162
- completer_test(o).call('[1].push')
163
-
164
- # Hash
165
- completer_test(o).call('{"a" => "b"}.keys')
166
-
167
- # Proc
168
- completer_test(o).call('{2}.call')
169
-
170
- # Symbol
171
- completer_test(o).call(':symbol.to_s')
172
-
173
- # Absolute Constant
174
- completer_test(o).call('::IndexError')
175
- end
176
-
177
- it 'should complete for target symbols' do
178
- o = Object.new
179
-
180
- # Constant
181
- module Mod
182
- Con = 'Constant'
183
- module Mod2
184
- end
185
- end
186
-
187
- completer_test(Mod).call('Con')
188
-
189
- # Constants or Class Methods
190
- completer_test(o).call('Mod::Con')
191
-
192
- # Symbol
193
- foo = :symbol
194
- completer_test(o).call(':symbol')
195
-
196
- # Variables
197
- class << o
198
- attr_accessor :foo
199
- end
200
- o.foo = 'bar'
201
- completer_test(binding).call('o.foo')
202
-
203
- # trailing slash
204
- new_completer(Mod).call('Mod2/').include?('Mod2/').should == true
205
-
206
- end
207
-
208
- it 'should complete for arbitrary scopes' do
209
- module Bar
210
- @barvar = :bar
211
- end
212
-
213
- module Baz
214
- @bar = Bar
215
- @bazvar = :baz
216
- Con = :constant
217
- end
218
-
219
- pry = Pry.new()
220
- stack = pry.binding_stack
221
- stack.push(Pry.binding_for(Baz))
222
- stack.push(Pry.binding_for(Bar))
223
-
224
- b = Pry.binding_for(Bar)
225
- completer_test(b, pry).call("../@bazvar")
226
- completer_test(b, pry).call('/Con')
227
- end
228
-
229
- it 'should not return nil in its output' do
230
- pry = Pry.new
231
- new_completer(binding, pry).call("pry.").should.not.include nil
232
- end
233
-
234
- it "does not raise when complete file paths" do
235
- should.not.raise(Pry::CommandError) {
236
- new_completer(binding, Pry.new).call("cat lib/p")
237
- }
238
- end
239
- end
@@ -1,58 +0,0 @@
1
- require 'helper'
2
-
3
- describe Pry::DEFAULT_CONTROL_D_HANDLER do
4
-
5
- describe "control-d press" do
6
-
7
- before do
8
- # Simulates a ^D press.
9
- @control_d = "Pry::DEFAULT_CONTROL_D_HANDLER.call('', _pry_)"
10
- end
11
-
12
- describe "in an expression" do
13
- it "should clear out passed string" do
14
- str = 'hello world'
15
- Pry::DEFAULT_CONTROL_D_HANDLER.call(str, nil)
16
- str.should == ''
17
- end
18
- end
19
-
20
-
21
- describe "at top-level session" do
22
- it "breaks out of a REPL" do
23
- pry_tester(0).simulate_repl do |t|
24
- t.eval @control_d
25
- end.should == nil
26
- end
27
- end
28
-
29
- describe "in a nested session" do
30
- it "pops last binding from the binding stack" do
31
- pry_tester(0).simulate_repl { |t|
32
- t.eval 'cd :foo'
33
- t.eval('_pry_.binding_stack.size').should == 2
34
- t.eval(@control_d)
35
- t.eval('_pry_.binding_stack.size').should == 1
36
- t.eval 'exit-all'
37
- }
38
- end
39
-
40
- it "breaks out of the parent session" do
41
- pry_tester(:outer).simulate_repl do |o|
42
- o.context = :inner
43
- o.simulate_repl { |i|
44
- i.eval('_pry_.current_context.eval("self")').should == :inner
45
- i.eval('_pry_.binding_stack.size').should == 2
46
- i.eval @control_d
47
- i.eval('_pry_.binding_stack.size').should == 1
48
- i.eval('_pry_.current_context.eval("self")').should == :outer
49
- i.eval 'throw :breakout'
50
- }
51
- o.eval 'exit-all'
52
- end
53
- end
54
- end
55
-
56
- end
57
-
58
- end
@@ -1,73 +0,0 @@
1
- require 'helper'
2
-
3
- describe Pry::Helpers::DocumentationHelpers do
4
- before do
5
- @helper = Pry::Helpers::DocumentationHelpers
6
- end
7
-
8
- describe "get_comment_content" do
9
- it "should strip off the hash and unindent" do
10
- @helper.get_comment_content(" # hello\n # world\n").should == "hello\nworld\n"
11
- end
12
-
13
- it "should strip out leading lines of hashes" do
14
- @helper.get_comment_content("###############\n#hello\n#world\n").should == "hello\nworld\n"
15
- end
16
-
17
- it "should remove shebangs" do
18
- @helper.get_comment_content("#!/usr/bin/env ruby\n# This is a program\n").should == "This is a program\n"
19
- end
20
-
21
- it "should unindent past separators" do
22
- @helper.get_comment_content(" # Copyright Me <me@cirw.in>\n #--\n # So there.\n").should == "Copyright Me <me@cirw.in>\n--\nSo there.\n"
23
- end
24
- end
25
-
26
- describe "process_rdoc" do
27
- before do
28
- Pry.color = true
29
- end
30
-
31
- after do
32
- Pry.color = false
33
- end
34
-
35
- it "should syntax highlight indented code" do
36
- @helper.process_rdoc(" 4 + 4\n").should.not == " 4 + 4\n"
37
- end
38
-
39
- it "should highlight words surrounded by +s" do
40
- @helper.process_rdoc("the +parameter+").should =~ /the \e.*parameter\e.*/
41
- end
42
-
43
- it "should syntax highlight things in backticks" do
44
- @helper.process_rdoc("for `Example`").should =~ /for `\e.*Example\e.*`/
45
- end
46
-
47
- it "should emphasise em tags" do
48
- @helper.process_rdoc("for <em>science</em>").should == "for \e[1mscience\e[0m"
49
- end
50
-
51
- it "should emphasise italic tags" do
52
- @helper.process_rdoc("for <i>science</i>").should == "for \e[1mscience\e[0m"
53
- end
54
-
55
- it "should syntax highlight code in <code>" do
56
- @helper.process_rdoc("for <code>Example</code>").should =~ /for \e.*Example\e.*/
57
- end
58
-
59
- it "should not double-highlight backticks inside indented code" do
60
- @helper.process_rdoc(" `echo 5`").should =~ /echo 5/
61
- end
62
-
63
- it "should not remove ++" do
64
- @helper.process_rdoc("--\n comment in a bubble\n++").should =~ /\+\+/
65
- end
66
-
67
- it "should do nothing if Pry.color is false" do
68
- Pry.color = false
69
- @helper.process_rdoc(" 4 + 4\n").should == " 4 + 4\n"
70
- end
71
- end
72
-
73
- end
data/spec/editor_spec.rb DELETED
@@ -1,79 +0,0 @@
1
- require 'pathname'
2
- require 'helper'
3
-
4
- describe Pry::Editor do
5
- class << Pry::Editor
6
- public :build_editor_invocation_string
7
- end
8
-
9
- before do
10
- # OS-specific tempdir name. For GNU/Linux it's "tmp", for Windows it's
11
- # something "Temp".
12
- @tf_dir =
13
- if Pry::Helpers::BaseHelpers.mri_19?
14
- Pathname.new(Dir::Tmpname.tmpdir)
15
- else
16
- Pathname.new(Dir.tmpdir)
17
- end
18
-
19
- @tf_path = File.join(@tf_dir.to_s, 'hello world.rb')
20
- end
21
-
22
- unless Pry::Helpers::BaseHelpers.windows?
23
- describe "build_editor_invocation_string" do
24
- before do
25
- class << Pry::Editor
26
- public :build_editor_invocation_string
27
- end
28
- end
29
-
30
- it 'should shell-escape files' do
31
- invocation_str = Pry::Editor.build_editor_invocation_string(@tf_path, 5, true)
32
- invocation_str.should =~ /#@tf_dir.+hello\\ world\.rb/
33
- end
34
- end
35
- end
36
-
37
- describe "build_editor_invocation_string on windows" do
38
- before do
39
- class << Pry::Editor
40
- def windows?; true; end
41
- end
42
- end
43
-
44
- after do
45
- class << Pry::Editor
46
- undef windows?
47
- end
48
- end
49
-
50
- it "should replace / by \\" do
51
- invocation_str = Pry::Editor.build_editor_invocation_string(@tf_path, 5, true)
52
- invocation_str.should =~ %r(\\#{@tf_dir.basename}\\)
53
- end
54
-
55
- it "should not shell-escape files" do
56
- invocation_str = Pry::Editor.build_editor_invocation_string(@tf_path, 5, true)
57
- invocation_str.should =~ /hello world\.rb/
58
- end
59
- end
60
-
61
- describe 'invoke_editor with a proc' do
62
- before do
63
- @old_editor = Pry.config.editor
64
- Pry.config.editor = proc{ |file, line, blocking|
65
- @file = file
66
- nil
67
- }
68
- end
69
-
70
- after do
71
- Pry.config.editor = @old_editor
72
- end
73
-
74
- it 'should not shell-escape files' do
75
- Pry::Editor.invoke_editor(@tf_path, 10, true)
76
- @file.should == @tf_path
77
- end
78
- end
79
- end
@@ -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
-
@@ -1,11 +0,0 @@
1
- # rank 0
2
- class CandidateTest
3
- def test1
4
- end
5
-
6
- def test2
7
- end
8
-
9
- def test3
10
- end
11
- end
@@ -1,8 +0,0 @@
1
- # rank 1
2
- class CandidateTest
3
- def test4
4
- end
5
-
6
- def test5
7
- end
8
- end
@@ -1,5 +0,0 @@
1
- <html>
2
-
3
- Look at me, testing my erb!
4
-
5
- </html>