mirror of
https://github.com/pry/pry.git
synced 2022-11-09 12:35:05 -05:00
Start converting context tests
This commit is contained in:
parent
62a684b9d9
commit
8a19a1996f
2 changed files with 30 additions and 4 deletions
|
@ -424,7 +424,7 @@ class Pry
|
|||
# @param [String] eval_string The cumulative lines of input.
|
||||
# @param [Binding] target The target of the Pry session.
|
||||
# @return [Boolean] `true` if `val` is a command, `false` otherwise
|
||||
def process_command(val, eval_string = '', target = TOPLEVEL_BINDING)
|
||||
def process_command(val, eval_string = '', target = binding_stack.last)
|
||||
result = commands.process_line(val, {
|
||||
:target => target,
|
||||
:output => output,
|
||||
|
|
|
@ -1,8 +1,29 @@
|
|||
require 'helper'
|
||||
|
||||
describe "Pry::DefaultCommands::Context" do
|
||||
module ContextTestHelpers
|
||||
def pry
|
||||
@pry ||= Pry.new
|
||||
end
|
||||
|
||||
def process_commands(*args)
|
||||
args.flatten.each do |cmd|
|
||||
pry.process_command cmd
|
||||
end
|
||||
end
|
||||
|
||||
def evaluate_ruby(ruby)
|
||||
pry.evaluate_ruby ruby
|
||||
end
|
||||
|
||||
def evaluate_self
|
||||
pry.evaluate_ruby 'self'
|
||||
end
|
||||
end
|
||||
|
||||
describe "Pry::DefaultCommands::Context" do
|
||||
before do
|
||||
extend ContextTestHelpers
|
||||
|
||||
@self = "Pad.self = self"
|
||||
@inner = "Pad.inner = self"
|
||||
@outer = "Pad.outer = self"
|
||||
|
@ -47,12 +68,17 @@ describe "Pry::DefaultCommands::Context" do
|
|||
class Cor
|
||||
def blimey!
|
||||
Cor.send :undef_method, :blimey!
|
||||
# using [.] so the regex doesn't match itself
|
||||
mock_pry(binding, 'whereami').should =~ /self[.]blimey!/
|
||||
Pad.binding = binding
|
||||
end
|
||||
end
|
||||
|
||||
Cor.new.blimey!
|
||||
|
||||
pry.binding_stack << Pad.binding
|
||||
process_commands 'whereami'
|
||||
|
||||
# using [.] so the regex doesn't match itself
|
||||
# mock_pry(binding, 'whereami').should =~ /self[.]blimey!/
|
||||
Object.remove_const(:Cor)
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue