Class: CypressOnRails::Server

Inherits:
Object
  • Object
show all
Defined in:
lib/cypress_on_rails/server.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Server

Returns a new instance of Server.



11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/cypress_on_rails/server.rb', line 11

def initialize(options = {})
  config = CypressOnRails.configuration

  @framework = options[:framework] || :cypress
  @host = options[:host] || config.server_host
  @port = options[:port] || config.server_port || find_available_port
  @port = @port.to_i if @port
  @install_folder = options[:install_folder] || config.install_folder || detect_install_folder
  @transactional = options.fetch(:transactional, config.transactional_server)
  # Process management: track PID and process group for proper cleanup
  @server_pid = nil
  @server_pgid = nil
end

Instance Attribute Details

#frameworkObject (readonly)

Returns the value of attribute framework.



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

def framework
  @framework
end

#hostObject (readonly)

Returns the value of attribute host.



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

def host
  @host
end

#install_folderObject (readonly)

Returns the value of attribute install_folder.



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

def install_folder
  @install_folder
end

#portObject (readonly)

Returns the value of attribute port.



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

def port
  @port
end

Instance Method Details

#initObject



38
39
40
41
# File 'lib/cypress_on_rails/server.rb', line 38

def init
  ensure_install_folder_exists
  puts "#{framework.to_s.capitalize} configuration initialized at #{install_folder}"
end

#openObject



25
26
27
28
29
# File 'lib/cypress_on_rails/server.rb', line 25

def open
  start_server do
    run_command(open_command, "Opening #{framework} test runner")
  end
end

#runObject



31
32
33
34
35
36
# File 'lib/cypress_on_rails/server.rb', line 31

def run
  start_server do
    result = run_command(run_command_args, "Running #{framework} tests")
    exit(result ? 0 : 1)
  end
end