blob: 1ffdc5bab21a89cd4d6257eb8bdfc7eb570c27dd (
plain)
| 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
 | RSpec.describe CommonHelper do
  subject do
    Object.new.extend( described_class )
  end
  describe 'string_keys_to_symbols' do
    context 'nullpotency on symbol keys' do
      it { expect(subject.string_keys_to_symbols({})).to eq({}) }
      it do
        expect(subject.string_keys_to_symbols(
          a: 1, b: 2
        )).to  eq(a: 1, b: 2)
      end
    end
    context 'changing string keys' do
      it { expect(subject.string_keys_to_symbols('alpha' => 100)).to eq(alpha: 100) }
      it do
        expect( subject.string_keys_to_symbols('a' => 10, b: 20) )
          .to eq(a: 10, b: 20)
      end
      it do
        expect( subject.string_keys_to_symbols('a' => 10, 'b' => 20) )
          .to eq(a: 10, b: 20)
      end
    end
    context 'keys, not values, are changed' do
      it do
        expect(subject.string_keys_to_symbols(a: 'a', 'b' => 'b', 'c' => :c))
          .to eq(a: 'a', b: 'b', c: :c)
      end
    end
  end
end
 |