title: Defining where Paperclip stores the attachment locally when running Spec tests
body: <p>I'm using AmazonS3 to store Paperclip attachments on all non-<code>test</code> environments.</p>
  
  <p>For <code>test</code> specifically I use a local path/url setup to avoid interacting with S3 remotely </p>
  
  <pre><code>Paperclip::Attachment.default_options[:path] =
    ":rails_root/public/system/:rails_env/:class/:attachment/:id_partition/:filename"
  
  Paperclip::Attachment.default_options[:url] =
    "/system/:rails_env/:class/:attachment/:id_partition/:filename"
  </code></pre>
  
  <p>I define my attachment as follows in the model</p>
  
  <pre><code>has_attached_file :source_file, use_timestamp: false
  </code></pre>
  
  <p>In my Production code I <strong>need</strong> to access the file using <code>Model.source_file.url</code> because <code>.url</code> returns the remote fully qualified Amazon S3 path to the file. This generally works fine for non-<code>test</code> environments.</p>
  
  <p>However on my <code>test</code> environment I can't use <code>.url</code> because Paperclip creates and stores the file under the path defined by <code>:path</code> above. So I need to use <code>.path</code>. If I use <code>.url</code> I get the error -</p>
  
  <pre><code>Errno::ENOENT:
    No such file or directory @ rb_sysopen - /system/test/imports/source_files/000/000/030/sample.txt
  </code></pre>
  
  <p>which makes sense because paperclip didn't store the file there...</p>
  
  <p>How do I get paperclip on my <code>test</code> environment to store/create my file under the <code>:url</code> path so I can use <code>.url</code> correctly? </p>
  
  <p><strong>Edit</strong>: If it helps, in <code>test</code> I create the attachment from a locally stored fixture file</p>
  
  <pre><code>factory :import do
    source_file { File.new(Rails.root + "spec/fixtures/files/sample.tsv") }
  end
  </code></pre>
  
  <p><strong>Edit2</strong>: Setting <code>:path</code> and <code>:url</code> to be the same path in the initializer might seem like a quick fix, but I'm working on a larger app with several contributors, so I don't the have the luxury to do that or break any one else's specs. Plus it looks like Thoughtbot themselves recommend this setup, so there should be a "proper" way to get it working as is.</p>
  
  <p>Thanks!</p>