Sha256: 41d74ef08c10c0b4047a7bcf1994d14a87777b89ca0b728ea219656d668d7c45

Contents?: true

Size: 1.7 KB

Versions: 1

Compression:

Stored size: 1.7 KB

Contents

module ThousandIsland
  module Utilities

    describe DeepMerge do

      let(:default) {{
        header:{
          height: 33,
          repeated: true,
        },
        footer: {
          height: 33,
          repeated: true,
          numbering_options: {
            align: :right,
            start_count_at: 1,
          },
          number_pages: true,
          numbering_string: '<page>',
          style: {
            font_size: 23
          },
        },
      }}
      let(:options) {{
        header: {
            height: 33,
            repeated: false,
        },
        footer: {
          height: 40,
          repeated: true,
          numbering_options: {
            align: :right,
            start_count_at: 2,
          },
        },
      }}
      let(:over) {{
        header: {
          height: 50,
          repeated: true,
        },
        footer: {
          height: 50,
          repeated: false,
          numbering_options: {
            align: :left,
          },
          style: {
            font_size: 5
          },
        },
      }}

      it 'deep merges the hashes intelligently' do
        expected = {
          header: {
            height: 50,
            repeated: true,
          },
          footer: {
            height: 50,
            repeated: false,
            numbering_options: {
              align: :left,
              start_count_at: 2,
            },
            number_pages: true,
            numbering_string: '<page>',
            style: {
              font_size: 5
            },
          },
          body: {},
        }
        final = described_class.merge_options(over, options, default)
        expect(final).to eq(expected)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
thousand_island-0.0.1 spec/thousand_island/utilities/utilities_spec.rb