Matt Van Horn

Things I Like

(and some that I don't)

Cleaning Up After Paperclip Cucumber Tests

November 24th 2011

I love using cucumber for acceptance testing, but recently on a personal project I noticed that I was accumulating files in my public/system directory every time a paperclip step was executed. A little googling got me to a solution, which I’ve adapted below for Rails 3.1

In features/support/env.rb: require ‘paperclip’

module Paperclip::Interpolations 
  alias_method :orig_attachment, :attachment 
  def attachment(att, style) 
    "cucumber/" + orig_attachment(att, style) 

After do 
  `rm -rf #{"#{Rails.root}/public/system/cucumber"}`  #remove paperclip files
blog comments powered by Disqus