Sha256: 8031186e13e0cb3d6a3b46389f955b25906faff3d487f2fb5041678cc99ebe73

Contents?: true

Size: 846 Bytes

Versions: 9

Compression:

Stored size: 846 Bytes

Contents

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

Version data entries

9 entries across 9 versions & 1 rubygems

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