1
0
Fork 0
mirror of https://github.com/pry/pry.git synced 2022-11-09 12:35:05 -05:00

merged in robgleeson's patch to pass pry instance to prompts, also added test_special_local.rb and test_shell.rb tests

This commit is contained in:
John Mair 2011-09-02 22:25:18 +12:00
parent e97652fc5b
commit 6cd1d28d98
3 changed files with 54 additions and 0 deletions

View file

@ -20,6 +20,7 @@
* ^C no longer captured
* got rid of Pry.active_instance, Pry.last_exception and friends.
* also special locals now shared among bindings in a pry instance (i.e _ex_ (and friends) re-injected into new binding entered with 'cd')
* added third parameter to prompts, the pry instance itself (_pry) see https://github.com/pry/pry/issues/233 for why it's important
*/7/2011 version 0.9.3
* cat --ex (cats 5 lines above and below line in file where exception was raised)

View file

@ -0,0 +1,18 @@
require 'helper'
describe "Pry::DefaultCommands::Shell" do
describe "cat" do
# this doesnt work so well on rbx due to differences in backtrace
# so we currently skip rbx until we figure out a workaround
if !rbx?
it 'cat --ex should give warning when exception is raised in repl' do
mock_pry("this raises error", "cat --ex").should =~ /Cannot cat exceptions raised in REPL/
end
it 'cat --ex should correctly display code that generated exception' do
mock_pry("broken_method", "cat --ex").should =~ /this method is broken/
end
end
end
end

View file

@ -0,0 +1,35 @@
require 'helper'
describe "Special locals (_file_ and friends)" do
it 'locals should all exist upon initialization' do
mock_pry("_file_").should.not =~ /NameError/
mock_pry("_dir_").should.not =~ /NameError/
mock_pry("_ex_").should.not =~ /NameError/
mock_pry("_pry_").should.not =~ /NameError/
mock_pry("_").should.not =~ /NameError/
end
it 'locals should still exist after cd-ing into a new context' do
mock_pry("cd 0", "_file_").should.not =~ /NameError/
mock_pry("cd 0","_dir_").should.not =~ /NameError/
mock_pry("cd 0","_ex_").should.not =~ /NameError/
mock_pry("cd 0","_pry_").should.not =~ /NameError/
mock_pry("cd 0","_").should.not =~ /NameError/
end
it 'locals should keep value after cd-ing(_pry_ and _ex_)' do
mock_pry("$x = _pry_;", "cd 0", "_pry_ == $x").should =~ /true/
mock_pry("error blah;", "$x = _ex_;", "cd 0", "_ex_ == $x").should =~ /true/
end
it 'locals should keep value after cd-ing (_file_ and _dir_)' do
Pry.commands.command "file-and-dir-test" do
set_file_and_dir_locals("/blah/ostrich.rb")
end
mock_pry("file-and-dir-test", "cd 0", "_file_").should =~ /\/blah\/ostrich\.rb/
a = mock_pry("file-and-dir-test", "cd 0", "_dir_").should =~ /\/blah/
Pry.commands.delete "file-and-dir-test"
end
end