Sha256: 56d917566c5e40a8d92ee0835e3fc1614b60b59e92d8e56e77b7fa63509b59bc
Contents?: true
Size: 1.2 KB
Versions: 3
Compression:
Stored size: 1.2 KB
Contents
# frozen_string_literal: true module CypressRails class Runner def initialize(host:, port:, bin_path: "npx cypress", tests_path:, output: IO.new(1)) @host = host @port = port @bin_path = bin_path @tests_path = tests_path @output = output end def run command = [bin_path, "run", "-P #{tests_path}"] command << "--record" if ENV.fetch("CYPRESS_RECORD_KEY", false) pid = Process.spawn( { "CYPRESS_app_host" => host, "CYPRESS_app_port" => port.to_s, "CYPRESS_baseUrl" => "http://#{host}:#{port}" }, command.join(" "), out: output, err: [:child, :out] ) output.close _, status = Process.wait2(pid) status.exitstatus end def open pid = Process.spawn( { "CYPRESS_app_host" => host, "CYPRESS_app_port" => port.to_s, "CYPRESS_baseUrl" => "http://#{host}:#{port}" }, [bin_path, "open", "-P #{tests_path}"].join(" "), out: output, err: [:child, :out] ) output.close Process.wait(pid) end private attr_reader :host, :port, :bin_path, :tests_path, :output end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
cypress_rails-0.6.0 | lib/cypress_rails/runner.rb |
cypress_rails-0.5.0 | lib/cypress_rails/runner.rb |
cypress_rails-0.4.2 | lib/cypress_rails/runner.rb |