test/cases/spec_utility.rb in s33r-0.5.3 vs test/cases/spec_utility.rb in s33r-0.5.4
- old
+ new
@@ -61,11 +61,11 @@
specify 'can parse extra application-specific settings in config. file' do
config, options = S33r.load_config(@yaml_file)
options[:email_to].should == Testing::EMAIL
# Make sure the 'options' section has not been included in the general config..
- config.keys.should.not.include :options
+ config.keys.should_not include :options
end
specify 'should generate correct canonical strings' do
generate_canonical_string(@for_request_method, @for_request_path,
@for_request_headers).should == @correct_canonical_string
@@ -76,21 +76,21 @@
@correct_canonical_string).should == @correct_signature
end
specify 'should generate correct auth headers' do
generate_auth_header_value(@for_request_method, @for_request_path, @for_request_headers,
- Testing::ACCESS_KEY, Testing::SECRET_ACCESS_KEY).should == @correct_auth_header
+ Testing::ACCESS_KEY, Testing::SECRET_ACCESS_KEY, nil).should == @correct_auth_header
end
specify 'should not generate auth header if bad HTTP method passed' do
- lambda { generate_auth_header_value('duff', nil, nil, nil, nil) }.should.raise \
+ lambda { generate_auth_header_value('duff', nil, nil, nil, nil, nil) }.should raise_error \
MethodNotAllowed
end
specify 'should not generate auth header if required headers missing' do
lambda { generate_auth_header_value('PUT', '/', @for_incomplete_headers,
- nil, nil) }.should.raise MissingRequiredHeaders
+ nil, nil, nil) }.should raise_error MissingRequiredHeaders
end
specify 'when generating auth header, should allow addition of Date and Content-Type headers' do
now = Time.now
@@ -102,32 +102,32 @@
end
specify 'should generate correct x-amz-meta- headers from a hash' do
meta = {'myname' => 'elliot', 'myage' => 36}
headers = metadata_headers(meta)
- headers.should.include 'x-amz-meta-myname'
- headers.should.include 'x-amz-meta-myage'
+ headers.should include 'x-amz-meta-myname'
+ headers.should include 'x-amz-meta-myage'
headers['x-amz-meta-myname'].should == 'elliot'
headers['x-amz-meta-myage'].should == '36'
end
specify 'should not generate canned ACL header if invalid canned ACL supplied' do
- lambda { canned_acl_header('duff') }.should.raise \
+ lambda { canned_acl_header('duff') }.should raise_error \
UnsupportedCannedACL
end
specify 'should correctly add canned ACL headers' do
new_headers = canned_acl_header('private')
- new_headers.should.have(1).keys
- new_headers.keys.should.include 'x-amz-acl'
+ new_headers.should have(1).keys
+ new_headers.keys.should include 'x-amz-acl'
new_headers['x-amz-acl'].should == 'private'
end
specify 'should set sensible defaults for missing Content-Type and Date headers' do
fixed_headers = default_headers(@for_incomplete_headers)
fixed_headers['Content-Type'].should == ''
- fixed_headers.include?('Date').should.not.be nil
+ fixed_headers.include?('Date').should_not === nil
end
specify 'should default to text/plain mimetype for unknown file types' do
guess_mime_type('hello.madeup').should ==('text/plain')
end
@@ -142,13 +142,13 @@
headers['Content-Transfer-Encoding'].should == 'binary'
headers['Content-Disposition'].should == "attachment; filename=me.jpg"
end
specify 'should recognise invalid bucket names' do
- lambda { bucket_name_valid?(@with_invalid_bucket_name) }.should.raise \
+ lambda { bucket_name_valid?(@with_invalid_bucket_name) }.should raise_error \
MalformedBucketName
- lambda { bucket_name_valid?(@with_invalid_bucket_name2) }.should.raise \
+ lambda { bucket_name_valid?(@with_invalid_bucket_name2) }.should raise_error \
MalformedBucketName
end
specify 'should return empty string if generating querystring with no key/value pairs' do
generate_querystring({}).should == ''
@@ -232,18 +232,18 @@
# Default to DEFAULT_EXPIRY_SECS from now
expected_expiry = Time.now.to_i + DEFAULT_EXPIRY_SECS
expires = S33r.parse_expiry
expires.should == expected_expiry
- expires.should_be_kind_of Integer
+ expires.class.should == Bignum
# If :far_flung_future is passed, default to 20 years from now.
expected_expiry = Time.now.to_i +
(60 * 60 * 24 * 365.25 * 20).to_i
expires = S33r.parse_expiry(:far_flung_future)
expires.should == expected_expiry
- expires.should_be_kind_of Integer
+ expires.class.should == Bignum
class Time
remove_method(:to_i)
alias :to_i :old_to_i
end
@@ -252,11 +252,11 @@
specify 'should correctly set expiry from a datetime string' do
datetime_str = '9th January 2007 13:33'
expected_expiry = Time.parse(datetime_str).to_i
expires = S33r.parse_expiry(datetime_str)
expires.should == expected_expiry
- expires.should_be_kind_of Integer
+ expires.class.should == Bignum
end
specify 'should provide a method for converting string keys of a hash into symbols' do
h = {'access' => Testing::ACCESS_KEY, 'secret' => Testing::SECRET_ACCESS_KEY}
symbolised = S33r.keys_to_symbols(h)
@@ -266,6 +266,6 @@
specify 'can optionally escape keys passed in paths' do
s3_url(:bucket => 'quotes', :key => 'some key', :escape => true).should == @url_with_escaped_key
s3_url(:bucket => 'quotes', :key => 'some key').should == @url_with_unescaped_key
end
-end
\ No newline at end of file
+end