From aee2eae8e58fdc45e69a90f21625cf05cc6a2108 Mon Sep 17 00:00:00 2001 From: Ryan Fitzgerald Date: Sun, 6 Nov 2011 01:09:11 -0700 Subject: [PATCH] use a better prefix for tempfiles (fixes #331) --- lib/pry/helpers/command_helpers.rb | 2 +- test/helper.rb | 2 +- test/test_default_commands/test_introspection.rb | 12 ++++++------ test/test_default_commands/test_shell.rb | 2 +- test/test_pry_history.rb | 2 +- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/pry/helpers/command_helpers.rb b/lib/pry/helpers/command_helpers.rb index 98ec9e4f..99fed104 100644 --- a/lib/pry/helpers/command_helpers.rb +++ b/lib/pry/helpers/command_helpers.rb @@ -22,7 +22,7 @@ class Pry # Open a temp file and yield it to the block, closing it after # @return [String] The path of the temp file def temp_file - file = Tempfile.new(["tmp", ".rb"]) + file = Tempfile.new(['pry', '.rb']) yield file ensure file.close diff --git a/test/helper.rb b/test/helper.rb index b26723c7..31462fc5 100644 --- a/test/helper.rb +++ b/test/helper.rb @@ -163,7 +163,7 @@ end # Open a temp file and yield it to the block, closing it after # @return [String] The path of the temp file def temp_file - file = Tempfile.new("tmp") + file = Tempfile.new('pry') yield file ensure file.close diff --git a/test/test_default_commands/test_introspection.rb b/test/test_default_commands/test_introspection.rb index 1c9e86ea..d47371c9 100644 --- a/test/test_default_commands/test_introspection.rb +++ b/test/test_default_commands/test_introspection.rb @@ -48,7 +48,7 @@ describe "Pry::DefaultCommands::Introspection" do end 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 mock_pry("edit #{path}", "$rand").should =~ /#{@rand}/ @@ -57,7 +57,7 @@ describe "Pry::DefaultCommands::Introspection" do end 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 mock_pry("edit #{path}", "$rand").should.not =~ /#{@rand}/ @@ -66,7 +66,7 @@ describe "Pry::DefaultCommands::Introspection" do end 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 mock_pry("edit -n #{path}", "$rand").should.not =~ /#{@rand}/ @@ -75,7 +75,7 @@ describe "Pry::DefaultCommands::Introspection" do end 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 mock_pry("edit -r #{path}", "$rand").should =~ /#{@rand}/ @@ -87,7 +87,7 @@ describe "Pry::DefaultCommands::Introspection" do describe "with --ex" do before do - @tf = Tempfile.new(["tmp", ".rb"]) + @tf = Tempfile.new(["pry", ".rb"]) @path = @tf.path @tf << "1\n2\nraise RuntimeError" @tf.flush @@ -364,7 +364,7 @@ describe "Pry::DefaultCommands::Introspection" do describe "edit-method" do describe "on a method defined in a file" do before do - @tempfile = Tempfile.new(['tmp', '*.rb']) + @tempfile = Tempfile.new(['pry', '*.rb']) @tempfile.puts <<-EOS module A def a diff --git a/test/test_default_commands/test_shell.rb b/test/test_default_commands/test_shell.rb index 68ac3813..33fb3b5e 100644 --- a/test/test_default_commands/test_shell.rb +++ b/test/test_default_commands/test_shell.rb @@ -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 temp_files = [] 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.flush end diff --git a/test/test_pry_history.rb b/test/test_pry_history.rb index 2d0c9b07..8d2e77ee 100644 --- a/test/test_pry_history.rb +++ b/test/test_pry_history.rb @@ -5,7 +5,7 @@ describe Pry do before do Pry.history.clear - @file = Tempfile.new(["tmp", ".pry_history"]) + @file = Tempfile.new(["pry", ".pry_history"]) @hist = @file.path File.open(@hist, 'w') {|f| f << "1\n2\n3\n" } @old_hist = Pry.config.history.file