Module: Shoulda::Matchers::ActiveModel::Helpers
- Included in:
- AllowValueMatcher, ValidateConfirmationOfMatcher, ValidateLengthOfMatcher, ValidationMessageFinder, Validator, Shoulda::Matchers::ActiveRecord::ValidateUniquenessOfMatcher, Shoulda::Matchers::ActiveRecord::ValidateUniquenessOfMatcher::ExistingRecordInvalid
- Defined in:
- lib/shoulda/matchers/active_model/helpers.rb
Instance Method Summary collapse
- #default_error_message(type, options = {}) ⇒ Object
- #format_validation_errors(errors) ⇒ Object
- #pretty_error_messages(object) ⇒ Object
Instance Method Details
#default_error_message(type, options = {}) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/shoulda/matchers/active_model/helpers.rb', line 19 def (type, = {}) model_name = .delete(:model_name) attribute = .delete(:attribute) instance = .delete(:instance) RailsShim.( instance, attribute.to_sym, type, model_name, , ) end |
#format_validation_errors(errors) ⇒ Object
10 11 12 13 14 15 16 17 |
# File 'lib/shoulda/matchers/active_model/helpers.rb', line 10 def format_validation_errors(errors) list_items = errors.to_hash.keys.map do |attribute| = errors[attribute] "* #{attribute}: #{}" end list_items.join("\n") end |
#pretty_error_messages(object) ⇒ Object
6 7 8 |
# File 'lib/shoulda/matchers/active_model/helpers.rb', line 6 def (object) format_validation_errors(object.errors) end |