Sha256: ccbd531448a1cb5422a31fef0033e506358e007149cfc9063aa8b1919bc8c278

Contents?: true

Size: 1.95 KB

Versions: 41

Compression:

Stored size: 1.95 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:
    #
    #   RSpec.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

41 entries across 39 versions & 6 rubygems

Version Path
kt-paperclip-5.4.0 lib/paperclip/matchers.rb
kt-paperclip-4.4.0 lib/paperclip/matchers.rb
paperclip-6.1.0 lib/paperclip/matchers.rb
paperclip-6.0.0 lib/paperclip/matchers.rb
paperclip-5.3.0 lib/paperclip/matchers.rb
paperclip-5.2.1 lib/paperclip/matchers.rb
paperclip-5.2.0 lib/paperclip/matchers.rb
enju_leaf-1.2.1 vendor/bundle/ruby/2.3/gems/paperclip-5.1.0/lib/paperclip/matchers.rb
paperclip-5.1.0 lib/paperclip/matchers.rb
paperclip-5.0.0 lib/paperclip/matchers.rb
paperclip-4.3.7 lib/paperclip/matchers.rb
paperclip_jk-5.0.0.beta2 lib/paperclip/matchers.rb
ish_lib_manager-0.0.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/paperclip-4.3.6/lib/paperclip/matchers.rb
paperclip-5.0.0.beta2 lib/paperclip/matchers.rb
paperclip-5.0.0.beta1 lib/paperclip/matchers.rb
paperclip-4.3.6 lib/paperclip/matchers.rb
paperclip-4.3.5 lib/paperclip/matchers.rb
paperclip-4.3.4 lib/paperclip/matchers.rb
paperclip-4.3.3 lib/paperclip/matchers.rb
paperclip-4.3.2 lib/paperclip/matchers.rb