1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Move spec/rubyspec to spec/ruby for consistency

* Other ruby implementations use the spec/ruby directory.
  [Misc #13792] [ruby-core:82287]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59979 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
eregon 2017-09-20 20:18:52 +00:00
parent 75bfc6440d
commit 1d15d5f080
4370 changed files with 0 additions and 0 deletions

View file

@ -0,0 +1,18 @@
require File.expand_path('../../../../spec_helper', __FILE__)
describe "File::Stat#atime" do
before :each do
@file = tmp('i_exist')
touch(@file) { |f| f.write "rubinius" }
end
after :each do
rm_r @file
end
it "returns the atime of a File::Stat object" do
st = File.stat(@file)
st.atime.should be_kind_of(Time)
st.atime.should <= Time.now
end
end

View file

@ -0,0 +1,27 @@
require File.expand_path('../../../../spec_helper', __FILE__)
describe "File::Stat#birthtime" do
before :each do
@file = tmp('i_exist')
touch(@file) { |f| f.write "rubinius" }
end
after :each do
rm_r @file
end
platform_is :windows, :darwin, :freebsd, :netbsd do
it "returns the birthtime of a File::Stat object" do
st = File.stat(@file)
st.birthtime.should be_kind_of(Time)
st.birthtime.should <= Time.now
end
end
platform_is :linux, :openbsd do
it "raises an NotImplementedError" do
st = File.stat(@file)
lambda { st.birthtime }.should raise_error(NotImplementedError)
end
end
end

View file

@ -0,0 +1,27 @@
require File.expand_path('../../../../spec_helper', __FILE__)
describe "File::Stat#blksize" do
before :each do
@file = tmp('i_exist')
touch(@file) { |f| f.write "rubinius" }
end
after :each do
rm_r @file
end
platform_is_not :windows do
it "returns the blksize of a File::Stat object" do
st = File.stat(@file)
st.blksize.is_a?(Integer).should == true
st.blksize.should > 0
end
end
platform_is :windows do
it "returns nil" do
st = File.stat(@file)
st.blksize.should == nil
end
end
end

View file

@ -0,0 +1,7 @@
require File.expand_path('../../../../spec_helper', __FILE__)
require File.expand_path('../../../../shared/file/blockdev', __FILE__)
require File.expand_path('../fixtures/classes', __FILE__)
describe "File::Stat#blockdev?" do
it_behaves_like :file_blockdev, :blockdev?, FileStat
end

View file

@ -0,0 +1,27 @@
require File.expand_path('../../../../spec_helper', __FILE__)
describe "File::Stat#blocks" do
before :each do
@file = tmp('i_exist')
touch(@file) { |f| f.write "rubinius" }
end
after :each do
rm_r @file
end
platform_is_not :windows do
it "returns the blocks of a File::Stat object" do
st = File.stat(@file)
st.blocks.is_a?(Integer).should == true
st.blocks.should > 0
end
end
platform_is :windows do
it "returns nil" do
st = File.stat(@file)
st.blocks.should be_nil
end
end
end

View file

@ -0,0 +1,7 @@
require File.expand_path('../../../../spec_helper', __FILE__)
require File.expand_path('../../../../shared/file/chardev', __FILE__)
require File.expand_path('../fixtures/classes', __FILE__)
describe "File::Stat#chardev?" do
it_behaves_like :file_chardev, :chardev?, FileStat
end

View file

@ -0,0 +1,66 @@
require File.expand_path('../../../../spec_helper', __FILE__)
describe "File::Stat#<=>" do
before :each do
@name1 = tmp("i_exist")
@name2 = tmp("i_exist_too")
touch @name1
touch @name2
end
after :each do
rm_r @name1, @name2
end
it "is able to compare files by the same modification times" do
now = Time.now - 1 # 1 second ago to avoid NFS cache issue
File.utime(now, now, @name1)
File.utime(now, now, @name2)
File.open(@name1) { |file1|
File.open(@name2) { |file2|
(file1.stat <=> file2.stat).should == 0
}
}
end
it "is able to compare files by different modification times" do
now = Time.now
File.utime(now, now + 100, @name2)
File.open(@name1) { |file1|
File.open(@name2) { |file2|
(file1.stat <=> file2.stat).should == -1
}
}
File.utime(now, now - 100, @name2)
File.open(@name1) { |file1|
File.open(@name2) { |file2|
(file1.stat <=> file2.stat).should == 1
}
}
end
# TODO: Fix
it "includes Comparable and #== shows mtime equality between two File::Stat objects" do
File.open(@name1) { |file1|
File.open(@name2) { |file2|
(file1.stat == file1.stat).should == true
(file2.stat == file2.stat).should == true
}
}
now = Time.now
File.utime(now, now + 100, @name2)
File.open(@name1) { |file1|
File.open(@name2) { |file2|
(file1.stat == file2.stat).should == false
(file1.stat == file1.stat).should == true
(file2.stat == file2.stat).should == true
}
}
end
end

View file

@ -0,0 +1,18 @@
require File.expand_path('../../../../spec_helper', __FILE__)
describe "File::Stat#ctime" do
before :each do
@file = tmp('i_exist')
touch(@file) { |f| f.write "rubinius" }
end
after :each do
rm_r @file
end
it "returns the ctime of a File::Stat object" do
st = File.stat(@file)
st.ctime.should be_kind_of(Time)
st.ctime.should <= Time.now
end
end

View file

@ -0,0 +1,23 @@
require File.expand_path('../../../../spec_helper', __FILE__)
describe "File::Stat#dev_major" do
before :each do
@name = tmp("file.txt")
touch(@name)
end
after :each do
rm_r @name
end
platform_is_not :windows do
it "returns the major part of File::Stat#dev" do
File.stat(@name).dev_major.should be_kind_of(Integer)
end
end
platform_is :windows do
it "returns nil" do
File.stat(@name).dev_major.should be_nil
end
end
end

View file

@ -0,0 +1,23 @@
require File.expand_path('../../../../spec_helper', __FILE__)
describe "File::Stat#dev_minor" do
before :each do
@name = tmp("file.txt")
touch(@name)
end
after :each do
rm_r @name
end
platform_is_not :windows do
it "returns the minor part of File::Stat#dev" do
File.stat(@name).dev_minor.should be_kind_of(Integer)
end
end
platform_is :windows do
it "returns nil" do
File.stat(@name).dev_minor.should be_nil
end
end
end

View file

@ -0,0 +1,15 @@
require File.expand_path('../../../../spec_helper', __FILE__)
describe "File::Stat#dev" do
before :each do
@name = tmp("file.txt")
touch(@name)
end
after :each do
rm_r @name
end
it "returns the number of the device on which the file exists" do
File.stat(@name).dev.should be_kind_of(Integer)
end
end

View file

@ -0,0 +1,7 @@
require File.expand_path('../../../../spec_helper', __FILE__)
require File.expand_path('../../../../shared/file/directory', __FILE__)
require File.expand_path('../fixtures/classes', __FILE__)
describe "File::Stat#directory?" do
it_behaves_like :file_directory, :directory?, FileStat
end

View file

@ -0,0 +1,7 @@
require File.expand_path('../../../../spec_helper', __FILE__)
require File.expand_path('../../../../shared/file/executable_real', __FILE__)
require File.expand_path('../fixtures/classes', __FILE__)
describe "File::Stat#executable_real?" do
it_behaves_like :file_executable_real, :executable_real?, FileStat
end

View file

@ -0,0 +1,7 @@
require File.expand_path('../../../../spec_helper', __FILE__)
require File.expand_path('../../../../shared/file/executable', __FILE__)
require File.expand_path('../fixtures/classes', __FILE__)
describe "File::Stat#executable?" do
it_behaves_like :file_executable, :executable?, FileStat
end

View file

@ -0,0 +1,7 @@
require File.expand_path('../../../../spec_helper', __FILE__)
require File.expand_path('../../../../shared/file/file', __FILE__)
require File.expand_path('../fixtures/classes', __FILE__)
describe "File::Stat#file?" do
it_behaves_like :file_file, :file?, FileStat
end

View file

@ -0,0 +1,5 @@
class FileStat
def self.method_missing(meth, file)
File.lstat(file).send(meth)
end
end

View file

@ -0,0 +1,68 @@
require "#{File.dirname(__FILE__)}/../../../spec_helper"
require "#{File.dirname(__FILE__)}/../fixtures/file_types"
describe "File::Stat#ftype" do
before :all do
FileSpecs.configure_types
end
it "returns a String" do
FileSpecs.normal_file do |file|
File.lstat(file).ftype.should be_kind_of(String)
end
end
it "returns 'file' when the file is a file" do
FileSpecs.normal_file do |file|
File.lstat(file).ftype.should == 'file'
end
end
it "returns 'directory' when the file is a dir" do
FileSpecs.directory do |dir|
File.lstat(dir).ftype.should == 'directory'
end
end
platform_is_not :windows do
it "returns 'characterSpecial' when the file is a char" do
FileSpecs.character_device do |char|
File.lstat(char).ftype.should == 'characterSpecial'
end
end
end
platform_is_not :freebsd do # FreeBSD does not have block devices
with_block_device do
it "returns 'blockSpecial' when the file is a block" do
FileSpecs.block_device do |block|
File.lstat(block).ftype.should == 'blockSpecial'
end
end
end
end
platform_is_not :windows do
it "returns 'link' when the file is a link" do
FileSpecs.symlink do |link|
File.lstat(link).ftype.should == 'link'
end
end
it "returns fifo when the file is a fifo" do
FileSpecs.fifo do |fifo|
File.lstat(fifo).ftype.should == 'fifo'
end
end
# This will silently not execute the block if no socket
# can be found. However, if you are running X, there is
# a good chance that if nothing else, at least the X
# Server socket exists.
it "returns 'socket' when the file is a socket" do
FileSpecs.socket do |socket|
File.lstat(socket).ftype.should == 'socket'
end
end
end
end

View file

@ -0,0 +1,19 @@
require File.expand_path('../../../../spec_helper', __FILE__)
describe "File::Stat#gid" do
before :each do
@file = tmp('i_exist')
touch(@file) { |f| f.write "rubinius" }
File.chown(nil, Process.gid, @file)
end
after :each do
rm_r @file
end
it "returns the group owner attribute of a File::Stat object" do
st = File.stat(@file)
st.gid.is_a?(Integer).should == true
st.gid.should == Process.gid
end
end

View file

@ -0,0 +1,7 @@
require File.expand_path('../../../../spec_helper', __FILE__)
require File.expand_path('../../../../shared/file/grpowned', __FILE__)
require File.expand_path('../fixtures/classes', __FILE__)
describe "File::Stat#grpowned?" do
it_behaves_like :file_grpowned, :grpowned?, FileStat
end

View file

@ -0,0 +1,38 @@
require File.expand_path('../../../../spec_helper', __FILE__)
describe "File::Stat#ino" do
before :each do
@file = tmp('i_exist')
touch(@file) { |f| f.write "rubinius" }
end
after :each do
rm_r @file
end
platform_is_not :windows do
it "returns the ino of a File::Stat object" do
st = File.stat(@file)
st.ino.should be_kind_of(Integer)
st.ino.should > 0
end
end
platform_is :windows do
ruby_version_is ""..."2.3" do
it "returns 0" do
st = File.stat(@file)
st.ino.should be_kind_of(Integer)
st.ino.should == 0
end
end
ruby_version_is "2.3" do
it "returns BY_HANDLE_FILE_INFORMATION.nFileIndexHigh/Low of a File::Stat object" do
st = File.stat(@file)
st.ino.should be_kind_of(Integer)
st.ino.should > 0
end
end
end
end

View file

@ -0,0 +1,26 @@
require File.expand_path('../../../../spec_helper', __FILE__)
describe "File::Stat#inspect" do
before :each do
@file = tmp('i_exist')
touch(@file) { |f| f.write "rubinius" }
end
after :each do
rm_r @file
end
it "produces a nicely formatted description of a File::Stat object" do
st = File.stat(@file)
expected = "#<File::Stat dev=0x#{st.dev.to_s(16)}, ino=#{st.ino}, mode=#{sprintf("%07o", st.mode)}, nlink=#{st.nlink}"
expected << ", uid=#{st.uid}, gid=#{st.gid}, rdev=0x#{st.rdev.to_s(16)}, size=#{st.size}, blksize=#{st.blksize.inspect}"
expected << ", blocks=#{st.blocks.inspect}, atime=#{st.atime}, mtime=#{st.mtime}, ctime=#{st.ctime}"
platform_is :bsd, :darwin do
# Windows has File.birthtime but it's not here since already shown by ctime.
expected << ", birthtime=#{st.birthtime}"
end
expected << ">"
st.inspect.should == expected
end
end

View file

@ -0,0 +1,19 @@
require File.expand_path('../../../../spec_helper', __FILE__)
describe "File::Stat#mode" do
before :each do
@file = tmp('i_exist')
touch(@file) { |f| f.write "rubinius" }
File.chmod(0644, @file)
end
after :each do
rm_r @file
end
it "returns the mode of a File::Stat object" do
st = File.stat(@file)
st.mode.is_a?(Integer).should == true
(st.mode & 0777).should == 0644
end
end

View file

@ -0,0 +1,18 @@
require File.expand_path('../../../../spec_helper', __FILE__)
describe "File::Stat#mtime" do
before :each do
@file = tmp('i_exist')
touch(@file) { |f| f.write "rubinius" }
end
after :each do
rm_r @file
end
it "returns the mtime of a File::Stat object" do
st = File.stat(@file)
st.mtime.should be_kind_of(Time)
st.mtime.should <= Time.now
end
end

View file

@ -0,0 +1,30 @@
require File.expand_path('../../../../spec_helper', __FILE__)
describe "File::Stat#initialize" do
before :each do
@file = tmp('i_exist')
touch(@file) { |f| f.write "rubinius" }
File.chmod(0755, @file)
end
after :each do
rm_r @file
end
it "raises an exception if the file doesn't exist" do
lambda { File::Stat.new(tmp("i_am_a_dummy_file_that_doesnt_exist")) }.should raise_error
end
it "creates a File::Stat object for the given file" do
st = File::Stat.new(@file)
st.should be_kind_of(File::Stat)
st.ftype.should == 'file'
end
it "calls #to_path on non-String arguments" do
p = mock('path')
p.should_receive(:to_path).and_return @file
File::Stat.new p
end
end

View file

@ -0,0 +1,21 @@
require File.expand_path('../../../../spec_helper', __FILE__)
describe "File::Stat#nlink" do
before :each do
@file = tmp("stat_nlink")
@link = @file + ".lnk"
touch @file
end
after :each do
rm_r @link, @file
end
platform_is_not :windows do
it "returns the number of links to a file" do
File::Stat.new(@file).nlink.should == 1
File.link(@file, @link)
File::Stat.new(@file).nlink.should == 2
end
end
end

View file

@ -0,0 +1,31 @@
require File.expand_path('../../../../spec_helper', __FILE__)
require File.expand_path('../../../../shared/file/owned', __FILE__)
require File.expand_path('../fixtures/classes', __FILE__)
describe "File::Stat#owned?" do
it_behaves_like :file_owned, :owned?, FileStat
end
describe "File::Stat#owned?" do
before :each do
@file = tmp("i_exist")
touch(@file)
end
after :each do
rm_r @file
end
it "returns true if the file is owned by the user" do
st = File.stat(@file)
st.owned?.should == true
end
platform_is_not :windows do
it "returns false if the file is not owned by the user" do
system_file = '/etc/passwd'
st = File.stat(system_file)
st.owned?.should == false
end
end
end

View file

@ -0,0 +1,32 @@
require File.expand_path('../../../../spec_helper', __FILE__)
require File.expand_path('../../../../shared/file/pipe', __FILE__)
require File.expand_path('../fixtures/classes', __FILE__)
describe "File::Stat#pipe?" do
it_behaves_like :file_pipe, :pipe?, FileStat
end
describe "File::Stat#pipe?" do
it "returns false if the file is not a pipe" do
filename = tmp("i_exist")
touch(filename)
st = File.stat(filename)
st.pipe?.should == false
rm_r filename
end
platform_is_not :windows do
it "returns true if the file is a pipe" do
filename = tmp("i_am_a_pipe")
system "mkfifo #{filename}"
st = File.stat(filename)
st.pipe?.should == true
rm_r filename
end
end
end

View file

@ -0,0 +1,31 @@
require File.expand_path('../../../../spec_helper', __FILE__)
describe "File::Stat#rdev_major" do
before :each do
platform_is :solaris do
@name = "/dev/zfs"
end
platform_is_not :solaris do
@name = tmp("file.txt")
touch(@name)
end
end
after :each do
platform_is_not :solaris do
rm_r @name
end
end
platform_is_not :windows do
it "returns the major part of File::Stat#rdev" do
File.stat(@name).rdev_major.should be_kind_of(Integer)
end
end
platform_is :windows do
it "returns nil" do
File.stat(@name).rdev_major.should be_nil
end
end
end

View file

@ -0,0 +1,31 @@
require File.expand_path('../../../../spec_helper', __FILE__)
describe "File::Stat#rdev_minor" do
before :each do
platform_is :solaris do
@name = "/dev/zfs"
end
platform_is_not :solaris do
@name = tmp("file.txt")
touch(@name)
end
end
after :each do
platform_is_not :solaris do
rm_r @name
end
end
platform_is_not :windows do
it "returns the minor part of File::Stat#rdev" do
File.stat(@name).rdev_minor.should be_kind_of(Integer)
end
end
platform_is :windows do
it "returns nil" do
File.stat(@name).rdev_minor.should be_nil
end
end
end

View file

@ -0,0 +1,15 @@
require File.expand_path('../../../../spec_helper', __FILE__)
describe "File::Stat#rdev" do
before :each do
@name = tmp("file.txt")
touch(@name)
end
after :each do
rm_r @name
end
it "returns the number of the device this file represents which the file exists" do
File.stat(@name).rdev.should be_kind_of(Integer)
end
end

View file

@ -0,0 +1,7 @@
require File.expand_path('../../../../spec_helper', __FILE__)
require File.expand_path('../../../../shared/file/readable_real', __FILE__)
require File.expand_path('../fixtures/classes', __FILE__)
describe "File::Stat#readable_real?" do
it_behaves_like :file_readable_real, :readable_real?, FileStat
end

View file

@ -0,0 +1,7 @@
require File.expand_path('../../../../spec_helper', __FILE__)
require File.expand_path('../../../../shared/file/readable', __FILE__)
require File.expand_path('../fixtures/classes', __FILE__)
describe "File::Stat#readable?" do
it_behaves_like :file_readable, :readable?, FileStat
end

View file

@ -0,0 +1,11 @@
require File.expand_path('../../../../spec_helper', __FILE__)
require File.expand_path('../../../../shared/file/setgid', __FILE__)
require File.expand_path('../fixtures/classes', __FILE__)
describe "File::Stat#setgid?" do
it_behaves_like :file_setgid, :setgid?, FileStat
end
describe "File::Stat#setgid?" do
it "needs to be reviewed for spec completeness"
end

View file

@ -0,0 +1,11 @@
require File.expand_path('../../../../spec_helper', __FILE__)
require File.expand_path('../../../../shared/file/setuid', __FILE__)
require File.expand_path('../fixtures/classes', __FILE__)
describe "File::Stat#setuid?" do
it_behaves_like :file_setuid, :setuid?, FileStat
end
describe "File::Stat#setuid?" do
it "needs to be reviewed for spec completeness"
end

View file

@ -0,0 +1,21 @@
require File.expand_path('../../../../spec_helper', __FILE__)
require File.expand_path('../../../../shared/file/size', __FILE__)
require File.expand_path('../fixtures/classes', __FILE__)
describe "File::Stat.size?" do
it_behaves_like :file_size, :size?, FileStat
it_behaves_like :file_size_nil_when_empty, :size?, FileStat
end
describe "File::Stat.size" do
it_behaves_like :file_size, :size, FileStat
it_behaves_like :file_size_0_when_empty, :size, FileStat
end
describe "File::Stat#size" do
it "needs to be reviewed for spec completeness"
end
describe "File::Stat#size?" do
it "needs to be reviewed for spec completeness"
end

View file

@ -0,0 +1,11 @@
require File.expand_path('../../../../spec_helper', __FILE__)
require File.expand_path('../../../../shared/file/socket', __FILE__)
require File.expand_path('../fixtures/classes', __FILE__)
describe "File::Stat#socket?" do
it_behaves_like :file_socket, :socket?, FileStat
end
describe "File::Stat#socket?" do
it "needs to be reviewed for spec completeness"
end

View file

@ -0,0 +1,11 @@
require File.expand_path('../../../../spec_helper', __FILE__)
require File.expand_path('../../../../shared/file/sticky', __FILE__)
require File.expand_path('../fixtures/classes', __FILE__)
describe "File::Stat#sticky?" do
it_behaves_like :file_sticky, :sticky?, FileStat
end
describe "File::Stat#sticky?" do
it "needs to be reviewed for spec completeness"
end

View file

@ -0,0 +1,7 @@
require File.expand_path('../../../../spec_helper', __FILE__)
require File.expand_path('../../../../shared/file/symlink', __FILE__)
require File.expand_path('../fixtures/classes', __FILE__)
describe "File::Stat#symlink?" do
it_behaves_like :file_symlink, :symlink?, FileStat
end

View file

@ -0,0 +1,18 @@
require File.expand_path('../../../../spec_helper', __FILE__)
describe "File::Stat#uid" do
before :each do
@file = tmp('i_exist')
touch(@file) { |f| f.write "rubinius" }
end
after :each do
rm_r @file
end
it "returns the owner attribute of a File::Stat object" do
st = File.stat(@file)
st.uid.is_a?(Integer).should == true
st.uid.should == Process.uid
end
end

View file

@ -0,0 +1,11 @@
require File.expand_path('../../../../spec_helper', __FILE__)
require File.expand_path('../../../../shared/file/world_readable', __FILE__)
require File.expand_path('../fixtures/classes', __FILE__)
describe "File::Stat.world_readable?" do
it_behaves_like(:file_world_readable, :world_readable?, FileStat)
end
describe "File::Stat#world_readable?" do
it "needs to be reviewed for spec completeness"
end

View file

@ -0,0 +1,11 @@
require File.expand_path('../../../../spec_helper', __FILE__)
require File.expand_path('../../../../shared/file/world_writable', __FILE__)
require File.expand_path('../fixtures/classes', __FILE__)
describe "File::Stat.world_writable?" do
it_behaves_like(:file_world_writable, :world_writable?, FileStat)
end
describe "File::Stat#world_writable?" do
it "needs to be reviewed for spec completeness"
end

View file

@ -0,0 +1,7 @@
require File.expand_path('../../../../spec_helper', __FILE__)
require File.expand_path('../../../../shared/file/writable_real', __FILE__)
require File.expand_path('../fixtures/classes', __FILE__)
describe "File::Stat#writable_real?" do
it_behaves_like :file_writable_real, :writable_real?, FileStat
end

View file

@ -0,0 +1,7 @@
require File.expand_path('../../../../spec_helper', __FILE__)
require File.expand_path('../../../../shared/file/writable', __FILE__)
require File.expand_path('../fixtures/classes', __FILE__)
describe "File::Stat#writable?" do
it_behaves_like :file_writable, :writable?, FileStat
end

View file

@ -0,0 +1,7 @@
require File.expand_path('../../../../spec_helper', __FILE__)
require File.expand_path('../../../../shared/file/zero', __FILE__)
require File.expand_path('../fixtures/classes', __FILE__)
describe "File::Stat#zero?" do
it_behaves_like :file_zero, :zero?, FileStat
end