require 'spec_helper' require 'flydata/command/setup' module Flydata module Command describe Setup do subject { described_class.new } let(:sender) { double("sender") } let(:de) { {'type' => 'RedshiftMysqlDataEntry'} } let(:data_entries) { [ de ] } let(:flydata) { double('flydata') } let(:data_port) { double('data_port') } let(:dp) { double('dp') } let(:conf) { double('conf') } let(:sync_fm) { double('sync_fm') } let(:credentials) { double('credentials') } let(:login) { double('login') } before do allow(subject).to receive(:retrieve_data_entries).and_return(data_entries) allow(subject).to receive(:flydata).and_return(flydata) allow(flydata).to receive(:data_port).and_return(data_port) allow(flydata).to receive(:flydata_api_host).and_return('localhost') expect(flydata).to receive(:credentials).and_return(credentials) expect(credentials).to receive(:authenticated?).and_return(false) allow(data_port).to receive(:get).and_return(dp) expect(sender).to receive(:process_exist?).and_return(true) expect(sender).to receive(:stop) allow(sync_fm).to receive(:source_pos_path).and_return('/tmp') expect(conf).to receive(:copy_templates) expect(login).to receive(:run) expect(sender).to receive(:restart) allow(Flydata::SyncFileManager).to receive(:new).with(de).and_return(sync_fm) end it do expect(Flydata::Command::Conf).to receive(:new).and_return(conf) expect(Flydata::Command::Login).to receive(:new).and_return(login) expect(Flydata::Command::Sender).to receive(:new).and_return(sender).twice subject.initial_run end end end end