pry 0.9.0pre3-i386-mingw32 → 0.9.1-i386-mingw32

Sign up to get free protection for your applications and to get access to all the features.
@@ -12,6 +12,8 @@ class Pry
12
12
  "e.g: show-method hello_method"
13
13
 
14
14
  opt.on :l, "line-numbers", "Show line numbers."
15
+ opt.on :b, "base-one", "Show line numbers but start numbering at 1 (useful for `amend-line` and `play` commands)."
16
+
15
17
  opt.on :M, "instance-methods", "Operate on instance methods."
16
18
  opt.on :m, :methods, "Operate on methods."
17
19
  opt.on :f, :flood, "Do not use a pager to view text longer than one screen."
@@ -44,6 +46,9 @@ class Pry
44
46
  start_line = meth.source_location ? meth.source_location.last : 1
45
47
  end
46
48
 
49
+ start_line = opts.b? ? 1 : start_line
50
+
51
+
47
52
  render_output(opts.flood?, start_line, code)
48
53
  code
49
54
  end
@@ -98,6 +103,39 @@ class Pry
98
103
  end
99
104
  end
100
105
 
106
+ command "edit", "Invoke the default editor on a file. Type `edit --help` for more info" do |*args|
107
+ opts = Slop.parse!(args) do |opt|
108
+ opt.banner "Usage: edit [OPTIONS] [FILE]\n" \
109
+ "Edit the method FILE in an editor.\n" \
110
+ "Ensure #{text.bold("Pry.editor")} is set to your editor of choice.\n" \
111
+ "e.g: edit sample.rb"
112
+
113
+ opt.on :r, "reload", "Eval file content after editing (using `load`)"
114
+ opt.on :p, "play", "Use the pry `play` command to eval the file content after editing (instead of the `load` method)."
115
+ opt.on :l, "line", "Specify line number to jump to in file", true, :as => Integer
116
+ opt.on :h, :help, "This message." do
117
+ output.puts opt
118
+ end
119
+ end
120
+ next if opts.h?
121
+
122
+ next output.puts("Need to specify a file.") if !args.first
123
+ file_name = File.expand_path(args.first)
124
+
125
+ invoke_editor(file_name, opts[:l].to_i)
126
+ set_file_and_dir_locals(file_name)
127
+
128
+ if opts[:r]
129
+ silence_warnings do
130
+ load file_name
131
+ end
132
+ elsif opts[:p]
133
+ silence_warnings do
134
+ Pry.active_instance.input = StringIO.new(File.readlines(file_name).join)
135
+ end
136
+ end
137
+ end
138
+
101
139
  command "edit-method", "Edit a method. Type `edit-method --help` for more info." do |*args|
102
140
  target = target()
103
141
 
@@ -139,34 +177,42 @@ class Pry
139
177
  file, line = path_line_for(meth)
140
178
  set_file_and_dir_locals(file)
141
179
 
180
+ invoke_editor(file, opts["no-jump"] ? 0 : line)
181
+ silence_warnings do
182
+ load file if !opts.n?
183
+ end
184
+ end
185
+ end
186
+
187
+ helpers do
188
+
189
+ def invoke_editor(file, line)
142
190
  if Pry.editor.respond_to?(:call)
143
191
  editor_invocation = Pry.editor.call(file, line)
144
192
  else
145
- # only use start line if -n option is not used
146
- start_line_syntax = opts["no-jump"] ? "" : start_line_for_editor(line)
147
- editor_invocation = "#{Pry.editor} #{start_line_syntax} #{file}"
193
+ editor_invocation = "#{Pry.editor} #{start_line_syntax_for_editor(file, line)}"
148
194
  end
149
195
 
150
196
  run ".#{editor_invocation}"
151
- silence_warnings do
152
- load file if !opts.n?
153
- end
154
197
  end
155
- end
156
198
 
