Sha256: 267e1b091cf2907f5a607308c4bcea0a01306fb8300161ff4fee71e7286c64ed

Contents?: true

Size: 793 Bytes

Versions: 10

Compression:

Stored size: 793 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
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 2 rubygems

Version Path
challah-1.0.0.beta3 vendor/bundle/gems/shoulda-matchers-1.5.6/lib/shoulda/matchers/active_model/only_integer_matcher.rb
challah-1.0.0.beta2 vendor/bundle/gems/shoulda-matchers-1.5.6/lib/shoulda/matchers/active_model/only_integer_matcher.rb
challah-1.0.0.beta vendor/bundle/gems/shoulda-matchers-1.5.6/lib/shoulda/matchers/active_model/only_integer_matcher.rb
shoulda-matchers-2.0.0 lib/shoulda/matchers/active_model/only_integer_matcher.rb
shoulda-matchers-1.5.6 lib/shoulda/matchers/active_model/only_integer_matcher.rb
shoulda-matchers-1.5.5 lib/shoulda/matchers/active_model/only_integer_matcher.rb
shoulda-matchers-1.5.4 lib/shoulda/matchers/active_model/only_integer_matcher.rb
shoulda-matchers-1.5.2 lib/shoulda/matchers/active_model/only_integer_matcher.rb
shoulda-matchers-1.5.1 lib/shoulda/matchers/active_model/only_integer_matcher.rb
shoulda-matchers-1.5.0 lib/shoulda/matchers/active_model/only_integer_matcher.rb