forked from piotrmurach/github
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathparameter_filter_spec.rb
More file actions
34 lines (26 loc) · 821 Bytes
/
parameter_filter_spec.rb
File metadata and controls
34 lines (26 loc) · 821 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# 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)
expect(hash.deep_key?(:a)).to be_true
expect(hash.deep_key?(:b)).to be_false
expect(hash.deep_key?(:c)).to be_false
end
it 'recursively filters inputs tree' do
instance.filter!([:a, :b], hash)
expect(hash.deep_key?(:c)).to be_false
end
it 'filters inputs tree only on top level' do
instance.filter!([:a, :b], hash, :recursive => false)
expect(hash.deep_key?(:c)).to be_true
end
end # Github::ParameterFilter