157
- helpers do
199
+ def start_line_syntax_for_editor(file_name, line_number)
200
+ file_name.gsub!(/\//, '\\') if RUBY_PLATFORM =~ /mswin|mingw/
158
201
 
159
- def start_line_for_editor(line_number)
160
202
  case Pry.editor
161
203
  when /^[gm]?vi/, /^emacs/, /^nano/, /^pico/, /^gedit/, /^kate/
162
- "+#{line_number}"
204
+ "+#{line_number} #{file_name}"
163
205
  when /^mate/, /^geany/
164
- "-l #{line_number}"
206
+ "-l #{line_number} #{file_name}"
207
+ when /^uedit32/
208
+ "#{file_name}/#{line_number}"
209
+ when /^jedit/
210
+ "#{file_name} +#{line_number}"
165
211
  else
166
212
  if RUBY_PLATFORM =~ /mswin|mingw/
167
- ""
213
+ "#{file_name}"
168
214
  else
169
- "+#{line_number}"
215
+ "+#{line_number} #{file_name}"
170
216
  end
171
217
  end
172
218
  end
@@ -3,6 +3,16 @@ class Pry
3
3
 
4
4
  Ls = Pry::CommandSet.new do
5
5
 
6
+ helpers do
7
+ def trim_methods(options, visibility)
8
+ if options[:e]
9
+ []
10
+ else
11
+ Object.send("#{visibility}_methods")
12
+ end
13
+ end
14
+ end
15
+
6
16
  command "ls", "Show the list of vars and methods in the current scope. Type `ls --help` for more info." do |*args|
7
17
  options = {}
8
18
  # Set target local to the default -- note that we can set a different target for
@@ -59,10 +69,14 @@ Shows local and instance variables by default.
59
69
  options[:j] = true
60
70
  end
61
71
 
62
- opts.on("-s", "--super", "Include superclass entries (relevant to constant and methods options).") do
72
+ opts.on("-s", "--super", "Include superclass entries excluding Object (relevant to constant and methods options).") do
63
73
  options[:s] = true
64
74
  end
65
75
 
76
+ opts.on("-e", "--everything", "Include superclass entries including Object (relevant to constant and methods options).") do
77
+ options[:e] = true
78
+ end
79
+
66
80
  opts.on("-a", "--all", "Display all types of entries.") do
67
81
  options[:a] = true
68
82
  end
@@ -126,19 +140,19 @@ Shows local and instance variables by default.
126
140
 
127
141
  info["global variables"] = [Array(target.eval("global_variables")).sort, i += 1] if options[:g] || options[:a]
128
142
 
129
- info["public methods"] = [Array(target.eval("public_methods(#{options[:s]})")).uniq.sort, i += 1] if (options[:m] && options[:P]) || options[:a]
143
+ info["public methods"] = [Array(target.eval("public_methods(#{options[:s]})")).uniq.sort - trim_methods(options, :public), i += 1] if (options[:m] && options[:P]) || options[:a]
130
144
 
131
- info["protected methods"] = [Array(target.eval("protected_methods(#{options[:s]})")).sort, i += 1] if (options[:m] && options[:r]) || options[:a]
145
+ info["protected methods"] = [Array(target.eval("protected_methods(#{options[:s]})")).sort - trim_methods(options, :protected), i += 1] if (options[:m] && options[:r]) || options[:a]
132
146
 
133
- info["private methods"] = [Array(target.eval("private_methods(#{options[:s]})")).sort, i += 1] if (options[:m] && options[:p]) || options[:a]
147
+ info["private methods"] = [Array(target.eval("private_methods(#{options[:s]})")).sort - trim_methods(options, :private), i += 1] if (options[:m] && options[:p]) || options[:a]
134
148
 
135
149
  info["just singleton methods"] = [Array(target.eval("methods(#{options[:s]})")).sort, i += 1] if (options[:m] && options[:j]) || options[:a]
136
150
 
137
- info["public instance methods"] = [Array(target.eval("public_instance_methods(#{options[:s]})")).uniq.sort, i += 1] if target_self.is_a?(Module) && ((options[:M] && options[:P]) || options[:a])
151
+ info["public instance methods"] = [Array(target.eval("public_instance_methods(#{options[:s]})")).uniq.sort - trim_methods(options, :public), i += 1] if target_self.is_a?(Module) && ((options[:M] && options[:P]) || options[:a])
138
152
 
139
- info["protected instance methods"] = [Array(target.eval("protected_instance_methods(#{options[:s]})")).uniq.sort, i += 1] if target_self.is_a?(Module) && ((options[:M] && options[:r]) || options[:a])
153
+ info["protected instance methods"] = [Array(target.eval("protected_instance_methods(#{options[:s]})")).uniq.sort - trim_methods(options, :protected), i += 1] if target_self.is_a?(Module) && ((options[:M] && options[:r]) || options[:a])
140
154
 
141
- info["private instance methods"] = [Array(target.eval("private_instance_methods(#{options[:s]})")).uniq.sort, i += 1] if target_self.is_a?(Module) && ((options[:M] && options[:p]) || options[:a])
155
+ info["private instance methods"] = [Array(target.eval("private_instance_methods(#{options[:s]})")).uniq.sort - trim_methods(options, :private), i += 1] if target_self.is_a?(Module) && ((options[:M] && options[:p]) || options[:a])
142
156
 
143
157
  # dealing with 1.8/1.9 compatibility issues :/
144
158
  csuper = options[:s]
@@ -3,7 +3,6 @@ class Pry
3
3
 
4
4
  Experimental = Pry::CommandSet.new do
5
5
 
6
-
7
6
  command "reload-method", "Reload the source specifically for a method", :requires_gem => "method_reload" do |meth_name|
8
7
  if (meth = get_method_object(meth_name, target, {})).nil?
9
8
  output.puts "Invalid method name: #{meth_name}."
@@ -13,36 +12,6 @@ class Pry
13
12
  meth.reload
14
13
  end
15
14
 
16
- command "play", "Play a string as input" do |*args|
17
- Slop.parse!(args) do |opt|
18
- opt.banner "Usage: play-method [--replay START..END] [--clear] [--grep PATTERN] [--help]\n"
19
-
20
- opt.on :l, :lines, 'The line (or range of lines) to replay.', true, :as => Range
21
- opt.on :m, :method, 'Play a method.', true do |meth_name|
22
- if (meth = get_method_object(meth_name, target, {})).nil?
23
- output.puts "Invalid method name: #{meth_name}."
24
- next
25
- end
26
- code, code_type = code_and_code_type_for(meth)
27
- next if !code
28
-
29
- range = opt.l? ? opt[:l] : (0..-1)
30
-
31
- Pry.active_instance.input = StringIO.new(code[range])
32
- end
33
-
34
- opt.on :f, "file", 'The line (or range of lines) to replay.', true do |file_name|
35
- text = File.read File.expand_path(file_name)
36
- range = opt.l? ? opt[:l] : (0..-1)
37
-
38
- Pry.active_instance.input = StringIO.new(text[range])
39
- end
40
-
41
- opt.on :h, :help, "This message." do
42
- output.puts opt
43
- end
44
- end
45
- end
46
15
  end
47
16
  end
48
17
  end
@@ -3,7 +3,7 @@ class Pry
3
3
 
4
4
  UserCommandAPI = Pry::CommandSet.new do
5
5
 
6
- command "define-command", "To honor Mon-Ouie" do |arg|
6
+ command "define-command", "Define a command in the session, use same syntax as `command` method for command API" do |arg|
7
7
  next output.puts("Provide an arg!") if arg.nil?
8
8
 
9
9
  prime_string = "command #{arg_string}\n"
@@ -63,6 +63,14 @@ class Pry
63
63
  end
64
64
  end
65
65
 
66
+ def colorize_code(code)
67
+ if Pry.color
68
+ CodeRay.scan(code, :ruby).term
69
+ else
70
+ code
71
+ end
72
+ end
73
+
66
74
  def highlight(string, regexp, highlight_color=:bright_yellow)
67
75
  highlighted = string.gsub(regexp) { |match| "<#{highlight_color}>#{match}</#{highlight_color}>" }
68
76
  end
@@ -93,7 +101,7 @@ class Pry
93
101
  # Try to use `less` for paging, if it fails then use
94
102
  # simple_pager. Also do not page if Pry.pager is falsey
95
103
  # FIXME! Another JRuby hack
96
- def stagger_output(text)
104
+ def stagger_output(text, output=output())
97
105
  if text.lines.count < page_size || !Pry.pager
98
106
  output.puts text
99
107
  return
data/lib/pry/plugins.rb CHANGED
@@ -6,10 +6,10 @@ class Pry
6
6
  MessageSink = Object.new.tap { |o| def o.method_missing(*args) end }
7
7
 
8
8
  class Plugin
9
- attr_accessor :name, :gem_name, :enabled, :active
9
+ attr_accessor :name, :gem_name, :enabled, :spec, :active
10
10
 
11
- def initialize(name, gem_name, enabled)
12
- @name, @gem_name, @enabled = name, gem_name, enabled
11
+ def initialize(name, gem_name, spec, enabled)
12
+ @name, @gem_name, @enabled, @spec = name, gem_name, enabled, spec
13
13
  end
14
14
 
15
15
  # Disable a plugin.
@@ -47,7 +47,7 @@ class Pry
47
47
  (Gem::Specification.respond_to?(:each) ? Gem::Specification : Gem.source_index.find_name('')).each do |gem|
48
48
  next if gem.name !~ PRY_PLUGIN_PREFIX
49
49
  plugin_name = gem.name.split('-', 2).last
50
- @plugins << Plugin.new(plugin_name, gem.name, true) if !gem_located?(gem.name)
50
+ @plugins << Plugin.new(plugin_name, gem.name, gem, true) if !gem_located?(gem.name)
51
51
  end
52
52
  @plugins
53
53
  end
data/lib/pry/pry_class.rb CHANGED
@@ -97,7 +97,7 @@ class Pry
97
97
  # multiple times per each new session (i.e in debugging)
98
98
  load_rc if Pry.config.should_load_rc
99
99
  load_plugins if Pry.config.plugins.enabled
100
- load_history if Pry.config.history.load
100
+ load_history if Pry.config.history.should_load
101
101
 
102
102
  @initial_session = false
103
103
  end
@@ -196,11 +196,12 @@ class Pry
196
196
  config.plugins.strict_loading = true
197
197
 
198
198
  config.history ||= OpenStruct.new
199
- config.history.save = true
200
- config.history.load = true
199
+ config.history.should_save = true
200
+ config.history.should_load = true
201
201
  config.history.file = File.expand_path("~/.pry_history")
202
202
 
203
203
  config.memory_size = 100
204
+ config.results_pager = true
204
205
  end
205
206
 
206
207
  # Set all the configurable options back to their default values
@@ -149,7 +149,7 @@ class Pry
149
149
  throw :breakout, break_data
150
150
  end
151
151
 
152
- save_history if Pry.config.history.save && finished_top_level_session?
152
+ save_history if Pry.config.history.should_save && finished_top_level_session?
153
153
 
154
154
  return_value
155
155
  end
@@ -302,15 +302,15 @@ class Pry
302
302
  # This method should not need to be invoked directly.
303
303
  # @param [String] val The line to process.
304
304
  # @param [String] eval_string The cumulative lines of input.
305
- # @target [Binding] target The target of the Pry session.
305
+ # @param [Binding] target The target of the Pry session.
306
306
  def process_line(val, eval_string, target)
307
- val.rstrip!
308
307
  Pry.cmd_ret_value = @command_processor.process_commands(val, eval_string, target)
309
308
 
310
309
  if Pry.cmd_ret_value
311
310
  eval_string << "Pry.cmd_ret_value\n"
312
311
  else
313
- eval_string << "#{val}\n" if !val.empty?
312
+ # only commands (with no ret_value) should have an empty `val` so this ignores their result
313
+ eval_string << "#{val.rstrip}\n" if !val.empty?
314
314
  end
315
315
  end
316
316
 
@@ -329,6 +329,13 @@ class Pry
329
329
  # @param [Exception] ex The exception.
330
330
  # @param [Binding] target The binding to set `_ex_` on.
331
331
  def set_last_exception(ex, target)
332
+ class << ex
333
+ attr_accessor :file, :line
334
+ end
335
+
336
+ ex.backtrace.first =~ /(.*):(\d+)/
337
+ ex.file, ex.line = $1, $2.to_i
338
+
332
339
  Pry.last_exception = ex
333
340
  target.eval("_ex_ = ::Pry.last_exception")
334
341
  end
data/lib/pry/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  class Pry
2
- VERSION = "0.9.0pre3"
2
+ VERSION = "0.9.1"
3
3
  end
data/pry.gemspec ADDED
@@ -0,0 +1,45 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.unshift File.expand_path('../lib', __FILE__)
3
+ require 'pry/version'
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = %q{pry}
7
+ s.version = Pry::VERSION
8
+
9
+ s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
10
+ s.authors = [%q{John Mair (banisterfiend)}]
11
+ s.description = %q{an IRB alternative and runtime developer console}
12
+ s.email = %q{jrmair@gmail.com}
13
+ s.executables = [%q{pry}]
14
+ s.files = [%q{.document}, %q{.gemtest}, %q{.gitignore}, %q{.yardopts}, %q{CHANGELOG}, %q{LICENSE}, %q{README.markdown}, %q{Rakefile}, %q{TODO}, %q{bin/pry}, %q{examples/example_basic.rb}, %q{examples/example_command_override.rb}, %q{examples/example_commands.rb}, %q{examples/example_hooks.rb}, %q{examples/example_image_edit.rb}, %q{examples/example_input.rb}, %q{examples/example_input2.rb}, %q{examples/example_output.rb}, %q{examples/example_print.rb}, %q{examples/example_prompt.rb}, %q{examples/helper.rb}, %q{lib/pry.rb}, %q{lib/pry/command_context.rb}, %q{lib/pry/command_processor.rb}, %q{lib/pry/command_set.rb}, %q{lib/pry/commands.rb}, %q{lib/pry/completion.rb}, %q{lib/pry/config.rb}, %q{lib/pry/core_extensions.rb}, %q{lib/pry/custom_completions.rb}, %q{lib/pry/default_commands/basic.rb}, %q{lib/pry/default_commands/context.rb}, %q{lib/pry/default_commands/documentation.rb}, %q{lib/pry/default_commands/easter_eggs.rb}, %q{lib/pry/default_commands/gems.rb}, %q{lib/pry/default_commands/input.rb}, %q{lib/pry/default_commands/introspection.rb}, %q{lib/pry/default_commands/ls.rb}, %q{lib/pry/default_commands/shell.rb}, %q{lib/pry/extended_commands/experimental.rb}, %q{lib/pry/extended_commands/user_command_api.rb}, %q{lib/pry/helpers.rb}, %q{lib/pry/helpers/base_helpers.rb}, %q{lib/pry/helpers/command_helpers.rb}, %q{lib/pry/helpers/text.rb}, %q{lib/pry/history_array.rb}, %q{lib/pry/plugins.rb}, %q{lib/pry/pry_class.rb}, %q{lib/pry/pry_instance.rb}, %q{lib/pry/version.rb}, %q{pry.gemspec}, %q{test/helper.rb}, %q{test/test_command_helpers.rb}, %q{test/test_command_processor.rb}, %q{test/test_command_set.rb}, %q{test/test_default_commands.rb}, %q{test/test_default_commands/test_context.rb}, %q{test/test_default_commands/test_documentation.rb}, %q{test/test_default_commands/test_gems.rb}, %q{test/test_default_commands/test_input.rb}, %q{test/test_default_commands/test_introspection.rb}, %q{test/test_history_array.rb}, %q{test/test_pry.rb}, %q{test/testrc}, %q{wiki/Customizing-pry.md}, %q{wiki/Home.md}]
15
+ s.homepage = %q{http://banisterfiend.wordpress.com}
16
+ s.summary = %q{an IRB alternative and runtime developer console}
17
+ s.test_files = [%q{test/helper.rb}, %q{test/test_command_helpers.rb}, %q{test/test_command_processor.rb}, %q{test/test_command_set.rb}, %q{test/test_default_commands.rb}, %q{test/test_default_commands/test_context.rb}, %q{test/test_default_commands/test_documentation.rb}, %q{test/test_default_commands/test_gems.rb}, %q{test/test_default_commands/test_input.rb}, %q{test/test_default_commands/test_introspection.rb}, %q{test/test_history_array.rb}, %q{test/test_pry.rb}, %q{test/testrc}]
18
+
19
+ if s.respond_to? :specification_version then
20
+ s.specification_version = 3
21
+
22
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
23
+ s.add_runtime_dependency(%q<ruby_parser>, [">= 2.0.5"])
24
+ s.add_runtime_dependency(%q<coderay>, [">= 0.9.8"])
25
+ s.add_runtime_dependency(%q<slop>, ["~> 1.7.0"])
26
+ s.add_runtime_dependency(%q<method_source>, [">= 0.4.0"])
27
+ s.add_development_dependency(%q<bacon>, [">= 1.1.0"])
28
+ s.add_development_dependency(%q<open4>, ["~> 1.0.1"])
29
+ else
30
+ s.add_dependency(%q<ruby_parser>, [">= 2.0.5"])
31
+ s.add_dependency(%q<coderay>, [">= 0.9.8"])
32
+ s.add_dependency(%q<slop>, ["~> 1.7.0"])
33
+ s.add_dependency(%q<method_source>, [">= 0.4.0"])
34
+ s.add_dependency(%q<bacon>, [">= 1.1.0"])
35
+ s.add_dependency(%q<open4>, ["~> 1.0.1"])
36
+ end
37
+ else
38
+ s.add_dependency(%q<ruby_parser>, [">= 2.0.5"])
39
+ s.add_dependency(%q<coderay>, [">= 0.9.8"])
40
+ s.add_dependency(%q<slop>, ["~> 1.7.0"])
41
+ s.add_dependency(%q<method_source>, [">= 0.4.0"])
42
+ s.add_dependency(%q<bacon>, [">= 1.1.0"])
43
+ s.add_dependency(%q<open4>, ["~> 1.0.1"])
44
+ end
45
+ end
data/test/helper.rb CHANGED
@@ -20,8 +20,8 @@ class << Pry
20
20
  Pry.pager = false
21
21
  Pry.config.should_load_rc = false
22
22
  Pry.config.plugins.enabled = false
23
- Pry.config.history.load = false
24
- Pry.config.history.save = false
23
+ Pry.config.history.should_load = false
24
+ Pry.config.history.should_save = false
25
25
  end
26
26
  end
27
27
 
@@ -19,8 +19,17 @@ describe "Pry::CommandProcessor" do
19
19
  valid = @command_processor.valid_command? "blah"
20
20
  valid.should == false
21
21
 
22
+
22
23
  a = "test-command"
23
- lambda { @command_processor.valid_command? '#{a}' }.should.raise NameError
24
+
25
+ # not passing in a binding so 'a' shouldn't exist and no command
26
+ # will be matched
27
+ valid = @command_processor.valid_command?('#{a}')
28
+ valid.should == false
29
+
30
+ # passing in the optional binding (against which interpolation is performed)
31
+ valid = @command_processor.valid_command? '#{a}', binding
32
+ valid.should == true
24
33
  end
25
34
 
26
35
  it 'should correctly match a simple string command' do
@@ -119,6 +128,59 @@ describe "Pry::CommandProcessor" do
119
128
  pos.should == command.name.length
120
129
  end
121
130
 
131
+ it 'should correctly match a regex command and interpolation should not break the regex' do
132
+ regex_command_name = /blah(\d)/
133
+ @pry.commands.command(regex_command_name) {}
134
+
135
+ sample_text = "blah5"
136
+ a = "5"
137
+ command, captures, pos = @command_processor.command_matched 'blah#{a}', binding
138
+
139
+ command.name.should == regex_command_name
140
+ captures.should == ["5"]
141
+ pos.should == sample_text.size
142
+ end
143
+
144
+ it 'should NOT match a regex command that is interpolated when :interpolate => false' do
145
+ regex_command_name = /blah(\d)/
146
+ @pry.commands.command(regex_command_name, "", :interpolate => false) {}
147
+
148
+ sample_text = "blah5"
149
+ a = "5"
150
+ command, captures, pos = @command_processor.command_matched 'blah#{a}', binding
151
+
152
+ command.should == nil
153
+ end
154
+
155
+ it 'should correctly match a regex command and interpolation should not break the regex where entire regex command is interpolated' do
156
+ regex_command_name = /blah(\d)/
157
+ @pry.commands.command(regex_command_name) {}
158
+
159
+ sample_text = "blah5"
160
+ a = "bl"
161
+ b = "ah"
162
+ c = "5"
163
+
164
+ command, captures, pos = @command_processor.command_matched '#{a}#{b}#{c}', binding
165
+
166
+ command.name.should == regex_command_name
167
+ captures.should == ["5"]
168
+ pos.should == sample_text.size
169
+ end
170
+
171
+ it 'should NOT match a regex command where entire regex command is interpolated and :interpolate => false' do
172
+ regex_command_name = /blah(\d)/
173
+ @pry.commands.command(regex_command_name, "", :interpolate => false) {}
174
+
175
+ sample_text = "blah5"
176
+ a = "bl"
177
+ b = "ah"
178
+ c = "5"
179
+
180
+ command, captures, pos = @command_processor.command_matched '#{a}#{b}#{c}', binding
181
+ command.should == nil
182
+ end
183
+
122
184
  it 'should NOT match a command whose name is interpolated when :interpolate => false' do
123
185
  @pry.commands.command("boast", "", :interpolate => false) {}
124
186
  a = "boa"
@@ -130,4 +192,14 @@ describe "Pry::CommandProcessor" do
130
192
 
131
193
  command.should == nil
132
194
  end
195
+
196
+
197
+ it 'commands that have :interpolate => false should not be interpolated (interpolate_string should *not* be called)' do
198
+ @pry.commands.command("boast", "", :interpolate => false) {}
199
+
200
+ # remember to use '' instead of "" when testing interpolation or
201
+ # you'll cause yourself incredible confusion
202
+ lambda { @command_processor.command_matched('boast #{c}', binding) }.should.not.raise NameError
203
+ end
204
+
133
205
  end