Sha256: 5f246e92fb01b4dd34b43b930d9387960e6aaa6a76393d184d224be1737577cb

Contents?: true

Size: 1.29 KB

Versions: 39

Compression:

Stored size: 1.29 KB

Contents

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

Version data entries

39 entries across 39 versions & 1 rubygems

Version Path
github_api-0.10.1 spec/github/s3_uploader_spec.rb
github_api-0.10.0 spec/github/s3_uploader_spec.rb
github_api-0.9.7 spec/github/s3_uploader_spec.rb
github_api-0.9.6 spec/github/s3_uploader_spec.rb
github_api-0.9.5 spec/github/s3_uploader_spec.rb
github_api-0.9.4 spec/github/s3_uploader_spec.rb
github_api-0.9.3 spec/github/s3_uploader_spec.rb
github_api-0.9.2 spec/github/s3_uploader_spec.rb
github_api-0.9.1 spec/github/s3_uploader_spec.rb
github_api-0.9.0 spec/github/s3_uploader_spec.rb
github_api-0.8.11 spec/github/s3_uploader_spec.rb
github_api-0.8.10 spec/github/s3_uploader_spec.rb
github_api-0.8.9 spec/github/s3_uploader_spec.rb
github_api-0.8.8 spec/github/s3_uploader_spec.rb
github_api-0.8.7 spec/github/s3_uploader_spec.rb
github_api-0.8.6 spec/github/s3_uploader_spec.rb
github_api-0.8.5 spec/github/s3_uploader_spec.rb
github_api-0.8.4 spec/github/s3_uploader_spec.rb
github_api-0.8.3 spec/github/s3_uploader_spec.rb
github_api-0.8.2 spec/github/s3_uploader_spec.rb