mirror of
https://github.com/pry/pry.git
synced 2022-11-09 12:35:05 -05:00
Added a heap of tests to test for: suppressinos using ';', command
interpolation etc, changed some `run ".blah"` commands to straight-up `system` (maybe should change back?).
This commit is contained in:
parent
1dafe61d16
commit
7486c3c0d6
2 changed files with 27 additions and 3 deletions
|
@ -89,7 +89,7 @@ class Pry
|
|||
end
|
||||
|
||||
command "ri", "View ri documentation. e.g `ri Array#each`" do |*args|
|
||||
run target, ".ri", *args
|
||||
system "ri", *args
|
||||
end
|
||||
|
||||
command "stat", "View method information and set _file_ and _dir_ locals" do |*args|
|
||||
|
|
26
test/test.rb
26
test/test.rb
|
@ -379,6 +379,30 @@ describe Pry do
|
|||
end
|
||||
|
||||
describe "commands" do
|
||||
it 'should interpolate ruby code into commands' do
|
||||
klass = Class.new(Pry::CommandBase) do
|
||||
command "hello", "", :keep_retval => true do |arg|
|
||||
arg
|
||||
end
|
||||
end
|
||||
|
||||
$test_interpolation = "bing"
|
||||
str_output = StringIO.new
|
||||
Pry.new(:input => StringIO.new("hello #{$test_interpolation}"), :output => str_output, :commands => klass).rep
|
||||
str_output.string.should =~ /bing/
|
||||
$test_interpolation = nil
|
||||
end
|
||||
|
||||
it 'should create a comand in a nested context and that command should be accessible from the parent' do
|
||||
str_input = StringIO.new("@x=nil\ncd 7\n_pry_.commands.instance_eval {\ncommand('bing') { |arg| run arg }\n}\ncd ..\nbing ls\nexit")
|
||||
str_output = StringIO.new
|
||||
Pry.input = str_input
|
||||
obj = Object.new
|
||||
Pry.new(:output => str_output).repl(obj)
|
||||
Pry.input = Readline
|
||||
str_output.string.should =~ /@x/
|
||||
end
|
||||
|
||||
it 'should define a command that keeps its return value' do
|
||||
class Command68 < Pry::CommandBase
|
||||
command "hello", "", :keep_retval => true do
|
||||
|
@ -500,7 +524,7 @@ describe Pry do
|
|||
end
|
||||
|
||||
command "run_v" do
|
||||
run target, "v"
|
||||
run "v"
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue