Class: BeValidDNSName

Inherits:
Object show all
Defined in:
lib/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


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

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

#matches?(actual) ⇒ Boolean


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

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

#negative_failure_messageObject


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

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