Method: Remarkable::MongoMapper::Matchers#allow_values_for

Defined in:
lib/remarkable/mongo_mapper/matchers/allow_values_for_matcher.rb

#allow_values_for(attribute, *args, &block) ⇒ Object

Ensures that the attribute can be set to the given values.

Options

  • :allow_nil - when supplied, validates if it allows nil or not.

  • :allow_blank - when supplied, validates if it allows blank or not.

  • :message - value the test expects to find in errors.on(:attribute). Regexp, string or symbol. Default = I18n.translate('activerecord.errors.messages.invalid')

Examples

should_allow_values_for :isbn, "isbn 1 2345 6789 0", "ISBN 1-2345-6789-0"
it { should allow_values_for(:isbn, "isbn 1 2345 6789 0", "ISBN 1-2345-6789-0") }


79
80
81
82
# File 'lib/remarkable/mongo_mapper/matchers/allow_values_for_matcher.rb', line 79

def allow_values_for(attribute, *args, &block)
  options = args.extract_options!
  AllowValuesForMatcher.new(attribute, options.merge!(:in => args), &block).spec(self)
end