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/hash/empty_spec.rb

16 lines
409 B
Ruby
Raw Normal View History

require_relative '../../spec_helper'
require_relative 'fixtures/classes'
describe "Hash#empty?" do
it "returns true if the hash has no entries" do
2020-05-03 06:28:29 -04:00
{}.should.empty?
{ 1 => 1 }.should_not.empty?
end
it "returns true if the hash has no entries and has a default value" do
2020-05-03 06:28:29 -04:00
Hash.new(5).should.empty?
Hash.new { 5 }.should.empty?
Hash.new { |hsh, k| hsh[k] = k }.should.empty?
end
end