Skip to content

Instantly share code, notes, and snippets.

@boone
Created August 17, 2009 14:14
Show Gist options
  • Save boone/169143 to your computer and use it in GitHub Desktop.
Save boone/169143 to your computer and use it in GitHub Desktop.
Shoulda macro for file_column plugin
# file_column Shoulda macro, based off the Paperclip method given here:
# http://giantrobots.thoughtbot.com/2008/3/18/for-attaching-files-use-paperclip#comment--614050918
# pass the extra option :magick => true to test the extra method for the columns that use RMagick
def self.should_have_file_column(attachment, options = {})
klass = described_type
fields = ["#{attachment}", "#{attachment}=", "#{attachment}_temp", "#{attachment}_temp=",
"#{attachment}_dir", "#{attachment}_just_uploaded?", "#{attachment}_options",
"#{attachment}_relative_dir", "#{attachment}_relative_path"]
fields << "#{attachment}_magick_after_assign" if options[:magick]
should "have_file_column #{attachment}" do
fields.each do |method_name|
assert klass.instance_methods.include?(method_name), "#{klass.name} does not have a #{method_name} instance method."
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment