summaryrefslogtreecommitdiff
path: root/spec/hashie/extensions/merge_initializer_spec.rb
blob: 66a14885df23e0edff1a78274e81680d4e0e8418 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
require 'spec_helper'

describe Hashie::Extensions::MergeInitializer do
  class MergeInitializerHash < Hash
    include Hashie::Extensions::MergeInitializer
  end

  subject { MergeInitializerHash }

  it 'initializes with no arguments' do
    expect(subject.new).to eq({})
  end

  it 'initializes with a hash' do
    expect(subject.new(abc: 'def')).to eq(abc: 'def')
  end

  it 'initializes with a hash and a default' do
    h = subject.new({ abc: 'def' }, 'bar')
    expect(h[:foo]).to eq 'bar'
    expect(h[:abc]).to eq 'def'
  end
end