Sha256: 37690878df70908483fe7f8dc4ae660d1b5f5c5e62280ea08b0922e19ff108c5

Contents?: true

Size: 1.97 KB

Versions: 16

Compression:

Stored size: 1.97 KB

Contents

require 'paperclip/matchers/have_attached_file_matcher'
require 'paperclip/matchers/validate_attachment_presence_matcher'
require 'paperclip/matchers/validate_attachment_content_type_matcher'
require 'paperclip/matchers/validate_attachment_size_matcher'

module Paperclip
  module Shoulda
    # Provides RSpec-compatible & Test::Unit-compatible matchers for testing Paperclip attachments.
    #
    # *RSpec*
    #
    # In spec_helper.rb, you'll need to require the matchers:
    #
    #   require "paperclip/matchers"
    #
    # And _include_ the module:
    #
    #   Spec::Runner.configure do |config|
    #     config.include Paperclip::Shoulda::Matchers
    #   end
    #
    # Example:
    #   describe User do
    #     it { should have_attached_file(:avatar) }
    #     it { should validate_attachment_presence(:avatar) }
    #     it { should validate_attachment_content_type(:avatar).
    #                   allowing('image/png', 'image/gif').
    #                   rejecting('text/plain', 'text/xml') }
    #     it { should validate_attachment_size(:avatar).
    #                   less_than(2.megabytes) }
    #   end
    #
    #
    # *TestUnit*
    #
    # In test_helper.rb, you'll need to require the matchers as well:
    #
    #   require "paperclip/matchers"
    #
    # And _extend_ the module:
    #
    #   class ActiveSupport::TestCase
    #     extend Paperclip::Shoulda::Matchers
    #     
    #     #...other initializers...#
    #   end
    #
    # Example:
    #   require 'test_helper'
    #
    #   class UserTest < ActiveSupport::TestCase
    #     should have_attached_file(:avatar)
    #     should validate_attachment_presence(:avatar)
    #     should validate_attachment_content_type(:avatar).
    #                  allowing('image/png', 'image/gif').
    #                  rejecting('text/plain', 'text/xml')
    #     should validate_attachment_size(:avatar).
    #                  less_than(2.megabytes)
    #   end
    #  
    module Matchers
    end
  end
end

Version data entries

16 entries across 16 versions & 3 rubygems

Version Path
paperclip-v2_7-patched-ruby-1_8_6-2.7.5 lib/paperclip/matchers.rb
paperclip-2.7.5 lib/paperclip/matchers.rb
paperclip-2.7.4 lib/paperclip/matchers.rb
paperclip-2.7.2 lib/paperclip/matchers.rb
paperclip-2.8.0 lib/paperclip/matchers.rb
paperclip-2.7.1 lib/paperclip/matchers.rb
paperclip-3.0.4 lib/paperclip/matchers.rb
paperclip-3.0.3 lib/paperclip/matchers.rb
cloudfuji_paperclip-3.0.3 lib/paperclip/matchers.rb
cloudfuji_paperclip-2.4.6 lib/paperclip/matchers.rb
paperclip-3.0.2 lib/paperclip/matchers.rb
paperclip-2.7.0 lib/paperclip/matchers.rb
paperclip-2.6.0 lib/paperclip/matchers.rb
paperclip-2.5.2 lib/paperclip/matchers.rb
paperclip-2.5.1 lib/paperclip/matchers.rb
paperclip-2.5.0 lib/paperclip/matchers.rb