Sha256: 032ae3295b6ba7e5ff1f240aa9278c5e98b34a691d85f08fba74449a08d59dec

Contents?: true

Size: 695 Bytes

Versions: 31

Compression:

Stored size: 695 Bytes

Contents

require 'rspec'
require 'abstractivator/trees/recursive_delete'
require 'json'
require 'rails'
require 'pp'

describe Abstractivator::Trees do

  include Abstractivator::Trees

  describe '#recursive_delete!' do
    it 'deletes keys in the root hash' do
      h = {a: 1, b: 2}
      recursive_delete!(h, [:a])
      expect(h).to eql({b: 2})
    end
    it 'deletes keys in sub hashes' do
      h = {a: 1, b: {c: 3, d: 4}}
      recursive_delete!(h, [:c])
      expect(h).to eql({a: 1, b: {d: 4}})
    end
    it 'deletes keys in hashes inside arrays' do
      h = {a: [{b: 1, c: 2}, {b: 3, c: 4}]}
      recursive_delete!(h, [:b])
      expect(h).to eql({a: [{c: 2}, {c: 4}]})
    end
  end
end

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
abstractivator-0.1.1 spec/lib/abstractivator/trees/recursive_delete_spec.rb
abstractivator-0.1.0 spec/lib/abstractivator/trees/recursive_delete_spec.rb
abstractivator-0.0.31 spec/lib/abstractivator/trees/recursive_delete_spec.rb
abstractivator-0.0.30 spec/lib/abstractivator/trees/recursive_delete_spec.rb
abstractivator-0.0.29 spec/lib/abstractivator/trees/recursive_delete_spec.rb
abstractivator-0.0.28 spec/lib/abstractivator/trees/recursive_delete_spec.rb
abstractivator-0.0.27 spec/lib/abstractivator/trees/recursive_delete_spec.rb
abstractivator-0.0.26 spec/lib/abstractivator/trees/recursive_delete_spec.rb
abstractivator-0.0.25 spec/lib/abstractivator/trees/recursive_delete_spec.rb
abstractivator-0.0.24 spec/lib/abstractivator/trees/recursive_delete_spec.rb
abstractivator-0.0.23 spec/lib/abstractivator/trees/recursive_delete_spec.rb