summaryrefslogtreecommitdiff
path: root/spec/ruby/core/hash/empty_spec.rb
blob: 881e1cc34b677cbb503a88f1de3cacb7c0e72372 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
require_relative '../../spec_helper'
require_relative 'fixtures/classes'

describe "Hash#empty?" do
  it "returns true if the hash has no entries" do
    {}.should.empty?
    { 1 => 1 }.should_not.empty?
  end

  it "returns true if the hash has no entries and has a default value" do
    Hash.new(5).should.empty?
    Hash.new { 5 }.should.empty?
    Hash.new { |hsh, k| hsh[k] = k }.should.empty?
  end
end