base = File.dirname(__FILE__) require File.join(base, '../test_setup') require 'rubygems' require_gem 'FakeWeb' context 'S33r Client' do setup do @base = File.dirname(__FILE__) @client = Client.new(Testing::ACCESS_KEY, Testing::SECRET_ACCESS_KEY, :use_ssl => false, :dump_requests => true) @client2 = Client.new(Testing::ACCESS_KEY, Testing::SECRET_ACCESS_KEY) @bucket = 'testingtesting' @url = url_join('http://', HOST, @bucket) @plain_config_file = File.join(@base, '../files/client_config.yml') @custom_config_file = File.join(@base, '../files/namedbucket_config.yml') xml_file = File.join(@base, '../files/bucket_listing.xml') @bucket_listing_xml = File.open(xml_file) { |f| f.read } listbucket_response = Net::HTTPResponse.new('1.1', '200', 'OK') listbucket_response.body = @bucket_listing_xml FakeWeb.register_uri(@url, :status => 200, :response => listbucket_response) end specify 'should return use_ssl setting correctly' do @client.use_ssl?.should.not.be true @client2.use_ssl?.should.be true end specify 'should trap max_keys too high in bucket listing request' do lambda { @client.list_bucket('duff', :max_keys => (BUCKET_LIST_MAX_MAX_KEYS + 1)) }.should.raise \ BucketListingMaxKeysError end specify 'should fetch bucket listing ok' do resp, _ = @client.list_bucket(@bucket) resp.ok?.should.be true end specify 'can be initialised from plain config file' do c = Client.init(@plain_config_file) c.aws_access_key.should.equal 'youraccesskey' c.aws_secret_access_key.should.equal 'yoursecretkey' end specify 'should be able to convert paths to keys' do todo end specify 'should attach BucketListing instance to ListBucketResult response' do todo end specify 'should retain leading slashes on keys when constructing request URLs' do todo end specify 'should recognise custom config variables passed to configuration file loader' do _, _, _, custom = Client.load_config(@custom_config_file) custom[:from_email].should.equal 'you@example.com' custom[:to_email].should.equal 'me@example.com' end end