1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
ruby--ruby/spec/ruby/core/dir/empty_spec.rb
2019-07-27 12:40:09 +02:00

31 lines
664 B
Ruby

require_relative '../../spec_helper'
describe "Dir.empty?" do
before :all do
@empty_dir = tmp("empty_dir")
mkdir_p @empty_dir
end
after :all do
rm_r @empty_dir
end
it "returns true for empty directories" do
result = Dir.empty? @empty_dir
result.should be_true
end
it "returns false for non-empty directories" do
result = Dir.empty? __dir__
result.should be_false
end
it "returns false for a non-directory" do
result = Dir.empty? __FILE__
result.should be_false
end
it "raises ENOENT for nonexistent directories" do
-> { Dir.empty? tmp("nonexistent") }.should raise_error(Errno::ENOENT)
end
end