Sha256: 586c1e8062d37dad8073acf1ba4dfbe31a4af8b549b4dd7fd488efbac3f00386

Contents?: true

Size: 914 Bytes

Versions: 7

Compression:

Stored size: 914 Bytes

Contents

module Shoulda # :nodoc:
  module Matchers
    module ActiveModel # :nodoc:
      class OnlyIntegerMatcher # :nodoc:
        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 matches?(subject)
          @disallow_value_matcher.matches?(subject)
        end

        def with_message(message)
          @disallow_value_matcher.with_message(message)
          self
        end

        def allowed_types
          'integer'
        end

        def failure_message_for_should
          @disallow_value_matcher.failure_message_for_should
        end

        def failure_message_for_should_not
          @disallow_value_matcher.failure_message_for_should_not
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 2 rubygems

Version Path
shoulda-matchers-2.4.0 lib/shoulda/matchers/active_model/only_integer_matcher.rb
shoulda-matchers-2.4.0.rc1 lib/shoulda/matchers/active_model/only_integer_matcher.rb
shoulda-matchers-2.3.0 lib/shoulda/matchers/active_model/only_integer_matcher.rb
challah-1.0.0 vendor/bundle/gems/shoulda-matchers-2.2.0/lib/shoulda/matchers/active_model/only_integer_matcher.rb
shoulda-matchers-2.2.0 lib/shoulda/matchers/active_model/only_integer_matcher.rb
challah-1.0.0.beta3 vendor/bundle/gems/shoulda-matchers-2.1.0/lib/shoulda/matchers/active_model/only_integer_matcher.rb
shoulda-matchers-2.1.0 lib/shoulda/matchers/active_model/only_integer_matcher.rb