cypress-rails 0.4.2 → 0.5.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c66865f1f844c8e3bd6fc86a881db8059fe26db9ebe70b1eeb0fc05e6ace601a
4
- data.tar.gz: b94c1d60432ba1cf738f43574ef5ee9a831a2420cfcc4091446d6c0837860b64
3
+ metadata.gz: efaf85898e684adf953cc9951a47fd6c97dde338cb0b5719ed6686dcb7b2b19b
4
+ data.tar.gz: 3685cd5e6be4e515c65da1c4b756e8847ead9899936fd0925b97145332b7b977
5
5
  SHA512:
6
- metadata.gz: e8878b2be16bd34dbcb4994a0d2cec648dc1fdf41ea88dea4b51092d9e882d7e199dbd189dbc1873f96b3c5834f04df05b08a7592de55b71649cd8f7720e3c07
7
- data.tar.gz: 1f200193af7bdddc8e4c56f9d3a3f9b38eeed17fef9e7cd5a26fa0c31b93eb6ba04a4e62b73ed42c5d7c79d6382d9883754311a5a946d4cf8ef00861d1c1d609
6
+ metadata.gz: '088fbf9e266da8d373d4e8f2b70635dc80956bc38a22c28b74555ed0e5ecf0774188bcf9e35f4d612dbdb4ea94f7c904da82b06c21162a9390edccde254328d4'
7
+ data.tar.gz: 327e0a512b34dfa1157465b77d42a4150cf54d2a93e03ef1f342b388bb5e0dfd9a95d9b30a1b707d3ac819c113d0c9a3cd84f612e71b4e4d55b3d3aced211b8a
@@ -0,0 +1,21 @@
1
+ name: CI
2
+
3
+ on: [push, pull_request, workflow_dispatch]
4
+
5
+ jobs:
6
+ build:
7
+ runs-on: ubuntu-latest
8
+
9
+ strategy:
10
+ matrix:
11
+ ruby-version: ['2.7', '3.0']
12
+
13
+ steps:
14
+ - uses: actions/checkout@v2
15
+ - uses: ruby/setup-ruby@v1
16
+ with:
17
+ ruby-version: ${{ matrix.ruby-version }}
18
+ bundler-cache: true
19
+
20
+ - name: Run tests
21
+ run: ./script/test
data/.standard.yml CHANGED
@@ -1,4 +1,5 @@
1
+ ruby_version: 2.5
1
2
  ignore:
2
3
  - 'vendor/bundle/**/*'
