mirror of
https://github.com/pry/pry.git
synced 2022-11-09 12:35:05 -05:00
Directify specs for save-file and cat
This commit is contained in:
parent
699c3aab69
commit
f4c3ada10a
5 changed files with 112 additions and 142 deletions
|
@ -36,7 +36,6 @@ class Pry
|
||||||
# @param [Symbol] code_type The type of code the file contains.
|
# @param [Symbol] code_type The type of code the file contains.
|
||||||
# @return [Code]
|
# @return [Code]
|
||||||
def from_file(fn, code_type=type_from_filename(fn))
|
def from_file(fn, code_type=type_from_filename(fn))
|
||||||
|
|
||||||
if fn == Pry.eval_path
|
if fn == Pry.eval_path
|
||||||
new(Pry.line_buffer.drop(1), 1, code_type)
|
new(Pry.line_buffer.drop(1), 1, code_type)
|
||||||
else
|
else
|
||||||
|
|
|
@ -426,6 +426,7 @@ class Pry
|
||||||
# @param [Binding] target The target of the Pry session.
|
# @param [Binding] target The target of the Pry session.
|
||||||
# @return [Boolean] `true` if `val` is a command, `false` otherwise
|
# @return [Boolean] `true` if `val` is a command, `false` otherwise
|
||||||
def process_command(val, eval_string = '', target = binding_stack.last)
|
def process_command(val, eval_string = '', target = binding_stack.last)
|
||||||
|
val = val.chomp
|
||||||
result = commands.process_line(val, {
|
result = commands.process_line(val, {
|
||||||
:target => target,
|
:target => target,
|
||||||
:output => output,
|
:output => output,
|
||||||
|
|
|
@ -230,6 +230,7 @@ class PryTester
|
||||||
result = nil
|
result = nil
|
||||||
|
|
||||||
strs.flatten.each do |str|
|
strs.flatten.each do |str|
|
||||||
|
str = "#{str}\n" unless str.end_with?("\n")
|
||||||
if @pry.process_command(str)
|
if @pry.process_command(str)
|
||||||
result = last_command_result_or_output
|
result = last_command_result_or_output
|
||||||
else
|
else
|
||||||
|
|
|
@ -268,7 +268,7 @@ describe "Pry::DefaultCommands::Introspection" do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should edit a range of lines if a range is given" do
|
it "should edit a range of lines if a range is given" do
|
||||||
pry_eval "10\n", "11\n", "edit -i 1,2"
|
pry_eval "10", "11", "edit -i 1,2"
|
||||||
@contents.should == "10\n11\n"
|
@contents.should == "10\n11\n"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,7 @@ describe "Pry::DefaultCommands::Shell" do
|
||||||
before do
|
before do
|
||||||
@tf = Tempfile.new(["pry", ".py"])
|
@tf = Tempfile.new(["pry", ".py"])
|
||||||
@path = @tf.path
|
@path = @tf.path
|
||||||
|
@t = pry_tester
|
||||||
end
|
end
|
||||||
|
|
||||||
after do
|
after do
|
||||||
|
@ -13,38 +14,29 @@ describe "Pry::DefaultCommands::Shell" do
|
||||||
|
|
||||||
describe "-f" do
|
describe "-f" do
|
||||||
it 'should save a file to a file' do
|
it 'should save a file to a file' do
|
||||||
f = Tempfile.new(["pry", ".py"])
|
temp_file do |f|
|
||||||
path = f.path
|
path = f.path
|
||||||
f.write ":cute_horse"
|
f.puts ":cute_horse"
|
||||||
|
f.flush
|
||||||
|
|
||||||
redirect_pry_io(InputTester.new("save-file -f #{path} #{@path}",
|
@t.eval("save-file -f #{path} #{@path}")
|
||||||
"exit-all")) do
|
|
||||||
Pry.start(@o)
|
File.read(@path).should == File.read(path)
|
||||||
end
|
end
|
||||||
File.read(@path).should == File.read(path)
|
|
||||||
|
|
||||||
f.close(true)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "-i" do
|
describe "-i" do
|
||||||
it 'should save input expressions to a file (single expression)' do
|
it 'should save input expressions to a file (single expression)' do
|
||||||
redirect_pry_io(InputTester.new(":horse_nostrils",
|
@t.eval ':horse_nostrils'
|
||||||
"save-file -i 1 #{@path}",
|
@t.eval "save-file -i 1 #{@path}"
|
||||||
"exit-all")) do
|
|
||||||
Pry.start(@o)
|
|
||||||
end
|
|
||||||
File.read(@path).should == ":horse_nostrils\n"
|
File.read(@path).should == ":horse_nostrils\n"
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should save input expressions to a file (range)' do
|
it 'should save input expressions to a file (range)' do
|
||||||
redirect_pry_io(InputTester.new(":horse_nostrils",
|
@t.eval ':or_nostrils', ':sucking_up_all_the_oxygen', ':or_whatever'
|
||||||
":sucking_up_all_the_oxygen",
|
@t.eval "save-file -i 1..2 #{@path}"
|
||||||
"save-file -i 1..2 #{@path}",
|
File.read(@path).should == ":or_nostrils\n:sucking_up_all_the_oxygen\n"
|
||||||
"exit-all")) do
|
|
||||||
Pry.start(@o)
|
|
||||||
end
|
|
||||||
File.read(@path).should == ":horse_nostrils\n:sucking_up_all_the_oxygen\n"
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -57,107 +49,80 @@ describe "Pry::DefaultCommands::Shell" do
|
||||||
def @o.bang
|
def @o.bang
|
||||||
:bang
|
:bang
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@t = pry_tester(@o)
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "single method" do
|
describe "single method" do
|
||||||
it 'should save a method to a file' do
|
it 'should save a method to a file' do
|
||||||
redirect_pry_io(InputTester.new("save-file #{@path} -m baby",
|
@t.eval "save-file #{@path} -m baby"
|
||||||
"exit-all")) do
|
|
||||||
Pry.start(@o)
|
|
||||||
end
|
|
||||||
File.read(@path).should == Pry::Method.from_obj(@o, :baby).source
|
File.read(@path).should == Pry::Method.from_obj(@o, :baby).source
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should save a method to a file truncated by --lines' do
|
it 'should save a method to a file truncated by --lines' do
|
||||||
redirect_pry_io(InputTester.new("save-file #{@path} -m baby --lines 2..4",
|
@t.eval "save-file #{@path} -m baby --lines 2..4"
|
||||||
"exit-all")) do
|
|
||||||
Pry.start(@o)
|
|
||||||
end
|
|
||||||
|
|
||||||
# must add 1 as first line of method is 1
|
# must add 1 as first line of method is 1
|
||||||
File.read(@path).should == Pry::Method.from_obj(@o, :baby).source.lines.to_a[1..5].join
|
File.read(@path).should ==
|
||||||
|
Pry::Method.from_obj(@o, :baby).source.lines.to_a[1..5].join
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "multiple method" do
|
describe "multiple method" do
|
||||||
it 'should save multiple methods to a file' do
|
it 'should save multiple methods to a file' do
|
||||||
redirect_pry_io(InputTester.new("save-file #{@path} -m baby -m bang",
|
@t.eval "save-file #{@path} -m baby -m bang"
|
||||||
"exit-all")) do
|
|
||||||
Pry.start(@o)
|
|
||||||
end
|
|
||||||
File.read(@path).should == Pry::Method.from_obj(@o, :baby).source +
|
File.read(@path).should == Pry::Method.from_obj(@o, :baby).source +
|
||||||
Pry::Method.from_obj(@o, :bang).source
|
Pry::Method.from_obj(@o, :bang).source
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should save multiple methods to a file trucated by --lines' do
|
it 'should save multiple methods to a file trucated by --lines' do
|
||||||
redirect_pry_io(InputTester.new("save-file #{@path} -m baby -m bang --lines 2..-2",
|
@t.eval "save-file #{@path} -m baby -m bang --lines 2..-2"
|
||||||
"exit-all")) do
|
|
||||||
Pry.start(@o)
|
|
||||||
end
|
|
||||||
|
|
||||||
# must add 1 as first line of method is 1
|
# must add 1 as first line of method is 1
|
||||||
File.read(@path).should == (Pry::Method.from_obj(@o, :baby).source +
|
File.read(@path).should == (Pry::Method.from_obj(@o, :baby).source +
|
||||||
Pry::Method.from_obj(@o, :bang).source).lines.to_a[1..-2].join
|
Pry::Method.from_obj(@o, :bang).source).lines.to_a[1..-2].join
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should save multiple methods to a file trucated by --lines 1 (single parameter, not range)' do
|
it 'should save multiple methods to a file trucated by --lines 1 ' \
|
||||||
redirect_pry_io(InputTester.new("save-file #{@path} -m baby -m bang --lines 1",
|
'(single parameter, not range)' do
|
||||||
"exit-all")) do
|
@t.eval "save-file #{@path} -m baby -m bang --lines 1"
|
||||||
Pry.start(@o)
|
|
||||||
end
|
|
||||||
|
|
||||||
# must add 1 as first line of method is 1
|
# must add 1 as first line of method is 1
|
||||||
File.read(@path).should == (Pry::Method.from_obj(@o, :baby).source +
|
File.read(@path).should == (Pry::Method.from_obj(@o, :baby).source +
|
||||||
Pry::Method.from_obj(@o, :bang).source).lines.to_a[0]
|
Pry::Method.from_obj(@o, :bang).source).lines.to_a[0]
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "overwrite by default (no --append)" do
|
describe "overwrite by default (no --append)" do
|
||||||
it 'should overwrite specified file with new input' do
|
it 'should overwrite specified file with new input' do
|
||||||
redirect_pry_io(InputTester.new(":horse_nostrils",
|
@t.eval ':horse_nostrils'
|
||||||
"save-file -i 1 #{@path}",
|
@t.eval "save-file -i 1 #{@path}"
|
||||||
"exit-all")) do
|
|
||||||
Pry.start(@o)
|
|
||||||
end
|
|
||||||
|
|
||||||
redirect_pry_io(InputTester.new(":sucking_up_all_the_oxygen",
|
@t.eval ':sucking_up_all_the_oxygen'
|
||||||
"save-file -i 1 #{@path}",
|
@t.eval "save-file -i 2 #{@path}"
|
||||||
"exit-all")) do
|
|
||||||
Pry.start(@o)
|
|
||||||
end
|
|
||||||
|
|
||||||
File.read(@path).should == ":sucking_up_all_the_oxygen\n"
|
File.read(@path).should == ":sucking_up_all_the_oxygen\n"
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "--append" do
|
describe "--append" do
|
||||||
it 'should append to end of specified file' do
|
it 'should append to end of specified file' do
|
||||||
redirect_pry_io(InputTester.new(":horse_nostrils",
|
@t.eval ':horse_nostrils'
|
||||||
"save-file -i 1 #{@path}",
|
@t.eval "save-file -i 1 #{@path}"
|
||||||
"exit-all")) do
|
|
||||||
Pry.start(@o)
|
|
||||||
end
|
|
||||||
|
|
||||||
redirect_pry_io(InputTester.new(":sucking_up_all_the_oxygen",
|
@t.eval ':sucking_up_all_the_oxygen'
|
||||||
"save-file -i 1 #{@path} -a",
|
@t.eval "save-file -i 2 #{@path} -a"
|
||||||
"exit-all")) do
|
|
||||||
Pry.start(@o)
|
|
||||||
end
|
|
||||||
|
|
||||||
File.read(@path).should == ":horse_nostrils\n:sucking_up_all_the_oxygen\n"
|
File.read(@path).should ==
|
||||||
|
":horse_nostrils\n:sucking_up_all_the_oxygen\n"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "-c" do
|
describe "-c" do
|
||||||
it 'should save a command to a file' do
|
it 'should save a command to a file' do
|
||||||
redirect_pry_io(InputTester.new("save-file #{@path} -k show-method",
|
@t.eval "save-file #{@path} -k show-method"
|
||||||
"exit-all")) do
|
|
||||||
Pry.start(@o)
|
|
||||||
end
|
|
||||||
cmd = Pry::Method.new(Pry.commands.find_command("show-method").block)
|
cmd = Pry::Method.new(Pry.commands.find_command("show-method").block)
|
||||||
File.read(@path).should == Pry::Code.from_method(cmd).to_s
|
File.read(@path).should == Pry::Code.from_method(cmd).to_s
|
||||||
end
|
end
|
||||||
|
@ -169,24 +134,24 @@ describe "Pry::DefaultCommands::Shell" do
|
||||||
def @o.baby
|
def @o.baby
|
||||||
:baby
|
:baby
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@t = pry_tester(@o)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should save input cache and a method to a file (in that order)' do
|
it 'should save input cache and a method to a file (in that order)' do
|
||||||
redirect_pry_io(InputTester.new(":horse_nostrils",
|
@t.eval ":horse_nostrils"
|
||||||
"save-file -i 1 -m baby #{@path}",
|
@t.eval "save-file -i 1 -m baby #{@path}"
|
||||||
"exit-all")) do
|
|
||||||
Pry.start(@o)
|
File.read(@path).should == ":horse_nostrils\n" +
|
||||||
end
|
Pry::Method.from_obj(@o, :baby).source
|
||||||
File.read(@path).should == ":horse_nostrils\n" + Pry::Method.from_obj(@o, :baby).source
|
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should select a portion to save using --lines' do
|
it 'should select a portion to save using --lines' do
|
||||||
redirect_pry_io(InputTester.new(":horse_nostrils",
|
@t.eval ":horse_nostrils"
|
||||||
"save-file -i 1 -m baby #{@path} --lines 2..-2",
|
@t.eval "save-file -i 1 -m baby #{@path} --lines 2..-2"
|
||||||
"exit-all")) do
|
|
||||||
Pry.start(@o)
|
str = ":horse_nostrils\n" + Pry::Method.from_obj(@o, :baby).source
|
||||||
end
|
File.read(@path).should == str.lines.to_a[1..-2].join
|
||||||
File.read(@path).should == (":horse_nostrils\n" + Pry::Method.from_obj(@o, :baby).source).lines.to_a[1..-2].join
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -194,46 +159,61 @@ describe "Pry::DefaultCommands::Shell" do
|
||||||
describe "cat" do
|
describe "cat" do
|
||||||
before do
|
before do
|
||||||
@str_output = StringIO.new
|
@str_output = StringIO.new
|
||||||
|
|
||||||
|
@t = pry_tester do
|
||||||
|
def insert_nil_input
|
||||||
|
@pry.update_input_history(nil)
|
||||||
|
end
|
||||||
|
|
||||||
|
def last_exception=(e)
|
||||||
|
@pry.last_exception = e
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "on receiving a file that does not exist" do
|
describe "on receiving a file that does not exist" do
|
||||||
it 'should display an error message' do
|
it 'should display an error message' do
|
||||||
mock_pry("cat supercalifragilicious66").should =~ /Cannot open/
|
proc {
|
||||||
|
@t.eval 'cat supercalifragilicious66'
|
||||||
|
}.should.raise(StandardError).message.should =~ /Cannot open/
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "with --in" do
|
describe "with --in" do
|
||||||
it 'should display the last few expressions with indices' do
|
it 'should display the last few expressions with indices' do
|
||||||
output = mock_pry("10", "20", "cat --in")
|
@t.eval('10', '20', 'cat --in').should == unindent(<<-STR)
|
||||||
output.should =~ /^1:/
|
1:
|
||||||
output.should =~ /^ 10/
|
10
|
||||||
output.should =~ /^2:/
|
2:
|
||||||
output.should =~ /^ 20/
|
20
|
||||||
|
STR
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "with --in 1" do
|
describe "with --in 1" do
|
||||||
it 'should display the first expression with no index' do
|
it 'should display the first expression with no index' do
|
||||||
output = mock_pry("10", "20", "cat --in 1")
|
@t.eval('10', '20', 'cat --in 1').should == "10\n"
|
||||||
output.should.not =~ /^\d+:/
|
|
||||||
output.should =~ /^10/
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "with --in -1" do
|
describe "with --in -1" do
|
||||||
it 'should display the last expression with no index' do
|
it 'should display the last expression with no index' do
|
||||||
output = mock_pry("10", "20", "cat --in -1")
|
@t.eval('10', '20', 'cat --in -1').should == "20\n"
|
||||||
output.should.not =~ /^\d+:/
|
|
||||||
output.should =~ /^20/
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "with --in 1..2" do
|
describe "with --in 1..2" do
|
||||||
it 'should display the given range with indices, omitting nils' do
|
it 'should display the given range with indices, omitting nils' do
|
||||||
output = mock_pry("10", "20", "cat --ex", ":hello", "cat --in 1..4")
|
@t.eval '10'
|
||||||
output.should =~ /^1:/
|
@t.insert_nil_input # normally happens when a command is executed
|
||||||
output.should.not =~ /^3:/
|
@t.eval ':hello'
|
||||||
output.should =~ /^ :hello/
|
|
||||||
|
@t.eval('cat --in 1..3').should == unindent(<<-EOS)
|
||||||
|
1:
|
||||||
|
10
|
||||||
|
3:
|
||||||
|
:hello
|
||||||
|
EOS
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -241,74 +221,70 @@ describe "Pry::DefaultCommands::Shell" do
|
||||||
# so we currently skip rbx until we figure out a workaround
|
# so we currently skip rbx until we figure out a workaround
|
||||||
describe "with --ex" do
|
describe "with --ex" do
|
||||||
if !Pry::Helpers::BaseHelpers.rbx?
|
if !Pry::Helpers::BaseHelpers.rbx?
|
||||||
it 'cat --ex should correctly display code that generated exception even if raised in repl' do
|
it 'cat --ex should display repl code that generated exception' do
|
||||||
mock_pry("this raises error", "cat --ex").should =~ /\d+:(\s*) this raises error/
|
@t.eval unindent(<<-EOS)
|
||||||
|
begin
|
||||||
|
this raises error
|
||||||
|
rescue => e
|
||||||
|
_pry_.last_exception = e
|
||||||
|
end
|
||||||
|
EOS
|
||||||
|
@t.eval('cat --ex').should =~ /\d+:(\s*) this raises error/
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'cat --ex should correctly display code that generated exception' do
|
it 'cat --ex should correctly display code that generated exception' do
|
||||||
mock_pry("broken_method", "cat --ex").should =~ /this method is broken/
|
begin
|
||||||
|
broken_method
|
||||||
|
rescue => e
|
||||||
|
@t.last_exception = e
|
||||||
|
end
|
||||||
|
@t.eval('cat --ex').should =~ /this method is broken/
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "with --ex N" do
|
describe "with --ex N" do
|
||||||
it 'should cat first level of backtrace when --ex used with no argument ' do
|
it 'should cat first level of backtrace when --ex used with no argument ' do
|
||||||
pry_instance = Pry.new(:input => StringIO.new("cat --ex"), :output => @str_output)
|
|
||||||
|
|
||||||
temp_file do |f|
|
temp_file do |f|
|
||||||
f << "bt number 1"
|
f << "bt number 1"
|
||||||
f.flush
|
f.flush
|
||||||
pry_instance.last_exception = mock_exception("#{f.path}:1", "x", "x")
|
@t.last_exception = mock_exception("#{f.path}:1", 'x', 'x')
|
||||||
pry_instance.rep(self)
|
@t.eval('cat --ex').should =~ /bt number 1/
|
||||||
end
|
end
|
||||||
|
|
||||||
@str_output.string.should =~ /bt number 1/
|
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should cat first level of backtrace when --ex 0 used ' do
|
it 'should cat first level of backtrace when --ex 0 used ' do
|
||||||
pry_instance = Pry.new(:input => StringIO.new("cat --ex 0"), :output => @str_output)
|
|
||||||
|
|
||||||
temp_file do |f|
|
temp_file do |f|
|
||||||
f << "bt number 1"
|
f << "bt number 1"
|
||||||
f.flush
|
f.flush
|
||||||
pry_instance.last_exception = mock_exception("#{f.path}:1", "x", "x")
|
@t.last_exception = mock_exception("#{f.path}:1", 'x', 'x')
|
||||||
pry_instance.rep(self)
|
@t.eval('cat --ex 0').should =~ /bt number 1/
|
||||||
end
|
end
|
||||||
|
|
||||||
@str_output.string.should =~ /bt number 1/
|
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should cat second level of backtrace when --ex 1 used ' do
|
it 'should cat second level of backtrace when --ex 1 used ' do
|
||||||
pry_instance = Pry.new(:input => StringIO.new("cat --ex 1"), :output => @str_output)
|
|
||||||
|
|
||||||
temp_file do |f|
|
temp_file do |f|
|
||||||
f << "bt number 2"
|
f << "bt number 2"
|
||||||
f.flush
|
f.flush
|
||||||
pry_instance.last_exception = mock_exception("x", "#{f.path}:1", "x")
|
@t.last_exception = mock_exception('x', "#{f.path}:1", 'x')
|
||||||
pry_instance.rep(self)
|
@t.eval('cat --ex 1').should =~ /bt number 2/
|
||||||
end
|
end
|
||||||
|
|
||||||
@str_output.string.should =~ /bt number 2/
|
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should cat third level of backtrace when --ex 2 used' do
|
it 'should cat third level of backtrace when --ex 2 used' do
|
||||||
pry_instance = Pry.new(:input => StringIO.new("cat --ex 2"), :output => @str_output)
|
|
||||||
|
|
||||||
temp_file do |f|
|
temp_file do |f|
|
||||||
f << "bt number 3"
|
f << "bt number 3"
|
||||||
f.flush
|
f.flush
|
||||||
pry_instance.last_exception = mock_exception("x", "x", "#{f.path}:1")
|
@t.last_exception = mock_exception('x', 'x', "#{f.path}:1")
|
||||||
pry_instance.rep(self)
|
@t.eval('cat --ex 2').should =~ /bt number 3/
|
||||||
end
|
end
|
||||||
|
|
||||||
@str_output.string.should =~ /bt number 3/
|
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should show error when backtrace level out of bounds' do
|
it 'should show error when backtrace level out of bounds' do
|
||||||
pry_instance = Pry.new(:input => StringIO.new("cat --ex 3"), :output => @str_output)
|
@t.last_exception = mock_exception('x', 'x', 'x')
|
||||||
pry_instance.last_exception = mock_exception("x", "x", "x")
|
proc {
|
||||||
pry_instance.rep(self)
|
@t.eval('cat --ex 3')
|
||||||
@str_output.string.should =~ /out of bounds/
|
}.should.raise(Pry::CommandError).message.should =~ /out of bounds/
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'each successive cat --ex should show the next level of backtrace, and going past the final level should return to the first' do
|
it 'each successive cat --ex should show the next level of backtrace, and going past the final level should return to the first' do
|
||||||
|
@ -319,25 +295,18 @@ describe "Pry::DefaultCommands::Shell" do
|
||||||
temp_files.last.flush
|
temp_files.last.flush
|
||||||
end
|
end
|
||||||
|
|
||||||
pry_instance = Pry.new(:input => StringIO.new("cat --ex\n" * 4),
|
@t.last_exception = mock_exception(*temp_files.map { |f| "#{f.path}:1" })
|
||||||
:output => @str_output)
|
|
||||||
|
|
||||||
pry_instance.last_exception = mock_exception(*temp_files.map { |f| "#{f.path}:1" })
|
|
||||||
|
|
||||||
3.times do |i|
|
3.times do |i|
|
||||||
pry_instance.rep(self)
|
@t.eval('cat --ex').should =~ /bt number #{i}/
|
||||||
@str_output.string.should =~ /bt number #{i}/
|
|
||||||
end
|
end
|
||||||
|
|
||||||
@str_output.reopen
|
@t.eval('cat --ex').should =~ /bt number 0/
|
||||||
pry_instance.rep(self)
|
|
||||||
@str_output.string.should =~ /bt number 0/
|
|
||||||
|
|
||||||
temp_files.each do |file|
|
temp_files.each do |file|
|
||||||
file.close(true)
|
file.close(true)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Reference in a new issue