cypress-rails 0.1.3 → 0.4.0

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: 2044306eee0e5e184bd9c1166e2906648a05015c03a28290634374683ff49ff4
4
- data.tar.gz: 3e3cc908007c231913778a3627864a40520edd6ef7e0de6a735d2fbf0597b820
3
+ metadata.gz: b753d03802970fd8e870d84825cf9338ddb220749a94776b059bc76efba15569
4
+ data.tar.gz: '09f816ccaf74d9af77155079de053fa25c874bac8dfc7423852314a97be95a34'
5
5
  SHA512:
6
- metadata.gz: 81bb4a5648105bf5660dd55f3c77fc7a2cbbd4a0fb82e1f6b6cbc563aa8baa57f2e29d8018418e6b3649decdb5e249e6f31f2164df5a79b3c35deed16d12bedb
7
- data.tar.gz: 9c25c2109428646b925254e85f5c893db6ef9ca5993a7cb31568f176e42c4b01c45011875521845bf280b6c7822eed2b8e55a7798ba5d704257f21cbadeaa1e1
6
+ metadata.gz: b5e66032ab98b6e029485816713bb42eee64c3effccf35fd7b1d69cad84844b232156dc2bcde4413f0247946486aa2f129eb3201f0cbc4cb2ec1b2fc90675b61
7
+ data.tar.gz: 87b6866d459c8e6a235e635e062ea687c8478e798d716b93a805f463441def37eb9d573f4b89a580b4f617c05a66fff30089ab3131ffe9e8c9d2ef18555eb1dd
@@ -10,6 +10,7 @@ jobs:
10
10
  - type: cache-restore
11
11
  key: v1-main-{{ checksum "Gemfile.lock" }}
12
12
 
13
+ - run: gem install bundler --version `tail -1 Gemfile.lock`
13
14
  - run: bundle install --path vendor/bundle
14
15
 
15
16
  - type: cache-save
@@ -33,9 +34,9 @@ jobs:
33
34
  # Yarn dependencies
34
35
  - restore_cache:
35
36
  keys:
36
- - v2-yarn-{{ checksum "example/an_app/package.json" }}
37
+ - v3-yarn-{{ checksum "example/an_app/package.json" }}
37
38
  # fallback to using the latest cache if no exact match is found
38
- - v2-yarn-
39
+ - v3-yarn-
39
40
 
40
41
  - run: |
41
42
  cd example/an_app
@@ -45,7 +46,7 @@ jobs:
45
46
  paths:
46
47
  - example/an_app/node_modules
47
48
  - ~/.cache
48
- key: v2-yarn-{{ checksum "example/an_app/package.json" }}
49
+ key: v3-yarn-{{ checksum "example/an_app/package.json" }}
49
50
 
50
51
  - run: bundle exec rake
51
52
  - run: ./script/test_example_app
@@ -1,5 +1,25 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 0.4.0
4
+
5
+ * Add a `CYPRESS_RAILS_HOST` option that allows a hostname to be specified (as
6
+ opposed to 127.0.0.1). Puma will still bind to 127.0.0.1, but Cypress will use
7
+ the hostname in its `baseUrl`, which may be necessary for some folks' tests to
8
+ work
9
+
10
+ ## 0.3.0
11
+
12
+ * Add a `CYPRESS_RAILS_BASE_PATH` option which will be appended to the
13
+ `CYPRESS_BASE_URL` option that cypress-rails sets when launching cypress
14
+ commands. Apps that set `baseUrl` to something other than "/" can set this env
15
+ var to match for consistent behavior (or else set it using Cypress.config in a
16
+ support file)
17
+
18
+ ## 0.2.0
19
+
20
+ * If `RAILS_ENV` has been explicitly set when the CLI or rake task is run,
21
+ respect that set value instead of overriding it to "test"
22
+
3
23
  ## 0.1.3
4
24
 
5
25
  * Improve behavior of SIGINT (Ctrl-C) so a traceback isn't printed and stdout
@@ -1,55 +1,55 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- cypress-rails (0.1.3)
4
+ cypress-rails (0.4.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.0.2.1)
12
- actionview (= 6.0.2.1)
13
- activesupport (= 6.0.2.1)
11
+ actionpack (6.0.3.2)
12
+ actionview (= 6.0.3.2)
13
+ activesupport (= 6.0.3.2)
14
14
  rack (~> 2.0, >= 2.0.8)
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.0.2.1)
19
- activesupport (= 6.0.2.1)
18
+ actionview (6.0.3.2)
19
+ activesupport (= 6.0.3.2)
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.0.2.1)
24
+ activesupport (6.0.3.2)
25
25
  concurrent-ruby (~> 1.0, >= 1.0.2)
