title: Test file image size validation with rspec without using a large file in fixtures
body: <p>I'm using paperclip in rails 3 and I want to ensure that my application doesn't allow the user to upload large images.</p>
  
  <p>I can test for the file's existence and mime type of an image using a fixture like so:</p>
  
  <pre><code>it "is not valid without an image" do
    @post.image = nil
    @post.should_not be_valid
  end
  
  it "is not valid with the wrong file extension" do
    @post.image = File.new(Rails.root + 'spec/fixtures/images/rails.bmp')
    @post.should_not be_valid
  end
  </code></pre>
  
  <p>These tests work just fine. But I don't want to use a large binary file in my fixture for testing. I don't want to have a 6Mb file in my code base for testing purposes.</p>
  
  <p>How can I mock up the image somehow or create an image file during the test rather than use a fixture? Should I bother testing this at all?</p>
  
  <p>Many thanks...</p>