Skip to content
This repository was archived by the owner on Dec 11, 2020. It is now read-only.

Commit 626a3fc

Browse files
committed
More focus in integration test
1 parent 4a9b6d3 commit 626a3fc

File tree

2 files changed

+21
-25
lines changed

2 files changed

+21
-25
lines changed
Lines changed: 19 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,45 @@
11
require "spec_helper"
22

3-
describe "client creates a finalized transfer with 5 files" do
3+
describe "transfer integration" do
44
around do |example|
55
WebMock.allow_net_connect!
66
example.run
77
WebMock.disable_net_connect!
88
end
99

10-
it "works" do
10+
it "Create a client, a transfer, it uploads files and finalizes the transfer" do
1111
client = WeTransfer::Client.new(api_key: ENV.fetch("WT_API_KEY"))
1212

1313
client.create_transfer(message: "test transfer") do |transfer|
14-
transfer.add_file(name: "test_file_1", size: 10)
15-
transfer.add_file(name: "test_file_2", size: 10, io: StringIO.new("#" * 10))
16-
# transfer.add_file(name: "test_file_3", size: 10)
17-
# test_file_4 is a file of more than 1 chunk
18-
transfer.add_file(name: "test_file_4", io: File.open('spec/fixtures/Japan-01.jpg'))
19-
transfer.add_file(name: "test_file_5", io: File.open("Gemfile"))
14+
transfer.add_file(name: "small_file", size: 80)
15+
transfer.add_file(name: "small_file_with_io", size: 10, io: StringIO.new("#" * 10))
16+
transfer.add_file(name: "multi_chunk_big_file", io: File.open('spec/fixtures/Japan-01.jpg'))
2017
end
2118

2219
transfer = client.transfer
23-
# these next expectations should check against state (that it is persisted, and the corresponding flag is truthy)
20+
21+
expect(transfer.url)
22+
.to be_nil
23+
2424
expect(transfer.id.nil?).to eq false
2525
expect(transfer.state).to eq "uploading"
2626
expect(transfer.files.none? { |f| f.id.nil? }).to eq true
2727

28-
transfer.upload_file(name: "test_file_1", io: StringIO.new("#" * 10))
29-
transfer.complete_file(name: "test_file_1")
30-
31-
transfer.upload_file(name: "test_file_2")
32-
transfer.complete_file(name: "test_file_2")
28+
transfer.upload_file(name: "small_file", io: StringIO.new("#" * 80))
29+
transfer.complete_file(name: "small_file")
3330

34-
# upload "test_file_3" using Faraday to express we aren't bound to using the SDK for uploading
35-
# transfer.add_file(name: "test_file_3", size: 10)
31+
transfer.upload_file(name: "small_file_with_io")
32+
transfer.complete_file(name: "small_file_with_io")
3633

37-
transfer.upload_file(name: "test_file_4")
38-
transfer.complete_file(name: "test_file_4")
34+
transfer.upload_file(name: "multi_chunk_big_file")
35+
transfer.complete_file(name: "multi_chunk_big_file")
3936

40-
transfer.upload_file(name: "test_file_5")
41-
transfer.complete_file(name: "test_file_5")
37+
transfer.finalize
4238

4339
expect(transfer.state).to eq "processing"
4440

45-
transfer.finalize
46-
47-
# If the server on the other end is done, the transfer will become downloadable.
48-
# But I don't feel like `sleep`ing
49-
# expect(transfer.state).to eq "downloadable"
41+
# Your transfer is available (after processing) at `transfer.url`
42+
expect(transfer.url)
43+
.to match %r|https://we.tl/t-|
5044
end
5145
end

spec/we_transfer/transfer_spec.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -489,5 +489,7 @@
489489
transfer.finalize
490490
expect(transfer.state).to eq "processing"
491491
end
492+
493+
it "url?"
492494
end
493495
end

0 commit comments

Comments
 (0)