Class: Shoulda::Matchers::ActiveModel::ValidateCnsMatcher
- Inherits:
-
ValidationMatcher
- Object
- ValidationMatcher
- Shoulda::Matchers::ActiveModel::ValidateCnsMatcher
- Defined in:
- lib/cns_brazil/validate_cns_matcher.rb
Constant Summary collapse
- ALLOW_VALUES =
[ '166947669770008', 222_491_445_220_008, '736 3347 8546 0000', '807769250350009', 954_180_214_890_002 ].freeze
- DISALLOW_VALUES =
%w[12345678912314 1234567891234516].freeze
Instance Method Summary collapse
- #description ⇒ Object
- #does_not_match?(subject) ⇒ Boolean
- #failure_message ⇒ Object
-
#initialize(attribute) ⇒ ValidateCnsMatcher
constructor
A new instance of ValidateCnsMatcher.
- #matches?(subject) ⇒ Boolean
Constructor Details
#initialize(attribute) ⇒ ValidateCnsMatcher
Returns a new instance of ValidateCnsMatcher.
23 24 25 26 |
# File 'lib/cns_brazil/validate_cns_matcher.rb', line 23 def initialize(attribute) super(attribute) @options = {} end |
Instance Method Details
#description ⇒ Object
28 29 30 31 32 33 34 |
# File 'lib/cns_brazil/validate_cns_matcher.rb', line 28 def description = 'requires a valid CNS' += ' included blank' if expects_to_allow_blank? end |
#does_not_match?(subject) ⇒ Boolean
46 47 48 49 50 |
# File 'lib/cns_brazil/validate_cns_matcher.rb', line 46 def does_not_match?(subject) super(subject) DISALLOW_VALUES.each { |value| disallows_value_of(value) } end |
#failure_message ⇒ Object
36 37 38 |
# File 'lib/cns_brazil/validate_cns_matcher.rb', line 36 def 'does not require a valid CNS' end |
#matches?(subject) ⇒ Boolean
40 41 42 43 44 |
# File 'lib/cns_brazil/validate_cns_matcher.rb', line 40 def matches?(subject) super(subject) ALLOW_VALUES.each { |value| allows_value_of(value) } end |