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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c08ef4f9087d66f0f04df9831568414e757aae3fb83baf6bfd85c0d7a3509312
4
- data.tar.gz: aa4baeebd6d8035ca9b9fc6ba91b0c487e9cf3a385a25ee9da92c96e2fd4ce2c
3
+ metadata.gz: ff1a69096cba0508c006c7ec8d96796c12026e8ef0e89956eab2af77112a7c96
4
+ data.tar.gz: ec1076a20ae68ae94359cb35ce81b63b515857eb239fb361da4953d935c400a9
5
5
  SHA512:
6
- metadata.gz: 15cf818dd04eb1eb89853d2a14839dd54d25ed4c39b21a705fcae507c7cecb12813477913fab43e486a7f80f0bcc4df8cb18cafa0252d3a38c33608b8441c6b7
7
- data.tar.gz: 2fa87db917ccc275d14c8dc28f67a55c13a375e13d6a9f25887fc9ad87989d18bb515b2eabab19ef58dcee6da9b098cf1ccabf97ee6a057649468d8f4f740245
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
 
@@ -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
@@ -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
- config_path = File.join(cypress_dir, "cypress.config.js")
24
- if !File.exist?(config_path)
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
 
@@ -1,7 +1,7 @@
1
1
  require "pathname"
2
2
  CLI = Pathname.new(File.dirname(__FILE__)).join("../../exe/cypress-rails")
3
3
 
4
- desc "Initialize cypress.config.js"
4
+ desc "Initialize Cypress config"
5
5
  task :"cypress:init" do
6
6
  system "#{CLI} init"
7
7
  end
@@ -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
- # Rack::Handler::Puma.run(app, { Host: host, Port: port, Threads: "0:4", workers: 0, daemon: false }.merge(options))
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)
@@ -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
@@ -1,3 +1,3 @@
1
1
  module CypressRails
2
- VERSION = "0.9.0"
2
+ VERSION = "0.9.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cypress-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.9.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin Searls