26
26
  i18n (>= 0.7, < 2)
27
27
  minitest (~> 5.1)
28
28
  tzinfo (~> 1.1)
29
- zeitwerk (~> 2.2)
29
+ zeitwerk (~> 2.2, >= 2.2.2)
30
30
  ast (2.4.0)
31
31
  builder (3.2.4)
32
32
  concurrent-ruby (1.1.6)
33
33
  crass (1.0.6)
34
34
  erubi (1.9.0)
35
- i18n (1.8.2)
35
+ i18n (1.8.5)
36
36
  concurrent-ruby (~> 1.0)
37
37
  jaro_winkler (1.5.4)
38
- loofah (2.4.0)
38
+ loofah (2.6.0)
39
39
  crass (~> 1.0.2)
40
40
  nokogiri (>= 1.5.9)
41
- method_source (0.9.2)
41
+ method_source (1.0.0)
42
42
  mini_portile2 (2.4.0)
43
43
  minitest (5.14.0)
44
44
  nio4r (2.5.2)
45
- nokogiri (1.10.9)
45
+ nokogiri (1.10.10)
46
46
  mini_portile2 (~> 2.4.0)
47
47
  parallel (1.19.1)
48
- parser (2.7.0.4)
48
+ parser (2.7.1.2)
49
49
  ast (~> 2.4.0)
50
- puma (4.3.3)
50
+ puma (4.3.5)
51
51
  nio4r (~> 2.0)
52
- rack (2.2.2)
52
+ rack (2.2.3)
53
53
  rack-test (1.1.0)
54
54
  rack (>= 1.0, < 3)
55
55
  rails-dom-testing (2.0.3)
@@ -57,43 +57,45 @@ GEM
57
57
  nokogiri (>= 1.6)
58
58
  rails-html-sanitizer (1.3.0)
59
59
  loofah (~> 2.3)
60
- railties (6.0.2.1)
61
- actionpack (= 6.0.2.1)
62
- activesupport (= 6.0.2.1)
60
+ railties (6.0.3.2)
61
+ actionpack (= 6.0.3.2)
62
+ activesupport (= 6.0.3.2)
63
63
  method_source
64
64
  rake (>= 0.8.7)
65
65
  thor (>= 0.20.3, < 2.0)
66
66
  rainbow (3.0.0)
67
67
  rake (13.0.1)
68
- rubocop (0.79.0)
68
+ rexml (3.2.4)
69
+ rubocop (0.82.0)
69
70
  jaro_winkler (~> 1.5.1)
70
71
  parallel (~> 1.10)
71
72
  parser (>= 2.7.0.1)
72
73
  rainbow (>= 2.2.2, < 4.0)
74
+ rexml
73
75
  ruby-progressbar (~> 1.7)
74
- unicode-display_width (>= 1.4.0, < 1.7)
76
+ unicode-display_width (>= 1.4.0, < 2.0)
75
77
  rubocop-performance (1.5.2)
76
78
  rubocop (>= 0.71.0)
77
79
  ruby-progressbar (1.10.1)
78
- standard (0.2.1)
79
- rubocop (~> 0.79.0)
80
- rubocop-performance (~> 1.5.1)
80
+ standard (0.4.1)
81
+ rubocop (~> 0.82.0)
82
+ rubocop-performance (~> 1.5.2)
81
83
  thor (1.0.1)
82
84
  thread_safe (0.3.6)
83
- tzinfo (1.2.6)
85
+ tzinfo (1.2.7)
84
86
  thread_safe (~> 0.1)
85
- unicode-display_width (1.6.1)
86
- zeitwerk (2.3.0)
87
+ unicode-display_width (1.7.0)
88
+ zeitwerk (2.4.0)
87
89
 
88
90
  PLATFORMS
89
91
  ruby
90
92
 
91
93
  DEPENDENCIES
92
- bundler (~> 1.17)
94
+ bundler
93
95
  cypress-rails!
94
96
  minitest (~> 5.0)
95
97
  rake (~> 13.0)
96
98
  standard (>= 0.2.0)
97
99
 
98
100
  BUNDLED WITH
99
- 1.17.3
101
+ 2.1.4
data/README.md CHANGED
@@ -25,7 +25,7 @@ If you're on newer versions of Rails and using
25
25
  then you're likely already using yarn to manage your JavaScript dependencies. If
26
26
  that's the case, you can add Cypress with:
27
27
 
28
- ```
28
+ ```sh
29
29
  $ yarn add --dev cypress
