Sha256: 48c999e7d10fb320719a40450b22e9bf58b8dab0c2eeb0895c18fe0e33a2a380

Contents?: true

Size: 1.16 KB

Versions: 14

Compression:

Stored size: 1.16 KB

Contents

describe "hash" do
  describe "except" do
    it "should remove key" do
      original = { :a => 'x', :b => 'y', :c => 10 }
      expected = { :a => 'x', :b => 'y' }

      original.except(:c).should == expected
      original.should.not == expected
    end
    
    it "should remove more than one key" do
      original = { :a => 'x', :b => 'y', :c => 10 }
      expected = { :a => 'x' }
      original.except(:b, :c).should == expected
    end
    
    it "should work on frozen hash" do
      original = { :a => 'x', :b => 'y' }
      original.freeze
      lambda { original.except(:a) }.should.not.raise
    end
  end
  
  describe "except!" do
    it "should remove key in place" do
      original = { :a => 'x', :b => 'y', :c => 10 }
      expected = { :a => 'x', :b => 'y' }

      original.should.not == expected
      original.except!(:c).should == expected
      original.should == expected
    end
    
    it "should remove more than one key in place" do
      original = { :a => 'x', :b => 'y', :c => 10 }
      expected = { :a => 'x' }

      original.should.not == expected
      original.except!(:b, :c).should == expected
      original.should == expected
    end
  end
end

Version data entries

14 entries across 14 versions & 2 rubygems

Version Path
motion-support-1.2.1 spec/motion-support/core_ext/hash/except_spec.rb
motion-support-1.1.1 spec/motion-support/core_ext/hash/except_spec.rb
motion-support-1.2.0 spec/motion-support/core_ext/hash/except_spec.rb
motion-support-1.1.0 spec/motion-support/core_ext/hash/except_spec.rb
motion-support-1.0.0 spec/motion-support/core_ext/hash/except_spec.rb
motion-support-0.3.0 spec/motion-support/core_ext/hash/except_spec.rb
motion_blender-support-0.2.8 spec/motion-support/core_ext/hash/except_spec.rb
motion_blender-support-0.2.7 spec/motion-support/core_ext/hash/except_spec.rb
motion-support-0.2.6 spec/motion-support/core_ext/hash/except_spec.rb
motion-support-0.2.5 spec/motion-support/core_ext/hash/except_spec.rb
motion-support-0.2.4 spec/motion-support/core_ext/hash/except_spec.rb
motion-support-0.2.3 spec/motion-support/core_ext/hash/except_spec.rb
motion-support-0.2.2 spec/motion-support/core_ext/hash/except_spec.rb
motion-support-0.2.0 spec/motion-support/core_ext/hash/except_spec.rb