Sha256: 694545ae4e3e11d13de36e78b6dc6dbe24e93808783ac3412b1c7c3e21eb6ca2

Contents?: true

Size: 789 Bytes

Versions: 1

Compression:

Stored size: 789 Bytes

Contents

# frozen_string_literal: true
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
      %w[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

1 entries across 1 versions & 1 rubygems

Version Path
bitbuckets-0.2.0 spec/bitbucket_rest_api/normalizer_spec.rb