Skip to content

Commit 3a4a99d

Browse files
committed
Address PR feedback
1 parent 31e51bd commit 3a4a99d

File tree

6 files changed

+15
-15
lines changed

6 files changed

+15
-15
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ preferred environment variables project-wide using a tool like
155155
[dotenv](https://github.com/bkeepers/dotenv).
156156

157157

158-
* **CYPRESS_RAILS_DIR** (default: `Dir.pwd`) the directory of your project
158+
* **CYPRESS_RAILS_DIR** (default: `Dir.pwd`) the directory of your Rails project
159159
* **CYPRESS_DIR** (default: `Dir.pwd`) the directory of your Cypress project
160160
* **CYPRESS_RAILS_HOST** (default: `"127.0.0.1"`) the hostname to bind to
161161
* **CYPRESS_RAILS_PORT** (default: _a random available port_) the port to run

exe/cypress-rails

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
ENV["RAILS_ENV"] ||= "test"
44
require "pathname"
55
require "cypress-rails"
6-
require Pathname.new(CypressRails::Config.new.dir).join("config/environment")
6+
require Pathname.new(CypressRails::Config.new.rails_dir).join("config/environment")
77

88
command = ARGV[0]
99
case command

lib/cypress-rails/config.rb

+7-7
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,19 @@
22

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

77
def initialize(
8-
dir: Env.fetch("CYPRESS_RAILS_DIR", default: Dir.pwd),
9-
cy_dir: Env.fetch("CYPRESS_DIR", default: Dir.pwd),
8+
rails_dir: Env.fetch("CYPRESS_RAILS_DIR", default: Dir.pwd),
9+
cypress_dir: Env.fetch("CYPRESS_DIR", default: Dir.pwd),
1010
host: Env.fetch("CYPRESS_RAILS_HOST", default: "127.0.0.1"),
1111
port: Env.fetch("CYPRESS_RAILS_PORT"),
1212
base_path: Env.fetch("CYPRESS_RAILS_BASE_PATH", default: "/"),
1313
transactional_server: Env.fetch("CYPRESS_RAILS_TRANSACTIONAL_SERVER", type: :boolean, default: true),
1414
cypress_cli_opts: Env.fetch("CYPRESS_RAILS_CYPRESS_OPTS", default: "")
1515
)
16-
@dir = dir
17-
@cy_dir = cy_dir
16+
@rails_dir = rails_dir
17+
@cypress_dir = cypress_dir
1818
@host = host
1919
@port = port
2020
@base_path = base_path
@@ -27,8 +27,8 @@ def to_s
2727
2828
cypress-rails configuration:
2929
============================
30-
CYPRESS_RAILS_DIR.....................#{dir.inspect}
31-
CYPRESS_DIR...........................#{cy_dir.inspect}
30+
CYPRESS_RAILS_DIR.....................#{rails_dir.inspect}
31+
CYPRESS_DIR...........................#{cypress_dir.inspect}
3232
CYPRESS_RAILS_HOST....................#{host.inspect}
3333
CYPRESS_RAILS_PORT....................#{port.inspect}
3434
CYPRESS_RAILS_BASE_PATH...............#{base_path.inspect}

lib/cypress-rails/finds_bin.rb

+2-2
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(cy_dir = Dir.pwd)
8-
local_path = Pathname.new(cy_dir).join(LOCAL_PATH)
7+
def call(cypress_dir = Dir.pwd)
8+
local_path = Pathname.new(cypress_dir).join(LOCAL_PATH)
99
if File.exist?(local_path)
1010
local_path
1111
else

lib/cypress-rails/init.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ class Init
1919
})
2020
JS
2121

22-
def call(dir = Dir.pwd)
23-
config_path = File.join(dir, "cypress.config.js")
22+
def call(cypress_dir = Config.new.cypress_dir)
23+
config_path = File.join(cypress_dir, "cypress.config.js")
2424
if !File.exist?(config_path)
2525
File.write(config_path, DEFAULT_CONFIG)
2626
puts "Cypress config initialized in `#{config_path}'"

lib/cypress-rails/launches_cypress.rb

+2-2
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.cy_dir)
27+
bin = @finds_bin.call(config.cypress_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.cy_dir}" #{config.cypress_cli_opts}
32+
CYPRESS_BASE_URL="http://#{server.host}:#{server.port}#{config.base_path}" "#{bin}" #{command} --project "#{config.cypress_dir}" #{config.cypress_cli_opts}
3333
EXEC
3434

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

0 commit comments

Comments
 (0)