Sha256: b289d5f6f9aa8b0210937db2a19cd1f1780281ae6fcdfa2df485cbaf4fad37d7

Contents?: true

Size: 1.35 KB

Versions: 27

Compression:

Stored size: 1.35 KB

Contents

require 'spec_helper'

RSpec.describe 'Core Extensions' do
  describe Hash do
    describe '#stringify_keys' do
      it 'converts keys into strings' do
        expect({ :key1 => 'value1', 'key2' => 'value2' }.stringify_keys).to eq('key1' => 'value1', 'key2' => 'value2')
      end
    end

    describe '#symbolize_keys' do
      it 'converts keys into symbols' do
        expect({ :key1 => 'value1', 'key2' => 'value2' }.symbolize_keys).to eq(key1: 'value1', key2: 'value2')
      end
    end

    describe '#deep_symbolize_keys' do
      it 'converts keys into symbols' do
        expect({ :key1 => 'value1',
                 'key2' => 'value2',
                 'key3' => {
                   'key31' => { 'key311' => 'value311' },
                   'key32' => 'value32'
                 } }.deep_symbolize_keys).to eq(key1: 'value1',
                                                key2: 'value2',
                                                key3: { key31:                                                                                     { key311: 'value311' },
                                                        key32: 'value32' })
      end
    end
  end

  describe String do
    describe '#constantize' do
      class HelloWorld; end
      it 'returns a class from a string' do
        expect('HelloWorld'.constantize).to eq HelloWorld
      end
    end
  end
end

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
shoryuken-6.2.1 spec/shoryuken/core_ext_spec.rb
shoryuken-6.2.0 spec/shoryuken/core_ext_spec.rb
shoryuken-6.1.1 spec/shoryuken/core_ext_spec.rb
shoryuken-6.1.0 spec/shoryuken/core_ext_spec.rb
shoryuken-6.0.0 spec/shoryuken/core_ext_spec.rb
shoryuken-5.3.2 spec/shoryuken/core_ext_spec.rb
shoryuken-5.3.1 spec/shoryuken/core_ext_spec.rb
shoryuken-5.3.0 spec/shoryuken/core_ext_spec.rb
shoryuken-5.2.3 spec/shoryuken/core_ext_spec.rb
shoryuken-5.2.2 spec/shoryuken/core_ext_spec.rb
shoryuken-5.2.1 spec/shoryuken/core_ext_spec.rb
shoryuken-5.2.0 spec/shoryuken/core_ext_spec.rb
shoryuken-5.1.1 spec/shoryuken/core_ext_spec.rb
shoryuken-5.1.0 spec/shoryuken/core_ext_spec.rb
shoryuken-5.0.6 spec/shoryuken/core_ext_spec.rb
shoryuken-5.0.5 spec/shoryuken/core_ext_spec.rb
shoryuken-5.0.4 spec/shoryuken/core_ext_spec.rb
shoryuken-5.0.3 spec/shoryuken/core_ext_spec.rb
shoryuken-5.0.2 spec/shoryuken/core_ext_spec.rb
shoryuken-5.0.1 spec/shoryuken/core_ext_spec.rb