cypress-rails 0.9.0 → 0.9.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +12 -0
- data/README.md +4 -0
- data/lib/cypress-rails/config.rb +5 -2
- data/lib/cypress-rails/init.rb +7 -4
- data/lib/cypress-rails/launches_cypress.rb +2 -1
- data/lib/cypress-rails/rake.rb +1 -1
- data/lib/cypress-rails/server/puma.rb +2 -4
- data/lib/cypress-rails/server.rb +4 -2
- data/lib/cypress-rails/starts_rails_server.rb +2 -2
- data/lib/cypress-rails/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ff1a69096cba0508c006c7ec8d96796c12026e8ef0e89956eab2af77112a7c96
|
|
4
|
+
data.tar.gz: ec1076a20ae68ae94359cb35ce81b63b515857eb239fb361da4953d935c400a9
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a3d7559054e9c3a3d67190294253f7df4994a5d784f25bb4aac2782d65eaa03437d53a612ed9b1559ea405b34e661a1ad9203f1e737253403a9a3d5e512c1680
|
|
7
|
+
data.tar.gz: 244632d0f95e460ada182b882a0d95cd618264cf10434b337698bbc1c45e9eb40cfa7499b8398b30568ec36a422755228fe2ec9ff36a77bb5608c66d4560ffd5
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# CHANGELOG
|
|
2
2
|
|
|
3
|
+
## 0.9.2
|
|
4
|
+
|
|
5
|
+
* Fix `rake cypress:init` so it recognizes an existing Cypress config file of
|
|
6
|
+
any supported extension (`.js`, `.ts`, `.mjs`, `.cjs`, `.mts`, `.cts`)
|
|
7
|
+
instead of only `cypress.config.js` [#170](https://github.com/testdouble/cypress-rails/issues/170)
|
|
8
|
+
|
|
9
|
+
## 0.9.1
|
|
10
|
+
|
|
11
|
+
* Add `CYPRESS_RAILS_SERVER_THREADS` (default: `"0:4"`) to configure the min:max
|
|
12
|
+
thread count passed to Puma's `Threads:` option, so you can e.g. set it to
|
|
13
|
+
`"1:1"` for single-threaded mode.
|
|
14
|
+
|
|
3
15
|
## 0.9.0
|
|
4
16
|
|
|
5
17
|
* **[Breaking]** Require Rails 7.1 or newer
|
data/README.md
CHANGED
|
@@ -216,6 +216,10 @@ preferred environment variables project-wide using a tool like
|
|
|
216
216
|
transactional server](#turning-off-the-transactional-server)
|
|
217
217
|
* **CYPRESS_RAILS_CYPRESS_OPTS** (default: _none_) any options you want to
|
|
218
218
|
forward to the Cypress CLI when running its `open` or `run` commands.
|
|
219
|
+
* **CYPRESS_RAILS_SERVER_THREADS** (default: `"0:4"`) the min:max thread count
|
|
220
|
+
passed to Puma's `Threads:` option when cypress-rails boots its own test
|
|
221
|
+
server. Set to `"1:1"` for single-threaded mode. This is independent of your
|
|
222
|
+
app's `config/puma.rb`, which cypress-rails does not read.
|
|
219
223
|
|
|
220
224
|
#### Example: Running a single spec from the command line
|
|
221
225
|
|
data/lib/cypress-rails/config.rb
CHANGED
|
@@ -2,7 +2,7 @@ require_relative "env"
|
|
|
2
2
|
|
|
3
3
|
module CypressRails
|
|
4
4
|
class Config
|
|
5
|
-
attr_accessor :rails_dir, :cypress_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, :server_threads
|
|
6
6
|
|
|
7
7
|
def initialize(
|
|
8
8
|
rails_dir: Env.fetch("CYPRESS_RAILS_DIR", default: Dir.pwd),
|
|
@@ -11,7 +11,8 @@ module CypressRails
|
|
|
11
11
|
port: Env.fetch("CYPRESS_RAILS_PORT"),
|
|
12
12
|
base_path: Env.fetch("CYPRESS_RAILS_BASE_PATH", default: "/"),
|
|
13
13
|
transactional_server: Env.fetch("CYPRESS_RAILS_TRANSACTIONAL_SERVER", type: :boolean, default: true),
|
|
14
|
-
cypress_cli_opts: Env.fetch("CYPRESS_RAILS_CYPRESS_OPTS", default: "")
|
|
14
|
+
cypress_cli_opts: Env.fetch("CYPRESS_RAILS_CYPRESS_OPTS", default: ""),
|
|
15
|
+
server_threads: Env.fetch("CYPRESS_RAILS_SERVER_THREADS", default: "0:4")
|
|
15
16
|
)
|
|
16
17
|
@rails_dir = rails_dir
|
|
17
18
|
@cypress_dir = cypress_dir
|
|
@@ -20,6 +21,7 @@ module CypressRails
|
|
|
20
21
|
@base_path = base_path
|
|
21
22
|
@transactional_server = transactional_server
|
|
22
23
|
@cypress_cli_opts = cypress_cli_opts
|
|
24
|
+
@server_threads = server_threads
|
|
23
25
|
end
|
|
24
26
|
|
|
25
27
|
def to_s
|
|
@@ -34,6 +36,7 @@ module CypressRails
|
|
|
34
36
|
CYPRESS_RAILS_BASE_PATH...............#{base_path.inspect}
|
|
35
37
|
CYPRESS_RAILS_TRANSACTIONAL_SERVER....#{transactional_server.inspect}
|
|
36
38
|
CYPRESS_RAILS_CYPRESS_OPTS............#{cypress_cli_opts.inspect}
|
|
39
|
+
CYPRESS_RAILS_SERVER_THREADS..........#{server_threads.inspect}
|
|
37
40
|
|
|
38
41
|
DESC
|
|
39
42
|
end
|
data/lib/cypress-rails/init.rb
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
module CypressRails
|
|
2
2
|
class Init
|
|
3
|
+
CONFIG_EXTENSIONS = %w[js ts mjs cjs mts cts]
|
|
4
|
+
|
|
3
5
|
DEFAULT_CONFIG = <<~JS
|
|
4
6
|
const { defineConfig } = require('cypress')
|
|
5
7
|
|
|
@@ -20,12 +22,13 @@ module CypressRails
|
|
|
20
22
|
JS
|
|
21
23
|
|
|
22
24
|
def call(cypress_dir = Config.new.cypress_dir)
|
|
23
|
-
|
|
24
|
-
if
|
|
25
|
+
existing_config_path = Dir.glob(File.join(cypress_dir, "cypress.config.{#{CONFIG_EXTENSIONS.join(",")}}")).first
|
|
26
|
+
if existing_config_path
|
|
27
|
+
warn "Cypress config already exists in `#{existing_config_path}'. Skipping."
|
|
28
|
+
else
|
|
29
|
+
config_path = File.join(cypress_dir, "cypress.config.js")
|
|
25
30
|
File.write(config_path, DEFAULT_CONFIG)
|
|
26
31
|
puts "Cypress config initialized in `#{config_path}'"
|
|
27
|
-
else
|
|
28
|
-
warn "Cypress config already exists in `#{config_path}'. Skipping."
|
|
29
32
|
end
|
|
30
33
|
end
|
|
31
34
|
end
|
|
@@ -22,7 +22,8 @@ module CypressRails
|
|
|
22
22
|
server = @starts_rails_server.call(
|
|
23
23
|
host: config.host,
|
|
24
24
|
port: config.port,
|
|
25
|
-
transactional_server: config.transactional_server
|
|
25
|
+
transactional_server: config.transactional_server,
|
|
26
|
+
server_threads: config.server_threads
|
|
26
27
|
)
|
|
27
28
|
bin = @finds_bin.call(config.cypress_dir)
|
|
28
29
|
|
data/lib/cypress-rails/rake.rb
CHANGED
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
module CypressRails
|
|
2
2
|
class Server
|
|
3
3
|
module Puma
|
|
4
|
-
def self.create(app, port, host)
|
|
4
|
+
def self.create(app, port, host, threads = "0:4")
|
|
5
5
|
require "rack/handler/puma"
|
|
6
6
|
|
|
7
7
|
# If we just run the Puma Rack handler it installs signal handlers which prevent us from being able to interrupt tests.
|
|
8
8
|
# Therefore construct and run the Server instance ourselves.
|
|
9
|
-
|
|
10
|
-
default_options = {Host: host, Port: port, Threads: "0:4", workers: 0, daemon: false}
|
|
11
|
-
options = default_options # .merge(options)
|
|
9
|
+
options = {Host: host, Port: port, Threads: threads, workers: 0, daemon: false}
|
|
12
10
|
|
|
13
11
|
puma_rack_handler = defined?(Rackup::Handler::Puma) ? Rackup::Handler::Puma : Rack::Handler::Puma
|
|
14
12
|
conf = puma_rack_handler.config(app, options)
|
data/lib/cypress-rails/server.rb
CHANGED
|
@@ -25,7 +25,8 @@ module CypressRails
|
|
|
25
25
|
reportable_errors: [Exception],
|
|
26
26
|
extra_middleware: [],
|
|
27
27
|
initializer_hooks: InitializerHooks.instance,
|
|
28
|
-
puma: Puma
|
|
28
|
+
puma: Puma,
|
|
29
|
+
threads: "0:4")
|
|
29
30
|
@app = app
|
|
30
31
|
@extra_middleware = extra_middleware
|
|
31
32
|
@server_thread = nil # suppress warnings
|
|
@@ -37,6 +38,7 @@ module CypressRails
|
|
|
37
38
|
@checker = Checker.new(@host, @port)
|
|
38
39
|
@initializer_hooks = initializer_hooks
|
|
39
40
|
@puma = puma
|
|
41
|
+
@threads = threads
|
|
40
42
|
end
|
|
41
43
|
|
|
42
44
|
def reset_error!
|
|
@@ -75,7 +77,7 @@ module CypressRails
|
|
|
75
77
|
Server.ports[port_key] = port
|
|
76
78
|
|
|
77
79
|
@server_thread = Thread.new {
|
|
78
|
-
@puma.create(middleware, port, host)
|
|
80
|
+
@puma.create(middleware, port, host, @threads)
|
|
79
81
|
}
|
|
80
82
|
|
|
81
83
|
timer = Timer.new(60)
|
|
@@ -3,9 +3,9 @@ require_relative "server"
|
|
|
3
3
|
|
|
4
4
|
module CypressRails
|
|
5
5
|
class StartsRailsServer
|
|
6
|
-
def call(host:, port:, transactional_server:)
|
|
6
|
+
def call(host:, port:, transactional_server:, server_threads:)
|
|
7
7
|
app = create_rack_app(transactional_server)
|
|
8
|
-
Server.new(app, host: host, port: port).tap do |server|
|
|
8
|
+
Server.new(app, host: host, port: port, threads: server_threads).tap do |server|
|
|
9
9
|
server.boot
|
|
10
10
|
end
|
|
11
11
|
end
|