cypress-rails 0.2.0 → 0.5.0
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/.circleci/config.yml +3 -3
- data/CHANGELOG.md +36 -0
- data/Gemfile.lock +55 -48
- data/README.md +55 -5
- data/lib/cypress-rails/config.rb +13 -2
- data/lib/cypress-rails/initializer_hooks.rb +4 -0
- data/lib/cypress-rails/launches_cypress.rb +6 -2
- data/lib/cypress-rails/manages_transactions.rb +2 -14
- data/lib/cypress-rails/server.rb +5 -6
- data/lib/cypress-rails/starts_rails_server.rb +2 -2
- data/lib/cypress-rails/version.rb +1 -1
- metadata +7 -7
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 562fe8191d39ef805cb9f6ff8cc82f7c1329acc61332425bd23a6c6ff1ccccd2
|
|
4
|
+
data.tar.gz: 267ac2d8ef9c9969205798acbe5239d398eb35ba93a2a45bedaa18fba8056a60
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 9b8b12ab6e9f8f565afd72dfc345d717fb8b957ebe6ca4e73f883d9a2f4278eef4ae89335b85e305065114bedbe797e4ba2fb5cdb5b4457ccd93ea9b245f7a51
|
|
7
|
+
data.tar.gz: 90945b95efc3e0d58651af35d1a13a7740eea905103aa4b8263af380c789f6f0c8a605f58542d8077e26639136ca9f5f0e44ca915b216c8decabd4f2c8e20999
|
data/.circleci/config.yml
CHANGED
|
@@ -34,9 +34,9 @@ jobs:
|
|
|
34
34
|
# Yarn dependencies
|
|
35
35
|
- restore_cache:
|
|
36
36
|
keys:
|
|
37
|
-
-
|
|
37
|
+
- v4-yarn-{{ checksum "example/an_app/yarn.lock" }}
|
|
38
38
|
# fallback to using the latest cache if no exact match is found
|
|
39
|
-
-
|
|
39
|
+
- v4-yarn-
|
|
40
40
|
|
|
41
41
|
- run: |
|
|
42
42
|
cd example/an_app
|
|
@@ -46,7 +46,7 @@ jobs:
|
|
|
46
46
|
paths:
|
|
47
47
|
- example/an_app/node_modules
|
|
48
48
|
- ~/.cache
|
|
49
|
-
key:
|
|
49
|
+
key: v4-yarn-{{ checksum "example/an_app/yarn.lock" }}
|
|
50
50
|
|
|
51
51
|
- run: bundle exec rake
|
|
52
52
|
- run: ./script/test_example_app
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,41 @@
|
|
|
1
1
|
# CHANGELOG
|
|
2
2
|
|
|
3
|
+
## 0.5.0
|
|
4
|
+
|
|
5
|
+
* Add hook `before_server_start`
|
|
6
|
+
[#63](https://github.com/testdouble/cypress-rails/pull/63)
|
|
7
|
+
* Fix namespace bug
|
|
8
|
+
[#64](https://github.com/testdouble/cypress-rails/pull/64)
|
|
9
|
+
|
|
10
|
+
## 0.4.2
|
|
11
|
+
|
|
12
|
+
* Add support to Rails 6.1 ([#52](https://github.com/testdouble/cypress-rails/issue/52))
|
|
13
|
+
|
|
14
|
+
## 0.4.1
|
|
15
|
+
|
|
16
|
+
* Add backcompat for Ruby 2.4
|
|
17
|
+
([#47](https://github.com/testdouble/cypress-rails/pull/47))
|
|
18
|
+
|
|
19
|
+
## 0.4.0
|
|
20
|
+
|
|
21
|
+
* Add a `CYPRESS_RAILS_HOST` option that allows a hostname to be specified (as
|
|
22
|
+
opposed to 127.0.0.1). Puma will still bind to 127.0.0.1, but Cypress will use
|
|
23
|
+
the hostname in its `baseUrl`, which may be necessary for some folks' tests to
|
|
24
|
+
work
|
|
25
|
+
|
|
26
|
+
## 0.3.0
|
|
27
|
+
|
|
28
|
+
* Add a `CYPRESS_RAILS_BASE_PATH` option which will be appended to the
|
|
29
|
+
`CYPRESS_BASE_URL` option that cypress-rails sets when launching cypress
|
|
30
|
+
commands. Apps that set `baseUrl` to something other than "/" can set this env
|
|
31
|
+
var to match for consistent behavior (or else set it using Cypress.config in a
|
|
32
|
+
support file)
|
|
33
|
+
|
|
34
|
+
## 0.2.0
|
|
35
|
+
|
|
36
|
+
* If `RAILS_ENV` has been explicitly set when the CLI or rake task is run,
|
|
37
|
+
respect that set value instead of overriding it to "test"
|
|
38
|
+
|
|
3
39
|
## 0.1.3
|
|
4
40
|
|
|
5
41
|
* Improve behavior of SIGINT (Ctrl-C) so a traceback isn't printed and stdout
|
data/Gemfile.lock
CHANGED
|
@@ -1,55 +1,56 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
cypress-rails (0.
|
|
4
|
+
cypress-rails (0.5.0)
|
|
5
5
|
puma (>= 3.8.0)
|
|
6
6
|
railties (>= 5.2.0)
|
|
7
7
|
|
|
8
8
|
GEM
|
|
9
9
|
remote: https://rubygems.org/
|
|
10
10
|
specs:
|
|
11
|
-
actionpack (6.
|
|
12
|
-
actionview (= 6.
|
|
13
|
-
activesupport (= 6.
|
|
14
|
-
rack (~> 2.0, >= 2.0.
|
|
11
|
+
actionpack (6.1.3.1)
|
|
12
|
+
actionview (= 6.1.3.1)
|
|
13
|
+
activesupport (= 6.1.3.1)
|
|
14
|
+
rack (~> 2.0, >= 2.0.9)
|
|
15
15
|
rack-test (>= 0.6.3)
|
|
16
16
|
rails-dom-testing (~> 2.0)
|
|
17
17
|
rails-html-sanitizer (~> 1.0, >= 1.2.0)
|
|
18
|
-
actionview (6.
|
|
19
|
-
activesupport (= 6.
|
|
18
|
+
actionview (6.1.3.1)
|
|
19
|
+
activesupport (= 6.1.3.1)
|
|
20
20
|
builder (~> 3.1)
|
|
21
21
|
erubi (~> 1.4)
|
|
22
22
|
rails-dom-testing (~> 2.0)
|
|
23
23
|
rails-html-sanitizer (~> 1.1, >= 1.2.0)
|
|
24
|
-
activesupport (6.
|
|
24
|
+
activesupport (6.1.3.1)
|
|
25
25
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
|
26
|
-
i18n (>=
|
|
27
|
-
minitest (
|
|
28
|
-
tzinfo (~>
|
|
29
|
-
zeitwerk (~> 2.
|
|
30
|
-
ast (2.4.
|
|
26
|
+
i18n (>= 1.6, < 2)
|
|
27
|
+
minitest (>= 5.1)
|
|
28
|
+
tzinfo (~> 2.0)
|
|
29
|
+
zeitwerk (~> 2.3)
|
|
30
|
+
ast (2.4.1)
|
|
31
31
|
builder (3.2.4)
|
|
32
|
-
concurrent-ruby (1.1.
|
|
32
|
+
concurrent-ruby (1.1.8)
|
|
33
33
|
crass (1.0.6)
|
|
34
|
-
erubi (1.
|
|
35
|
-
i18n (1.8.
|
|
34
|
+
erubi (1.10.0)
|
|
35
|
+
i18n (1.8.10)
|
|
36
36
|
concurrent-ruby (~> 1.0)
|
|
37
|
-
|
|
38
|
-
loofah (2.5.0)
|
|
37
|
+
loofah (2.9.0)
|
|
39
38
|
crass (~> 1.0.2)
|
|
40
39
|
nokogiri (>= 1.5.9)
|
|
41
40
|
method_source (1.0.0)
|
|
42
|
-
mini_portile2 (2.
|
|
43
|
-
minitest (5.14.
|
|
44
|
-
nio4r (2.5.
|
|
45
|
-
nokogiri (1.
|
|
46
|
-
mini_portile2 (~> 2.
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
41
|
+
mini_portile2 (2.5.0)
|
|
42
|
+
minitest (5.14.2)
|
|
43
|
+
nio4r (2.5.7)
|
|
44
|
+
nokogiri (1.11.2)
|
|
45
|
+
mini_portile2 (~> 2.5.0)
|
|
46
|
+
racc (~> 1.4)
|
|
47
|
+
parallel (1.20.1)
|
|
48
|
+
parser (2.7.2.0)
|
|
49
|
+
ast (~> 2.4.1)
|
|
50
|
+
puma (5.2.2)
|
|
51
51
|
nio4r (~> 2.0)
|
|
52
|
-
|
|
52
|
+
racc (1.5.2)
|
|
53
|
+
rack (2.2.3)
|
|
53
54
|
rack-test (1.1.0)
|
|
54
55
|
rack (>= 1.0, < 3)
|
|
55
56
|
rails-dom-testing (2.0.3)
|
|
@@ -57,33 +58,39 @@ GEM
|
|
|
57
58
|
nokogiri (>= 1.6)
|
|
58
59
|
rails-html-sanitizer (1.3.0)
|
|
59
60
|
loofah (~> 2.3)
|
|
60
|
-
railties (6.
|
|
61
|
-
actionpack (= 6.
|
|
62
|
-
activesupport (= 6.
|
|
61
|
+
railties (6.1.3.1)
|
|
62
|
+
actionpack (= 6.1.3.1)
|
|
63
|
+
activesupport (= 6.1.3.1)
|
|
63
64
|
method_source
|
|
64
65
|
rake (>= 0.8.7)
|
|
65
|
-
thor (
|
|
66
|
+
thor (~> 1.0)
|
|
66
67
|
rainbow (3.0.0)
|
|
67
68
|
rake (13.0.1)
|
|
68
|
-
|
|
69
|
-
|
|
69
|
+
regexp_parser (2.0.0)
|
|
70
|
+
rexml (3.2.4)
|
|
71
|
+
rubocop (1.4.2)
|
|
70
72
|
parallel (~> 1.10)
|
|
71
|
-
parser (>= 2.7.
|
|
73
|
+
parser (>= 2.7.1.5)
|
|
72
74
|
rainbow (>= 2.2.2, < 4.0)
|
|
75
|
+
regexp_parser (>= 1.8)
|
|
76
|
+
rexml
|
|
77
|
+
rubocop-ast (>= 1.1.1)
|
|
73
78
|
ruby-progressbar (~> 1.7)
|
|
74
|
-
unicode-display_width (>= 1.4.0, <
|
|
75
|
-
rubocop-
|
|
76
|
-
|
|
79
|
+
unicode-display_width (>= 1.4.0, < 2.0)
|
|
80
|
+
rubocop-ast (1.3.0)
|
|
81
|
+
parser (>= 2.7.1.5)
|
|
82
|
+
rubocop-performance (1.9.1)
|
|
83
|
+
rubocop (>= 0.90.0, < 2.0)
|
|
84
|
+
rubocop-ast (>= 0.4.0)
|
|
77
85
|
ruby-progressbar (1.10.1)
|
|
78
|
-
standard (0.2
|
|
79
|
-
rubocop (
|
|
80
|
-
rubocop-performance (
|
|
81
|
-
thor (1.0
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
zeitwerk (2.3.0)
|
|
86
|
+
standard (0.10.2)
|
|
87
|
+
rubocop (= 1.4.2)
|
|
88
|
+
rubocop-performance (= 1.9.1)
|
|
89
|
+
thor (1.1.0)
|
|
90
|
+
tzinfo (2.0.4)
|
|
91
|
+
concurrent-ruby (~> 1.0)
|
|
92
|
+
unicode-display_width (1.7.0)
|
|
93
|
+
zeitwerk (2.4.2)
|
|
87
94
|
|
|
88
95
|
PLATFORMS
|
|
89
96
|
ruby
|
|
@@ -96,4 +103,4 @@ DEPENDENCIES
|
|
|
96
103
|
standard (>= 0.2.0)
|
|
97
104
|
|
|
98
105
|
BUNDLED WITH
|
|
99
|
-
2.
|
|
106
|
+
2.2.3
|
data/README.md
CHANGED
|
@@ -102,7 +102,7 @@ like:
|
|
|
102
102
|
return unless Rails.env.test?
|
|
103
103
|
|
|
104
104
|
CypressRails.hooks.before_server_start do
|
|
105
|
-
# Called once, before
|
|
105
|
+
# Called once, before either the transaction or the server is started
|
|
106
106
|
end
|
|
107
107
|
|
|
108
108
|
CypressRails.hooks.after_transaction_start do
|
|
@@ -138,9 +138,9 @@ This way, you can easily instruct the server to reset its test state from your
|
|
|
138
138
|
Cypress tests like so:
|
|
139
139
|
|
|
140
140
|
```js
|
|
141
|
-
beforeEach(() =>
|
|
141
|
+
beforeEach(() => {
|
|
142
142
|
cy.request('/cypress_rails_reset_state')
|
|
143
|
-
)
|
|
143
|
+
})
|
|
144
144
|
```
|
|
145
145
|
|
|
146
146
|
(Remember, in Cypress, `before` is a before-all hook and `beforeEach` is run
|
|
@@ -158,14 +158,36 @@ preferred environment variables project-wide using a tool like
|
|
|
158
158
|
|
|
159
159
|
|
|
160
160
|
* **CYPRESS_RAILS_DIR** (default: `Dir.pwd`) the directory of your project
|
|
161
|
+
* **CYPRESS_RAILS_HOST** (default: `"127.0.0.1"`) the hostname to bind to
|
|
161
162
|
* **CYPRESS_RAILS_PORT** (default: _a random available port_) the port to run
|
|
162
163
|
the Rails test server on
|
|
164
|
+
* **CYPRESS_RAILS_BASE_PATH** (default: `"/"`) the base path for all Cypress's
|
|
165
|
+
requests to the app (e.g. via `cy.visit()`). If you've customized your
|
|
166
|
+
`baseUrl` setting (e.g. in `cypress.json`), you'll need to duplicate it with
|
|
167
|
+
this environment variable
|
|
163
168
|
* **CYPRESS_RAILS_TRANSACTIONAL_SERVER** (default: `true`) when true, will start
|
|
164
169
|
a transaction on all database connections before launching the server. In
|
|
165
170
|
general this means anything done during `cypress open` or `cypress run` will
|
|
166
171
|
be rolled back on exit (similar to running a Rails System test)
|
|
167
172
|
* **CYPRESS_RAILS_CYPRESS_OPTS** (default: _none_) any options you want to
|
|
168
|
-
forward to the Cypress CLI when running its `open` or `run` commands
|
|
173
|
+
forward to the Cypress CLI when running its `open` or `run` commands.
|
|
174
|
+
|
|
175
|
+
#### Example: Running a single spec from the command line
|
|
176
|
+
|
|
177
|
+
It's a little verbose, but an example of using the above options to run a single
|
|
178
|
+
Cypress test would look like this:
|
|
179
|
+
|
|
180
|
+
```
|
|
181
|
+
$ CYPRESS_RAILS_CYPRESS_OPTS="--spec cypress/integration/a_test.js" bin/rake cypress:run
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
#### Example: Running your tests in Chromium
|
|
185
|
+
|
|
186
|
+
By default, Cypress will run its tests in its packaged Electron app, unless you've configured it globally. To choose which browser it will run from the command line, try this:
|
|
187
|
+
|
|
188
|
+
```
|
|
189
|
+
$ CYPRESS_RAILS_CYPRESS_OPTS="--browser chromium" bin/rake cypress:run
|
|
190
|
+
```
|
|
169
191
|
|
|
170
192
|
### Initializer hooks
|
|
171
193
|
|
|
@@ -176,6 +198,11 @@ will execute before the server or any transaction has been started. If you use
|
|
|
176
198
|
Rails fixtures, it may make sense to load them here, so they don't need to be
|
|
177
199
|
re-inserted for each request
|
|
178
200
|
|
|
201
|
+
### after_server_start
|
|
202
|
+
|
|
203
|
+
Pass a block to `CypressRails.hooks.after_server_start` to register a hook that
|
|
204
|
+
will execute after the server has booted.
|
|
205
|
+
|
|
179
206
|
### after_transaction_start
|
|
180
207
|
|
|
181
208
|
If there's any custom behavior or state management you want to do inside the
|
|
@@ -198,6 +225,22 @@ pollute other test suites or scripts, you can use the `before_server_stop` to
|
|
|
198
225
|
of your test database. To set up the hook, pass a block to
|
|
199
226
|
`CypressRails.hooks.before_server_stop`.
|
|
200
227
|
|
|
228
|
+
## Configuring Rails
|
|
229
|
+
|
|
230
|
+
Beyond the configuration options above, you'll probably also want to disable caching
|
|
231
|
+
in your Rails app's [config/environments/test.rb](/example/an_app/config/environments/test.rb#L9)
|
|
232
|
+
file, so that changes to your Ruby code are reflected in your tests while you
|
|
233
|
+
work on them with `rake cypress:open`. (If either option is set to
|
|
234
|
+
`true`, any changes to your Ruby code will require a server restart to be reflected as you work
|
|
235
|
+
on your tests.)
|
|
236
|
+
|
|
237
|
+
To illustrate, here's what that might look like in `config/environments/test.rb`:
|
|
238
|
+
|
|
239
|
+
```ruby
|
|
240
|
+
config.cache_classes = false
|
|
241
|
+
config.action_view.cache_template_loading = false
|
|
242
|
+
```
|
|
243
|
+
|
|
201
244
|
## Setting up continuous integration
|
|
202
245
|
|
|
203
246
|
#### Circle CI
|
|
@@ -274,7 +317,7 @@ experience. In particular:
|
|
|
274
317
|
and more information dense than using Capybara and Selenium. Rather than
|
|
275
318
|
running a test from the command line, seeing it fail, then adding a debug
|
|
276
319
|
breakpoint to a test to try to manipulate the browser or tweaking a call to a
|
|
277
|
-
Capybara API method, failures to be rather obvious when using Cypress and
|
|
320
|
+
Capybara API method, failures tend to be rather obvious when using Cypress and
|
|
278
321
|
fixing it is usually as easy as tweaking a command, hitting save, and watching
|
|
279
322
|
it re-run
|
|
280
323
|
* With very few exceptions, a Cypress test that works in a browser window will
|
|
@@ -305,5 +348,12 @@ adopting Cypress and writing a bunch of browser tests for every application.
|
|
|
305
348
|
But, if the above points sound like solutions to problems you experience, you
|
|
306
349
|
might consider trying it out.
|
|
307
350
|
|
|
351
|
+
## Code of Conduct
|
|
308
352
|
|
|
353
|
+
This project follows Test Double's [code of
|
|
354
|
+
conduct](https://testdouble.com/code-of-conduct) for all community interactions,
|
|
355
|
+
including (but not limited to) one-on-one communications, public posts/comments,
|
|
356
|
+
code reviews, pull requests, and GitHub issues. If violations occur, Test Double
|
|
357
|
+
will take any action they deem appropriate for the infraction, up to and
|
|
358
|
+
including blocking a user from the organization's repositories.
|
|
309
359
|
|
data/lib/cypress-rails/config.rb
CHANGED
|
@@ -1,14 +1,23 @@
|
|
|
1
1
|
require_relative "env"
|
|
2
2
|
|
|
3
3
|
module CypressRails
|
|
4
|
-
class Config
|
|
4
|
+
class Config
|
|
5
|
+
attr_accessor :dir, :host, :port, :base_path, :transactional_server, :cypress_cli_opts
|
|
6
|
+
|
|
5
7
|
def initialize(
|
|
6
8
|
dir: Env.fetch("CYPRESS_RAILS_DIR", default: Dir.pwd),
|
|
9
|
+
host: Env.fetch("CYPRESS_RAILS_HOST", default: "127.0.0.1"),
|
|
7
10
|
port: Env.fetch("CYPRESS_RAILS_PORT"),
|
|
11
|
+
base_path: Env.fetch("CYPRESS_RAILS_BASE_PATH", default: "/"),
|
|
8
12
|
transactional_server: Env.fetch("CYPRESS_RAILS_TRANSACTIONAL_SERVER", type: :boolean, default: true),
|
|
9
13
|
cypress_cli_opts: Env.fetch("CYPRESS_RAILS_CYPRESS_OPTS", default: "")
|
|
10
14
|
)
|
|
11
|
-
|
|
15
|
+
@dir = dir
|
|
16
|
+
@host = host
|
|
17
|
+
@port = port
|
|
18
|
+
@base_path = base_path
|
|
19
|
+
@transactional_server = transactional_server
|
|
20
|
+
@cypress_cli_opts = cypress_cli_opts
|
|
12
21
|
end
|
|
13
22
|
|
|
14
23
|
def to_s
|
|
@@ -17,7 +26,9 @@ module CypressRails
|
|
|
17
26
|
cypress-rails configuration:
|
|
18
27
|
============================
|
|
19
28
|
CYPRESS_RAILS_DIR.....................#{dir.inspect}
|
|
29
|
+
CYPRESS_RAILS_HOST....................#{host.inspect}
|
|
20
30
|
CYPRESS_RAILS_PORT....................#{port.inspect}
|
|
31
|
+
CYPRESS_RAILS_BASE_PATH...............#{base_path.inspect}
|
|
21
32
|
CYPRESS_RAILS_TRANSACTIONAL_SERVER....#{transactional_server.inspect}
|
|
22
33
|
CYPRESS_RAILS_CYPRESS_OPTS............#{cypress_cli_opts.inspect}
|
|
23
34
|
|
|
@@ -20,6 +20,7 @@ module CypressRails
|
|
|
20
20
|
@manages_transactions.begin_transaction
|
|
21
21
|
end
|
|
22
22
|
server = @starts_rails_server.call(
|
|
23
|
+
host: config.host,
|
|
23
24
|
port: config.port,
|
|
24
25
|
transactional_server: config.transactional_server
|
|
25
26
|
)
|
|
@@ -27,9 +28,12 @@ module CypressRails
|
|
|
27
28
|
|
|
28
29
|
set_exit_hooks!(config)
|
|
29
30
|
|
|
30
|
-
|
|
31
|
-
CYPRESS_BASE_URL=http://#{server.host}:#{server.port} "#{bin}" #{command} --project "#{config.dir}" #{config.cypress_cli_opts}
|
|
31
|
+
command = <<~EXEC
|
|
32
|
+
CYPRESS_BASE_URL="http://#{server.host}:#{server.port}#{config.base_path}" "#{bin}" #{command} --project "#{config.dir}" #{config.cypress_cli_opts}
|
|
32
33
|
EXEC
|
|
34
|
+
|
|
35
|
+
puts "\nLaunching Cypress…\n$ #{command}\n"
|
|
36
|
+
system command
|
|
33
37
|
end
|
|
34
38
|
|
|
35
39
|
private
|
|
@@ -20,7 +20,7 @@ module CypressRails
|
|
|
20
20
|
|
|
21
21
|
begin
|
|
22
22
|
connection = ActiveRecord::Base.connection_handler.retrieve_connection(spec_name)
|
|
23
|
-
rescue ConnectionNotEstablished
|
|
23
|
+
rescue ActiveRecord::ConnectionNotEstablished
|
|
24
24
|
connection = nil
|
|
25
25
|
end
|
|
26
26
|
|
|
@@ -68,19 +68,7 @@ module CypressRails
|
|
|
68
68
|
# need to share a connection pool so that the reading connection
|
|
69
69
|
# can see data in the open transaction on the writing connection.
|
|
70
70
|
def setup_shared_connection_pool
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
writing_handler = ActiveRecord::Base.connection_handler
|
|
74
|
-
ActiveRecord::Base.connection_handlers.values.each do |handler|
|
|
75
|
-
if handler != writing_handler
|
|
76
|
-
handler.connection_pool_list.each do |pool|
|
|
77
|
-
name = pool.spec.name
|
|
78
|
-
writing_connection = writing_handler.retrieve_connection_pool(name)
|
|
79
|
-
return nil unless writing_connection
|
|
80
|
-
handler.send(:owner_to_pool)[name] = writing_connection
|
|
81
|
-
end
|
|
82
|
-
end
|
|
83
|
-
end
|
|
71
|
+
ActiveRecord::TestFixtures.instance_method(:setup_shared_connection_pool).bind(self).call
|
|
84
72
|
end
|
|
85
73
|
end
|
|
86
74
|
end
|
data/lib/cypress-rails/server.rb
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
require "uri"
|
|
4
4
|
require "net/http"
|
|
5
5
|
require "rack"
|
|
6
|
+
require_relative "initializer_hooks"
|
|
6
7
|
require_relative "server/middleware"
|
|
7
8
|
require_relative "server/checker"
|
|
8
9
|
require_relative "server/timer"
|
|
@@ -16,11 +17,11 @@ module CypressRails
|
|
|
16
17
|
end
|
|
17
18
|
end
|
|
18
19
|
|
|
19
|
-
attr_reader :app, :
|
|
20
|
+
attr_reader :app, :host, :port
|
|
20
21
|
|
|
21
22
|
def initialize(app,
|
|
23
|
+
host:,
|
|
22
24
|
port:,
|
|
23
|
-
host: "127.0.0.1",
|
|
24
25
|
reportable_errors: [Exception],
|
|
25
26
|
extra_middleware: [])
|
|
26
27
|
@app = app
|
|
@@ -32,6 +33,7 @@ module CypressRails
|
|
|
32
33
|
@port ||= Server.ports[port_key]
|
|
33
34
|
@port ||= find_available_port(host)
|
|
34
35
|
@checker = Checker.new(@host, @port)
|
|
36
|
+
@initializer_hooks = InitializerHooks.instance
|
|
35
37
|
end
|
|
36
38
|
|
|
37
39
|
def reset_error!
|
|
@@ -78,16 +80,13 @@ module CypressRails
|
|
|
78
80
|
raise "Rack application timed out during boot" if timer.expired?
|
|
79
81
|
|
|
80
82
|
@server_thread.join(0.1)
|
|
83
|
+
@initializer_hooks.run(:after_server_start)
|
|
81
84
|
end
|
|
82
85
|
end
|
|
83
86
|
|
|
84
87
|
self
|
|
85
88
|
end
|
|
86
89
|
|
|
87
|
-
def base_url
|
|
88
|
-
"http#{"s" if using_ssl?}://#{host}:#{port}"
|
|
89
|
-
end
|
|
90
|
-
|
|
91
90
|
private
|
|
92
91
|
|
|
93
92
|
def middleware
|
|
@@ -3,10 +3,10 @@ require_relative "server"
|
|
|
3
3
|
|
|
4
4
|
module CypressRails
|
|
5
5
|
class StartsRailsServer
|
|
6
|
-
def call(port:, transactional_server:)
|
|
6
|
+
def call(host:, port:, transactional_server:)
|
|
7
7
|
configure_rails_to_run_our_state_reset_on_every_request!(transactional_server)
|
|
8
8
|
app = create_rack_app
|
|
9
|
-
Server.new(app, port: port).tap do |server|
|
|
9
|
+
Server.new(app, host: host, port: port).tap do |server|
|
|
10
10
|
server.boot
|
|
11
11
|
end
|
|
12
12
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: cypress-rails
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.5.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Justin Searls
|
|
8
|
-
autorequire:
|
|
8
|
+
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2021-03-31 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: railties
|
|
@@ -94,7 +94,7 @@ dependencies:
|
|
|
94
94
|
- - ">="
|
|
95
95
|
- !ruby/object:Gem::Version
|
|
96
96
|
version: 0.2.0
|
|
97
|
-
description:
|
|
97
|
+
description:
|
|
98
98
|
email:
|
|
99
99
|
- searls@gmail.com
|
|
100
100
|
executables:
|
|
@@ -142,7 +142,7 @@ homepage: https://github.com/testdouble/cypress-rails
|
|
|
142
142
|
licenses:
|
|
143
143
|
- MIT
|
|
144
144
|
metadata: {}
|
|
145
|
-
post_install_message:
|
|
145
|
+
post_install_message:
|
|
146
146
|
rdoc_options: []
|
|
147
147
|
require_paths:
|
|
148
148
|
- lib
|
|
@@ -157,8 +157,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
157
157
|
- !ruby/object:Gem::Version
|
|
158
158
|
version: '0'
|
|
159
159
|
requirements: []
|
|
160
|
-
rubygems_version: 3.
|
|
161
|
-
signing_key:
|
|
160
|
+
rubygems_version: 3.2.3
|
|
161
|
+
signing_key:
|
|
162
162
|
specification_version: 4
|
|
163
163
|
summary: Helps you write Cypress tests of your Rails app
|
|
164
164
|
test_files: []
|