# frozen_string_literal: true require 'rails_helper' RSpec.describe SchedulePipeline::SchedulePipeline, type: :service do let(:queue_factory) { double(for_name: nil) } describe '#initialize' do it 'uses 3 queues' do described_class.new(queue_factory) expect(queue_factory).to have_received(:for_name).with(:fetch_vendor_schedules) expect(queue_factory).to have_received(:for_name).with(:unprocessed_schedules) expect(queue_factory).to have_received(:for_name).with(:processed_schedules) end end context 'after construction' do let(:service) { described_class.new(queue_factory) } let(:stages) { (1..3).collect{ double(start: nil, stop: nil) } } before { allow(service).to receive(:stages).and_return(stages) } describe '#start' do it 'starts each stage' do service.start stages.each { |stg| expect(stg).to have_received(:start).once } end end describe '#stop' do it 'stops each stage' do service.stop stages.each { |stg| expect(stg).to have_received(:stop).once } end end end end