Skip to content

Instantly share code, notes, and snippets.

@mikegehard
Created April 22, 2011 01:13
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mikegehard/935825 to your computer and use it in GitHub Desktop.
Save mikegehard/935825 to your computer and use it in GitHub Desktop.
Mocking fog for use with carrierwave
# drop this into a file in spec/support or feature/support and you should be all set.
unless Kernel.const_defined?("S3_CONFIG")
S3_CONFIG = YAML.load_file("#{Rails.root}/config/s3.yml")[Rails.env].try(:symbolize_keys)
end
Fog.mock!
connection = ::Fog::Storage.new(
:aws_access_key_id => S3_CONFIG[:access_key_id],
:aws_secret_access_key => S3_CONFIG[:secret_access_key],
:provider => 'AWS',
:region => "us-east-1"
)
connection.directories.create(:key => S3_CONFIG[:bucket])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment