spec/pa/dir_spec.rb in pa-1.0.3 vs spec/pa/dir_spec.rb in pa-1.1.3
- old
+ new
@@ -18,33 +18,33 @@
after(:all) do
Dir.chdir(@curdir)
FileUtils.rm_r @tmpdir
end
- describe "#glob" do
+ describe "#glob2" do
before(:each) do
@files = %w(fa .fa)
FileUtils.touch(@files)
end
after(:each) do
FileUtils.rm @files
end
context "call without any option" do
it "returns 1 items" do
- Pa.glob("*").should have(1).items
+ Pa.glob2("*").should have(1).items
end
end
context "call with :dotmatch option" do
it "returns 2 items" do
- Pa.glob("*", dotmatch: true).should have(2).items
+ Pa.glob2("*", dotmatch: true).should have(2).items
end
end
end
- describe "#each" do
+ describe "#each2" do
# fa .fa fa~
# dira/
# dirb/
# b
before(:each) do
@@ -58,37 +58,37 @@
FileUtils.rm_r @dirs
end
it "runs on" do
ret = []
- Pa.each{|pa| ret << pa.fname}
+ Pa.each2{|pa| ret << pa}
ret.sort.should == %w(.fa dira fa fa~)
end
it "return a Enumerator when call without block" do
- Pa.each.should be_an_instance_of Enumerator
+ Pa.each2.should be_an_instance_of Enumerator
end
it "raise Errno::ENOENT if path doesn't exists" do
- lambda { Pa.each("path_doesn't_exits"){} }.should raise_error(Errno::ENOENT)
+ lambda { Pa.each2("path_doesn't_exits"){} }.should raise_error(Errno::ENOENT)
end
it "raise Errno::ENOTDIDR if path isn't a directory" do
- lambda { Pa.each("fa"){} }.should raise_error(Errno::ENOTDIR)
+ lambda { Pa.each2("fa"){} }.should raise_error(Errno::ENOTDIR)
end
- it "each(.) return 'foo' not '.foo'" do
- Pa.each.with_object([]){|pa,m| m<<pa.p}.sort.should == %w(.fa dira fa fa~)
+ it "each2(.) return 'foo' not '.foo'" do
+ Pa.each2.with_object([]){|pa,m| m<<pa}.sort.should == %w(.fa dira fa fa~)
end
- it "each(nodot: true) -> list all files except dot file" do
- Pa.each(nodot: true).with_object([]){|pa,m|m<<pa.b}.sort.should == %w(dira fa fa~)
+ it "each2(nodot: true) -> list all files except dot file" do
+ Pa.each2(nodot: true).with_object([]){|pa,m|m<<pa}.sort.should == %w(dira fa fa~)
end
end
- describe "#each_r" do
+ describe "#each2_r" do
# fa .fa fa~
# dira/
# dirb/
# b
before(:each) do
@@ -100,18 +100,18 @@
after(:each) do
FileUtils.rm @files
FileUtils.rm_r @dirs
end
- it "each_r -> Enumerator" do
- Pa.each_r.should be_an_instance_of Enumerator
- Pa.each_r.with_object([]){|(pa,r),m|m<<r}.sort.should == %w(.fa dira dira/dirb dira/dirb/b fa fa~)
+ it "each2_r -> Enumerator" do
+ Pa.each2_r.should be_an_instance_of Enumerator
+ Pa.each2_r.with_object([]){|(pa,r),m|m<<r}.sort.should == %w(.fa dira dira/dirb dira/dirb/b fa fa~)
end
end
- describe "#ls" do
+ describe "#ls2" do
# filea
# dira/
# fileb
before(:each) do
@dirs = %w(dira)
@@ -123,15 +123,13 @@
FileUtils.rm @files
FileUtils.rm_r @dirs
end
it "runs ok -> Array" do
- Pa.ls.should == ["filea", "dira"]
+ Pa.ls2.should == ["filea", "dira"]
end
it "call a block" do
- Pa.ls { |pa, fname| pa.directory? }.should == ["dira"]
+ Pa.ls2 { |pa, fname| File.directory?(pa) }.should == ["dira"]
end
end
-
-
end