wetransfer 0.4.4 → 0.9.0.beta
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/.rspec +1 -2
- data/.rubocop.yml +1 -1
- data/.travis.yml +3 -2
- data/Guardfile +11 -0
- data/README.md +81 -38
- data/V2_README.md +53 -0
- data/examples/create_collection.rb +13 -0
- data/examples/create_transfer.rb +1 -1
- data/lib/we_transfer_client.rb +86 -120
- data/lib/we_transfer_client/board_builder.rb +33 -0
- data/lib/we_transfer_client/boards.rb +74 -0
- data/lib/we_transfer_client/future_board.rb +32 -0
- data/lib/we_transfer_client/future_file.rb +28 -0
- data/lib/we_transfer_client/future_link.rb +28 -0
- data/lib/we_transfer_client/future_transfer.rb +11 -5
- data/lib/we_transfer_client/remote_board.rb +47 -0
- data/lib/we_transfer_client/remote_file.rb +55 -0
- data/lib/we_transfer_client/remote_link.rb +9 -0
- data/lib/we_transfer_client/remote_transfer.rb +24 -1
- data/lib/we_transfer_client/transfer_builder.rb +3 -10
- data/lib/we_transfer_client/transfers.rb +73 -0
- data/lib/we_transfer_client/version.rb +2 -2
- data/spec/board_integration_spec.rb +68 -0
- data/spec/features/add_items_to_board_spec.rb +55 -0
- data/spec/features/create_board_spec.rb +46 -0
- data/spec/features/get_board_spec.rb +34 -0
- data/spec/features/transfer_spec.rb +41 -0
- data/spec/fixtures/Japan-01.jpg +0 -0
- data/spec/fixtures/Japan-02.jpg +0 -0
- data/spec/spec_helper.rb +20 -0
- data/spec/transfer_integration_spec.rb +54 -0
- data/spec/we_transfer_client/board_builder_spec.rb +66 -0
- data/spec/we_transfer_client/boards_spec.rb +56 -0
- data/spec/we_transfer_client/future_board_spec.rb +98 -0
- data/spec/we_transfer_client/future_file_spec.rb +48 -0
- data/spec/we_transfer_client/future_link_spec.rb +44 -0
- data/spec/we_transfer_client/future_transfer_spec.rb +30 -13
- data/spec/we_transfer_client/remote_board_spec.rb +92 -0
- data/spec/we_transfer_client/remote_file_spec.rb +91 -0
- data/spec/we_transfer_client/remote_link_spec.rb +33 -0
- data/spec/we_transfer_client/remote_transfer_spec.rb +101 -0
- data/spec/we_transfer_client/transfer_builder_spec.rb +48 -51
- data/spec/we_transfer_client/transfers_spec.rb +45 -0
- data/spec/we_transfer_client_spec.rb +51 -3
- data/wetransfer.gemspec +11 -5
- metadata +67 -27
- data/lib/we_transfer_client/future_file_item.rb +0 -16
- data/lib/we_transfer_client/future_web_item.rb +0 -18
- data/lib/we_transfer_client/remote_item.rb +0 -2
- data/spec/integration_spec.rb +0 -160
- data/spec/we_transfer_client/future_file_item_spec.rb +0 -39
- data/spec/we_transfer_client/future_web_item_spec.rb +0 -39
@@ -1,3 +1,3 @@
|
|
1
|
-
|
2
|
-
VERSION = '0.
|
1
|
+
module WeTransfer
|
2
|
+
VERSION = '0.9.0.beta'
|
3
3
|
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe WeTransfer::Client do
|
4
|
+
let(:small_file_name) { 'Japan-02.jpg' }
|
5
|
+
let(:big_file) { File.open(fixtures_dir + 'Japan-01.jpg', 'rb') }
|
6
|
+
let(:client) do
|
7
|
+
WeTransfer::Client.new(api_key: ENV.fetch('WT_API_KEY'))
|
8
|
+
end
|
9
|
+
|
10
|
+
it 'creates a board with files and web items as a block' do
|
11
|
+
# Create a board with three items, one small file, one multipart file, and one web url
|
12
|
+
board = client.create_board_and_upload_items(name: 'Test Board', description: 'Test description') do |b|
|
13
|
+
b.add_file(name: File.basename(__FILE__), io: File.open(__FILE__, 'rb'))
|
14
|
+
b.add_file(name: 'big file', io: big_file)
|
15
|
+
b.add_file_at(path: fixtures_dir + small_file_name)
|
16
|
+
b.add_web_url(url: 'http://www.wetransfer.com', title: 'WeTransfer Website')
|
17
|
+
end
|
18
|
+
|
19
|
+
# the board url is set
|
20
|
+
expect(board.url =~ %r|https://we.tl/b-|).to be_truthy
|
21
|
+
|
22
|
+
expect(board.items.map(&:class)).to eq([RemoteFile, RemoteFile, RemoteFile, RemoteLink])
|
23
|
+
expect(board.items[1].multipart.part_numbers).to be > 1
|
24
|
+
expect(board.items.count).to be(4)
|
25
|
+
|
26
|
+
# TODO: make these experimental steps public
|
27
|
+
# # Add two new items to the board, one small file and one web url
|
28
|
+
# client.add_items(board: board) do |b|
|
29
|
+
# b.add_file(name: File.basename(__FILE__), io: File.open(__FILE__, 'rb'))
|
30
|
+
# b.add_web_url(url: 'http://www.google.com', title: 'google')
|
31
|
+
# end
|
32
|
+
# expect(board.items.count).to be(6)
|
33
|
+
|
34
|
+
# # Check if the board includes 3 File items and 2 Link items
|
35
|
+
# expect(board.items.select { |i| i.type == 'file' }.count).to be(4)
|
36
|
+
# expect(board.items.select { |i| i.type == 'link' }.count).to be(2)
|
37
|
+
|
38
|
+
# # Upload the Files to the Board
|
39
|
+
# file_items = board.items.select { |i| i.type == 'file' }
|
40
|
+
# client.upload_file(object: board, file: file_items[0], io: File.open(__FILE__, 'rb'))
|
41
|
+
# client.upload_file(object: board, file: file_items[1], io: big_file)
|
42
|
+
# client.upload_file(object: board, file: file_items[2], io: File.open(fixtures_dir + small_file_name, 'rb'))
|
43
|
+
# client.upload_file(object: board, file: file_items[3], io: File.open(__FILE__, 'rb'))
|
44
|
+
|
45
|
+
# # Complete all the files of the board
|
46
|
+
# file_items.each do |item|
|
47
|
+
# client.complete_file!(object: board, file: item)
|
48
|
+
# end
|
49
|
+
|
50
|
+
# Do a get request to see if url is available
|
51
|
+
response = Faraday.get(board.url)
|
52
|
+
|
53
|
+
# that should redirect us...
|
54
|
+
expect(response.status).to eq(302)
|
55
|
+
# ... to a board in the wetransfer domain
|
56
|
+
expect(response['location']).to start_with('https://boards.wetransfer')
|
57
|
+
|
58
|
+
# Check for the Boards status to be downloadable
|
59
|
+
resulting_board = loop do
|
60
|
+
res = client.get_board(board: board)
|
61
|
+
break res if res.state != 'processing'
|
62
|
+
sleep 1
|
63
|
+
end
|
64
|
+
|
65
|
+
expect(resulting_board.state).to eq('downloadable')
|
66
|
+
expect(resulting_board.items.count).to be(4)
|
67
|
+
end
|
68
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe WeTransfer::Client::Boards do
|
4
|
+
let(:client) { WeTransfer::Client.new(api_key: ENV.fetch('WT_API_KEY')) }
|
5
|
+
let(:board) do
|
6
|
+
client.create_board(name: 'Test Board', description: 'Test Descritpion')
|
7
|
+
end
|
8
|
+
|
9
|
+
describe '#add_items' do
|
10
|
+
before do
|
11
|
+
skip "this interface is still experimental"
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'adds items to a board' do
|
15
|
+
client.add_items(board: board) do |b|
|
16
|
+
b.add_file(name: File.basename(__FILE__), io: File.open(__FILE__, 'rb'))
|
17
|
+
b.add_file_at(path: fixtures_dir + 'Japan-02.jpg')
|
18
|
+
b.add_web_url(url: 'http://www.google.com', title: 'google')
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'fails when no block is given' do
|
23
|
+
expect {
|
24
|
+
client.add_items(board: board)
|
25
|
+
}.to raise_error ArgumentError, /No items/
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'fails when no board is passed as keyword argument' do
|
29
|
+
expect {
|
30
|
+
client.add_items do |b|
|
31
|
+
b.add_file_at(path: fixtures_dir + 'Japan-01.jpg')
|
32
|
+
end
|
33
|
+
}.to raise_error ArgumentError, /board/
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'fails when file is not found' do
|
37
|
+
expect {
|
38
|
+
client.add_items(board: board) do |b|
|
39
|
+
b.add_file(name: 'file_not_found.rb', io: File.open('/path/to/non-existent-file.rb', 'r'))
|
40
|
+
end
|
41
|
+
}.to raise_error Errno::ENOENT, /No such file/
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'fails when board is not a existing remote board' do
|
45
|
+
new_board = RemoteBoard.new(id: 123456, state: 'proccessing', url: 'https://www.we.tl/123456', name: 'fake board')
|
46
|
+
expect {
|
47
|
+
client.add_items(board: new_board) do |b|
|
48
|
+
b.add_file(name: File.basename(__FILE__), io: File.open(__FILE__, 'rb'))
|
49
|
+
b.add_file_at(path: fixtures_dir + 'Japan-01.jpg')
|
50
|
+
b.add_web_url(url: 'http://www.google.com', title: 'google')
|
51
|
+
end
|
52
|
+
}.to raise_error WeTransfer::Client::Error, /404 code/
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe WeTransfer::Client::Boards do
|
4
|
+
let(:big_file) { File.open(fixtures_dir + 'Japan-01.jpg', 'r') }
|
5
|
+
let(:client) { WeTransfer::Client.new(api_key: ENV.fetch('WT_API_KEY')) }
|
6
|
+
|
7
|
+
describe '#create_board' do
|
8
|
+
before {
|
9
|
+
skip "this interface is still experimental"
|
10
|
+
}
|
11
|
+
|
12
|
+
it 'creates a remote board' do
|
13
|
+
client.create_board(name: 'Test Board', description: 'Test Descritpion')
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'creates a board with items' do
|
17
|
+
client.create_board(name: 'Test Board', description: 'Test descrition') do |b|
|
18
|
+
b.add_file(name: File.basename(__FILE__), io: File.open(__FILE__, 'rb'))
|
19
|
+
b.add_file(name: 'big file', io: big_file)
|
20
|
+
b.add_web_url(url: 'http://www.wetransfer.com', title: 'WeTransfer Website')
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'fails when name is missing' do
|
25
|
+
expect {
|
26
|
+
client.create_board(name: '', description: 'Test Descritpion')
|
27
|
+
}.to raise_error WeTransfer::Client::Error, /400 code/
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'fails when file path is wrong' do
|
31
|
+
expect {
|
32
|
+
client.create_board(name: 'Test Board', description: 'Test descrition') do |b|
|
33
|
+
b.add_file(name: 'file_not_found.rb', io: File.open('path/to/non-existing-file.rb', 'r'))
|
34
|
+
end
|
35
|
+
}.to raise_error Errno::ENOENT, /No such file/
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'fails when file name is missing' do
|
39
|
+
expect {
|
40
|
+
client.create_board(name: 'Test Board', description: 'Test descrition') do |b|
|
41
|
+
b.add_file(name: '', io: File.open(__FILE__, 'rb'))
|
42
|
+
end
|
43
|
+
}.to raise_error WeTransfer::Client::Error, /400 code/
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe WeTransfer::Client::Boards do
|
4
|
+
let(:client) do
|
5
|
+
WeTransfer::Client.new(api_key: ENV.fetch('WT_API_KEY'))
|
6
|
+
end
|
7
|
+
|
8
|
+
let(:board) do
|
9
|
+
client.create_board(name: 'Test Board', description: 'Test Descritpion')
|
10
|
+
end
|
11
|
+
|
12
|
+
describe '#get_board' do
|
13
|
+
before do
|
14
|
+
skip "this interface is still experimental"
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'it gets a exisiting board' do
|
18
|
+
client.get_board(board: board)
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'fails when no board is given' do
|
22
|
+
expect {
|
23
|
+
client.get_board
|
24
|
+
}.to raise_error ArgumentError, /board/
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'fails when board doenst exists' do
|
28
|
+
new_board = RemoteBoard.new(id: 123456, state: 'proccessing', url: 'https://www.we.tl/123456', name: 'fake board')
|
29
|
+
expect {
|
30
|
+
client.get_board(board: new_board)
|
31
|
+
}.to raise_error WeTransfer::Client::Error, /404 code/
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe WeTransfer::Client::Transfers do
|
4
|
+
let(:client) do
|
5
|
+
WeTransfer::Client.new(api_key: ENV.fetch('WT_API_KEY'), logger: test_logger)
|
6
|
+
end
|
7
|
+
|
8
|
+
let(:file_location) { fixtures_dir + 'Japan-02.jpg' }
|
9
|
+
|
10
|
+
let(:created_transfer) do
|
11
|
+
client.create_transfer(message: 'Test transfer') do |builder|
|
12
|
+
builder.add_file(name: File.basename(file_location), io: File.open(file_location, 'rb'))
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
describe "#create_transfer" do
|
17
|
+
before do
|
18
|
+
skip "this interface is still experimental"
|
19
|
+
end
|
20
|
+
|
21
|
+
it "is needed to add a file" do
|
22
|
+
expect { client.create_transfer(message: "Transfer name") }
|
23
|
+
.to raise_error(ArgumentError, /^No files were added/)
|
24
|
+
end
|
25
|
+
|
26
|
+
it "accepts a block to add files by their location" do
|
27
|
+
client.create_transfer(message: 'Test transfer') do |builder|
|
28
|
+
builder.add_file_at(path: file_location)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
it "accepts a block to add files by their io" do
|
33
|
+
client.create_transfer(message: 'Test transfer') do |builder|
|
34
|
+
builder.add_file(name: File.basename(file_location), io: File.open(file_location, 'rb'))
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
describe "#complete_transfer"
|
40
|
+
describe "#get_transfer"
|
41
|
+
end
|
Binary file
|
Binary file
|
data/spec/spec_helper.rb
CHANGED
@@ -1,4 +1,6 @@
|
|
1
1
|
require 'simplecov'
|
2
|
+
require 'securerandom'
|
3
|
+
|
2
4
|
SimpleCov.start do
|
3
5
|
add_filter '/spec/'
|
4
6
|
end
|
@@ -12,8 +14,26 @@ require 'tempfile'
|
|
12
14
|
require 'dotenv'
|
13
15
|
Dotenv.load
|
14
16
|
|
17
|
+
module SpecHelpers
|
18
|
+
def fixtures_dir
|
19
|
+
__dir__ + '/fixtures/'
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_logger
|
23
|
+
Logger.new($stderr).tap { |log| log.level = Logger::WARN }
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
15
27
|
RSpec.configure do |config|
|
28
|
+
config.include SpecHelpers
|
29
|
+
config.extend SpecHelpers
|
30
|
+
|
16
31
|
config.expect_with :rspec do |c|
|
17
32
|
c.syntax = :expect
|
18
33
|
end
|
34
|
+
|
35
|
+
config.filter_run :focus
|
36
|
+
config.run_all_when_everything_filtered = true
|
37
|
+
config.default_formatter = 'doc'
|
38
|
+
config.order = :random
|
19
39
|
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe WeTransfer::Client do
|
6
|
+
let(:client) { WeTransfer::Client.new(api_key: ENV.fetch('WT_API_KEY')) }
|
7
|
+
let(:file_locations) { %w[Japan-01.jpg Japan-02.jpg] }
|
8
|
+
|
9
|
+
describe described_class::Transfers do
|
10
|
+
pending 'creates a transfer with multiple files' do
|
11
|
+
skip "this interface is still experimental"
|
12
|
+
transfer = client.create_transfer(message: 'Japan: 🏯 & 🎎') do |builder|
|
13
|
+
file_locations.each do |file_location|
|
14
|
+
builder.add_file(name: File.basename(file_location), io: File.open(fixtures_dir + file_location, 'rb'))
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
expect(transfer).to be_kind_of(RemoteTransfer)
|
19
|
+
|
20
|
+
# it has an url that is not available (yet)
|
21
|
+
expect(transfer.url).to be(nil)
|
22
|
+
# it has no files (yet)
|
23
|
+
expect(transfer.files.first.url).to be(nil)
|
24
|
+
# it is in an uploading state
|
25
|
+
expect(transfer.state).to eq('uploading')
|
26
|
+
|
27
|
+
# TODO: uncouple file_locations and transfer.files
|
28
|
+
file_locations.each_with_index do |location, index|
|
29
|
+
client.upload_file(
|
30
|
+
object: transfer,
|
31
|
+
file: transfer.files[index],
|
32
|
+
io: File.open(fixtures_dir + location, 'rb')
|
33
|
+
)
|
34
|
+
client.complete_file!(
|
35
|
+
object: transfer,
|
36
|
+
file: transfer.files[index]
|
37
|
+
)
|
38
|
+
end
|
39
|
+
|
40
|
+
result = client.complete_transfer(transfer: transfer)
|
41
|
+
|
42
|
+
# it has an url that is available
|
43
|
+
expect(result.url =~ %r|^https://we.tl/t-|).to be_truthy
|
44
|
+
|
45
|
+
# it is in a processing state
|
46
|
+
expect(result.state).to eq('processing')
|
47
|
+
|
48
|
+
response = Faraday.get(result.url)
|
49
|
+
# it hits the short-url with redirect
|
50
|
+
expect(response.status).to eq(302)
|
51
|
+
expect(response['location']).to start_with('https://wetransfer.com/')
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe BoardBuilder do
|
4
|
+
describe '#initialize' do
|
5
|
+
it 'initializes with an empty array' do
|
6
|
+
expect(subject.items.empty?).to be(true)
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
describe '#add_file' do
|
11
|
+
it 'returns an error when name is missing' do
|
12
|
+
expect {
|
13
|
+
subject.add_file(io: File.open(__FILE__, 'rb'))
|
14
|
+
}.to raise_error ArgumentError, /name/
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'returns an error when io is missing' do
|
18
|
+
expect {
|
19
|
+
subject.add_file(name: 'file name')
|
20
|
+
}.to raise_error ArgumentError, /io/
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'returns a error when file doesnt exists' do
|
24
|
+
expect {
|
25
|
+
subject.add_file(name: 'file name', io: File.open('foo', 'rb'))
|
26
|
+
}.to raise_error Errno::ENOENT
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'adds a file when name and io is given' do
|
30
|
+
subject.add_file(name: 'file name', io: File.open(__FILE__, 'rb'))
|
31
|
+
expect(subject.items.first).to be_kind_of(FutureFile)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe '#add_file_at' do
|
36
|
+
before do
|
37
|
+
skip "this interface is still experimental"
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'adds a file from a path' do
|
41
|
+
subject.add_file_at(path: __FILE__)
|
42
|
+
expect(subject.items.first).to be_kind_of(FutureFile)
|
43
|
+
end
|
44
|
+
|
45
|
+
it 'throws a Error when file doesnt exists' do
|
46
|
+
expect {
|
47
|
+
subject.add_file_at(path: '/this/path/leads/to/nothing.exe')
|
48
|
+
}.to raise_error Errno::ENOENT
|
49
|
+
end
|
50
|
+
|
51
|
+
it 'should call #add_file' do
|
52
|
+
client = WeTransfer::Client.new(api_key: ENV.fetch('WT_API_KEY'))
|
53
|
+
client.create_board(name: 'Test board', description: 'A board description') do |b|
|
54
|
+
expect(b).to receive(:add_file).with(name: anything, io: kind_of(::IO))
|
55
|
+
b.add_file_at(path: __FILE__)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
describe '#add_web_url' do
|
61
|
+
it 'adds a item to board when url and title are given' do
|
62
|
+
subject.add_web_url(url: 'http://www.wetransfer.com', title: 'wetransfer')
|
63
|
+
expect(subject.items.first).to be_kind_of(FutureLink)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
require_relative '../../lib/we_transfer_client.rb'
|
4
|
+
|
5
|
+
describe WeTransfer::Client::Boards do
|
6
|
+
describe '#create_board_and_upload_items' do
|
7
|
+
it 'creates a board and uploads the files' do
|
8
|
+
client = WeTransfer::Client.new(api_key: ENV.fetch('WT_API_KEY'))
|
9
|
+
board = client.create_board_and_upload_items(name: 'test', description: 'test description') do |b|
|
10
|
+
b.add_file(name: File.basename(__FILE__), io: File.open(__FILE__, 'rb'))
|
11
|
+
b.add_web_url(url: 'http://www.wetransfer.com', title: 'WeTransfer Website')
|
12
|
+
end
|
13
|
+
expect(board).to be_kind_of(RemoteBoard)
|
14
|
+
expect(board.url).to start_with('https://we.tl/')
|
15
|
+
expect(board.state).to eq('downloadable')
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
describe "experimental features" do
|
20
|
+
before do
|
21
|
+
skip "this interface is still experimental"
|
22
|
+
end
|
23
|
+
|
24
|
+
describe '#create_board' do
|
25
|
+
it 'creates a board' do
|
26
|
+
client = WeTransfer::Client.new(api_key: ENV.fetch('WT_API_KEY'))
|
27
|
+
board = client.create_board(name: 'test', description: 'test description')
|
28
|
+
expect(board).to be_kind_of(RemoteBoard)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
describe "#add_items" do
|
33
|
+
it 'adds items to an existing board' do
|
34
|
+
client = WeTransfer::Client.new(api_key: ENV.fetch('WT_API_KEY'))
|
35
|
+
board = client.create_board(name: 'test', description: 'test description')
|
36
|
+
updated_board = client.add_items(board: board) do |b|
|
37
|
+
b.add_file(name: File.basename(__FILE__), io: File.open(__FILE__, 'rb'))
|
38
|
+
b.add_web_url(url: 'http://www.wetransfer.com', title: 'WeTransfer Website')
|
39
|
+
end
|
40
|
+
expect(updated_board).to be_kind_of(RemoteBoard)
|
41
|
+
expect(updated_board.items.size).to eq(2)
|
42
|
+
expect(updated_board.items.map(&:class)).to eq([RemoteFile, RemoteLink])
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
describe "#get_board" do
|
47
|
+
it 'gets board' do
|
48
|
+
client = WeTransfer::Client.new(api_key: ENV.fetch('WT_API_KEY'))
|
49
|
+
board = client.create_board(name: 'test', description: 'test description')
|
50
|
+
board_request = client.get_board(board: board)
|
51
|
+
|
52
|
+
expect(board_request).to be_kind_of(RemoteBoard)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|