Class: Paperclip::Shoulda::Matchers::ValidateAttachmentContentTypeMatcher
- Inherits:
-
Object
- Object
- Paperclip::Shoulda::Matchers::ValidateAttachmentContentTypeMatcher
- Defined in:
- lib/paperclip/matchers/validate_attachment_content_type_matcher.rb
Instance Method Summary collapse
- #allowing(*types) ⇒ Object
- #description ⇒ Object
- #failure_message ⇒ Object
-
#initialize(attachment_name) ⇒ ValidateAttachmentContentTypeMatcher
constructor
A new instance of ValidateAttachmentContentTypeMatcher.
- #matches?(subject) ⇒ Boolean
- #negative_failure_message ⇒ Object
- #rejecting(*types) ⇒ Object
Constructor Details
#initialize(attachment_name) ⇒ ValidateAttachmentContentTypeMatcher
Returns a new instance of ValidateAttachmentContentTypeMatcher.
9 10 11 |
# File 'lib/paperclip/matchers/validate_attachment_content_type_matcher.rb', line 9 def initialize @attachment_name = end |
Instance Method Details
#allowing(*types) ⇒ Object
13 14 15 16 |
# File 'lib/paperclip/matchers/validate_attachment_content_type_matcher.rb', line 13 def allowing *types @allowed_types = types.flatten self end |
#description ⇒ Object
39 40 41 |
# File 'lib/paperclip/matchers/validate_attachment_content_type_matcher.rb', line 39 def description "validate the content types allowed on attachment #{@attachment_name}" end |
#failure_message ⇒ Object
29 30 31 32 |
# File 'lib/paperclip/matchers/validate_attachment_content_type_matcher.rb', line 29 def "Content types #{@allowed_types.join(", ")} should be accepted" + " and #{@rejected_types.join(", ")} rejected by #{@attachment_name}" end |
#matches?(subject) ⇒ Boolean
23 24 25 26 27 |
# File 'lib/paperclip/matchers/validate_attachment_content_type_matcher.rb', line 23 def matches? subject @subject = subject @allowed_types && @rejected_types && allowed_types_allowed? && rejected_types_rejected? end |
#negative_failure_message ⇒ Object
34 35 36 37 |
# File 'lib/paperclip/matchers/validate_attachment_content_type_matcher.rb', line 34 def "Content types #{@allowed_types.join(", ")} should be rejected" + " and #{@rejected_types.join(", ")} accepted by #{@attachment_name}" end |
#rejecting(*types) ⇒ Object
18 19 20 21 |
# File 'lib/paperclip/matchers/validate_attachment_content_type_matcher.rb', line 18 def rejecting *types @rejected_types = types.flatten self end |