Class: VatIdValidator::Matchers::ValidateVatIdOf
- Inherits:
-
Object
- Object
- VatIdValidator::Matchers::ValidateVatIdOf
- Defined in:
- lib/rspec/matchers/validate_vat_id_of.rb
Overview
Represents the rspec matcher for the vat_id validator
Instance Method Summary collapse
-
#description ⇒ String
Returns the description for the matcher.
-
#failure_message_for_should ⇒ String
Returns a error message for should matches.
-
#failure_message_for_should_not ⇒ String
Returns a error message for should_not matches.
-
#initialize(expected) ⇒ ValidateVatIdOf
constructor
A new instance of ValidateVatIdOf.
-
#matches?(actual) ⇒ boolean
Checks if the given Objects has a validator for the expected attribute.
Constructor Details
#initialize(expected) ⇒ ValidateVatIdOf
Returns a new instance of ValidateVatIdOf.
14 15 16 |
# File 'lib/rspec/matchers/validate_vat_id_of.rb', line 14 def initialize(expected) @expected = expected end |
Instance Method Details
#description ⇒ String
Returns the description for the matcher
44 45 46 |
# File 'lib/rspec/matchers/validate_vat_id_of.rb', line 44 def description 'be a vat id' end |
#failure_message_for_should ⇒ String
Returns a error message for should matches
30 31 32 |
# File 'lib/rspec/matchers/validate_vat_id_of.rb', line 30 def "expected that #{@expected} would be a vat id" end |
#failure_message_for_should_not ⇒ String
Returns a error message for should_not matches
37 38 39 |
# File 'lib/rspec/matchers/validate_vat_id_of.rb', line 37 def "expected that #{@expected} would not be a vat id" end |
#matches?(actual) ⇒ boolean
Checks if the given Objects has a validator for the expected attribute
22 23 24 25 |
# File 'lib/rspec/matchers/validate_vat_id_of.rb', line 22 def matches?(actual) validators = actual._validators[@expected] validators.select { |val| val.is_a?(ActiveModel::Validations::VatIdValidator) }.count > 0 end |