module RSpecBackgroundProcess::BackgroundProcess::Server
Public Class Methods
extended(mod)
click to toggle source
# File lib/rspec-background-process/server.rb, line 12 def self.extended(mod) mod.allocate_ports end
Public Instance Methods
allocate_ports()
click to toggle source
# File lib/rspec-background-process/server.rb, line 22 def allocate_ports base_port = @options[:base_port] or fail "no base_port option set for #{self}: #{@options}" port_count = @options[:port_count] or fail "no port_count option set for #{self}: #{@options}" global_ports = @options[:global_context][:ports] ||= Set[] begin @ports = (base_port ... base_port + port_count).to_a base_port += port_count end until (global_ports & @ports).empty? @options[:global_context][:ports] = global_ports + @ports end
allocated_port(port_no)
click to toggle source
# File lib/rspec-background-process/server.rb, line 40 def allocated_port(port_no) @ports[port_no.to_i - 1] or fail "no port #{port_no} allocated: #{@ports}" end
ports()
click to toggle source
# File lib/rspec-background-process/server.rb, line 36 def ports @ports end
template_variables()
click to toggle source
Calls superclass method
# File lib/rspec-background-process/server.rb, line 16 def template_variables super.merge( /allocated port (\d)/ => ->(port_no) { allocated_port(port_no) } ) end
to_s()
click to toggle source
Calls superclass method
# File lib/rspec-background-process/server.rb, line 44 def to_s super + "{ports: #{ports.join(', ')}}" end