Sha256: 3dc8a49d92fdb9a18e59d632bf1a52944e7eb2af06d655595249d1ce8e51cc5a

Contents?: true

Size: 785 Bytes

Versions: 9

Compression:

Stored size: 785 Bytes

Contents

# encoding: utf-8

require 'spec_helper'
require 'bitbucket_rest_api/core_ext/hash'

describe BitBucket::Normalizer, '#normalize!' do
  let(:hash) { { 'a' => { :b => { 'c' => 1 }, 'd' => ['a', { :e => 2 }] } } }

  let(:klass) do
    Class.new do
      include BitBucket::Normalizer
    end
  end

  subject(:instance) { klass.new }

  context '#normalize!' do
    it 'converts hash keys to string' do
      ['a', 'b', 'c'].each do |key|
        expect(subject.normalize!(hash).has_deep_key?(key)).to eq(true)
      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 }] } }
      expect(actual).to eq expected
    end
  end
end # BitBucket::Normalizer

Version data entries

9 entries across 9 versions & 2 rubygems

Version Path
zz_bitbucket_rest_api-0.1.11 spec/bitbucket_rest_api/normalizer_spec.rb
zz_bitbucket_rest_api-0.1.10 spec/bitbucket_rest_api/normalizer_spec.rb
zz_bitbucket_rest_api-0.1.9 spec/bitbucket_rest_api/normalizer_spec.rb
zz_bitbucket_rest_api-0.1.8 spec/bitbucket_rest_api/normalizer_spec.rb
bitbucket_rest_api2-0.9.5 spec/bitbucket_rest_api/normalizer_spec.rb
bitbucket_rest_api2-0.9.1 spec/bitbucket_rest_api/normalizer_spec.rb
bitbucket_rest_api2-0.2.2 spec/bitbucket_rest_api/normalizer_spec.rb
bitbucket_rest_api2-0.2.1 spec/bitbucket_rest_api/normalizer_spec.rb
bitbucket_rest_api2-0.2.0 spec/bitbucket_rest_api/normalizer_spec.rb