# encoding:utf-8 require 'spec_helper' describe TaxGenerator::Processor do let(:actor_pool) {mock} let(:workers) { TaxGenerator::FileCreator.new } before(:each) do Celluloid::SupervisionGroup.stubs(:run!).returns(actor_pool) actor_pool.stubs(:pool).returns(workers) Actor.current.stubs(:link).returns(true) end context "intialize" do it 'boots the celluloid' do Celluloid.expects(:boot).returns(true) TaxGenerator::Processor.new end it 'runs the supervision group' do Celluloid::SupervisionGroup.expects(:run!).returns(actor_pool) TaxGenerator::Processor.new end it 'creates the pool of workers' do actor_pool.expects(:pool).with(TaxGenerator::FileCreator, as: :workers, size: 50).returns(workers) TaxGenerator::Processor.new end it "links the actor to the current actor" do Actor.current.stubs(:link).returns(true) TaxGenerator::Processor.new end end context "intialize" do specify { expect(subject.jobs).to eq({}) } specify { expect(subject.job_to_worker).to eq({}) } specify { expect(subject.worker_to_job).to eq({}) } end it 'returns the input folder' do subject.options.expects(:fetch).with(:input_dir, "#{root}/data/input") subject.input_folder end it 'returns the output_folder' do subject.options.expects(:fetch).with(:output_dir, "#{root}/data/output") subject.output_folder end it 'returns the taxonomy_filename' do subject.options.expects(:fetch).with(:taxonomy_filename, 'taxonomy.xml') subject.taxonomy_file_name end it 'returns the destinations_file_name' do subject.options.expects(:fetch).with(:destinations_filename, 'destinations.xml') subject.destinations_file_name end it 'returns the taxonomy_file_path' do File.expects(:join).with(subject.input_folder, subject.taxonomy_file_name).returns(true) subject.taxonomy_file_path end it 'returns the destinations_file_path' do File.expects(:join).with(subject.input_folder, subject.destinations_file_name).returns(true) subject.destinations_file_path end it 'returns the static_output_dir' do File.expects(:join).with(subject.output_folder, 'static').returns(true) subject.static_output_dir end end