Sha256: d5f70b93451eb0b58e2616b38e034c5e5d4920137bb5803b7defce34119bf434

Contents?: true

Size: 630 Bytes

Versions: 46

Compression:

Stored size: 630 Bytes

Contents

class BeValidDNSName
  # http://stackoverflow.com/questions/106179/regular-expression-to-match-hostname-or-ip-address
  # ftp://ftp.rfc-editor.org/in-notes/rfc3696.txt
  VALID_DNS = /^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z]|[A-Za-z][A-Za-z0-9\-]*[A-Za-z0-9])\.?$/

  def matches?(actual)
    @actual = actual
    (VALID_DNS =~ @actual) == 0
  end

  def failure_message
    ["Expected '#{@actual}'", "to be a valid DNS name"]
  end

  def negative_failure_message
    ["Expected '#{@actual}'", "not to be a valid DNS name"]
  end
end

class Object
  def be_valid_DNS_name
    BeValidDNSName.new
  end
end

Version data entries

46 entries across 46 versions & 2 rubygems

Version Path
rhodes-5.5.18 lib/extensions/mspec/mspec/matchers/be_valid_dns_name.rb
rhodes-5.5.17 lib/extensions/mspec/mspec/matchers/be_valid_dns_name.rb
rhodes-5.5.15 lib/extensions/mspec/mspec/matchers/be_valid_dns_name.rb
rhodes-5.5.0.22 lib/extensions/mspec/mspec/matchers/be_valid_dns_name.rb
rhodes-5.5.2 lib/extensions/mspec/mspec/matchers/be_valid_dns_name.rb
rhodes-5.5.0.7 lib/extensions/mspec/mspec/matchers/be_valid_dns_name.rb
rhodes-5.5.0.3 lib/extensions/mspec/mspec/matchers/be_valid_dns_name.rb
rhodes-5.5.0 lib/extensions/mspec/mspec/matchers/be_valid_dns_name.rb
tauplatform-1.0.3 lib/extensions/mspec/mspec/matchers/be_valid_dns_name.rb
tauplatform-1.0.2 lib/extensions/mspec/mspec/matchers/be_valid_dns_name.rb
tauplatform-1.0.1 lib/extensions/mspec/mspec/matchers/be_valid_dns_name.rb
rhodes-3.5.1.12 lib/extensions/mspec/mspec/matchers/be_valid_dns_name.rb
rhodes-3.3.5 lib/extensions/mspec/mspec/matchers/be_valid_dns_name.rb
rhodes-3.4.2 lib/extensions/mspec/mspec/matchers/be_valid_dns_name.rb
rhodes-3.3.4 lib/extensions/mspec/mspec/matchers/be_valid_dns_name.rb
rhodes-3.3.3 lib/extensions/mspec/mspec/matchers/be_valid_dns_name.rb
rhodes-3.3.3.beta.4 lib/extensions/mspec/mspec/matchers/be_valid_dns_name.rb
rhodes-3.3.3.beta.3 lib/extensions/mspec/mspec/matchers/be_valid_dns_name.rb
rhodes-3.3.3.beta.2 lib/extensions/mspec/mspec/matchers/be_valid_dns_name.rb
rhodes-3.3.3.beta.1 lib/extensions/mspec/mspec/matchers/be_valid_dns_name.rb