Sha256: 9f6d022b0d0c1ddda6abf75077091400a6c81ab39af688053d10c3edb48b703c

Contents?: true

Size: 937 Bytes

Versions: 4

Compression:

Stored size: 937 Bytes

Contents

module Woulda
  module Paperclip
    module Macros
      # Original source: http://giantrobots.thoughtbot.com/2008/6/3/testing-paperclip-with-shoulda
      def should_have_attached_file(attachment)
        klass = self.name.gsub(/Test$/, '').constantize

        context "To support a paperclip attachment named #{attachment}, #{klass}" do
          should_have_db_column("#{attachment}_file_name", :type => :string)
          should_have_db_column("#{attachment}_content_type", :type => :string)
          should_have_db_column("#{attachment}_file_size", :type => :integer)
        end

        should "have a paperclip attachment named ##{attachment}" do
          assert klass.new.respond_to?(attachment.to_sym),
                 "@#{klass.name.underscore} doesn't have a paperclip field named #{attachment}"
          assert_equal Paperclip::Attachment, klass.new.send(attachment.to_sym).class
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
seanhussey-woulda-0.1.1 lib/woulda/paperclip/macros.rb
seanhussey-woulda-0.1.2 lib/woulda/paperclip/macros.rb
seanhussey-woulda-0.1.3 lib/woulda/paperclip/macros.rb
seanhussey-woulda-0.1.4 lib/woulda/paperclip/macros.rb