Sha256: b992a440e1ca44bb13729b2516ab52b92a61cad62af6a6dfce5105d14523f5b3

Contents?: true

Size: 696 Bytes

Versions: 2

Compression:

Stored size: 696 Bytes

Contents

require 'remarkable/active_model'

module Remarkable
  module ActiveModel
    module Matchers
      class IpMatcher < Remarkable::ActiveModel::Base
        arguments :ip

        collection_assertions :accept_valid_value?, :reject_valid_value?

        protected

        def accept_valid_value?
          @subject.domain_name = '10.10.10.1'
          @subject.valid?.errors[:ip].should == []
        end

        def reject_valid_value?
          @subject.domain_name = '01'
          @subject.valid?.errors[:ip].should == ['is invalid']
        end
      end

      def require_a_valid_domain_name(*args, &block)
        HostNameMatcher.new(*args, &block).spec(self)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
validates_host-0.2.0 lib/validates_host/remarkable/ip_matcher.rb
validates_host-0.1.0 lib/validates_host/remarkable/ip_matcher.rb