Class: BeValidDNSName

Inherits:
Object show all
Defined in:
lib/extensions/mspec/mspec/matchers/be_valid_dns_name.rb

Constant Summary collapse

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])\.?$/

Instance Method Summary collapse

Instance Method Details

#failure_messageObject



11
12
13
# File 'lib/extensions/mspec/mspec/matchers/be_valid_dns_name.rb', line 11

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

#matches?(actual) ⇒ Boolean

Returns:

  • (Boolean)


6
7
8
9
# File 'lib/extensions/mspec/mspec/matchers/be_valid_dns_name.rb', line 6

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

#negative_failure_messageObject



15
16
17
# File 'lib/extensions/mspec/mspec/matchers/be_valid_dns_name.rb', line 15

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