Sha256: 7b7799d5fbb82114af5b47cfd5242f073f64ae7d2ace7087902fd5d6fe3c8082

Contents?: true

Size: 804 Bytes

Versions: 4

Compression:

Stored size: 804 Bytes

Contents

# encoding: utf-8

require 'spec_helper'
require 'github_api/core_ext/hash'

describe Github::ParameterFilter, '#filter!' do
  let(:hash) {  { :a => { :b => { :c => 1 } } }  }

  let(:klass) {
    Class.new do
      include Github::ParameterFilter
    end
  }

  subject(:instance) { klass.new }

  it 'removes unwanted keys from hash' do
    instance.filter!([:a], hash)
    hash.all_keys.should     include :a
    hash.all_keys.should_not include :b
    hash.all_keys.should_not include :c
  end

  it 'recursively filters inputs tree' do
    instance.filter!([:a, :b], hash)
    hash.all_keys.should_not include :c
  end

  it 'filters inputs tree only on top level' do
    instance.filter!([:a, :b], hash, :recursive => false)
    hash.all_keys.should include :c
  end

end # Github::ParameterFilter

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
github_api-0.11.2 spec/github/parameter_filter_spec.rb
github_api-0.11.1 spec/github/parameter_filter_spec.rb
github_api-0.11.0 spec/github/parameter_filter_spec.rb
github_api-0.10.2 spec/github/parameter_filter_spec.rb