pry 0.8.0pre9 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -6,7 +6,7 @@ class Pry
6
6
 
7
7
  # Implements tab completion for Readline in Pry
8
8
  module InputCompleter
9
-
9
+
10
10
  if Readline.respond_to?("basic_word_break_characters=")
11
11
  Readline.basic_word_break_characters= " \t\n\"\\'`><=;|&{("
12
12
  end
@@ -2,20 +2,16 @@ class Pry
2
2
 
3
3
  # The default hooks - display messages when beginning and ending Pry sessions.
4
4
  DEFAULT_HOOKS = {
5
-
6
- :before_session => proc do |out, target|
7
- # out.puts "Beginning Pry session for #{Pry.view_clip(target.eval('self'))}"
8
5
 
6
+ :before_session => proc do |out, target|
9
7
  # ensure we're actually in a method
10
8
  meth_name = target.eval('__method__')
11
9
  file = target.eval('__FILE__')
12
10
 
13
11
  # /unknown/ for rbx
14
- if file !~ /(\(.*\))|<.*>/ && file !~ /__unknown__/ && file != ""
12
+ if file !~ /(\(.*\))|<.*>/ && file !~ /__unknown__/ && file != "" && file != "-e"
15
13
  Pry.run_command "whereami 5", :output => out, :show_output => true, :context => target, :commands => Pry::Commands
16
14
  end
17
15
  end,
18
-
19
- # :after_session => proc { |out, target| out.puts "Ending Pry session for #{Pry.view_clip(target.eval('self'))}" }
20
16
  }
21
17
  end
@@ -1,19 +1,16 @@
1
1
  class Pry
2
-
3
- # The default print object - only show first line of backtrace and
4
- # prepend output with `=>`
5
2
  DEFAULT_PRINT = proc do |output, value|
6
- case value
7
- when Exception
8
- output.puts "#{value.class}: #{value.message}"
9
- output.puts "from #{value.backtrace.first}"
3
+ if Pry.color
4
+ output.puts "=> #{CodeRay.scan(Pry.view(value), :ruby).term}"
10
5
  else
11
- if Pry.color
12
- output.puts "=> #{CodeRay.scan(Pry.view(value), :ruby).term}"
13
- else
14
- output.puts "=> #{Pry.view(value)}"
15
- end
6
+ output.puts "=> #{Pry.view(value)}"
16
7
  end
17
8
  end
9
+
10
+ # Will only show the first line of the backtrace
11
+ DEFAULT_EXCEPTION_HANDLER = proc do |output, exception|
12
+ output.puts "#{exception.class}: #{exception.message}"
13
+ output.puts "from #{exception.backtrace.first}"
14
+ end
18
15
  end
19
-
16
+
@@ -1,6 +1,6 @@
1
1
  class Pry
2
2
 
3
-
3
+
4
4
  # The default prompt; includes the target and nesting level