30
30
  ```
31
31
 
@@ -40,7 +40,7 @@ Now, to install the cypress-rails gem, you'll want to add it to your development
40
40
  & test gem groups of your Gemfile, so that you have easy access to its rake
41
41
  tasks:
42
42
 
43
- ``` ruby
43
+ ```ruby
44
44
  group :development, :test do
45
45
  gem "cypress-rails"
46
46
  end
@@ -48,7 +48,7 @@ end
48
48
 
49
49
  Once installed, you'll want to run:
50
50
 
51
- ```
51
+ ```sh
52
52
  $ rake cypress:init
53
53
  ```
54
54
 
@@ -69,7 +69,7 @@ a wrapper for running `cypress open` with a dedicated Rails test server.
69
69
 
70
70
  So, by running:
71
71
 
72
- ```
72
+ ```sh
73
73
  $ rake cypress:open
74
74
  ```
75
75
 
@@ -83,7 +83,7 @@ itself.
83
83
  To run your tests headlessly (e.g. when you're in CI), you'll want the `run`
84
84
  command:
85
85
 
86
- ```
86
+ ```sh
87
87
  $ rake cypress:run
88
88
  ```
89
89
 
@@ -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 ether the transaction or the server is started
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
@@ -158,8 +158,13 @@ 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
@@ -198,6 +203,22 @@ pollute other test suites or scripts, you can use the `before_server_stop` to
198
203
  of your test database. To set up the hook, pass a block to
199
204
  `CypressRails.hooks.before_server_stop`.
200
205
 
206
+ ## Configuring Rails
207
+
208
+ Beyond the configuration options above, you'll probably also want to disable caching
209
+ in your Rails app's [config/environments/test.rb](/example/an_app/config/environments/test.rb#L9)
210
+ file, so that changes to your Ruby code are reflected in your tests while you
211
+ work on them with `rake cypress:open`. (If either option is set to
212
+ `true`, any changes to your Ruby code will require a server restart to be reflected as you work
213
+ on your tests.)
214
+
215
+ To illustrate, here's what that might look like in `config/environments/test.rb`:
216
+
217
+ ```ruby
218
+ config.cache_classes = false
219
+ config.action_view.cache_template_loading = false
220
+ ```
221
+
201
222
  ## Setting up continuous integration
202
223
 
203
224
  #### Circle CI
@@ -233,7 +254,7 @@ jobs:
233
254
  # Yarn dependencies
234
255
  - restore_cache:
235
256
  keys:
236
- - v1-yarn-{{ checksum "package.json" }}
257
+ - v1-yarn-{{ checksum "yarn.lock" }}
237
258
  # fallback to using the latest cache if no exact match is found
238
259
  - v1-yarn-
239
260
 
@@ -243,7 +264,7 @@ jobs:
243
264
  paths:
244
265
  - node_modules
245
266
  - ~/.cache
246
- key: v1-yarn-{{ checksum "package.json" }}
267
+ key: v1-yarn-{{ checksum "yarn.lock" }}
247
268
 
248
269
  # Run your cypress tests
249
270
  - run: bin/rake cypress:run
@@ -305,5 +326,12 @@ adopting Cypress and writing a bunch of browser tests for every application.
305
326
  But, if the above points sound like solutions to problems you experience, you
306
327
  might consider trying it out.
307
328
 
329
+ ## Code of Conduct
308
330
 
