From 05d4d13f375f477edbdea832b35ebc482314281f Mon Sep 17 00:00:00 2001 From: Kyrylo Silin Date: Mon, 14 Jan 2013 12:11:37 +0200 Subject: [PATCH] Fix errors on Rubinius and JRuby These implementations have slightly different APIs for getting your temp directory path. --- spec/commands/edit_spec.rb | 8 +++++++- spec/editor_spec.rb | 7 ++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/spec/commands/edit_spec.rb b/spec/commands/edit_spec.rb index 38bd8f53..2e9f5aa6 100644 --- a/spec/commands/edit_spec.rb +++ b/spec/commands/edit_spec.rb @@ -16,10 +16,16 @@ describe "edit" do end describe "with FILE" do + before do # OS-specific tempdir name. For GNU/Linux it's "tmp", for Windows it's # something "Temp". - @tf_dir = Pathname.new(Dir::Tmpname.tmpdir) + @tf_dir = + if Pry::Helpers::BaseHelpers.rbx? || Pry::Helpers::BaseHelpers.jruby? + Pathname.new(Dir.tmpdir) + else + Pathname.new(Dir::Tmpname.tmpdir) + end @tf_path = File.expand_path(File.join(@tf_dir.to_s, 'bar.rb')) FileUtils.touch(@tf_path) diff --git a/spec/editor_spec.rb b/spec/editor_spec.rb index 1c2b4562..ece785d4 100644 --- a/spec/editor_spec.rb +++ b/spec/editor_spec.rb @@ -9,7 +9,12 @@ describe Pry::Editor do before do # OS-specific tempdir name. For GNU/Linux it's "tmp", for Windows it's # something "Temp". - @tf_dir = Pathname.new(Dir::Tmpname.tmpdir) + @tf_dir = + if Pry::Helpers::BaseHelpers.rbx? || Pry::Helpers::BaseHelpers.jruby? + Pathname.new(Dir.tmpdir) + else + Pathname.new(Dir::Tmpname.tmpdir) + end @tf_path = File.join(@tf_dir.to_s, 'hello world.rb') end