class Shoulda::Matchers::ActiveModel::NumericalityMatchers::EvenNumberMatcher

@private

Constants

NON_EVEN_NUMBER_VALUE

Public Instance Methods

allowed_type_adjective() click to toggle source
# File lib/shoulda/matchers/active_model/numericality_matchers/even_number_matcher.rb, line 20
def allowed_type_adjective
  'even'
end
diff_to_compare() click to toggle source
# File lib/shoulda/matchers/active_model/numericality_matchers/even_number_matcher.rb, line 24
def diff_to_compare
  2
end
simple_description() click to toggle source
# File lib/shoulda/matchers/active_model/numericality_matchers/even_number_matcher.rb, line 9
def simple_description
  description = ''

  if expects_strict?
    description << 'strictly '
  end

  description +
    "disallow :#{attribute} from being an odd number"
end

Protected Instance Methods

disallowed_value() click to toggle source
# File lib/shoulda/matchers/active_model/numericality_matchers/even_number_matcher.rb, line 34
def disallowed_value
  if @numeric_type_matcher.given_numeric_column?
    NON_EVEN_NUMBER_VALUE
  else
    NON_EVEN_NUMBER_VALUE.to_s
  end
end
wrap_disallow_value_matcher(matcher) click to toggle source
# File lib/shoulda/matchers/active_model/numericality_matchers/even_number_matcher.rb, line 30
def wrap_disallow_value_matcher(matcher)
  matcher.with_message(:even)
end