Sha256: 23bd4d060b2704225203c69b40bc1780d6b6df63dd98d00df989130ba4f99859

Contents?: true

Size: 1.71 KB

Versions: 2

Compression:

Stored size: 1.71 KB

Contents

# frozen_string_literal: true

require 'spec_helper'
describe Qfill::Origin do
  describe '#new' do
    context 'with no arguments' do
      it 'raises ArgumentError' do
        expect { described_class.new }.to raise_error(ArgumentError)
      end
    end

    context 'with name' do
      before do
        @arguments = { name: 'High List' }
      end

      it 'does not raise any errors' do
        expect { described_class.new(@arguments) }.not_to raise_error
      end

      it 'instantiates with name' do
        expect(described_class.new(@arguments).name).to eq('High List')
      end
    end

    context 'with elements' do
      before do
        @arguments = {  name: 'High List',
                        elements: [1, 2] }
      end

      it 'instantiates with elements' do
        expect(described_class.new(@arguments).elements).to eq([1, 2])
      end
    end

    context 'with backfill' do
      before do
        @arguments = {  name: 'High List',
                        elements: [1, 2],
                        backfill: 'Medium List' }
      end

      it 'instantiates with elements' do
        expect(described_class.new(@arguments).backfill).to eq('Medium List')
      end
    end

    context 'with filter' do
      before do
        lambda = ->(object) { !object.nil? }
        @filter = Qfill::Filter.new(lambda)
        @arguments = {  name: 'High List',
                        elements: [1, 2],
                        backfill: 'Medium List',
                        filter: @filter }
      end

      it 'instantiates with processor' do
        expect(described_class.new(@arguments).filter).to be_a(Qfill::Filter)
        expect(described_class.new(@arguments).filter).to eq(@filter)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
qfill-0.1.1 spec/qfill/origin_spec.rb
qfill-0.1.0 spec/qfill/origin_spec.rb