Sha256: c0d64157f1fbad03a9bcb39eff4db53f51ce56b81eadf0ae83c186a107aeb8a6

Contents?: true

Size: 1.18 KB

Versions: 83

Compression:

Stored size: 1.18 KB

Contents

require File.dirname(File.join(__rhoGetCurrentDir(), __FILE__)) + '/../../spec_helper'
require File.dirname(File.join(__rhoGetCurrentDir(), __FILE__)) + '/fixtures/classes'

describe "Hash#clear" do
  it "removes all key, value pairs" do
    h = new_hash(1 => 2, 3 => 4)
    h.clear.should equal(h)
    h.should == new_hash
  end

  it "does not remove default values" do
    h = new_hash 5
    h.clear
    h.default.should == 5

    h = new_hash("a" => 100, "b" => 200)
    h.default = "Go fish"
    h.clear
    h["z"].should == "Go fish"
  end

  it "does not remove default procs" do
    h = new_hash { 5 }
    h.clear
    h.default_proc.should_not == nil
  end

  ruby_version_is ""..."1.9" do
    it "raises a TypeError if called on a frozen instance" do
      lambda { HashSpecs.frozen_hash.clear  }.should raise_error(TypeError)
      lambda { HashSpecs.empty_frozen_hash.clear }.should raise_error(TypeError)
    end
  end
  ruby_version_is "1.9" do
    it "raises a RuntimeError if called on a frozen instance" do
      lambda { HashSpecs.frozen_hash.clear  }.should raise_error(RuntimeError)
      lambda { HashSpecs.empty_frozen_hash.clear }.should raise_error(RuntimeError)
    end
  end
end

Version data entries

83 entries across 83 versions & 1 rubygems

Version Path
rhodes-3.1.1 spec/framework_spec/app/spec/core/hash/clear_spec.rb
rhodes-3.1.1.beta spec/framework_spec/app/spec/core/hash/clear_spec.rb
rhodes-3.1.0 spec/framework_spec/app/spec/core/hash/clear_spec.rb
rhodes-3.1.0.beta.5 spec/framework_spec/app/spec/core/hash/clear_spec.rb
rhodes-3.1.0.beta.4 spec/framework_spec/app/spec/core/hash/clear_spec.rb
rhodes-3.1.0.beta.3 spec/framework_spec/app/spec/core/hash/clear_spec.rb
rhodes-3.1.0.beta.2 spec/framework_spec/app/spec/core/hash/clear_spec.rb
rhodes-3.1.0.beta.1 spec/framework_spec/app/spec/core/hash/clear_spec.rb
rhodes-3.0.2 spec/framework_spec/app/spec/core/hash/clear_spec.rb
rhodes-3.0.2.beta.1 spec/framework_spec/app/spec/core/hash/clear_spec.rb
rhodes-3.0.1 spec/framework_spec/app/spec/core/hash/clear_spec.rb
rhodes-3.0.1.beta.8 spec/framework_spec/app/spec/core/hash/clear_spec.rb
rhodes-3.0.1.beta.7 spec/framework_spec/app/spec/core/hash/clear_spec.rb
rhodes-3.0.1.beta.6 spec/framework_spec/app/spec/core/hash/clear_spec.rb
rhodes-3.0.1.beta.5 spec/framework_spec/app/spec/core/hash/clear_spec.rb
rhodes-3.0.1.beta.4 spec/framework_spec/app/spec/core/hash/clear_spec.rb
rhodes-3.0.1.beta.3 spec/framework_spec/app/spec/core/hash/clear_spec.rb
rhodes-3.0.1.beta.2 spec/framework_spec/app/spec/core/hash/clear_spec.rb
rhodes-3.0.0 spec/framework_spec/app/spec/core/hash/clear_spec.rb
rhodes-3.0.0.beta.7 spec/framework_spec/app/spec/core/hash/clear_spec.rb