Sha256: c3bbedccf5acf116f554b0049d318e1670509f1322a7c05b92aeb890e976c8fd

Contents?: true

Size: 863 Bytes

Versions: 19

Compression:

Stored size: 863 Bytes

Contents

# encoding: utf-8

require 'spec_helper'

require_relative '../../../lib/locomotive/wagon/tools/yaml_ext.rb'

describe Locomotive::Wagon::YamlExt do

  describe '.transform' do

    let(:hash)  { nil }
    let(:block) { -> (value) { value + '!' } }

    subject { described_class.transform(hash, &block); hash }

    it { expect(subject).to eq nil }

    describe 'simple hash' do

      let(:hash) { { 'foo' => 'a', 'bar' => 'b' } }

      it { expect(subject['foo']).to eq 'a!' }
      it { expect(subject['bar']).to eq 'b!' }

    end

    describe 'hash of hashes' do

      let(:hash) { { 'foo' => { 'bar' => 'a' } } }

      it { expect(subject['foo']['bar']).to eq 'a!' }

    end

    describe 'hash with an array' do

      let(:hash) { { 'foo' => [{ 'bar' => 'a' }, 2] } }

      it { expect(subject['foo'][0]['bar']).to eq 'a!' }

    end


  end

end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
locomotivecms_wagon-3.0.0 spec/unit/tools/yaml_ext_spec.rb
locomotivecms_wagon-3.0.0.rc0 spec/unit/tools/yaml_ext_spec.rb
locomotivecms_wagon-3.0.0.beta2 spec/unit/tools/yaml_ext_spec.rb
locomotivecms_wagon-2.4.1 spec/unit/tools/yaml_ext_spec.rb
locomotivecms_wagon-2.4.0 spec/unit/tools/yaml_ext_spec.rb
locomotivecms_wagon-2.4.0.rc2 spec/unit/tools/yaml_ext_spec.rb
locomotivecms_wagon-2.4.0.rc1 spec/unit/tools/yaml_ext_spec.rb
locomotivecms_wagon-2.3.0 spec/unit/tools/yaml_ext_spec.rb
locomotivecms_wagon-2.3.0.rc1 spec/unit/tools/yaml_ext_spec.rb
locomotivecms_wagon-2.2.0 spec/unit/tools/yaml_ext_spec.rb
locomotivecms_wagon-2.2.0.rc3 spec/unit/tools/yaml_ext_spec.rb
locomotivecms_wagon-2.2.0.rc2 spec/unit/tools/yaml_ext_spec.rb
locomotivecms_wagon-2.2.0.rc1 spec/unit/tools/yaml_ext_spec.rb
locomotivecms_wagon-2.2.0.beta1 spec/unit/tools/yaml_ext_spec.rb
locomotivecms_wagon-2.1.1 spec/unit/tools/yaml_ext_spec.rb
locomotivecms_wagon-2.1.0 spec/unit/tools/yaml_ext_spec.rb
locomotivecms_wagon-2.1.0.rc5 spec/unit/tools/yaml_ext_spec.rb
locomotivecms_wagon-2.1.0.rc4 spec/unit/tools/yaml_ext_spec.rb
locomotivecms_wagon-2.1.0.rc3 spec/unit/tools/yaml_ext_spec.rb