Exception: Shoulda::Matchers::ActiveRecord::ValidateUniquenessOfMatcher::NonCaseSwappableValueError

Inherits:
Error
  • Object
show all
Defined in:
lib/shoulda/matchers/active_record/validate_uniqueness_of_matcher.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Error

create, #initialize, #inspect

Constructor Details

This class inherits a constructor from Shoulda::Matchers::Error

Instance Attribute Details

#attributeObject

Returns the value of attribute attribute.



1158
1159
1160
# File 'lib/shoulda/matchers/active_record/validate_uniqueness_of_matcher.rb', line 1158

def attribute
  @attribute
end

#modelObject

Returns the value of attribute model.



1158
1159
1160
# File 'lib/shoulda/matchers/active_record/validate_uniqueness_of_matcher.rb', line 1158

def model
  @model
end

#valueObject

Returns the value of attribute value.



1158
1159
1160
# File 'lib/shoulda/matchers/active_record/validate_uniqueness_of_matcher.rb', line 1158

def value
  @value
end

Instance Method Details

#messageObject



1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
# File 'lib/shoulda/matchers/active_record/validate_uniqueness_of_matcher.rb', line 1160

def message
  Shoulda::Matchers.word_wrap "Your \#{model.name} model has a uniqueness validation on :\#{attribute} which is\ndeclared to be case-sensitive, but the value the uniqueness matcher used,\n\#{value.inspect}, doesn't contain any alpha characters, so using it to\ntest the case-sensitivity part of the validation is ineffective. There are\ntwo possible solutions for this depending on what you're trying to do here:\n\na) If you meant for the validation to be case-sensitive, then you need to give\n   the uniqueness matcher a saved instance of \#{model.name} with a value for\n   :\#{attribute} that contains alpha characters.\n\nb) If you meant for the validation to be case-insensitive, then you need to\n   add `case_sensitive: false` to the validation and add `case_insensitive` to\n   the matcher.\n\nFor more information, please see:\n\nhttps://matchers.shoulda.io/docs/v\#{Shoulda::Matchers::VERSION}/file.NonCaseSwappableValueError.html\n  MESSAGE\nend\n"