Sha256: d6812c95d5a763b1c35736d5607648a451b7cd19cc916049be8065d315d9ca65

Contents?: true

Size: 1.33 KB

Versions: 27

Compression:

Stored size: 1.33 KB

Contents

# frozen_string_literal: true

require 'spec_helper'

describe Sinclair::InputHash do
  describe '.input_hash' do
    context 'when arguments are strings and symbols' do
      let(:hash) do
        described_class.input_hash(
          :attribute1,
          'attribute2'
        )
      end

      let(:expected_hash) do
        {
          attribute1: nil,
          'attribute2' => nil
        }
      end

      it 'uses attributes as keys for the hash' do
        expect(hash).to eq(expected_hash)
      end
    end

    context 'when arguments is a hash' do
      let(:hash) do
        described_class.input_hash(expected_hash)
      end

      let(:expected_hash) do
        {
          attribute1: 10,
          'attribute2' => 20
        }
      end

      it 'returns same hash' do
        expect(hash).to eq(expected_hash)
      end
    end

    context 'when arguments is a mix of names and hashes' do
      let(:hash) do
        described_class.input_hash(
          :attribute1, 'attribute2',
          attribute3: 10,
          'attribute4' => 20
        )
      end

      let(:expected_hash) do
        {
          attribute1: nil,
          'attribute2' => nil,
          attribute3: 10,
          'attribute4' => 20
        }
      end

      it 'returns same hash' do
        expect(hash).to eq(expected_hash)
      end
    end
  end
end

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
sinclair-2.1.1 spec/lib/sinclair/input_hash_spec.rb
sinclair-2.1.0 spec/lib/sinclair/input_hash_spec.rb
sinclair-2.0.1 spec/lib/sinclair/input_hash_spec.rb
sinclair-2.0.0 spec/lib/sinclair/input_hash_spec.rb
sinclair-1.16.3 spec/lib/sinclair/input_hash_spec.rb
sinclair-1.16.2 spec/lib/sinclair/input_hash_spec.rb
sinclair-1.16.1 spec/lib/sinclair/input_hash_spec.rb
sinclair-1.16.0 spec/lib/sinclair/input_hash_spec.rb
sinclair-1.15.0 spec/lib/sinclair/input_hash_spec.rb
sinclair-1.14.2 spec/lib/sinclair/input_hash_spec.rb
sinclair-1.14.1 spec/lib/sinclair/input_hash_spec.rb
sinclair-1.14.0 spec/lib/sinclair/input_hash_spec.rb
sinclair-1.13.0 spec/lib/sinclair/input_hash_spec.rb
sinclair-1.12.1 spec/lib/sinclair/input_hash_spec.rb
sinclair-1.12.0 spec/lib/sinclair/input_hash_spec.rb
sinclair-1.11.0 spec/lib/sinclair/input_hash_spec.rb
sinclair-1.10.0 spec/lib/sinclair/input_hash_spec.rb
sinclair-1.9.0 spec/lib/sinclair/input_hash_spec.rb
sinclair-1.8.0 spec/lib/sinclair/input_hash_spec.rb
sinclair-1.7.0 spec/lib/sinclair/input_hash_spec.rb