title: How to test a before_create that relies on a file?
body: <p>I have the following code in the model of my Rails app:</p>
  
  <pre><code>class Image
    before_create :choose_background   
    ...
  
    private
  
    def choose_background
      image = ChunkyPNG::Image.from_file(self.image_path)
      background = ImageManipulator::get_background(image)
      self.background = background unless background.nil?
    end
  end
  </code></pre>
  
  <p>Right now I just have these tests:</p>
  
  <pre><code>require 'test_helper'
  
  class ImageTest &lt; ActiveSupport::TestCase
    test "should not save without a url" do
      image = Image.new
      assert !image.save
    end
  
  end
  </code></pre>
  
  <p><code>image_path</code> is a route to a path of an <code>Image</code>, and <code>ImageManipulator::get_background</code> basically does some image processing in order to find a background. So, my question is: How should I test this? Where/how should I place those images in order to test the method?</p>