test/cases/spec_s3_object.rb in s33r-0.4.2 vs test/cases/spec_s3_object.rb in s33r-0.5

- old
+ new

@@ -3,33 +3,72 @@ context 'S3 object' do setup do @s3_object_xml = File.open(File.join(base, '../files/s3_object.xml')).read @s3obj = S3Object.from_xml_string(@s3_object_xml) + @s3obj.bucket = Bucket.new('test-bucket', :access => Testing::ACCESS_KEY, \ + :secret => Testing::SECRET_ACCESS_KEY) + + # Orphan s3obj (not attached to a bucket). + @orphan_obj = S3Object.new('my-key') + + bucket = Bucket.new('quotes', :access => Testing::ACCESS_KEY, \ + :secret => Testing::SECRET_ACCESS_KEY, :use_ssl => false) + @s3obj2 = S3Object.new('nelson', nil, :bucket => bucket) + authenticated_url_end = "s3.amazonaws.com/quotes/nelson?Signature=vjbyPxybdZaNmGa%2ByT272YEAiv4%3D&"+ + "AWSAccessKeyId=44CF9590006BF252F707&Expires=1141889120" + @correct_authenticated_url = "http://" + authenticated_url_end + @correct_public_url = "http://s3.amazonaws.com/quotes/nelson" + @correct_public_url_with_ssl = "https://s3.amazonaws.com/quotes/nelson" + @correct_public_url_with_subdomain = "http://quotes.s3.amazonaws.com/nelson" end specify 'can be initialised from XML fragment with correct data types' do @s3obj.key.should.equal '/home/ell/dir1/four.txt' d = @s3obj.last_modified [d.year, d.month, d.day, d.hour, d.min, d.sec].should.equal [2006, 8, 19, 22, 53, 29] @s3obj.etag.should.equal '24ce59274b89287b3960c184153ac24b' @s3obj.size.should.equal 14 end + + specify 'can be associated with bucket on creation' do + @s3obj2.bucket.name.should.equal 'quotes' + end + + specify 'can be created from a file' do + todo + end specify 'should treat the owner as an object in his/her own right' do [@s3obj.owner.user_id, @s3obj.owner.display_name].should.equal \ ['56efddfead5aa65da942f156fb2b294f44d78fd932d701331edc5fba19620fd4', 'elliotsmith3'] @s3obj.owner.should_be_instance_of S3ACL::CanonicalUser end - specify 'can be associated with a NamedBucket' do + specify 'can be saved' do todo end - - specify 'can be saved by proxing through the NamedBucket it is associated with' do + + specify 'can be renamed' do todo end - - specify 'cannot be saved unless associated with a NamedBucket' do + + specify 'can be deleted' do todo + end + + specify 'should return authenticated URL' do + @s3obj2.url(:authenticated => true, :expires => 1141889120).should.equal @correct_authenticated_url + end + + specify 'should return public URL' do + @s3obj2.url.should.equal @correct_public_url + end + + specify 'should optionally return HTTPS URL' do + @s3obj2.url(:use_ssl => true).should.equal @correct_public_url_with_ssl + end + + specify 'should optionally return URL with domain name set to bucket name' do + @s3obj2.url(:subdomain => true).should.equal @correct_public_url_with_subdomain end end \ No newline at end of file