use a better prefix for tempfiles (fixes #331)
This commit is contained in:
parent
fd488dfd01
commit
aee2eae8e5
|
@ -22,7 +22,7 @@ class Pry
|
||||||
# Open a temp file and yield it to the block, closing it after
|
# Open a temp file and yield it to the block, closing it after
|
||||||
# @return [String] The path of the temp file
|
# @return [String] The path of the temp file
|
||||||
def temp_file
|
def temp_file
|
||||||
file = Tempfile.new(["tmp", ".rb"])
|
file = Tempfile.new(['pry', '.rb'])
|
||||||
yield file
|
yield file
|
||||||
ensure
|
ensure
|
||||||
file.close
|
file.close
|
||||||
|
|
|
@ -163,7 +163,7 @@ end
|
||||||
# Open a temp file and yield it to the block, closing it after
|
# Open a temp file and yield it to the block, closing it after
|
||||||
# @return [String] The path of the temp file
|
# @return [String] The path of the temp file
|
||||||
def temp_file
|
def temp_file
|
||||||
file = Tempfile.new("tmp")
|
file = Tempfile.new('pry')
|
||||||
yield file
|
yield file
|
||||||
ensure
|
ensure
|
||||||
file.close
|
file.close
|
||||||
|
|
|
@ -48,7 +48,7 @@ describe "Pry::DefaultCommands::Introspection" do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should reload the file if it is a ruby file" do
|
it "should reload the file if it is a ruby file" do
|
||||||
tf = Tempfile.new(["tmp", ".rb"])
|
tf = Tempfile.new(["pry", ".rb"])
|
||||||
path = tf.path
|
path = tf.path
|
||||||
|
|
||||||
mock_pry("edit #{path}", "$rand").should =~ /#{@rand}/
|
mock_pry("edit #{path}", "$rand").should =~ /#{@rand}/
|
||||||
|
@ -57,7 +57,7 @@ describe "Pry::DefaultCommands::Introspection" do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should not reload the file if it is not a ruby file" do
|
it "should not reload the file if it is not a ruby file" do
|
||||||
tf = Tempfile.new(["tmp", ".py"])
|
tf = Tempfile.new(["pry", ".py"])
|
||||||
path = tf.path
|
path = tf.path
|
||||||
|
|
||||||
mock_pry("edit #{path}", "$rand").should.not =~ /#{@rand}/
|
mock_pry("edit #{path}", "$rand").should.not =~ /#{@rand}/
|
||||||
|
@ -66,7 +66,7 @@ describe "Pry::DefaultCommands::Introspection" do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should not reload a ruby file if -n is given" do
|
it "should not reload a ruby file if -n is given" do
|
||||||
tf = Tempfile.new(["tmp", ".rb"])
|
tf = Tempfile.new(["pry", ".rb"])
|
||||||
path = tf.path
|
path = tf.path
|
||||||
|
|
||||||
mock_pry("edit -n #{path}", "$rand").should.not =~ /#{@rand}/
|
mock_pry("edit -n #{path}", "$rand").should.not =~ /#{@rand}/
|
||||||
|
@ -75,7 +75,7 @@ describe "Pry::DefaultCommands::Introspection" do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should reload a non-ruby file if -r is given" do
|
it "should reload a non-ruby file if -r is given" do
|
||||||
tf = Tempfile.new(["tmp", ".pryrc"])
|
tf = Tempfile.new(["pry", ".pryrc"])
|
||||||
path = tf.path
|
path = tf.path
|
||||||
|
|
||||||
mock_pry("edit -r #{path}", "$rand").should =~ /#{@rand}/
|
mock_pry("edit -r #{path}", "$rand").should =~ /#{@rand}/
|
||||||
|
@ -87,7 +87,7 @@ describe "Pry::DefaultCommands::Introspection" do
|
||||||
|
|
||||||
describe "with --ex" do
|
describe "with --ex" do
|
||||||
before do
|
before do
|
||||||
@tf = Tempfile.new(["tmp", ".rb"])
|
@tf = Tempfile.new(["pry", ".rb"])
|
||||||
@path = @tf.path
|
@path = @tf.path
|
||||||
@tf << "1\n2\nraise RuntimeError"
|
@tf << "1\n2\nraise RuntimeError"
|
||||||
@tf.flush
|
@tf.flush
|
||||||
|
@ -364,7 +364,7 @@ describe "Pry::DefaultCommands::Introspection" do
|
||||||
describe "edit-method" do
|
describe "edit-method" do
|
||||||
describe "on a method defined in a file" do
|
describe "on a method defined in a file" do
|
||||||
before do
|
before do
|
||||||
@tempfile = Tempfile.new(['tmp', '*.rb'])
|
@tempfile = Tempfile.new(['pry', '*.rb'])
|
||||||
@tempfile.puts <<-EOS
|
@tempfile.puts <<-EOS
|
||||||
module A
|
module A
|
||||||
def a
|
def a
|
||||||
|
|
|
@ -121,7 +121,7 @@ describe "Pry::DefaultCommands::Shell" 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
|
it 'each successive cat --ex should show the next level of backtrace, and going past the final level should return to the first' do
|
||||||
temp_files = []
|
temp_files = []
|
||||||
3.times do |i|
|
3.times do |i|
|
||||||
temp_files << Tempfile.new(['tmp', '*.rb'])
|
temp_files << Tempfile.new(['pry', '*.rb'])
|
||||||
temp_files.last << "bt number #{i}"
|
temp_files.last << "bt number #{i}"
|
||||||
temp_files.last.flush
|
temp_files.last.flush
|
||||||
end
|
end
|
||||||
|
|
|
@ -5,7 +5,7 @@ describe Pry do
|
||||||
|
|
||||||
before do
|
before do
|
||||||
Pry.history.clear
|
Pry.history.clear
|
||||||
@file = Tempfile.new(["tmp", ".pry_history"])
|
@file = Tempfile.new(["pry", ".pry_history"])
|
||||||
@hist = @file.path
|
@hist = @file.path
|
||||||
File.open(@hist, 'w') {|f| f << "1\n2\n3\n" }
|
File.open(@hist, 'w') {|f| f << "1\n2\n3\n" }
|
||||||
@old_hist = Pry.config.history.file
|
@old_hist = Pry.config.history.file
|
||||||
|
|
Loading…
Reference in New Issue