module Shoulda::Matchers::ActiveModel::StrictValidator
@private
Public Instance Methods
allow_description(allowed_values)
click to toggle source
# File lib/shoulda/matchers/active_model/strict_validator.rb, line 6 def allow_description(allowed_values) "doesn't raise when #{attribute} is set to #{allowed_values}" end
expected_message_from(attribute_message)
click to toggle source
# File lib/shoulda/matchers/active_model/strict_validator.rb, line 10 def expected_message_from(attribute_message) "#{human_attribute_name} #{attribute_message}" end
expected_messages_description(expected_message)
click to toggle source
# File lib/shoulda/matchers/active_model/strict_validator.rb, line 26 def expected_messages_description(expected_message) if expected_message "exception to include #{expected_message.inspect}" else 'an exception to have been raised' end end
formatted_messages()
click to toggle source
# File lib/shoulda/matchers/active_model/strict_validator.rb, line 14 def formatted_messages [messages.first.message] end
messages_description()
click to toggle source
# File lib/shoulda/matchers/active_model/strict_validator.rb, line 18 def messages_description if has_messages? ': ' + messages.first.message.inspect else ' no exception' end end
Protected Instance Methods
collect_messages()
click to toggle source
# File lib/shoulda/matchers/active_model/strict_validator.rb, line 36 def collect_messages validation_exceptions end
Private Instance Methods
validation_exceptions()
click to toggle source
# File lib/shoulda/matchers/active_model/strict_validator.rb, line 42 def validation_exceptions record.valid?(context) [] rescue ::ActiveModel::StrictValidationFailed => exception [exception] end