Class: Paperclip::Shoulda::Matchers::ValidateAttachmentSizeMatcher
- Inherits:
-
Object
- Object
- Paperclip::Shoulda::Matchers::ValidateAttachmentSizeMatcher
- Defined in:
- lib/paperclip/matchers/validate_attachment_size_matcher.rb
Instance Method Summary collapse
- #description ⇒ Object
- #failure_message ⇒ Object
- #failure_message_when_negated ⇒ Object (also: #negative_failure_message)
- #greater_than(size) ⇒ Object
- #in(range) ⇒ Object
-
#initialize(attachment_name) ⇒ ValidateAttachmentSizeMatcher
constructor
A new instance of ValidateAttachmentSizeMatcher.
- #less_than(size) ⇒ Object
- #matches?(subject) ⇒ Boolean
Constructor Details
#initialize(attachment_name) ⇒ ValidateAttachmentSizeMatcher
Returns a new instance of ValidateAttachmentSizeMatcher.
21 22 23 |
# File 'lib/paperclip/matchers/validate_attachment_size_matcher.rb', line 21 def initialize() @attachment_name = end |
Instance Method Details
#description ⇒ Object
56 57 58 |
# File 'lib/paperclip/matchers/validate_attachment_size_matcher.rb', line 56 def description "validate the size of attachment #{@attachment_name}" end |
#failure_message ⇒ Object
47 48 49 |
# File 'lib/paperclip/matchers/validate_attachment_size_matcher.rb', line 47 def "Attachment #{@attachment_name} must be between #{@low} and #{@high} bytes" end |
#failure_message_when_negated ⇒ Object Also known as: negative_failure_message
51 52 53 |
# File 'lib/paperclip/matchers/validate_attachment_size_matcher.rb', line 51 def "Attachment #{@attachment_name} cannot be between #{@low} and #{@high} bytes" end |
#greater_than(size) ⇒ Object
30 31 32 33 |
# File 'lib/paperclip/matchers/validate_attachment_size_matcher.rb', line 30 def greater_than(size) @low = size self end |
#in(range) ⇒ Object
35 36 37 38 39 |
# File 'lib/paperclip/matchers/validate_attachment_size_matcher.rb', line 35 def in(range) @low = range.first @high = range.last self end |
#less_than(size) ⇒ Object
25 26 27 28 |
# File 'lib/paperclip/matchers/validate_attachment_size_matcher.rb', line 25 def less_than(size) @high = size self end |
#matches?(subject) ⇒ Boolean
41 42 43 44 45 |
# File 'lib/paperclip/matchers/validate_attachment_size_matcher.rb', line 41 def matches?(subject) @subject = subject @subject = @subject.new if @subject.class == Class lower_than_low? && higher_than_low? && lower_than_high? && higher_than_high? end |