forked from piotrmurach/github
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy paths3_uploader_spec.rb
More file actions
50 lines (42 loc) · 1.29 KB
/
s3_uploader_spec.rb
File metadata and controls
50 lines (42 loc) · 1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
require 'spec_helper'
require 'github_api/s3_uploader'
describe Github::S3Uploader do
let(:result) {
stub(:resource,
'path' => 'downloads/octokit/github/droid',
'acl' => 'public-read',
'name' => 'droid',
"accesskeyid"=>"1DWESVTPGHQVTX38V182",
"policy"=> "GlyYXRp==",
"signature" => "fMGgiss1w=",
"mime_type"=>"image/jpeg",
"file"=> '',
"s3_url" => 'https://github.s3.amazonaws.com/'
)
}
let(:filename) { '/Users/octokit/droid.jpg' }
let(:mapped_hash) { {} }
let(:uploader) { Github::S3Uploader.new result, filename }
before do
stub_post('https://github.s3.amazonaws.com/', '').
to_return(:body => '', :status => 201, :headers => {})
Faraday::UploadIO.stub(:new) { '' }
Github::CoreExt::OrderedHash.stub(:[]) { mapped_hash }
end
it 'checks for missing parameters' do
resource = stub(:resource)
uploader = Github::S3Uploader.new resource, filename
expect {
uploader.send
}.to raise_error(ArgumentError)
end
it 'serializes file' do
Faraday::UploadIO.should_receive(:new) { '' }
uploader.send
end
it 'sends request to amazon aws' do
uploader.send
a_post('https://github.s3.amazonaws.com/', '').with(mapped_hash).
should have_been_made
end
end # Github::S3Uploader