Sha256: f685286bef18d1b54edcc64210d59a055917b10d4313fe3c3b168efc97b566c4

Contents?: true

Size: 1.63 KB

Versions: 2

Compression:

Stored size: 1.63 KB

Contents

require 'spec_helper'

describe WeTransfer::Client::Transfers do
  describe '#create_transfer_and_upload_files' do
    it 'creates a transfer and uploads the files' do
      client = WeTransfer::Client.new(api_key: ENV.fetch('WT_API_KEY'))
      transfer = client.create_transfer_and_upload_files(message: 'test description') do |b|
        b.add_file(name: File.basename(__FILE__), io: File.open(__FILE__, 'rb'))
        b.add_file_at(path: fixtures_dir + 'Japan-01.jpg')
      end

      expect(transfer).to be_kind_of(RemoteTransfer)
      expect(transfer.url).to start_with('https://we.tl/')

      transfer = loop do
        res = client.get_transfer(transfer_id: transfer.id)
        break res if res.state != 'processing'
        sleep 1
      end

      expect(transfer.state).to eq('downloadable')
    end

    it 'fails when no files are added' do
      client = WeTransfer::Client.new(api_key: ENV.fetch('WT_API_KEY'))
      expect {
        client.create_transfer_and_upload_files(message: 'test description')
      }.to raise_error ArgumentError, /No files/
    end

    it 'fails with duplicate file names' do
      client = WeTransfer::Client.new(api_key: ENV.fetch('WT_API_KEY', logger: test_logger))
      expect {
        client.create_transfer_and_upload_files(message: 'All the (same) Things') do |builder|
          builder.add_file(name: 'README.txt', io: StringIO.new("A thing"))
          builder.add_file(name: 'README.txt', io: StringIO.new("another thing"))
        end
      }.to raise_error ArgumentError, /Duplicate file entry/
    end
  end

  pending '#create_transfers'
  pending "#complete_transfer"
  pending "#get_transfer"
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
wetransfer-0.9.0.beta1 spec/we_transfer_client/transfers_spec.rb
wetransfer-0.9.0.beta spec/we_transfer_client/transfers_spec.rb