Skip to content

Instantly share code, notes, and snippets.

@yeeguy
Created June 21, 2012 08:25
Show Gist options
  • Select an option

  • Save yeeguy/2964577 to your computer and use it in GitHub Desktop.

Select an option

Save yeeguy/2964577 to your computer and use it in GitHub Desktop.

Revisions

  1. yeeguy revised this gist Jun 21, 2012. No changes.
  2. yeeguy revised this gist Jun 21, 2012. 1 changed file with 5 additions and 0 deletions.
    5 changes: 5 additions & 0 deletions quickerclip.rb
    Original file line number Diff line number Diff line change
    @@ -4,6 +4,11 @@
    #
    # place this file in <app root>/spec/support
    #

    RSpec.configure do |config|
    $paperclip_stub_size = "800x800"
    end

    module Paperclip
    class Geometry
    def self.from_file file
  3. yeeguy created this gist Jun 21, 2012.
    37 changes: 37 additions & 0 deletions quickerclip.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,37 @@
    # inspired by https://gist.github.com/406460 and
    # http://pivotallabs.com/users/rolson/blog/articles/1249-stubbing-out-paperclip-imagemagick-in-tests
    # plus some additional monkeypatching to prevent "too many files open" err's
    #
    # place this file in <app root>/spec/support
    #
    module Paperclip
    class Geometry
    def self.from_file file
    parse($paperclip_stub_size)
    end
    end
    class Thumbnail
    def make
    src = fixture_file_upload('spec/fixtures/files/1x1.png')
    dst = Tempfile.new([@basename, @format].compact.join("."))
    dst.binmode
    FileUtils.cp(src.path, dst.path)
    return dst
    end
    end
    class Attachment
    def post_process
    end
    end
    module Storage
    module Filesystem
    def flush_writes
    @queued_for_write.each{|style, file| file.close}
    @queued_for_write = {}
    end
    def flush_deletes
    @queue_for_delete = []
    end
    end
    end
    end