Class: SchemaExpectations::RSpecMatchers::ValidateSchemaNullableMatcher
- Inherits:
-
Base
- Object
- Base
- SchemaExpectations::RSpecMatchers::ValidateSchemaNullableMatcher
- Defined in:
- lib/schema_expectations/rspec_matchers/validate_schema_nullable.rb
Instance Method Summary collapse
- #description ⇒ Object
- #failure_message ⇒ Object
- #failure_message_when_negated ⇒ Object
- #matches?(model) ⇒ Boolean
Methods inherited from Base
Instance Method Details
#description ⇒ Object
71 72 73 |
# File 'lib/schema_expectations/rspec_matchers/validate_schema_nullable.rb', line 71 def description 'validate NOT NULL columns are present' end |
#failure_message ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/schema_expectations/rspec_matchers/validate_schema_nullable.rb', line 47 def errors = [] (@present_column_names - @not_null_column_names).each do |column_name| errors << "#{@model.name} #{column_name} has unconditional presence validation but is missing NOT NULL" end (@not_null_column_names - @present_column_names).each do |column_name| conditions = validator_allow_nil_conditions_for_column_name(column_name) || validator_conditions_for_column_name(column_name) if conditions errors << "#{@model.name} #{column_name} is NOT NULL but its presence validator was conditional: #{conditions.inspect}" else errors << "#{@model.name} #{column_name} is NOT NULL but has no presence validation" end end errors.join(', ') end |
#failure_message_when_negated ⇒ Object
67 68 69 |
# File 'lib/schema_expectations/rspec_matchers/validate_schema_nullable.rb', line 67 def "#{@model.name} should not match NOT NULL with its presence validation but does" end |
#matches?(model) ⇒ Boolean
42 43 44 45 |
# File 'lib/schema_expectations/rspec_matchers/validate_schema_nullable.rb', line 42 def matches?(model) setup(model) @not_null_column_names == @present_column_names end |