Sha256: 62a4b2e4870adf9ce70969e0c4eac1f4333d2d7f1a87488a34ec387b77543d19
Contents?: true
Size: 1.34 KB
Versions: 9
Compression:
Stored size: 1.34 KB
Contents
require 'deltacloud/method_serializer' # Create 'mock' version of original driver client/gem: module Mock class S3 < RightAws::S3 include MethodSerializer::Cache def self.cached_methods [ :buckets ] end MethodSerializer::Cache::wrap_methods(self, :cache_dir => File.join(File.dirname(__FILE__), '..', '..', '..', '..', 'tests', 'ec2', 'support')) end class EC2 < AWS::EC2::Base include MethodSerializer::Cache def self.cached_methods [ :describe_images, :describe_availability_zones, :describe_keypairs, :create_keypair, :run_instances, :describe_instances, :reboot_instances, :terminate_instances, :delete_keypair ] end MethodSerializer::Cache::wrap_methods(self, :cache_dir => File.join(File.dirname(__FILE__), '..', '..', '..', '..', 'tests', 'ec2', 'support')) end end # Replace original client with mock client Deltacloud::Drivers::EC2::EC2Driver.class_eval do alias_method :original_new_client, :new_client alias_method :original_s3_client, :s3_client def new_client(credentials, opts={}) Mock::EC2.new( :access_key_id => credentials.user, :secret_access_key => credentials.password ) end def s3_client(credentials) Mock::S3.new(credentials.user, credentials.password) end end
Version data entries
9 entries across 9 versions & 2 rubygems