Sha256: 260323b4042e45a6b8078b17c4778d36d320ab9b08d9f6962821ce4141fd5c7f

Contents?: true

Size: 768 Bytes

Versions: 83

Compression:

Stored size: 768 Bytes

Contents

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

describe "Hash#each_key" do
  it "calls block once for each key, passing key" do
    r = new_hash
    h = new_hash(1 => -1, 2 => -2, 3 => -3, 4 => -4)
    h.each_key { |k| r[k] = k }.should equal(h)
    r.should == new_hash(1 => 1, 2 => 2, 3 => 3, 4 => 4)
  end

  it "processes keys in the same order as keys()" do
    keys = []
    h = new_hash(1 => -1, 2 => -2, 3 => -3, 4 => -4)
    h.each_key { |k| keys << k }
    keys.should == h.keys
  end

  it_behaves_like(:hash_iteration_no_block, :each_key)
end

Version data entries

83 entries across 83 versions & 1 rubygems

Version Path
rhodes-1.4.2 spec/framework_spec/app/spec/core/hash/each_key_spec.rb
rhodes-1.4.1 spec/framework_spec/app/spec/core/hash/each_key_spec.rb
rhodes-1.4.0 spec/framework_spec/app/spec/core/hash/each_key_spec.rb