Sha256: aa19bd6b409abaa99b317facb06ed65a61580f4bde0e48ea78c89e8de0351f95

Contents?: true

Size: 1.56 KB

Versions: 2

Compression:

Stored size: 1.56 KB

Contents

require 'spec_helper'

describe WeTransfer::Client::Boards do
  let(:big_file) { File.open(fixtures_dir + 'Japan-01.jpg', 'r') }
  let(:client) { WeTransfer::Client.new(api_key: ENV.fetch('WT_API_KEY')) }

  describe '#create_board' do
    before {
      skip "this interface is still experimental"
    }

    it 'creates a remote board' do
      client.create_board(name: 'Test Board', description: 'Test Descritpion')
    end

    it 'creates a board with items' do
      client.create_board(name: 'Test Board', description: 'Test descrition') do |b|
        b.add_file(name: File.basename(__FILE__), io: File.open(__FILE__, 'rb'))
        b.add_file(name: 'big file', io: big_file)
        b.add_web_url(url: 'http://www.wetransfer.com', title: 'WeTransfer Website')
      end
    end

    it 'fails when name is missing' do
      expect {
        client.create_board(name: '', description: 'Test Descritpion')
      }.to raise_error WeTransfer::Client::Error, /400 code/
    end

    it 'fails when file path is wrong' do
      expect {
        client.create_board(name: 'Test Board', description: 'Test descrition') do |b|
          b.add_file(name: 'file_not_found.rb', io: File.open('path/to/non-existing-file.rb', 'r'))
        end
      }.to raise_error Errno::ENOENT, /No such file/
    end

    it 'fails when file name is missing' do
      expect {
        client.create_board(name: 'Test Board', description: 'Test descrition') do |b|
          b.add_file(name: '', io: File.open(__FILE__, 'rb'))
        end
      }.to raise_error WeTransfer::Client::Error, /400 code/
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
wetransfer-0.9.0.beta1 spec/features/create_board_spec.rb
wetransfer-0.9.0.beta spec/features/create_board_spec.rb