module ThoughtBot::Shoulda::ActiveRecord::Macros
def should_require_attributes(*attributes)
should_require_attributes :name, :phone_number
Example:
Regexp or string. Default = I18n.translate('activerecord.errors.messages.blank')
* :message - value the test expects to find in errors.on(:attribute).
Options:
create a new instance to test against.
model being tested, then this method will use that. Otherwise, it will
If an instance variable has been created in the setup named after the
Ensures that the model cannot be saved if one of the attributes listed is not present.
def should_require_attributes(*attributes) message = get_options!(attributes, :message) message ||= default_error_message(:blank) klass = model_class attributes.each do |attribute| should "require #{attribute} to be set" do assert_bad_value(klass, attribute, nil, message) end end end