RSpec.describe ERDL::Executable do
  let(:fetcher) { instance_double(ERDL::URLFetcher) }
  let(:file_utils) { instance_double(ERDL::FileUtilities) }

  context 'ftp subcommand' do
    subject { ERDL::Executable.new(opts, 'ftp', { location: 'test_dir' }, fetcher: fetcher, file_utils: file_utils) }
    describe '#execute!' do
      context 'dry run' do
        let(:opts) { { dry_run: true } }

        it 'doesn\'t send the file to ftp' do
          expect(fetcher).to receive(:url).and_return('http://url.com')
          expect(file_utils).not_to receive(:stream_file)
          expect { subject.execute! }.to_not raise_error
        end
      end

      context 'real run' do
        let(:opts) { { dry_run: false } }

        it 'sends the file to ftp' do
          expect(fetcher).to receive(:url).and_return('http://url.com')
          allow(file_utils).to receive(:stream_file).and_return(true)
          expect { subject.execute! }.to_not raise_error
        end
      end
    end
  end
end
