Sha256: 0b3bc0351eb1fe1008f226edde72ed7c35949145e7951d4f3aa429d3cfc9b0e7

Contents?: true

Size: 1.82 KB

Versions: 2

Compression:

Stored size: 1.82 KB

Contents

require 'spec_helper'

describe WeTransfer::Client::Boards do
  let(:client) { WeTransfer::Client.new(api_key: ENV.fetch('WT_API_KEY')) }
  let(:board) do
    client.create_board(name: 'Test Board', description: 'Test Descritpion')
  end

  describe '#add_items' do
    before do
      skip "this interface is still experimental"
    end

    it 'adds items to a board' do
      client.add_items(board: board) do |b|
        b.add_file(name: File.basename(__FILE__), io: File.open(__FILE__, 'rb'))
        b.add_file_at(path: fixtures_dir + 'Japan-02.jpg')
        b.add_web_url(url: 'http://www.google.com', title: 'google')
      end
    end

    it 'fails when no block is given' do
      expect {
        client.add_items(board: board)
      }.to raise_error ArgumentError, /No items/
    end

    it 'fails when no board is passed as keyword argument' do
      expect {
        client.add_items do |b|
          b.add_file_at(path: fixtures_dir + 'Japan-01.jpg')
        end
      }.to raise_error ArgumentError, /board/
    end

    it 'fails when file is not found' do
      expect {
        client.add_items(board: board) do |b|
          b.add_file(name: 'file_not_found.rb', io: File.open('/path/to/non-existent-file.rb', 'r'))
        end
      }.to raise_error Errno::ENOENT, /No such file/
    end

    it 'fails when board is not a existing remote board' do
      new_board = RemoteBoard.new(id: 123456, state: 'proccessing', url: 'https://www.we.tl/123456', name: 'fake board')
      expect {
        client.add_items(board: new_board) do |b|
          b.add_file(name: File.basename(__FILE__), io: File.open(__FILE__, 'rb'))
          b.add_file_at(path: fixtures_dir + 'Japan-01.jpg')
          b.add_web_url(url: 'http://www.google.com', title: 'google')
        end
      }.to raise_error WeTransfer::Client::Error, /404 code/
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

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