Class: CypressRails::Server

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/cypress_rails/server.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(host, command, log_path) ⇒ Server

Returns a new instance of Server.



11
12
13
14
15
16
# File 'lib/cypress_rails/server.rb', line 11

def initialize(host, command, log_path)
  @host = host
  @port = find_free_port
  @command = command
  @log_path = log_path
end

Instance Attribute Details

#commandObject (readonly)

Returns the value of attribute command.



9
10
11
# File 'lib/cypress_rails/server.rb', line 9

def command
  @command
end

#hostObject (readonly)

Returns the value of attribute host.



9
10
11
# File 'lib/cypress_rails/server.rb', line 9

def host
  @host
end

#log_pathObject (readonly)

Returns the value of attribute log_path.



9
10
11
# File 'lib/cypress_rails/server.rb', line 9

def log_path
  @log_path
end

#portObject (readonly)

Returns the value of attribute port.



9
10
11
# File 'lib/cypress_rails/server.rb', line 9

def port
  @port
end

Instance Method Details

#startObject



18
19
20
21
22
23
24
25
26
# File 'lib/cypress_rails/server.rb', line 18

def start
  spawn_server
  until server_responsive?
    sleep 0.1
  end
  yield(host, port) if block_given?
ensure
  stop_server
end