Sha256: 0bd1516f761440c0f7083f6117e3499f23b773d5927fb626b924a8cf96e03f51

Contents?: true

Size: 865 Bytes

Versions: 4

Compression:

Stored size: 865 Bytes

Contents

# encoding: utf-8

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

4 entries across 4 versions & 1 rubygems

Version Path
github_api-0.11.2 spec/github/normalizer_spec.rb
github_api-0.11.1 spec/github/normalizer_spec.rb
github_api-0.11.0 spec/github/normalizer_spec.rb
github_api-0.10.2 spec/github/normalizer_spec.rb