Sha256: b62356e795a8f423cfde6a91db93da737dc3b1d35f0c01a042c0e3bd399cefbf

Contents?: true

Size: 695 Bytes

Versions: 1

Compression:

Stored size: 695 Bytes

Contents

require "shoulda-matchers"

module Shoulda
  module Matchers
    module ActiveModel
      def require_a_valid_host_name(attribute = :host_name)
        RequireAValidHostNameMatcher.new(attribute)
      end

      class RequireAValidHostNameMatcher < ValidationMatcher
        def description
          "require #{@attribute} to be a valid host name"
        end

        def matches?(subject)
          super(subject)

          disallows_invalid_value and allows_valid_value
        end

        private

        def disallows_invalid_value
          disallows_value_of("1bd")
        end

        def allows_valid_value
          allows_value_of("bd01")
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
validates_host-1.1.0 lib/validates_host/require_a_valid_host_name_matcher.rb