thoughtbot--shoulda-matchers/lib/shoulda/matchers/active_model/numericality_matchers/only_integer_matcher.rb

27 lines
582 B
Ruby
Raw Normal View History

module Shoulda
module Matchers
module ActiveModel
module NumericalityMatchers
# @private
class OnlyIntegerMatcher
NON_INTEGER_VALUE = 0.1
def initialize(attribute)
@attribute = attribute
@disallow_value_matcher = DisallowValueMatcher.new(NON_INTEGER_VALUE).
for(attribute).
with_message(:not_an_integer)
end
def allowed_type
'integers'
end
def diff_to_compare
1
end
end
end
end
end
end