Sha256: 380f9d6a2c553e799ae9419cc0ea6d1cce313b7db16f2a4d18f4e4dfbfc22156

Contents?: true

Size: 939 Bytes

Versions: 10

Compression:

Stored size: 939 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

10 entries across 10 versions & 4 rubygems

Version Path
clearlynuts-woulda-0.2.3 lib/woulda/paperclip/macros.rb
clearlynuts-woulda-0.2.4 lib/woulda/paperclip/macros.rb
seanhussey-woulda-0.1.5 lib/woulda/paperclip/macros.rb
seanhussey-woulda-0.1.6 lib/woulda/paperclip/macros.rb
seanhussey-woulda-0.2.0 lib/woulda/paperclip/macros.rb
seanhussey-woulda-0.2.1 lib/woulda/paperclip/macros.rb
seanhussey-woulda-0.2.2 lib/woulda/paperclip/macros.rb
webmat-woulda-0.1.7 lib/woulda/paperclip/macros.rb
svenaas-woulda-0.3.1 lib/woulda/paperclip/macros.rb
svenaas-woulda-0.2.3 lib/woulda/paperclip/macros.rb