Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

More fixes for File|FileTest.directory? and File::Stat#directory? specs.

  • Loading branch information...
commit cc77c9edd0d023b31dc6d72a904599c692e1ee0c 1 parent ed95666
@brixen brixen authored brixen committed
View
4 core/file/directory_spec.rb
@@ -4,3 +4,7 @@
describe "File.directory?" do
it_behaves_like :file_directory, :directory?, File
end
+
+describe "File.directory?" do
+ it_behaves_like :file_directory_io, :directory?, File
+end
View
4 core/filetest/directory_spec.rb
@@ -4,3 +4,7 @@
describe "FileTest.directory?" do
it_behaves_like :file_directory, :directory?, FileTest
end
+
+describe "FileTest.directory?" do
+ it_behaves_like :file_directory_io, :directory?, FileTest
+end
View
40 shared/file/directory.rb
@@ -25,6 +25,29 @@
end
end
+ it "raises a TypeError when passed an Integer" do
+ lambda { @object.send(@method, 1) }.should raise_error(TypeError)
+ lambda { @object.send(@method, bignum_value) }.should raise_error(TypeError)
+ end
+
+ it "raises a TypeError when passed nil" do
+ lambda { @object.send(@method, nil) }.should raise_error(TypeError)
+ end
+end
+
+describe :file_directory_io, :shared => true do
+ before :each do
+ @dir = tmp("file_directory_io")
+ @file = tmp("file_directory_io.txt")
+
+ mkdir_p @dir
+ touch @file
+ end
+
+ after :each do
+ rm_r @dir, @file
+ end
+
it "returns false if the argument is an IO that's not a directory" do
@object.send(@method, STDIN).should be_false
end
@@ -41,18 +64,11 @@
@object.send(@method, io).should be_false
end
- it "raises a TypeError when passed a Dir instance" do
- Dir.open(@dir) do |d|
- lambda { @object.send(@method, d) }.should raise_error(TypeError)
+ ruby_version_is ""..."1.9" do
+ it "raises a TypeError when passed a Dir instance" do
+ Dir.open(@dir) do |d|
+ lambda { @object.send(@method, d) }.should raise_error(TypeError)
+ end
end
end
-
- it "raises a TypeError when passed an Integer" do
- lambda { @object.send(@method, 1) }.should raise_error(TypeError)
- lambda { @object.send(@method, bignum_value) }.should raise_error(TypeError)
- end
-
- it "raises a TypeError when passed nil" do
- lambda { @object.send(@method, nil) }.should raise_error(TypeError)
- end
end
Please sign in to comment.
Something went wrong with that request. Please try again.