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
71 lines (63 loc) · 2.03 KB
/
parameter_filter_spec.rb
File metadata and controls
71 lines (63 loc) · 2.03 KB
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
require 'spec_helper'
require 'github_api/core_ext/hash'
describe Github::ParameterFilter do
let(:github) { Github.new }
let(:repos_instance) { Github::Repos.new }
let(:block) {
Proc.new do |repo|
repo = repos_instance
end
}
let(:hash) { { :a => { :b => { :c => 1 } } } }
context '#filter!' do
it 'removes unwanted keys from hash' do
github.repos.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
github.repos.filter!([:a, :b], hash)
hash.all_keys.should_not include :c
end
it 'filters inputs tree only on top level' do
github.repos.filter!([:a, :b], hash, :recursive => false)
hash.all_keys.should include :c
end
end
# context '#process_params' do
#
# it 'correctly yields current api instance' do
# github.repos.should_receive(:process_params).and_yield repos_instance
# github.repos.process_params(&block).should eq repos_instance
# end
# end
# context '#normalize' do
# it 'should call normalize on passed block' do
# github.repos.process_params(&block).should respond_to :normalize
# end
#
# it 'should normalize params inside block' do
# github.repos.stub(:process_params).and_yield repos_instance
# github.repos.process_params do |repo|
# repo.normalize hash
# end
# hash.all_keys.should include 'a'
# hash.all_keys.should_not include :a
# end
# end
# context '#filter' do
# it 'should call filter on passed block' do
# github.repos.process_params(&block).should respond_to :filter
# end
#
# it 'should filter params inside block' do
# github.repos.stub(:process_params).and_yield repos_instance
# github.repos.process_params do |repo|
# repo.filter [:a], hash
# end
# hash.all_keys.should include :a
# hash.all_keys.should_not include :b
# end
# end
end # Github::ParameterFilter