Class: Serverspec::Type::Port

Inherits:
Base
  • Object
show all
Defined in:
lib/serverspec/type/port.rb

Instance Method Summary collapse

Methods inherited from Base

#initialize, #to_ary, #to_s

Constructor Details

This class inherits a constructor from Serverspec::Type::Base

Instance Method Details

#listening?(protocol) ⇒ Boolean

Returns:

  • (Boolean)


4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/serverspec/type/port.rb', line 4

def listening?(protocol)
  if protocol
    protocol = protocol.to_s.downcase
    unless ["udp", "tcp", "tcp6", "udp6"].include?(protocol)
      raise ArgumentError.new("`be_listening` matcher doesn't support #{protocol}")
    end

    backend.check_listening_with_protocol(@name, protocol)
  else
    backend.check_listening(@name)
  end
end