Skip to content

Instantly share code, notes, and snippets.

@ahawkins
Created November 26, 2009 11:40
Show Gist options
  • Save ahawkins/243410 to your computer and use it in GitHub Desktop.
Save ahawkins/243410 to your computer and use it in GitHub Desktop.
# mocks s3 for testing
S3_MODELS = {
:user => :avatar,
:car => :picture
}
S3_MODELS.each do |model, attachment|
definition = model.to_s.gsub(" ", "_").classify.constantize.attachment_definitions[attachment.to_sym]
path = "http://s3.amazonaws.com/:id/#{definition[:path]}"
path.gsub!(/:([^\/\.]+)/) do |match|
"([^\/\.]+)"
end
FakeWeb.register_uri(:put, Regexp.new(path), :body => "OK")
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment