Finds message information from a model’s errors method.
# File lib/shoulda/matchers/active_model/validation_message_finder.rb, line 9 def initialize(instance, attribute) @instance = instance @attribute = attribute end
# File lib/shoulda/matchers/active_model/validation_message_finder.rb, line 14 def allow_description(allowed_values) "allow #{@attribute} to be set to #{allowed_values}" end
# File lib/shoulda/matchers/active_model/validation_message_finder.rb, line 18 def expected_message_from(attribute_message) attribute_message end
# File lib/shoulda/matchers/active_model/validation_message_finder.rb, line 22 def has_messages? errors.present? end
# File lib/shoulda/matchers/active_model/validation_message_finder.rb, line 38 def messages Array.wrap(messages_for_attribute) end
# File lib/shoulda/matchers/active_model/validation_message_finder.rb, line 30 def messages_description if errors.empty? "no errors" else "errors: #{pretty_error_messages(validated_instance)}" end end
# File lib/shoulda/matchers/active_model/validation_message_finder.rb, line 26 def source_description 'errors' end