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

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

32 lines
664 B
Ruby
Raw Normal View History

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