Sha256: 9e24b5b0e80dc1bbb05da8ad30c237be4b3a6d0dada7d652dc95497670cda5d1

Contents?: true

Size: 1.7 KB

Versions: 3

Compression:

Stored size: 1.7 KB

Contents

require 'spec_helper.rb'

class UploaderTest
  include S3Multipart::Uploader
end

describe "Uploader module" do
  before(:all) do
    @uploader = UploaderTest.new
  end

  it "should initiate an upload" do
    response = @uploader.initiate( object_name: "example_object.wmv",
                                  content_type: "video/x-ms-wmv" )

    response["upload_id"].should be_an_instance_of(String)
    response["key"].should be_an_instance_of(String)
    response["name"].should be_an_instance_of(String)
  end

  it "should sign many parts" do
    response = @uploader.sign_batch(    object_name: "example_object",
                                    content_lengths: "1000000-1000000-1000000",
                                          upload_id: "a83jrhfs94jcj3c3" ) 

    response.should be_an_instance_of(Array)
    response.first[:authorization].should match(/AWS/)
  end

  it "should sign a single part" do
    response = @uploader.sign_part(   object_name: "example_object",
                                   content_length: "1000000",
                                        upload_id: "a83jrhfs94jcj3c3" ) 

    response.should be_an_instance_of(Hash)
    response[:authorization].should match(/AWS/)
  end

  it "should unsuccessfully attempt to complete an upload that doesn't exist" do
    response = @uploader.complete(    object_name: "example_object",
                                   content_length: "1000000",
                                            parts: [{partNum: 1, ETag: "jf93nda3Sf8FSh"}],
                                     content_type: "application/xml",
                                        upload_id: "a83jrhfs94jcj3c3" ) 

    response[:error].should eql("Upload does not exist")
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
s3_multipart-0.0.4 spec/requests/uploader_spec.rb
s3_multipart-0.0.3 spec/requests/uploader_spec.rb
s3_multipart-0.0.2 spec/requests/uploader_spec.rb