5
5
  DEFAULT_PROMPT = [
6
6
  proc do |target_self, nest_level|
@@ -11,7 +11,7 @@ class Pry
11
11
  "pry(#{Pry.view_clip(target_self)}):#{Pry.view_clip(nest_level)}> "
12
12
  end
13
13
  end,
14
-
14
+
15
15
  proc do |target_self, nest_level|
16
16
  if nest_level == 0
17
17
  "pry(#{Pry.view_clip(target_self)})* "
@@ -24,7 +24,7 @@ class Pry
24
24
  # A simple prompt - doesn't display target or nesting level
25
25
  SIMPLE_PROMPT = [proc { ">> " }, proc { ">* " }]
26
26
 
27
- FILE_PROMPT = [
27
+ SHELL_PROMPT = [
28
28
  proc { |target_self, _| "pry #{Pry.view_clip(target_self)}:#{Dir.pwd} $ " },
29
29
  proc { |target_self, _| "pry #{Pry.view_clip(target_self)}:#{Dir.pwd} * " }
30
30
  ]
@@ -1,9 +1,9 @@
1
1
  # @author John Mair (banisterfiend)
2
2
  class Pry
3
3
 
4
- # The RC Files to load.
4
+ # The RC Files to load.
5
5
  RC_FILES = ["~/.pryrc"]
6
-
6
+
7
7
  # class accessors
8
8
  class << self
9
9
 
@@ -49,6 +49,10 @@ class Pry
49
49
  # Pry instances.
50
50
  attr_accessor :print
51
51
 
52
+ # @return [Proc] The Proc to use for printing exceptions by default by all
53
+ # Pry instances.
54
+ attr_accessor :exception_handler
55
+
52
56
  # Get/Set the Hash that defines Pry hooks used by default by all Pry
53
57
  # instances.
54
58
  # @return [Hash] The hooks used by default by all Pry instances.
@@ -57,7 +61,7 @@ class Pry
57
61
  # :after_session => proc { puts "goodbye" }
58
62
  attr_accessor :hooks
59
63
 
60
-
64
+
61
65
  # Get/Set the Proc that defines extra Readline completions (on top
62
66
  # of the ones defined for IRB).
63
67
  # @return [Proc] The Proc that defines extra Readline completions (on top
@@ -76,11 +80,15 @@ class Pry
76
80
  attr_accessor :cmd_ret_value
77
81
 
78
82
  # Determines whether colored output is enabled.
79
- # @return [Boolean]
83
+ # @return [Boolean]
80
84
  attr_accessor :color
81
85
 
86
+ # Determines whether paging (of long blocks of text) is enabled.
87
+ # @return [Boolean]
88
+ attr_accessor :pager
89
+
82
90
  # Determines whether the rc file (~/.pryrc) should be loaded.
83
- # @return [Boolean]
91
+ # @return [Boolean]
84
92
  attr_accessor :should_load_rc
85
93
 
86
94
  # Set to true if Pry is invoked from command line using `pry` executable
@@ -101,7 +109,7 @@ class Pry
101
109
  load(file_name) if File.exists?(file_name)
102
110
  end
103
111
  end
104
-
112
+
105
113
  # Start a Pry REPL.
106
114
  # This method also loads the files specified in `Pry::RC_FILES` the
107
115
  # first time it is invoked.
@@ -115,7 +123,7 @@ class Pry
115
123
  load_rc
116
124
  @rc_loaded = true
117
125
  end
118
-
126
+
119
127
  new(options).repl(target)
120
128
  end
121
129
 
@@ -125,7 +133,7 @@ class Pry
125
133
  # @return [String] The string representation of `obj`.
126
134
  def self.view(obj)
127
135
  case obj
128
- when String, Hash, Array, Symbol, nil
136
+ when String, Hash, Array, Symbol, Exception, nil
129
137
  obj.inspect
130
138
  else
131
139
  obj.to_s
@@ -169,23 +177,18 @@ class Pry
169
177
  def self.run_command(arg_string, options={})
170
178
  name, arg_string = arg_string.split(/\s+/, 2)
171
179
  arg_string = "" if !arg_string
172
-
180
+
173
181
  options = {
174
182
  :context => TOPLEVEL_BINDING,
175
183
  :show_output => false,
176
184
  :output => Pry.output,
177
185
  :commands => Pry.commands
178
186
  }.merge!(options)
179
-
187
+
180
188
  null_output = Object.new.tap { |v| v.instance_eval { def puts(*) end } }
181
-
182
- # FIXME! ugly hack to get around broken methods in both YARD and RBX
183
- if RUBY_VERSION =~ /1.9/
184
- commands = options[:commands].dup
185
- else
186
- commands = options[:commands].clone
187
- end
188
-
189
+
190
+ commands = options[:commands]
191
+
189
192
  commands.output = options[:show_output] ? options[:output] : null_output
190
193
  commands.target = Pry.binding_for(options[:context])
191
194
 
@@ -205,9 +208,11 @@ class Pry
205
208
  @commands = Pry::Commands
206
209
  @prompt = DEFAULT_PROMPT
207
210
  @print = DEFAULT_PRINT
211
+ @exception_handler = DEFAULT_EXCEPTION_HANDLER
208
212
  @hooks = DEFAULT_HOOKS
209
213
  @custom_completions = DEFAULT_CUSTOM_COMPLETIONS
210
214
  @color = true
215
+ @pager = true
211
216
  @should_load_rc = true
212
217
  @rc_loaded = false
213
218
  @cli = false
@@ -6,7 +6,8 @@ class Pry
6
6
 
7
7
  # The list of configuration options.
8
8
  CONFIG_OPTIONS = [:input, :output, :commands, :print,
9
- :prompt, :hooks, :custom_completions]
9
+ :exception_handler, :prompt, :hooks,
10
+ :custom_completions]
10
11
 
11
12
  attr_accessor *CONFIG_OPTIONS
12
13
 
@@ -17,8 +18,8 @@ class Pry
17
18
 
18
19
  # Create a new `Pry` object.
19
20
  # @param [Hash] options The optional configuration parameters.
20
- # @option options [#readline] :input The object to use for input.
21
- # @option options [#puts] :output The object to use for output.
21
+ # @option options [#readline] :input The object to use for input.
22
+ # @option options [#puts] :output The object to use for output.
22
23
  # @option options [Pry::CommandBase] :commands The object to use for commands. (see commands.rb)
23
24
  # @option options [Hash] :hooks The defined hook Procs (see hooks.rb)
24
25
  # @option options [Array<Proc>] :default_prompt The array of Procs to use for the prompts. (see prompts.rb)
@@ -91,7 +92,7 @@ class Pry
91
92
 
92
93
  # If break_data is an array, then the last element is the return value
93
94
  break_level, return_value = Array(break_data)
94
-
95
+
95
96
  # keep throwing until we reach the desired nesting level
96
97
  if nesting_level != break_level
97
98
  throw :breakout, break_data
@@ -113,7 +114,7 @@ class Pry
113
114
  target_self = target.eval('self')
114
115
 
115
116
  repl_prologue(target)
116
-
117
+
117
118
  # cannot rely on nesting.level as
118
119
  # nesting.level changes with new sessions
119
120
  nesting_level = nesting.size
@@ -129,7 +130,7 @@ class Pry
129
130
 
130
131
  # if one was provided, return the return value
131
132
  return return_value if return_value
132
-
133
+
133
134
  # otherwise return the target_self
134
135
  target_self
135
136
  end
@@ -143,13 +144,15 @@ class Pry
143
144
  target = Pry.binding_for(target)
144
145
  result = re(target)
145
146
 
146
- print.call output, result if should_print?(result)
147
+ show_result(result) if should_print?
147
148
  end
148
149
 
149
150
  # Perform a read-eval
150
151
  # If no parameter is given, default to top-level (main).
151
152
  # @param [Object, Binding] target The receiver of the read-eval-print
152
- # @return [Object] The result of the eval or an `Exception` object in case of error.
153
+ # @return [Object] The result of the eval or an `Exception` object in case of
154
+ # error. In the latter case, you can check whether the exception was raised
155
+ # or is just the result of the expression using #last_result_is_exception?
153
156
  # @example
154
157
  # Pry.new.re(Object.new)
155
158
  def re(target=TOPLEVEL_BINDING)
@@ -160,11 +163,12 @@ class Pry
160
163
  Readline.completion_proc = Pry::InputCompleter.build_completion_proc target, instance_eval(&custom_completions)
161
164
  end
162
165
 
163
-
164
166
  # save the pry instance to active_instance
165
167
  Pry.active_instance = self
166
168
  target.eval("_pry_ = ::Pry.active_instance")
167
169
 
170
+ @last_result_is_exception = false
171
+
168
172
  # eval the expression and save to last_result
169
173
  # Do not want __FILE__, __LINE__ here because we need to distinguish
170
174
  # (eval) methods for show-method and friends.
@@ -173,6 +177,7 @@ class Pry
173
177
  rescue SystemExit => e
174
178
  exit
175
179
  rescue Exception => e
180
+ @last_result_is_exception = true
176
181
  set_last_exception(e, target)
177
182
  end
178
183
 
@@ -190,16 +195,26 @@ class Pry
190
195
  @suppress_output = false
191
196
  eval_string = ""
192
197
 
198
+ val = ""
193
199
  loop do
194
200
  val = retrieve_line(eval_string, target)
195
201
  process_line(val, eval_string, target)
196
- break if valid_expression?(eval_string) && !null_input?(val)
202
+ break if valid_expression?(eval_string)
197
203
  end
198
204
 
199
- @suppress_output = true if eval_string =~ /;\Z/
200
-
205
+ @suppress_output = true if eval_string =~ /;\Z/ || null_input?(val)
206
+
201
207
  eval_string
202
- end
208
+ end
209
+
210
+ # FIXME should delete this method? it's exposing an implementation detail!
211
+ def show_result(result)
212
+ if last_result_is_exception?
213
+ exception_handler.call output, result
214
+ else
215
+ print.call output, result
216
+ end
217
+ end
203
218
 
204
219
  # Returns true if input is "" and a command is not returning a
205
220
  # value.
@@ -221,9 +236,9 @@ class Pry
221
236
  # exit session if we receive EOF character
222
237
  if !val
223
238
  output.puts
224
- throw(:breakout, nesting.level)
239
+ throw(:breakout, nesting.level)
225
240
  end
226
-
241
+
227
242
  val
228
243
  end
229
244
 
@@ -235,7 +250,7 @@ class Pry
235
250
  def process_line(val, eval_string, target)
236
251
  val.rstrip!
237
252
  Pry.cmd_ret_value = @command_processor.process_commands(val, eval_string, target)
238
-
253
+
239
254
  if Pry.cmd_ret_value
240
255
  eval_string << "Pry.cmd_ret_value\n"
241
256
  else
@@ -261,6 +276,13 @@ class Pry
261
276
  target.eval("_ex_ = ::Pry.last_exception")
262
277
  end
263
278
 
279
+ # @return [Boolean] True if the last result is an exception that was raised,
280
+ # as opposed to simply an instance of Exception (like the result of
281
+ # Exception.new)
282
+ def last_result_is_exception?
283
+ @last_result_is_exception
284
+ end
285
+
264
286
  # Returns the next line of input to be used by the pry instance.
265
287
  # This method should not need to be invoked directly.
266
288
  # @param [String] current_prompt The prompt to use for input.
@@ -279,29 +301,22 @@ class Pry
279
301
  else
280
302
  input.readline
281
303
  end
282
- rescue Exception => ex
304
+
305
+ rescue EOFError
283
306
  self.input = Readline
284
307
  ""
285
-
286
- # FIX ME!!!
287
- # failing test is due to null_input?() being true for a
288
- # command that doesn't return a value. This causes a EOFError
289
- # exception for a 'rep' (as in test) as it makes the read loop
290
- # redo and so it tries to read from a non-existent string
291
- # binding.pry
292
308
  end
293
309
  end
294
310
  end
295
311
 
296
312
  # Whether the print proc should be invoked.
297
- # Currently only invoked if the output is not suppressed OR the output
313
+ # Currently only invoked if the output is not suppressed OR the last result
298
314
  # is an exception regardless of suppression.
299
- # @param [Object] result The result of evaluation stage of the REPL
300
315
  # @return [Boolean] Whether the print proc should be invoked.
301
- def should_print?(result)
302
- !@suppress_output || result.is_a?(Exception)
316
+ def should_print?
317
+ !@suppress_output || last_result_is_exception?
303
318
  end
304
-
319
+
305
320
  # Returns the appropriate prompt to use.
306
321
  # This method should not need to be invoked directly.
307
322
  # @param [Boolean] first_line Whether this is the first line of input
@@ -1,3 +1,3 @@
1
1
  class Pry
2
- VERSION = "0.8.0pre9"
2
+ VERSION = "0.8.0"
3
3
  end
@@ -35,7 +35,7 @@ describe Pry do
35
35
  it 'should make self evaluate to the receiver of the rep session' do
36
36
  o = Object.new
37
37
  str_output = StringIO.new
38
-
38
+
39
39
  pry_tester = Pry.new(:input => InputTester.new("self"), :output => str_output)
40
40
  pry_tester.rep(o)
41
41
  str_output.string.should =~ /#{o.to_s}/
@@ -44,7 +44,7 @@ describe Pry do
44
44
  it 'should work with multi-line input' do
45
45
  o = Object.new
46
46
  str_output = StringIO.new
47
-
47
+
48
48
  pry_tester = Pry.new(:input => InputTester.new("x = ", "1 + 4"), :output => str_output)
49
49
  pry_tester.rep(o)
50
50
  str_output.string.should =~ /5/
@@ -55,6 +55,60 @@ describe Pry do
55
55
  pry_tester.rep(Hello)
56
56
  Hello.const_defined?(:Nested).should == true
57
57
  end
58
+
59
+ it 'should suppress output if input ends in a ";" and is an Exception object (single line)' do
60
+ o = Object.new
61
+ str_output = StringIO.new
62
+
63
+ pry_tester = Pry.new(:input => InputTester.new("Exception.new;"), :output => str_output)
64
+ pry_tester.rep(o)
65
+ str_output.string.should == ""
66
+ end
67
+
68
+ it 'should suppress output if input ends in a ";" (single line)' do
69
+ o = Object.new
70
+ str_output = StringIO.new
71
+
72
+ pry_tester = Pry.new(:input => InputTester.new("x = 5;"), :output => str_output)
73
+ pry_tester.rep(o)
74
+ str_output.string.should == ""
75
+ end
76
+
77
+
78
+ it 'should suppress output if input ends in a ";" (multi-line)' do
79
+ o = Object.new
80
+ str_output = StringIO.new
81
+
82
+ pry_tester = Pry.new(:input => InputTester.new("def self.blah", ":test", "end;"), :output => str_output)
83
+ pry_tester.rep(o)
84
+ str_output.string.should == ""
85
+ end
86
+
87
+ it 'should be able to evaluate exceptions normally' do
88
+ o = Exception.new
89
+ str_output = StringIO.new
90
+
91
+ was_called = false
92
+ pry_tester = Pry.new(:input => InputTester.new("self"),
93
+ :output => str_output,
94
+ :exception_handler => proc { was_called = true })
95
+
96
+ pry_tester.rep(o)
97
+ was_called.should == false
98
+ end
99
+
100
+ it 'should notice when exceptions are raised' do
101
+ o = Exception.new
102
+ str_output = StringIO.new
103
+
104
+ was_called = false
105
+ pry_tester = Pry.new(:input => InputTester.new("raise self"),
106
+ :output => str_output,
107
+ :exception_handler => proc { was_called = true })
108
+
109
+ pry_tester.rep(o)
110
+ was_called.should == true
111
+ end
58
112
  end
59
113
 
60
114
  describe "repl" do
@@ -69,18 +123,6 @@ describe Pry do
69
123
 
70
124
  o.instance_variable_get(:@x).should == 10
71
125
  end
72
-
73
- # # this is now deprecated
74
- # it 'should execute start session and end session hooks' do
75
- # next
76
- # input = InputTester.new("exit")
77
- # str_output = StringIO.new
78
- # o = Object.new
79
-
80
- # pry_tester = Pry.start(o, :input => input, :output => str_output)
81
- # str_output.string.should =~ /Beginning.*#{o}/
82
- # str_output.string.should =~ /Ending.*#{o}/
83
- # end
84
126
  end
85
127
 
86
128
  describe "test loading rc files" do
@@ -115,13 +157,13 @@ describe Pry do
115
157
  Pry.should_load_rc = false
116
158
  end
117
159
  end
118
-
160
+
119
161
  describe "nesting" do
120
162
  after do
121
163
  Pry.reset_defaults
122
164
  Pry.color = false
123
165
  end
124
-
166
+
125
167
  it 'should nest properly' do
126
168
  Pry.input = InputTester.new("pry", "pry", "pry", "\"nest:\#\{Pry.nesting.level\}\"", "exit_all")
127
169
 
@@ -140,7 +182,7 @@ describe Pry do
140
182
  [Object.new, {}, []].each do |val|
141
183
  str_input = StringIO.new("def hello;end")
142
184
  Pry.new(:input => str_input, :output => StringIO.new).rep(val)
143
-
185
+
144
186
  val.methods(false).map(&:to_sym).include?(:hello).should == true
145
187
  end
146
188
  end
@@ -168,9 +210,9 @@ describe Pry do
168
210
  val.class.instance_methods(false).map(&:to_sym).include?(:hello).should == true
169
211
  end
170
212
  end
171
-
172
- end
173
-
213
+
214
+ end
215
+
174
216
 
175
217
  describe "commands" do
176
218
  it 'should run a command with no parameter' do
@@ -208,7 +250,7 @@ describe Pry do
208
250
  Pry.reset_defaults
209
251
  Pry.color = false
210
252
  end
211
-
253
+
212
254
  it "should start a pry session on the receiver (first form)" do
213
255
  Pry.input = InputTester.new("self", "exit")
214
256
 
@@ -227,7 +269,7 @@ describe Pry do
227
269
  Pry.output = str_output
228
270
 
229
271
  pry 20
230
-
272
+
231
273
  str_output.string.should =~ /20/
232
274
  end
233
275
 
@@ -252,14 +294,14 @@ describe Pry do
252
294
  Pry.reset_defaults
253
295
  Pry.color = false
254
296
  end
255
-
297
+
256
298
  describe "input" do
257
299
 
258
300
  after do
259
301
  Pry.reset_defaults
260
302
  Pry.color = false
261
303
  end
262
-
304
+
263
305
  it 'should set the input default, and the default should be overridable' do
264
306
  Pry.input = InputTester.new("5")
265
307
 
@@ -304,7 +346,7 @@ describe Pry do
304
346
 
305
347
  arity_multi_input = Class.new do
306
348
  attr_accessor :prompt
307
-
349
+
308
350
  def readline(*args)
309
351
  @prompt = args.first
310
352
  "exit"
@@ -314,15 +356,15 @@ describe Pry do
314
356
  Pry.start(self, :input => arity_multi_input, :output => Pry::NullOutput)
315
357
  arity_multi_input.prompt.should == nil
316
358
  end
317
-
359
+
318
360
  end
319
361
 
320
362
  it 'should set the output default, and the default should be overridable' do
321
363
  Pry.input = InputTester.new("5", "6", "7")
322
-
364
+
323
365
  str_output = StringIO.new
324
366
  Pry.output = str_output
325
-
367
+
326
368
  Pry.new.rep
327
369
  str_output.string.should =~ /5/
328
370
 
@@ -347,7 +389,7 @@ describe Pry do
347
389
  after do
348
390
  Object.remove_const(:RCTest)
349
391
  end
350
-
392
+
351
393
  it "should execute command in the appropriate object context" do
352
394
  result = Pry.run_command "ls", :context => RCTest
353
395
  result.map(&:to_sym).should == [:@x]
@@ -361,7 +403,7 @@ describe Pry do
361
403
  it "should execute command and show output with :show_output => true flag" do
362
404
  str = StringIO.new
363
405
  Pry.output = str
364
- result = Pry.run_command "ls -av", :context => RCTest, :show_output => true
406
+ result = Pry.run_command "ls -afv", :context => RCTest, :show_output => true
365
407
  str.string.should =~ /global variables/
366
408
  Pry.output = $stdout
367
409
  end
@@ -373,6 +415,30 @@ describe Pry do
373
415
  end
374
416
 
375
417
  describe "commands" do
418
+ it 'should interpolate ruby code into commands' do
419
+ klass = Class.new(Pry::CommandBase) do
420
+ command "hello", "", :keep_retval => true do |arg|
421
+ arg
422
+ end
423
+ end
424
+
425
+ $test_interpolation = "bing"
426
+ str_output = StringIO.new
427
+ Pry.new(:input => StringIO.new("hello #{$test_interpolation}"), :output => str_output, :commands => klass).rep
428
+ str_output.string.should =~ /bing/
429
+ $test_interpolation = nil
430
+ end
431
+
432
+ it 'should create a comand in a nested context and that command should be accessible from the parent' do
433
+ str_input = StringIO.new("@x=nil\ncd 7\n_pry_.commands.instance_eval {\ncommand('bing') { |arg| run arg }\n}\ncd ..\nbing ls\nexit")
434
+ str_output = StringIO.new
435
+ Pry.input = str_input
436
+ obj = Object.new
437
+ Pry.new(:output => str_output).repl(obj)
438
+ Pry.input = Readline
439
+ str_output.string.should =~ /@x/
440
+ end
441
+
376
442
  it 'should define a command that keeps its return value' do
377
443
  class Command68 < Pry::CommandBase
378
444
  command "hello", "", :keep_retval => true do
@@ -382,6 +448,7 @@ describe Pry do
382
448
  str_output = StringIO.new
383
449
  Pry.new(:input => StringIO.new("hello\n"), :output => str_output, :commands => Command68).rep
384
450
  str_output.string.should =~ /:kept_hello/
451
+ str_output.string.should =~ /=>/
385
452
 
386
453
  Object.remove_const(:Command68)
387
454
  end
@@ -395,11 +462,11 @@ describe Pry do
395
462
  str_output = StringIO.new
396
463
  Pry.new(:input => StringIO.new("hello\n"), :output => str_output, :commands => Command68).rep
397
464
  (str_output.string =~ /:kept_hello/).should == nil
465
+ str_output.string !~ /=>/
398
466
 
399
467
  Object.remove_const(:Command68)
400
468
  end
401
-
402
-
469
+
403
470
  it 'should set the commands default, and the default should be overridable' do
404
471
  class Command0 < Pry::CommandBase
405
472
  command "hello" do
@@ -420,7 +487,7 @@ describe Pry do
420
487
  end
421
488
 
422
489
  str_output = StringIO.new
423
-
490
+
424
491
  Pry.new(:input => InputTester.new("goodbye"), :output => str_output, :commands => Command1).rep
425
492
  str_output.string.should =~ /goodbye world/
426
493
 
@@ -470,7 +537,7 @@ describe Pry do
470
537
  end
471
538
 
472
539
  it 'should change description of a command using desc' do
473
-
540
+
474
541
  class Command7 < Pry::Commands
475
542
  end
476
543
 
@@ -482,10 +549,10 @@ describe Pry do
482
549
 
483
550
  Command7.commands["help"][:description].should.not == orig
484
551
  Command7.commands["help"][:description].should == "blah"
485
-
552
+
486
553
  Object.remove_const(:Command7)
487
554
  end
488
-
555
+
489
556
  it 'should run a command from within a command' do
490
557
  class Command01 < Pry::Commands
491
558
  command "v" do
@@ -493,7 +560,7 @@ describe Pry do
493
560
  end
494
561
 
495
562
  command "run_v" do
496
- run target, "v"
563
+ run "v"
497
564
  end
498
565
  end
499
566
 
@@ -543,7 +610,7 @@ describe Pry do
543
610
  class Command3 < Pry::Commands
544
611
  command "v" do
545
612
  end
546
-
613
+
547
614
  delete "show_doc", "show_method"
548
615
  delete "ls"
549
616
  end
@@ -572,7 +639,7 @@ describe Pry do
572
639
 
573
640
  # suppress evaluation output
574
641
  Pry.print = proc {}
575
-
642
+
576
643
  str_output = StringIO.new
577
644
  Pry.new(:input => InputTester.new("jump-to"), :output => str_output, :commands => Command3).rep
578
645
  str_output.string.rstrip.should == "jump-to the music"
@@ -580,7 +647,7 @@ describe Pry do
580
647
  str_output = StringIO.new
581
648
  Pry.new(:input => InputTester.new("help"), :output => str_output, :commands => Command3).rep
582
649
  str_output.string.rstrip.should == "help to the music"
583
-
650
+
584
651
  Object.remove_const(:Command3)
585
652
 
586
653
  Pry.reset_defaults
@@ -601,7 +668,7 @@ describe Pry do
601
668
  Pry.new(:input => InputTester.new("\"test\""), :output => str_output,
602
669
  :print => proc { |out, value| out.puts value.reverse }).rep
603
670
  str_output.string.should == "tset\n"
604
-
671
+
605
672
  Pry.new.print.should == Pry.print
606
673
  str_output = StringIO.new
607
674
  Pry.new(:input => InputTester.new("\"test\""), :output => str_output).rep
@@ -629,7 +696,7 @@ describe Pry do
629
696
  Pry.start("carl", :input => StringIO.new("exit self"), :output => Pry::NullOutput).should == "carl"
630
697
  end
631
698
  end
632
-
699
+
633
700
  describe "prompts" do
634
701
  it 'should set the prompt default, and the default should be overridable (single prompt)' do
635
702
  new_prompt = proc { "test prompt> " }
@@ -644,7 +711,7 @@ describe Pry do
644
711
  pry_tester.prompt.should == new_prompt
645
712
  pry_tester.select_prompt(true, 0).should == "A"
646
713
  pry_tester.select_prompt(false, 0).should == "A"
647
-
714
+
648
715
  Pry.new.prompt.should == Pry.prompt
649
716
  Pry.new.select_prompt(true, 0).should == "test prompt> "
650
717
  Pry.new.select_prompt(false, 0).should == "test prompt> "
@@ -663,7 +730,7 @@ describe Pry do
663
730
  pry_tester.prompt.should == new_prompt
664
731
  pry_tester.select_prompt(true, 0).should == "A"
665
732
  pry_tester.select_prompt(false, 0).should == "B"
666
-
733
+
667
734
  Pry.new.prompt.should == Pry.prompt
668
735
  Pry.new.select_prompt(true, 0).should == "test prompt> "
669
736
  Pry.new.select_prompt(false, 0).should == "test prompt* "
@@ -676,12 +743,12 @@ describe Pry do
676
743
  :before_session => proc { |out,_| out.puts "HELLO" },
677
744
  :after_session => proc { |out,_| out.puts "BYE" }
678
745
  }
679
-
746
+
680
747
  str_output = StringIO.new
681
748
  Pry.new(:output => str_output).repl
682
749
  str_output.string.should =~ /HELLO/
683
750
  str_output.string.should =~ /BYE/
684
-
751
+
685
752
  Pry.input.rewind
686
753
 
687
754
  str_output = StringIO.new
@@ -703,7 +770,7 @@ describe Pry do
703
770
  :before_session => proc { |out,_| out.puts "OPEN" }
704
771
  }
705
772
  ).repl
706
-
773
+
707
774
  str_output.string.should =~ /OPEN/
708
775
 
709
776
  Pry.input.rewind