Sha256: 46c2651ee5601c18737192e65e030e5718605764a504103bcf29b6bb421505a1

Contents?: true

Size: 1.98 KB

Versions: 31

Compression:

Stored size: 1.98 KB

Contents

require "#{File.dirname(File.join(__rhoGetCurrentDir(), __FILE__))}/../../spec_helper"
require "#{File.dirname(File.join(__rhoGetCurrentDir(), __FILE__))}/fixtures/file_types.rb"

describe "File.ftype" do
  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).class.should == 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 (and Android) does not have block devices
  platform_is_not :freebsd, :windows, :android do
    it "returns 'blockSpecial' when the file is a block" do
      FileSpecs.block_device do |block|
        File.ftype(block).should == 'blockSpecial'
      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
  end

  platform_is_not :windows, :android do
    it "returns fifo when the file is a fifo" do
      FileSpecs.fifo do |fifo|
        File.ftype(fifo).should == 'fifo'
      end
    end
  end

# XXX we dont support unix sockets
#    it "returns 'socket' when the file is a socket" do
#      FileSpecs.socket do |socket|
#        File.ftype(socket).should == 'socket'
#      end
#    end
end

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
rhodes-3.1.1 spec/framework_spec/app/spec/core/file/ftype_spec.rb
rhodes-3.1.1.beta spec/framework_spec/app/spec/core/file/ftype_spec.rb
rhodes-3.1.0 spec/framework_spec/app/spec/core/file/ftype_spec.rb
rhodes-3.1.0.beta.5 spec/framework_spec/app/spec/core/file/ftype_spec.rb
rhodes-3.1.0.beta.4 spec/framework_spec/app/spec/core/file/ftype_spec.rb
rhodes-3.1.0.beta.3 spec/framework_spec/app/spec/core/file/ftype_spec.rb
rhodes-3.1.0.beta.2 spec/framework_spec/app/spec/core/file/ftype_spec.rb
rhodes-3.1.0.beta.1 spec/framework_spec/app/spec/core/file/ftype_spec.rb
rhodes-3.0.2 spec/framework_spec/app/spec/core/file/ftype_spec.rb
rhodes-3.0.2.beta.1 spec/framework_spec/app/spec/core/file/ftype_spec.rb
rhodes-3.0.1 spec/framework_spec/app/spec/core/file/ftype_spec.rb
rhodes-3.0.1.beta.8 spec/framework_spec/app/spec/core/file/ftype_spec.rb
rhodes-3.0.1.beta.7 spec/framework_spec/app/spec/core/file/ftype_spec.rb
rhodes-3.0.1.beta.6 spec/framework_spec/app/spec/core/file/ftype_spec.rb
rhodes-3.0.1.beta.5 spec/framework_spec/app/spec/core/file/ftype_spec.rb
rhodes-3.0.1.beta.4 spec/framework_spec/app/spec/core/file/ftype_spec.rb
rhodes-3.0.1.beta.3 spec/framework_spec/app/spec/core/file/ftype_spec.rb
rhodes-3.0.1.beta.2 spec/framework_spec/app/spec/core/file/ftype_spec.rb
rhodes-3.0.0 spec/framework_spec/app/spec/core/file/ftype_spec.rb
rhodes-3.0.0.beta.7 spec/framework_spec/app/spec/core/file/ftype_spec.rb