Sha256: 518d08781d31c107dbd2e59af818b89217a7d8e258e187dd8f3c31e2d9354e65

Contents?: true

Size: 698 Bytes

Versions: 2

Compression:

Stored size: 698 Bytes

Contents

require 'remarkable/active_model'

module Remarkable
  module ActiveModel
    module Matchers
      class SubnetMatcher < Remarkable::ActiveModel::Base
        arguments :value

        collection_assertions :accept_valid_value?, :reject_valid_value?

        protected

        def accept_valid_value?
          @subject.value = '10.10.10.1/28'
          @subject.valid?.errors[:value].should == []
        end

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

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
validates_host-0.3.1 lib/validates_host/remarkable/subnet_matcher.rb
validates_host-0.3.0 lib/validates_host/remarkable/subnet_matcher.rb