Skip to content

Commit b38b131

Browse files
committed
Configure new environment variable to allow specification of external Cypress project
1 parent bb1bf9b commit b38b131

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

lib/cypress-rails/config.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,19 @@
22

33
module CypressRails
44
class Config
5-
attr_accessor :dir, :host, :port, :base_path, :transactional_server, :cypress_cli_opts
5+
attr_accessor :dir, :cy_dir, :host, :port, :base_path, :transactional_server, :cypress_cli_opts
66

77
def initialize(
88
dir: Env.fetch("CYPRESS_RAILS_DIR", default: Dir.pwd),
9+
cy_dir: Env.fetch("CYPRESS_DIR", default: Dir.pwd),
910
host: Env.fetch("CYPRESS_RAILS_HOST", default: "127.0.0.1"),
1011
port: Env.fetch("CYPRESS_RAILS_PORT"),
1112
base_path: Env.fetch("CYPRESS_RAILS_BASE_PATH", default: "/"),
1213
transactional_server: Env.fetch("CYPRESS_RAILS_TRANSACTIONAL_SERVER", type: :boolean, default: true),
1314
cypress_cli_opts: Env.fetch("CYPRESS_RAILS_CYPRESS_OPTS", default: "")
1415
)
1516
@dir = dir
17+
@cy_dir = cy_dir
1618
@host = host
1719
@port = port
1820
@base_path = base_path

lib/cypress-rails/finds_bin.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ module CypressRails
44
class FindsBin
55
LOCAL_PATH = "node_modules/.bin/cypress"
66

7-
def call(dir = Dir.pwd)
8-
local_path = Pathname.new(dir).join(LOCAL_PATH)
7+
def call(cy_dir = Dir.pwd)
8+
local_path = Pathname.new(cy_dir).join(LOCAL_PATH)
99
if File.exist?(local_path)
1010
local_path
1111
else

lib/cypress-rails/launches_cypress.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@ def call(command, config)
2424
port: config.port,
2525
transactional_server: config.transactional_server
2626
)
27-
bin = @finds_bin.call(config.dir)
27+
bin = @finds_bin.call(config.cy_dir)
2828

2929
set_exit_hooks!(config)
3030

3131
command = <<~EXEC
32-
CYPRESS_BASE_URL="http://#{server.host}:#{server.port}#{config.base_path}" "#{bin}" #{command} --project "#{config.dir}" #{config.cypress_cli_opts}
32+
CYPRESS_BASE_URL="http://#{server.host}:#{server.port}#{config.base_path}" "#{bin}" #{command} --project "#{config.cy_dir}" #{config.cypress_cli_opts}
3333
EXEC
3434

3535
puts "\nLaunching Cypress…\n$ #{command}\n"

0 commit comments

Comments
 (0)