Class: RspecModelValidations::Matchers::Validate
- Inherits:
-
Object
- Object
- RspecModelValidations::Matchers::Validate
- Includes:
- Base
- Defined in:
- lib/rspec_model_validations/matchers/validate.rb
Overview
Test if model validation does not lead to errors on the given attribute.
Instance Method Summary collapse
-
#description ⇒ String
One line syntax description.
-
#failure_message ⇒ String
Explain why matches? fail and show errors.
-
#failure_message_when_negated ⇒ String
Explain why matches? fail when negated.
-
#matches?(model) ⇒ Boolean
Run the test.
Methods included from Base
Instance Method Details
#description ⇒ String
One line syntax description
34 |
# File 'lib/rspec_model_validations/matchers/validate.rb', line 34 def description; "validate #{@attribute.inspect} attribute" end |
#failure_message ⇒ String
Explain why matches? fail and show errors
22 23 24 |
# File 'lib/rspec_model_validations/matchers/validate.rb', line 22 def "#{attribute_value(@model).inspect} to be a valid value for #{@model.class}##{@attribute}", @errors end |
#failure_message_when_negated ⇒ String
Explain why matches? fail when negated
28 29 30 |
# File 'lib/rspec_model_validations/matchers/validate.rb', line 28 def "#{attribute_value(@model).inspect} to be an invalid value for #{@model.class}##{@attribute}", @errors end |
#matches?(model) ⇒ Boolean
Run the test
11 12 13 14 15 16 17 18 |
# File 'lib/rspec_model_validations/matchers/validate.rb', line 11 def matches? model attribute_belongs_to! model @model = model @errors = attribute_errors model @errors.empty? end |