forked from piotrmurach/github
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnormalizer_spec.rb
More file actions
32 lines (26 loc) · 846 Bytes
/
normalizer_spec.rb
File metadata and controls
32 lines (26 loc) · 846 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
require 'spec_helper'
require 'github_api/core_ext/hash'
describe Github::Normalizer, '#normalize!' do
let(:hash) { { 'a' => { :b => { 'c' => 1 }, 'd' => [ 'a', { :e => 2 }] } } }
let(:klass) {
Class.new do
include Github::Normalizer
end
}
subject(:instance) { klass.new }
context '#normalize!' do
it 'converts hash keys to string' do
['a', 'b', 'c'].each do |key|
subject.normalize!(hash).all_keys.should include key
end
[:a, :b, :c].each do |key|
subject.normalize!(hash).all_keys.should_not include key
end
end
it "should stringify all the keys inside nested hash" do
actual = subject.normalize! hash
expected = { 'a' => { 'b'=> { 'c' => 1 }, 'd' => [ 'a', { 'e'=> 2 }] } }
actual.should be_eql expected
end
end
end # Github::Normalizer