3
- - 'example/an_app/node_modules/**/*'
4
- - 'example/an_app/vendor/bundle/**/*'
4
+ - 'example/node_modules/**/*'
5
+ - 'example/vendor/bundle/**/*'
data/CHANGELOG.md CHANGED
@@ -1,5 +1,29 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 0.5.3
4
+
5
+ * Fix 2.5 & 2.6 compatibility
6
+ [#100](https://github.com/testdouble/cypress-rails/issues/100)
7
+
8
+ ## 0.5.2
9
+
10
+ * Fixes a puma deprecation warning
11
+ [#95](https://github.com/testdouble/cypress-rails/pull/95)
12
+
13
+ ## 0.5.1
14
+
15
+ * Sprinkles two instance variables to the custom transaction manager that cribs
16
+ its implementation from ActiveRecord::TestFixtures (see f75f280)
17
+ [#88](https://github.com/testdouble/cypress-rails/issues/88)
18
+ [#89](https://github.com/testdouble/cypress-rails/pull/89)
19
+
20
+ ## 0.5.0
21
+
22
+ * Add hook `after_server_start`
23
+ [#63](https://github.com/testdouble/cypress-rails/pull/63)
24
+ * Fix namespace bug
25
+ [#64](https://github.com/testdouble/cypress-rails/pull/64)
26
+
3
27
  ## 0.4.2
4
28
 
5
29
  * Add support to Rails 6.1 ([#52](https://github.com/testdouble/cypress-rails/issue/52))
data/Gemfile.lock CHANGED
@@ -1,93 +1,95 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- cypress-rails (0.4.2)
4
+ cypress-rails (0.5.3)
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.1.0)
12
- actionview (= 6.1.0)
13
- activesupport (= 6.1.0)
11
+ actionpack (6.1.4.1)
12
+ actionview (= 6.1.4.1)
13
+ activesupport (= 6.1.4.1)
14
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.1.0)
19
- activesupport (= 6.1.0)
18
+ actionview (6.1.4.1)
19
+ activesupport (= 6.1.4.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.1.0)
24
+ activesupport (6.1.4.1)
25
25
  concurrent-ruby (~> 1.0, >= 1.0.2)
26
26
  i18n (>= 1.6, < 2)
27
27
  minitest (>= 5.1)
28
28
  tzinfo (~> 2.0)
29
29
  zeitwerk (~> 2.3)
30
- ast (2.4.1)
30
+ ast (2.4.2)
31
31
  builder (3.2.4)
32
- concurrent-ruby (1.1.7)
32
+ concurrent-ruby (1.1.9)
33
33
  crass (1.0.6)
34
34
  erubi (1.10.0)
35
- i18n (1.8.5)
35
+ i18n (1.8.10)
36
36
  concurrent-ruby (~> 1.0)
37
- loofah (2.8.0)
37
+ loofah (2.12.0)
38
38
  crass (~> 1.0.2)
39
39
  nokogiri (>= 1.5.9)
40
40
  method_source (1.0.0)
41
- mini_portile2 (2.4.0)
42
- minitest (5.14.2)
43
- nio4r (2.5.4)
44
- nokogiri (1.10.10)
45
- mini_portile2 (~> 2.4.0)
41
+ mini_portile2 (2.6.1)
42
+ minitest (5.14.4)
43
+ nio4r (2.5.8)
44
+ nokogiri (1.12.4)
45
+ mini_portile2 (~> 2.6.1)
46
+ racc (~> 1.4)
46
47
  parallel (1.20.1)
47
- parser (2.7.2.0)
48
+ parser (3.0.1.1)
48
49
  ast (~> 2.4.1)
49
- puma (5.1.1)
50
+ puma (5.4.0)
50
51
  nio4r (~> 2.0)
52
+ racc (1.5.2)
51
53
  rack (2.2.3)
52
54
  rack-test (1.1.0)
53
55
  rack (>= 1.0, < 3)
54
56
  rails-dom-testing (2.0.3)
55
57
  activesupport (>= 4.2.0)
56
58
  nokogiri (>= 1.6)
57
- rails-html-sanitizer (1.3.0)
59
+ rails-html-sanitizer (1.4.2)
58
60
  loofah (~> 2.3)
59
- railties (6.1.0)
60
- actionpack (= 6.1.0)
61
- activesupport (= 6.1.0)
61
+ railties (6.1.4.1)
62
+ actionpack (= 6.1.4.1)
63
+ activesupport (= 6.1.4.1)
62
64
  method_source
63
- rake (>= 0.8.7)
65
+ rake (>= 0.13)
64
66
  thor (~> 1.0)
65
67
  rainbow (3.0.0)
66
- rake (13.0.1)
67
- regexp_parser (2.0.0)
68
- rexml (3.2.4)
69
- rubocop (1.4.2)
68
+ rake (13.0.4)
69
+ regexp_parser (2.1.1)
70
+ rexml (3.2.5)
71
+ rubocop (1.18.2)
70
72
  parallel (~> 1.10)
71
- parser (>= 2.7.1.5)
73
+ parser (>= 3.0.0.0)
72
74
  rainbow (>= 2.2.2, < 4.0)
73
- regexp_parser (>= 1.8)
75
+ regexp_parser (>= 1.8, < 3.0)
74
76
  rexml
75
- rubocop-ast (>= 1.1.1)
77
+ rubocop-ast (>= 1.7.0, < 2.0)
76
78
  ruby-progressbar (~> 1.7)
77
- unicode-display_width (>= 1.4.0, < 2.0)
78
- rubocop-ast (1.3.0)
79
- parser (>= 2.7.1.5)
80
- rubocop-performance (1.9.1)
81
- rubocop (>= 0.90.0, < 2.0)
79
+ unicode-display_width (>= 1.4.0, < 3.0)
80
+ rubocop-ast (1.7.0)
81
+ parser (>= 3.0.1.1)
82
+ rubocop-performance (1.11.3)
83
+ rubocop (>= 1.7.0, < 2.0)
82
84
  rubocop-ast (>= 0.4.0)
83
- ruby-progressbar (1.10.1)
84
- standard (0.10.2)
85
- rubocop (= 1.4.2)
86
- rubocop-performance (= 1.9.1)
87
- thor (1.0.1)
85
+ ruby-progressbar (1.11.0)
86
+ standard (1.1.4)
87
+ rubocop (= 1.18.2)
88
+ rubocop-performance (= 1.11.3)
89
+ thor (1.1.0)
88
90
  tzinfo (2.0.4)
89
91
  concurrent-ruby (~> 1.0)
90
- unicode-display_width (1.7.0)
92
+ unicode-display_width (2.0.0)
91
93
  zeitwerk (2.4.2)
92
94
 
93
95
  PLATFORMS
@@ -101,4 +103,4 @@ DEPENDENCIES
101
103
  standard (>= 0.2.0)
102
104
 
103
105
  BUNDLED WITH
104
- 2.1.4
106
+ 2.2.15
data/README.md CHANGED
@@ -1,7 +1,5 @@
1
1
  # cypress-rails
2
2
 
3
- [![CircleCI](https://circleci.com/gh/testdouble/cypress-rails/tree/master.svg?style=svg)](https://circleci.com/gh/testdouble/cypress-rails/tree/master)
4
-
5
3
  This is a simple gem to make it easier to start writing browser tests with
6
4
  [Cypress](http://cypress.io) for your [Rails](https://rubyonrails.org) apps,
7
5
  regardless of whether your app is server-side rendered HTML, completely
@@ -120,7 +118,7 @@ end
120
118
 
121
119
  (You can find [an
122
120
  example
123
- initializer](/example/an_app/config/initializers/cypress_rails_initializer.rb)
121
+ initializer](/example/config/initializers/cypress_rails_initializer.rb)
124
122
  in this repo.)
125
123
 
126
124
  The gem also provides a special route on the test server:
@@ -170,7 +168,7 @@ preferred environment variables project-wide using a tool like
170
168
  general this means anything done during `cypress open` or `cypress run` will
171
169
  be rolled back on exit (similar to running a Rails System test)
172
170
  * **CYPRESS_RAILS_CYPRESS_OPTS** (default: _none_) any options you want to
173
- forward to the Cypress CLI when running its `open` or `run` commands
171
+ forward to the Cypress CLI when running its `open` or `run` commands.
174
172
 
175
173
  #### Example: Running a single spec from the command line
176
174
 
@@ -181,6 +179,14 @@ Cypress test would look like this:
181
179
  $ CYPRESS_RAILS_CYPRESS_OPTS="--spec cypress/integration/a_test.js" bin/rake cypress:run
182
180
  ```
183
181
 
182
+ #### Example: Running your tests in Chromium
183
+
184
+ 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:
185
+
186
+ ```
187
+ $ CYPRESS_RAILS_CYPRESS_OPTS="--browser chromium" bin/rake cypress:run
188
+ ```
189
+
184
190
  ### Initializer hooks
185
191
 
186
192
  ### before_server_start
@@ -190,6 +196,11 @@ will execute before the server or any transaction has been started. If you use
190
196
  Rails fixtures, it may make sense to load them here, so they don't need to be
191
197
  re-inserted for each request
192
198
 
199
+ ### after_server_start
200
+
201
+ Pass a block to `CypressRails.hooks.after_server_start` to register a hook that
202
+ will execute after the server has booted.
203
+
193
204
  ### after_transaction_start
194
205
 
195
206
  If there's any custom behavior or state management you want to do inside the
@@ -215,7 +226,7 @@ of your test database. To set up the hook, pass a block to
215
226
  ## Configuring Rails
216
227
 
217
228
  Beyond the configuration options above, you'll probably also want to disable caching
218
- in your Rails app's [config/environments/test.rb](/example/an_app/config/environments/test.rb#L9)
229
+ in your Rails app's [config/environments/test.rb](/example/config/environments/test.rb#L9)
219
230
  file, so that changes to your Ruby code are reflected in your tests while you
220
231
  work on them with `rake cypress:open`. (If either option is set to
221
232
  `true`, any changes to your Ruby code will require a server restart to be reflected as you work
@@ -304,7 +315,7 @@ experience. In particular:
304
315
  and more information dense than using Capybara and Selenium. Rather than
305
316
  running a test from the command line, seeing it fail, then adding a debug
306
317
  breakpoint to a test to try to manipulate the browser or tweaking a call to a
307
- Capybara API method, failures to be rather obvious when using Cypress and
318
+ Capybara API method, failures tend to be rather obvious when using Cypress and
308
319
  fixing it is usually as easy as tweaking a command, hitting save, and watching
309
320
  it re-run
310
321
  * With very few exceptions, a Cypress test that works in a browser window will
@@ -4,11 +4,8 @@ module CypressRails
4
4
  return default unless ENV.key?(name)
5
5
 
6
6
  if type == :boolean
7
- if ["", "0", "n", "no", "false"].include?(ENV.fetch(name))
8
- false
9
- else
10
- true
11
- end
7
+ no_like_flag = ["", "0", "n", "no", "false"].include?(ENV.fetch(name))
8
+ !no_like_flag
12
9
  else
13
10
  ENV.fetch(name)
14
11
  end
@@ -24,7 +24,7 @@ module CypressRails
24
24
  end
25
25
 
26
26
  def merge_existing_with_defaults(json_path)
27
- Hash[JSON.parse(File.read(json_path)).merge(DEFAULT_CONFIG).sort]
27
+ JSON.parse(File.read(json_path)).merge(DEFAULT_CONFIG).sort.to_h
28
28
  end
29
29
  end
30
30
  end
@@ -12,6 +12,10 @@ module CypressRails
12
12
  register(:before_server_start, blk)
13
13
  end
14
14
 
15
+ def after_server_start(&blk)
16
+ register(:after_server_start, blk)
17
+ end
18
+
15
19
  def after_transaction_start(&blk)
16
20
  register(:after_transaction_start, blk)
17
21
  end
@@ -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,6 +68,9 @@ 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
+ @legacy_saved_pool_configs ||= Hash.new { |hash, key| hash[key] = {} }
72
+ @saved_pool_configs ||= Hash.new { |hash, key| hash[key] = {} }
73
+
71
74
  ActiveRecord::TestFixtures.instance_method(:setup_shared_connection_pool).bind(self).call
72
75
  end
73
76
  end
@@ -11,6 +11,7 @@ module CypressRails
11
11
  options = default_options # .merge(options)
12
12
 
13
13
  conf = Rack::Handler::Puma.config(app, options)
14
+ conf.clamp
14
15
  events = ::Puma::Events.stdio
15
16
 
16
17
  puma_ver = Gem::Version.new(::Puma::Const::PUMA_VERSION)
@@ -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"
@@ -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,6 +80,7 @@ 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
 
@@ -1,3 +1,3 @@
1
1
  module CypressRails
2
- VERSION = "0.4.2"
2
+ VERSION = "0.5.3"
3
3
  end
data/script/test ADDED
@@ -0,0 +1,19 @@
1
+ #!/usr/bin/env bash
2
+
3
+ PS4='[script/test:${LINENO}] $ '
4
+ set -euo pipefail
5
+ set -x
6
+
7
+ echo "---> Installing dependencies"
8
+ bundle
9
+ cd example
10
+ bundle
11
+ yarn
12
+ cd ..
13
+
14
+ echo "---> Running tests"
15
+ bundle exec rake
16
+ ./script/test_example_app
17
+
18
+ echo "---> Job's done!"
19
+
@@ -4,7 +4,7 @@ set -e
4
4
 
5
5
  directory=$1
6
6
 
7
- cd example/an_app
7
+ cd example
8
8
  bundle
9
9
  yarn install
10
10
 
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.2
4
+ version: 0.5.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin Searls
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-12-17 00:00:00.000000000 Z
11
+ date: 2021-09-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties
@@ -102,7 +102,7 @@ executables:
102
102
  extensions: []
103
103
  extra_rdoc_files: []
104
104
  files:
105
- - ".circleci/config.yml"
105
+ - ".github/workflows/main.yml"
106
106
  - ".gitignore"
107
107
  - ".standard.yml"
108
108
  - ".travis.yml"
@@ -137,6 +137,7 @@ files:
137
137
  - lib/cypress-rails/starts_rails_server.rb
138
138
  - lib/cypress-rails/tracks_resets.rb
139
139
  - lib/cypress-rails/version.rb
140
+ - script/test
140
141
  - script/test_example_app
141
142
  homepage: https://github.com/testdouble/cypress-rails
142
143
  licenses:
@@ -157,7 +158,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
157
158
  - !ruby/object:Gem::Version
158
159
  version: '0'
159
160
  requirements: []
160
- rubygems_version: 3.1.2
161
+ rubygems_version: 3.2.15
161
162
  signing_key:
162
163
  specification_version: 4
163
164
  summary: Helps you write Cypress tests of your Rails app
data/.circleci/config.yml DELETED
@@ -1,53 +0,0 @@
1
- version: 2
2
- jobs:
3
- build:
4
- docker:
5
- - image: circleci/ruby:2.6-node-browsers
6
- steps:
7
- - checkout
8
-
9
- # Bundle install dependencies
10
- - type: cache-restore
11
- key: v1-main-{{ checksum "Gemfile.lock" }}
12
-
13
- - run: gem install bundler --version `tail -1 Gemfile.lock`
14
- - run: bundle install --path vendor/bundle
15
-
16
- - type: cache-save
17
- key: v1-main-{{ checksum "Gemfile.lock" }}
18
- paths:
19
- - vendor/bundle
20
-
21
- # Bundle install dependencies for example app
22
- - type: cache-restore
23
- key: v1-example-{{ checksum "example/an_app/Gemfile.lock" }}
24
-
25
- - run: |
26
- cd example/an_app
27
- bundle install --path vendor/bundle
28
-
29
- - type: cache-save
30
- key: v1-example-{{ checksum "example/an_app/Gemfile.lock" }}
31
- paths:
32
- - example/an_app/vendor/bundle
33
-
34
- # Yarn dependencies
35
- - restore_cache:
36
- keys:
37
- - v4-yarn-{{ checksum "example/an_app/yarn.lock" }}
38
- # fallback to using the latest cache if no exact match is found
39
- - v4-yarn-
40
-
41
- - run: |
42
- cd example/an_app
43
- yarn install
44
-
45
- - save_cache:
46
- paths:
47
- - example/an_app/node_modules
48
- - ~/.cache
49
- key: v4-yarn-{{ checksum "example/an_app/yarn.lock" }}
50
-
51
- - run: bundle exec rake
52
- - run: ./script/test_example_app
53
-