def stub_paperclip_s3(model, attachment, extension)
      definition = model.gsub(" ", "_").classify.constantize.
                         attachment_definitions[attachment.to_sym]

      path = "http://s3.amazonaws.com/:id/#{definition[:path]}"
      path.gsub!(/:([^\/\.]+)/) do |match|
        "([^\/\.]+)"
      end

      begin
        FakeWeb.register_uri(:put, Regexp.new(path), :body => "OK")
      rescue NameError
        raise NameError, "the stub_paperclip_s3 shoulda macro requires the fakeweb gem."
      end
    end
def stub_paperclip_s3(model, attachment, extension)
      definition = model.gsub(" ", "_").classify.constantize.
                         attachment_definitions[attachment.to_sym]

      path = "http://s3.amazonaws.com/:id/#{definition[:path]}"
      path.gsub!(/:([^\/\.]+)/) do |match|
        "([^\/\.]+)"
      end

      begin
        FakeWeb.register_uri(:put, Regexp.new(path), :body => "OK")
      rescue NameError
        raise NameError, "the stub_paperclip_s3 shoulda macro requires the fakeweb gem."
      end
    end
Stubs the HTTP PUT for an attachment using S3 storage.

 @example
   stub_paperclip_s3('user', 'avatar', 'png')