cypress-rails 0.1.4 → 0.4.1

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: e85a638994d0276ebc68b10800509df072561944bc81b3a160a6b23ddbe2ee72
4
- data.tar.gz: 8e89d33888cf976c47dfec25f570a4c7631a86d1756d7561bb4cb79bc6204f6a
3
+ metadata.gz: a14e87a5a70d81fe84303607d0927c51766fb088af7ec1939ba73e57319ecc8e
4
+ data.tar.gz: 4afd968f15e3074ce55d7d24cedaa0362b9542d4661f061debc76fbd8ffa212e
5
5
  SHA512:
6
- metadata.gz: 70ba5dbaacfeefcbcc2bf5e015dc1eaceb1a3dfa506fea499247c0321e00caac3ff8e95d22c9188f4299d0536f34abc1ca1656dd2b48052183d8f86915286980
7
- data.tar.gz: d5498dba5154d8c2f2e277f251fcdd6a6d75011a03887e22bd5dafa3091e78bb31d5c47f99f737cf4fd2429122b14973ab861ec006b674a4391deed21f660237
6
+ metadata.gz: 2fe07821acc26a46e1480caf536d03d69f77e400e53fe28672930ec16ae62e55ddda54d1f296f57f5e1535c75c06c74a6221a3ca87f5cbb239236f3e3b0850dc
7
+ data.tar.gz: f3a026adf4ec214285eaf2fb004b9984d0bc2f1842495a7a6c6809e6363826ee951de8116380309e105ed887f541412aabe5a9c7980c4f2ce36e555ebcd567ee
@@ -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
+ - v4-yarn-{{ checksum "example/an_app/yarn.lock" }}
37
38
  # fallback to using the latest cache if no exact match is found
38
- - v2-yarn-
39
+ - v4-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: v4-yarn-{{ checksum "example/an_app/yarn.lock" }}
49
50
 
50
51
  - run: bundle exec rake
51
52
  - run: ./script/test_example_app
@@ -1,5 +1,30 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 0.4.1
4
+
5
+ * Add backcompat for Ruby 2.4
6
+ ([#47](https://github.com/testdouble/cypress-rails/pull/47))
7
+
8
+ ## 0.4.0
9
+
10
+ * Add a `CYPRESS_RAILS_HOST` option that allows a hostname to be specified (as
11
+ opposed to 127.0.0.1). Puma will still bind to 127.0.0.1, but Cypress will use
12
+ the hostname in its `baseUrl`, which may be necessary for some folks' tests to
13
+ work
14
+
15
+ ## 0.3.0
16
+
17
+ * Add a `CYPRESS_RAILS_BASE_PATH` option which will be appended to the
18
+ `CYPRESS_BASE_URL` option that cypress-rails sets when launching cypress
19
+ commands. Apps that set `baseUrl` to something other than "/" can set this env
20
+ var to match for consistent behavior (or else set it using Cypress.config in a
21
+ support file)
22
+
23
+ ## 0.2.0
24
+
25
+ * If `RAILS_ENV` has been explicitly set when the CLI or rake task is run,
26
+ respect that set value instead of overriding it to "test"
27
+
3
28
  ## 0.1.3
4
29
 
5
30
  * Improve behavior of SIGINT (Ctrl-C) so a traceback isn't printed and stdout
@@ -1,55 +1,54 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- cypress-rails (0.1.4)
4
+ cypress-rails (0.4.1)
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.4)
12
+ actionview (= 6.0.3.4)
13
+ activesupport (= 6.0.3.4)
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.4)
19
+ activesupport (= 6.0.3.4)
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.4)
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)
30
- ast (2.4.0)
29
+ zeitwerk (~> 2.2, >= 2.2.2)
30
+ ast (2.4.1)
31
31
  builder (3.2.4)
32
- concurrent-ruby (1.1.6)
32
+ concurrent-ruby (1.1.7)
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
- jaro_winkler (1.5.4)
38
- loofah (2.4.0)
37
+ loofah (2.7.0)
39
38
  crass (~> 1.0.2)
40
39
  nokogiri (>= 1.5.9)
41
40
  method_source (1.0.0)
42
41
  mini_portile2 (2.4.0)
