Sha256: 2c988158616693fd615209cfea77415d7a9d7ddfc92cd906147625c3ffd0f7e8
Contents?: true
Size: 1.88 KB
Versions: 4
Compression:
Stored size: 1.88 KB
Contents
require 'epitools/path' describe Path do it "initializes and accesses everything" do path = Path.new("/blah/what.mp4/.mp3/hello.avi") path.dirs.should == %w[ blah what.mp4 .mp3 ] path.dir.should == "/blah/what.mp4/.mp3" path.filename.should == "hello.avi" path.ext.should == ".avi" path.base.should == "hello" end it "works with relative paths" do path = Path.new("../hello.mp3/blah") path.filename.should == "blah" path.ext.should == nil abs_path = File.join(File.expand_path(".."), "hello.mp3") path.dir.should == abs_path end it "handles directories" do path = Path.new("/etc/") path.dirs.should_not == nil path.dir.should == "/etc" path.filename.should == nil end it "replaces ext" do path = Path.new("/blah/what.mp4/.mp3/hello.avi") path.ext.should == ".avi" path.ext = ".mkv" path.ext.should == ".mkv" path.ext = "mkv" path.ext.should == ".mkv" end it "replaces filename" do path = Path.new(__FILE__) path.dir?.should == false path.filename = nil path.dir?.should == true end it "fstats" do path = Path.new(__FILE__) path.exists?.should == true path.dir?.should == false path.file?.should == true path.symlink?.should == false path.mtime.class.should == Time end it "globs" do path = Path.new(__FILE__) glob = path.dir + "/*spec.rb" specs = Path.glob(glob) path.in?(specs).should == true end it "Path[file] and Path[glob]s" do path = Path.new(__FILE__) path.should == Path[__FILE__] glob = path.dir + "/*spec.rb" specs = Path.glob(glob) Path[glob].should == specs end it "String#to_paths" do __FILE__.to_path.should == Path.new(__FILE__) end it "to_strs" do path = Path.new(__FILE__) data = File.read(path) data.any?.should == true end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
epitools-0.4.14 | spec/path_spec.rb |
epitools-0.4.13 | spec/path_spec.rb |
epitools-0.4.10 | spec/path_spec.rb |
epitools-0.4.9 | spec/path_spec.rb |