2014-01-23 18:07:36 +00:00
|
|
|
module Shoulda
|
2013-11-01 21:57:42 +00:00
|
|
|
module Matchers
|
2014-01-23 18:07:36 +00:00
|
|
|
module ActiveModel
|
2013-11-01 21:57:42 +00:00
|
|
|
module NumericalityMatchers
|
2014-01-23 18:07:36 +00:00
|
|
|
# @private
|
|
|
|
class OnlyIntegerMatcher
|
2013-11-01 21:57:42 +00:00
|
|
|
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
|
|
|
|
|
2014-01-13 01:43:36 +00:00
|
|
|
def allowed_type
|
|
|
|
'integers'
|
2013-11-01 21:57:42 +00:00
|
|
|
end
|
2014-02-27 03:26:37 +00:00
|
|
|
|
|
|
|
def diff_to_compare
|
|
|
|
1
|
|
|
|
end
|
2013-11-01 21:57:42 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|