43
- minitest (5.14.0)
44
- nio4r (2.5.2)
45
- nokogiri (1.10.9)
42
+ minitest (5.14.2)
43
+ nio4r (2.5.4)
44
+ nokogiri (1.10.10)
46
45
  mini_portile2 (~> 2.4.0)
47
- parallel (1.19.1)
48
- parser (2.7.0.4)
49
- ast (~> 2.4.0)
50
- puma (4.3.3)
46
+ parallel (1.19.2)
47
+ parser (2.7.1.5)
48
+ ast (~> 2.4.1)
49
+ puma (5.0.2)
51
50
  nio4r (~> 2.0)
52
- rack (2.2.2)
51
+ rack (2.2.3)
53
52
  rack-test (1.1.0)
54
53
  rack (>= 1.0, < 3)
55
54
  rails-dom-testing (2.0.3)
@@ -57,43 +56,52 @@ GEM
57
56
  nokogiri (>= 1.6)
58
57
  rails-html-sanitizer (1.3.0)
59
58
  loofah (~> 2.3)
60
- railties (6.0.2.1)
61
- actionpack (= 6.0.2.1)
62
- activesupport (= 6.0.2.1)
59
+ railties (6.0.3.4)
60
+ actionpack (= 6.0.3.4)
61
+ activesupport (= 6.0.3.4)
63
62
  method_source
64
63
  rake (>= 0.8.7)
65
64
  thor (>= 0.20.3, < 2.0)
66
65
  rainbow (3.0.0)
67
66
  rake (13.0.1)
68
- rubocop (0.79.0)
69
- jaro_winkler (~> 1.5.1)
67
+ regexp_parser (1.8.1)
68
+ rexml (3.2.4)
69
+ rubocop (0.92.0)
70
70
  parallel (~> 1.10)
71
- parser (>= 2.7.0.1)
71
+ parser (>= 2.7.1.5)
72
72
  rainbow (>= 2.2.2, < 4.0)
73
+ regexp_parser (>= 1.7)
74
+ rexml
75
+ rubocop-ast (>= 0.5.0)
73
76
  ruby-progressbar (~> 1.7)
74
- unicode-display_width (>= 1.4.0, < 1.7)
75
- rubocop-performance (1.5.2)
76
- rubocop (>= 0.71.0)
77
+ unicode-display_width (>= 1.4.0, < 2.0)
78
+ rubocop-ast (0.7.0)
79
+ parser (>= 2.7.1.5)
80
+ strscan (>= 1.0.0)
81
+ rubocop-performance (1.8.1)
82
+ rubocop (>= 0.87.0)
83
+ rubocop-ast (>= 0.4.0)
77
84
  ruby-progressbar (1.10.1)
78
- standard (0.2.1)
79
- rubocop (~> 0.79.0)
80
- rubocop-performance (~> 1.5.1)
85
+ standard (0.7)
86
+ rubocop (= 0.92)
87
+ rubocop-performance (= 1.8.1)
88
+ strscan (1.0.3)
81
89
  thor (1.0.1)
82
90
  thread_safe (0.3.6)
83
- tzinfo (1.2.6)
91
+ tzinfo (1.2.7)
84
92
  thread_safe (~> 0.1)
85
- unicode-display_width (1.6.1)
86
- zeitwerk (2.3.0)
93
+ unicode-display_width (1.7.0)
94
+ zeitwerk (2.4.0)
87
95
 
88
96
  PLATFORMS
89
97
  ruby
90
98
 
91
99
  DEPENDENCIES
92
- bundler (~> 1.17)
100
+ bundler
93
101
  cypress-rails!
94
102
  minitest (~> 5.0)
95
103
  rake (~> 13.0)
96
104
  standard (>= 0.2.0)
97
105
 
98
106
  BUNDLED WITH
99
- 1.17.3
107
+ 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,14 +1,23 @@
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
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
- super
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
- 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
@@ -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.4"
2
+ VERSION = "0.4.1"
3
3
  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.1.4
4
+ version: 0.4.1
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-24 00:00:00.000000000 Z
11
+ date: 2020-10-13 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:
@@ -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.0.3
161
- signing_key:
160
+ rubygems_version: 3.1.2
161
+ signing_key:
162
162
  specification_version: 4
163
163
  summary: Helps you write Cypress tests of your Rails app
164
164
  test_files: []