Sha256: cc379366611730508912ee83ad42c0ec43bef1a8db09b07f0002d7c2d6cac001

Contents?: true

Size: 1.2 KB

Versions: 12

Compression:

Stored size: 1.2 KB

Contents

module Paperclip
  module Shoulda
    def should_have_attached_file name, options = {}
      klass = self.name.gsub(/Test$/, '').constantize
      context "Class #{klass.name} with attachment #{name}" do
        should "respond to all the right methods" do
          ["#{name}", "#{name}=", "#{name}?"].each do |meth|
            assert klass.instance_methods.include?(meth), "#{klass.name} does not respond to #{name}."
          end
        end

        should "have the correct definition" do
          expected = options
          actual   = klass.attachment_definitions[name]
          expected.delete(:validations)      if not options.key?(:validations)
          expected.delete(:whiny_thumbnails) if not options.key?(:whiny_thumbnails)

          assert_equal expected, actual
        end

        should "ensure that ImageMagick is available" do
          %w( convert identify ).each do |command|
            `#{Paperclip.path_for_command(command)}`
            assert_equal 0, $?, "ImageMagick's #{command} returned with an error. Make sure that #{command} is available at #{Paperclip.path_for_command(command)}"
          end
        end
      end
    end
  end
end

Test::Unit::TestCase.extend(Paperclip::Shoulda)

Version data entries

12 entries across 12 versions & 4 rubygems

Version Path
kdmny-spree-0.0.1 vendor/plugins/paperclip/shoulda_macros/paperclip.rb
thoughtbot-paperclip-2.1.5 shoulda_macros/paperclip.rb
paperclip-2.1.5 shoulda_macros/paperclip.rb
spree-0.8.4 vendor/plugins/paperclip/shoulda_macros/paperclip.rb
spree-0.8.5 vendor/plugins/paperclip/shoulda_macros/paperclip.rb
spree-0.6.0 vendor/plugins/paperclip/shoulda_macros/paperclip.rb
spree-0.7.0 vendor/plugins/paperclip/shoulda_macros/paperclip.rb
spree-0.7.1 vendor/plugins/paperclip/shoulda_macros/paperclip.rb
spree-0.8.0 vendor/plugins/paperclip/shoulda_macros/paperclip.rb
spree-0.8.1 vendor/plugins/paperclip/shoulda_macros/paperclip.rb
spree-0.8.2 vendor/plugins/paperclip/shoulda_macros/paperclip.rb
spree-0.8.3 vendor/plugins/paperclip/shoulda_macros/paperclip.rb