public
Rubygem
Fork of thoughtbot/shoulda
Description: Makes tests easy on the fingers and the eyes
Homepage: http://www.thoughtbot.com/projects/shoulda
Clone URL: git://github.com/technicalpickles/shoulda.git
convert_to_shoulda_syntax: use Dir::tmpdir instead of hardcoded /tmp
showaltb (author)
Tue Jul 29 12:59:43 -0700 2008
rmm5t (committer)
Wed Jul 30 05:25:25 -0700 2008
commit  abc3aa73a49502c874d4b3b184d1e94d075492a0
tree    40c4e28de397e200351e4ee1fd7eca73af8028d6
parent  630ce1744374c51e4e8e588caf4cecfc056e73fa
...
1
2
 
 
 
3
4
5
...
18
19
20
21
 
22
23
24
25
26
27
 
28
29
30
 
31
32
33
...
1
2
3
4
5
6
7
8
...
21
22
23
 
24
25
26
27
28
29
 
30
31
32
 
33
34
35
36
0
@@ -1,5 +1,8 @@
0
 #!/usr/bin/env ruby
0
 require 'fileutils'
0
+require 'tmpdir'
0
+
0
+TMP = Dir::tmpdir
0
 
0
 def usage(msg = nil)
0
   puts "Error: #{msg}" if msg
0
@@ -18,16 +21,16 @@ def usage(msg = nil)
0
   puts " ..."
0
   puts " end"
0
   puts
0
- puts "A copy of the old file will be left under /tmp/ in case this script just seriously screws up"
0
+ puts "A copy of the old file will be left under #{TMP} in case\nthis script just seriously screws up"
0
   puts
0
   exit (msg ? 2 : 0)
0
 end
0
 
0
 usage("Wrong number of arguments.") unless ARGV.size == 1
0
-usage("This system doesn't have a /tmp directory. wtf?") unless File.directory?('/tmp')
0
+usage("Temp directory '#{TMP}' is not valid. Set TMPDIR environment variable to a writeable directory.") unless File.directory?(TMP) && File.writable?(TMP)
0
 
0
 file = ARGV.shift
0
-tmpfile = "/tmp/#{File.basename(file)}"
0
+tmpfile = File.join(TMP, File.basename(file))
0
 usage("File '#{file}' doesn't exist") unless File.exists?(file)
0
 
0
 FileUtils.cp(file, tmpfile)

Comments

    No one has commented yet.