Sha256: 7f38c6e8a8d6fd96b5e937aaa48171f91bcea24fade65ba6b885902cbac85068

Contents?: true

Size: 1.49 KB

Versions: 128

Compression:

Stored size: 1.49 KB

Contents

# frozen_string_literal: true

require 'eac_ruby_utils/options_consumer'

RSpec.describe ::EacRubyUtils::OptionsConsumer do
  context 'instance created with some data' do
    subject(:instance) { described_class.new(a: 'a_value', b: 'b_value', c: 'c_value') }

    it 'left data should be Hash' do
      expect(instance.left_data).to be_a(::Hash)
    end

    it 'left data should be not empty' do
      expect { instance.validate }.to raise_error(::StandardError)
    end

    it 'parses args' do
      expect(instance.left_data).to eq({ a: 'a_value', b: 'b_value', c: 'c_value' }
          .with_indifferent_access)
      expect(instance.consume(:a)).to eq('a_value')
      expect(instance.left_data).to eq({ b: 'b_value', c: 'c_value' }.with_indifferent_access)
      expect(instance.consume(:c)).to eq('c_value')
      expect(instance.left_data).to eq({ b: 'b_value' }.with_indifferent_access)
      expect(instance.consume(:b)).to eq('b_value')
      expect(instance.left_data).to eq({}.with_indifferent_access)
      instance.validate
    end

    it 'raises if validate has left data' do
      expect(instance.left_data.empty?).to eq(false)
    end
  end

  describe '#consume_all' do
    subject(:instance) { described_class.new(a: 'a_value', b: 'b_value', c: 'c_value') }

    it 'return all options in arguments' do
      a, b, c, d = instance.consume_all(:a, :b, :c, :d)
      expect(a).to eq('a_value')
      expect(b).to eq('b_value')
      expect(c).to eq('c_value')
      expect(d).to eq(nil)
    end
  end
end

Version data entries

128 entries across 128 versions & 2 rubygems

Version Path
avm-tools-0.116.1 sub/eac_ruby_utils/spec/lib/eac_ruby_utils/options_consumer_spec.rb
avm-tools-0.116.0 sub/eac_ruby_utils/spec/lib/eac_ruby_utils/options_consumer_spec.rb
avm-tools-0.115.0 sub/eac_ruby_utils/spec/lib/eac_ruby_utils/options_consumer_spec.rb
avm-tools-0.114.2 sub/eac_ruby_utils/spec/lib/eac_ruby_utils/options_consumer_spec.rb
avm-tools-0.114.1 sub/eac_ruby_utils/spec/lib/eac_ruby_utils/options_consumer_spec.rb
avm-tools-0.114.0 sub/eac_ruby_utils/spec/lib/eac_ruby_utils/options_consumer_spec.rb
avm-tools-0.113.6 sub/eac_ruby_utils/spec/lib/eac_ruby_utils/options_consumer_spec.rb
avm-tools-0.113.5 sub/eac_ruby_utils/spec/lib/eac_ruby_utils/options_consumer_spec.rb
avm-tools-0.113.4 sub/eac_ruby_utils/spec/lib/eac_ruby_utils/options_consumer_spec.rb
avm-tools-0.113.3 sub/eac_ruby_utils/spec/lib/eac_ruby_utils/options_consumer_spec.rb
avm-tools-0.113.2 sub/eac_ruby_utils/spec/lib/eac_ruby_utils/options_consumer_spec.rb
ehbrs-tools-0.28.3 vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/options_consumer_spec.rb
avm-tools-0.110.0 vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/options_consumer_spec.rb
avm-tools-0.109.1 vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/options_consumer_spec.rb
avm-tools-0.109.0 vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/options_consumer_spec.rb
ehbrs-tools-0.28.2 vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/options_consumer_spec.rb
avm-tools-0.108.0 vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/options_consumer_spec.rb
ehbrs-tools-0.28.1 vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/options_consumer_spec.rb
avm-tools-0.107.0 vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/options_consumer_spec.rb
ehbrs-tools-0.28.0 vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/options_consumer_spec.rb