Sha256: 22fd0b58d3427f2f2f177a20a1b516fa1008d23b3896339050bca8b3c388e336

Contents?: true

Size: 1.43 KB

Versions: 2

Compression:

Stored size: 1.43 KB

Contents

# frozen_string_literal: true

require 'spec_helper'
describe Qfill::Pusher 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 arguments' do
      before do
        @filter = Qfill::Filter.new(->(object) { object.is_a?(Numeric) })
        @origin_queues = [
          Qfill::Result.new({ name: 'Top Results',
                              ratio: 0.4,
                              list_ratios: {
                                'High Price' => 0.2,
                                'Medium Price' => 0.3,
                                'Low Price' => 0.5
                              } }),
          Qfill::Result.new({ name: 'Page Results',
                              ratio: 0.6,
                              list_ratios: {
                                'High Price' => 0.5,
                                'Medium Price' => 0.3,
                                'Low Price' => 0.2
                              } })
        ]
      end

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

      it 'instantiates with name' do
        popper = described_class.new(*@origin_queues)
        expect(popper.queues.first.name).to eq('Top Results')
        expect(popper.queues.last.name).to eq('Page Results')
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

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