1
0
Fork 0
mirror of https://github.com/sinatra/sinatra synced 2023-03-27 23:18:01 -04:00

speed up reloader specs

This commit is contained in:
Konstantin Haase 2011-08-17 12:25:43 +02:00
parent 3e3f05863a
commit 4a1c2f8cb1

View file

@ -61,10 +61,9 @@ describe Sinatra::Reloader do
# needed to change the file's mtime.
def update_file(path, &block)
original_mtime = File.exist?(path) ? File.mtime(path) : Time.at(0)
begin
File.open(path, 'w', &block)
sleep 0.1
end until original_mtime != File.mtime(path)
new_time = original_mtime + 1
File.open(path, 'w', &block)
File.utime(new_time, new_time, path)
end
# Writes a Sinatra application to a file, requires the file, sets