Sha256: be3cfffe22833a11578407d584b336c3715503a3372b9b1c3e176082a9e530e3

Contents?: true

Size: 823 Bytes

Versions: 8

Compression:

Stored size: 823 Bytes

Contents

# frozen_string_literal: true

require 'spec_helper'

describe Arstotzka::KeyChanger do
  subject(:key_changer) { described_class.new(base_key, options) }

  describe '#key' do
    let(:base_key) { 'the_key' }

    context 'when no options are given' do
      let(:options) { {} }

      it 'returns lower camelized key' do
        expect(key_changer.key).to eq('theKey')
      end
    end

    context 'when setting upper camel' do
      let(:options) { { case: :upper_camel } }

      it 'returns upper camelized key' do
        expect(key_changer.key).to eq('TheKey')
      end
    end

    context 'when setting snake' do
      let(:options)  { { case: :snake } }
      let(:base_key) { 'TheKey' }

      it 'returns lower snakecased key' do
        expect(key_changer.key).to eq('the_key')
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
arstotzka-1.6.2 spec/lib/arstotzka/key_changer_spec.rb
arstotzka-1.6.1 spec/lib/arstotzka/key_changer_spec.rb
arstotzka-1.6.0 spec/lib/arstotzka/key_changer_spec.rb
arstotzka-1.5.0 spec/lib/arstotzka/key_changer_spec.rb
arstotzka-1.4.4 spec/lib/arstotzka/key_changer_spec.rb
arstotzka-1.4.3 spec/lib/arstotzka/key_changer_spec.rb
arstotzka-1.4.2 spec/lib/arstotzka/key_changer_spec.rb
arstotzka-1.4.1 spec/lib/arstotzka/key_changer_spec.rb