Sha256: 6b5b5f65d0e981494592657c0d1130b1a1c63e21fee98c16c6afa518b9ef1ab7

Contents?: true

Size: 609 Bytes

Versions: 23

Compression:

Stored size: 609 Bytes

Contents

describe "Hash#reject" do
  it "returns a new hash removing keys for which the block yields true" do
    h = {1=>false, 2=>true, 3=>false, 4=>true}
    h.reject { |k,v| v }.keys.should == [1,3]
  end

  it "is equivalent to hsh.dup.delete_if" do
    h = {:a => 'a', :b => 'b', :c => 'd'}
    h.reject { |k,v| k == 'd' }.should == (h.dup.delete_if { |k, v| k == 'd' })

    all_args_reject = []
    all_args_delete_if = []
    h = {1 => 2, 3 => 4}
    h.reject { |*args| all_args_reject << args }
    h.delete_if { |*args| all_args_delete_if << args }
    all_args_reject.should == all_args_delete_if
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
opal-0.4.4 spec/rubyspec/core/hash/reject_spec.rb
opal-0.4.3 spec/rubyspec/core/hash/reject_spec.rb
opal-0.4.2 spec/rubyspec/core/hash/reject_spec.rb
opal-0.4.1 spec/rubyspec/core/hash/reject_spec.rb
opal-0.4.0 spec/rubyspec/core/hash/reject_spec.rb
opal-0.3.44 spec/rubyspec/core/hash/reject_spec.rb
opal-0.3.43 spec/rubyspec/core/hash/reject_spec.rb
opal-0.3.42 spec/core/hash/reject_spec.rb
opal-0.3.41 spec/core/hash/reject_spec.rb
opal-0.3.40 spec/core/hash/reject_spec.rb
opal-0.3.39 spec/core/hash/reject_spec.rb
opal-0.3.38 spec/core/hash/reject_spec.rb
opal-0.3.37 spec/core/hash/reject_spec.rb
opal-0.3.36 spec/core/hash/reject_spec.rb
opal-0.3.35 spec/core/hash/reject_spec.rb
opal-0.3.34 spec/core/hash/reject_spec.rb
opal-0.3.33 spec/core/hash/reject_spec.rb
opal-0.3.32 spec/core/hash/reject_spec.rb
opal-0.3.31 spec/core/hash/reject_spec.rb
opal-0.3.30 spec/core/hash/reject_spec.rb