Class: RSpectacular::ActiveRecord::Matchers::PositivityMatcher
- Inherits:
-
Shoulda::ActiveRecord::Matchers::ValidateNumericalityOfMatcher
- Object
- Shoulda::ActiveRecord::Matchers::ValidateNumericalityOfMatcher
- RSpectacular::ActiveRecord::Matchers::PositivityMatcher
- Defined in:
- lib/rspectacular/matchers/active_record/positivity_matcher.rb
Instance Method Summary collapse
- #description ⇒ Object
- #disallows_negative_values ⇒ Object
- #disallows_zero_values ⇒ Object
- #failure_message ⇒ Object
- #matches?(positivitable) ⇒ Boolean
- #negative_failure_message ⇒ Object
Instance Method Details
#description ⇒ Object
29 30 31 |
# File 'lib/rspectacular/matchers/active_record/positivity_matcher.rb', line 29 def description "should be contain a positive number" end |
#disallows_negative_values ⇒ Object
20 21 22 23 |
# File 'lib/rspectacular/matchers/active_record/positivity_matcher.rb', line 20 def disallows_negative_values disallows_value_of(-1) && disallows_value_of(-100) end |
#disallows_zero_values ⇒ Object
25 26 27 |
# File 'lib/rspectacular/matchers/active_record/positivity_matcher.rb', line 25 def disallows_zero_values disallows_value_of(0) end |
#failure_message ⇒ Object
12 13 14 |
# File 'lib/rspectacular/matchers/active_record/positivity_matcher.rb', line 12 def "Expected #{@attribute.to_s} to be a positive number, got: #{(@attribute)}" end |
#matches?(positivitable) ⇒ Boolean
5 6 7 8 9 10 |
# File 'lib/rspectacular/matchers/active_record/positivity_matcher.rb', line 5 def matches?(positivitable) super(positivitable) disallows_zero_values && disallows_negative_values end |
#negative_failure_message ⇒ Object
16 17 18 |
# File 'lib/rspectacular/matchers/active_record/positivity_matcher.rb', line 16 def "Expected #{@attribute.to_s} to be a negative number, got: #{(@attribute)}" end |