Sha256: 9a2d326ab0a79c34ed8f9ea711b5d515f89f5b247719c04def6b7e83144aec13

Contents?: true

Size: 785 Bytes

Versions: 9

Compression:

Stored size: 785 Bytes

Contents

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

9 entries across 9 versions & 1 rubygems

Version Path
github_api-0.10.1 spec/github/parameter_filter_spec.rb
github_api-0.10.0 spec/github/parameter_filter_spec.rb
github_api-0.9.7 spec/github/parameter_filter_spec.rb
github_api-0.9.6 spec/github/parameter_filter_spec.rb
github_api-0.9.5 spec/github/parameter_filter_spec.rb
github_api-0.9.4 spec/github/parameter_filter_spec.rb
github_api-0.9.3 spec/github/parameter_filter_spec.rb
github_api-0.9.2 spec/github/parameter_filter_spec.rb
github_api-0.9.1 spec/github/parameter_filter_spec.rb