diff options
author | eregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-09-20 20:18:52 +0000 |
---|---|---|
committer | eregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-09-20 20:18:52 +0000 |
commit | 1d15d5f08032acf1b7bceacbb450d617ff6e0931 (patch) | |
tree | a3785a79899302bc149e4a6e72f624ac27dc1f10 /spec/ruby/core/file/ftype_spec.rb | |
parent | 75bfc6440d595bf339007f4fb280fd4d743e89c1 (diff) | |
download | ruby-1d15d5f08032acf1b7bceacbb450d617ff6e0931.tar.gz |
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
Diffstat (limited to 'spec/ruby/core/file/ftype_spec.rb')
-rw-r--r-- | spec/ruby/core/file/ftype_spec.rb | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/spec/ruby/core/file/ftype_spec.rb b/spec/ruby/core/file/ftype_spec.rb new file mode 100644 index 0000000000..7c010b3e9c --- /dev/null +++ b/spec/ruby/core/file/ftype_spec.rb @@ -0,0 +1,73 @@ +require "#{File.dirname(__FILE__)}/../../spec_helper" +require "#{File.dirname(__FILE__)}/fixtures/file_types" + +describe "File.ftype" do + before :all do + FileSpecs.configure_types + end + + it "raises ArgumentError if not given exactly one filename" do + lambda { File.ftype }.should raise_error(ArgumentError) + lambda { File.ftype('blah', 'bleh') }.should raise_error(ArgumentError) + end + + it "raises Errno::ENOENT if the file is not valid" do + l = lambda { File.ftype("/#{$$}#{Time.now.to_f}") } + l.should raise_error(Errno::ENOENT) + end + + it "returns a String" do + FileSpecs.normal_file do |file| + File.ftype(file).should be_kind_of(String) + end + end + + it "returns 'file' when the file is a file" do + FileSpecs.normal_file do |file| + File.ftype(file).should == 'file' + end + end + + it "returns 'directory' when the file is a dir" do + FileSpecs.directory do |dir| + File.ftype(dir).should == 'directory' + end + end + + # Both FreeBSD and Windows does not have block devices + platform_is_not :freebsd, :windows do + with_block_device do + it "returns 'blockSpecial' when the file is a block" do + FileSpecs.block_device do |block| + File.ftype(block).should == 'blockSpecial' + end + end + end + end + + platform_is_not :windows do + it "returns 'characterSpecial' when the file is a char" do + FileSpecs.character_device do |char| + File.ftype(char).should == 'characterSpecial' + end + end + + it "returns 'link' when the file is a link" do + FileSpecs.symlink do |link| + File.ftype(link).should == 'link' + end + end + + it "returns fifo when the file is a fifo" do + FileSpecs.fifo do |fifo| + File.ftype(fifo).should == 'fifo' + end + end + + it "returns 'socket' when the file is a socket" do + FileSpecs.socket do |socket| + File.ftype(socket).should == 'socket' + end + end + end +end |