331
+ This project follows Test Double's [code of
332
+ conduct](https://testdouble.com/code-of-conduct) for all community interactions,
333
+ including (but not limited to) one-on-one communications, public posts/comments,
334
+ code reviews, pull requests, and GitHub issues. If violations occur, Test Double
335
+ will take any action they deem appropriate for the infraction, up to and
336
+ including blocking a user from the organization's repositories.
309
337
 
@@ -24,7 +24,7 @@ Gem::Specification.new do |spec|
24
24
  spec.add_dependency "railties", ">= 5.2.0"
25
25
  spec.add_dependency "puma", ">= 3.8.0"
26
26
 
27
- spec.add_development_dependency "bundler", "~> 1.17"
27
+ spec.add_development_dependency "bundler"
28
28
  spec.add_development_dependency "rake", "~> 13.0"
29
29
  spec.add_development_dependency "minitest", "~> 5.0"
30
30
  spec.add_development_dependency "standard", ">= 0.2.0"
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- ENV["RAILS_ENV"] = "test"
3
+ ENV["RAILS_ENV"] ||= "test"
4
4
  require "pathname"
5
5
  require "cypress-rails"
6
6
  require Pathname.new(CypressRails::Config.new.dir).join("config/environment")
@@ -1,10 +1,12 @@
1
1
  require_relative "env"
2
2
 
3
3
  module CypressRails
4
- class Config < Struct.new(:dir, :port, :transactional_server, :cypress_cli_opts, keyword_init: true)
4
+ class Config < Struct.new(:dir, :host, :port, :base_path, :transactional_server, :cypress_cli_opts, keyword_init: true)
5
5
  def initialize(
6
6
  dir: Env.fetch("CYPRESS_RAILS_DIR", default: Dir.pwd),
7
+ host: Env.fetch("CYPRESS_RAILS_HOST", default: "127.0.0.1"),
7
8
  port: Env.fetch("CYPRESS_RAILS_PORT"),
9
+ base_path: Env.fetch("CYPRESS_RAILS_BASE_PATH", default: "/"),
8
10
  transactional_server: Env.fetch("CYPRESS_RAILS_TRANSACTIONAL_SERVER", type: :boolean, default: true),
9
11
  cypress_cli_opts: Env.fetch("CYPRESS_RAILS_CYPRESS_OPTS", default: "")
10
12
  )
@@ -17,7 +19,9 @@ module CypressRails
17
19
  cypress-rails configuration:
18
20
  ============================
19
21
  CYPRESS_RAILS_DIR.....................#{dir.inspect}
22
+ CYPRESS_RAILS_HOST....................#{host.inspect}
20
23
  CYPRESS_RAILS_PORT....................#{port.inspect}
24
+ CYPRESS_RAILS_BASE_PATH...............#{base_path.inspect}
21
25
  CYPRESS_RAILS_TRANSACTIONAL_SERVER....#{transactional_server.inspect}
22
26
  CYPRESS_RAILS_CYPRESS_OPTS............#{cypress_cli_opts.inspect}
23
27
 
@@ -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
- system <<~EXEC
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
@@ -68,8 +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
- writing_handler = ActiveRecord::Base.connection_handler
71
+ return unless ActiveRecord::Base.respond_to?(:connection_handlers)
72
72
 
73
+ writing_handler = ActiveRecord::Base.connection_handler
73
74
  ActiveRecord::Base.connection_handlers.values.each do |handler|
74
75
  if handler != writing_handler
75
76
  handler.connection_pool_list.each do |pool|
@@ -16,11 +16,11 @@ module CypressRails
16
16
  end
17
17
  end
18
18
 
19
- attr_reader :app, :port, :host
19
+ attr_reader :app, :host, :port
20
20
 
21
21
  def initialize(app,
22
+ host:,
22
23
  port:,
23
- host: "127.0.0.1",
24
24
  reportable_errors: [Exception],
25
25
  extra_middleware: [])
26
26
  @app = app
@@ -84,10 +84,6 @@ module CypressRails
84
84
  self
85
85
  end
86
86
 
87
- def base_url
88
- "http#{"s" if using_ssl?}://#{host}:#{port}"
89
- end
90
-
91
87
  private
92
88
 
93
89
  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
@@ -1,3 +1,3 @@
1
1
  module CypressRails
2
- VERSION = "0.1.3"
2
+ VERSION = "0.4.0"
3
3
  end
@@ -0,0 +1,10 @@
1
+ {
2
+ "systemParams": "darwin-x64-72",
3
+ "modulesFolders": [],
4
+ "flags": [],
5
+ "linkedModules": [],
6
+ "topLevelPatterns": [],
7
+ "lockfileEntries": {},
8
+ "files": [],
9
+ "artifacts": {}
10
+ }
@@ -0,0 +1,4 @@
1
+ # THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
2
+ # yarn lockfile v1
3
+
4
+
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.1.3
4
+ version: 0.4.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: 2020-03-16 00:00:00.000000000 Z
11
+ date: 2020-09-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties
@@ -42,16 +42,16 @@ dependencies:
42
42
  name: bundler
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "~>"
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: '1.17'
47
+ version: '0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - "~>"
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
- version: '1.17'
54
+ version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rake
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -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:
@@ -137,12 +137,14 @@ 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
+ - node_modules/.yarn-integrity
140
141
  - script/test_example_app
142
+ - yarn.lock
141
143
  homepage: https://github.com/testdouble/cypress-rails
142
144
  licenses:
143
145
  - MIT
144
146
  metadata: {}
145
- post_install_message:
147
+ post_install_message:
146
148
  rdoc_options: []
147
149
  require_paths:
148
150
  - lib
@@ -157,8 +159,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
157
159
  - !ruby/object:Gem::Version
158
160
  version: '0'
159
161
  requirements: []
160
- rubygems_version: 3.0.3
161
- signing_key:
162
+ rubygems_version: 3.1.2
163
+ signing_key:
162
164
  specification_version: 4
163
165
  summary: Helps you write Cypress tests of your Rails app
164
166
  test_files: []