cypress-on-rails 1.13.0 → 1.14.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: 4e692aca2d9231cc396238b157013e6208ab5522dcfc9de9a6db13eab6f2e432
4
- data.tar.gz: 9e131491dc1bbbdefeead03eda472b20bc2e2b9fb4c92e55a76fdda3cbb547a0
3
+ metadata.gz: be4a4a9207812860337d7976f7a97d1c9891f6d6f7f6e42c1b230d64983554db
4
+ data.tar.gz: d0c64c623d011387a8fd1462f7e51286709442e8486e4f474c41088c749803fc
5
5
  SHA512:
6
- metadata.gz: cb3f7b9e0496cd4033bd97b7c5c218f28af991fae0ab42e4fec7b23fad7a71103ea3a33cd0cf8c17c16095f7eacc0aca296b547bc559b8a833a688a62d9be88a
7
- data.tar.gz: 6cf57ee05e4b8f04000671969af5bf96c337ae2d69ff9df8cfaf1d99efac4d28f3f38cce1f7bf518db491b7a88a10265b82b1d8e0f96033de509f060d1e20b88
6
+ metadata.gz: 7b8ff159ab4deb96dca982e2a57abf0ec3db3e01176b9b4df866eaf04d7e113d05f6fa44c62366bc5e460bc4f3671034bd8bae9887ca17a32e9b426e753f029e
7
+ data.tar.gz: 7e7d86478a91503298e18242f2046641def314b8a0cc859ac7ac0e433d0dab01e57698b9766dd6342c7e81f7e83e5c1b0c338cdf1e837b9ef0fa5307a1904cd5
@@ -23,6 +23,8 @@ jobs:
23
23
  - run: gem install bundler -v '< 2'
24
24
  - name: Run interaction tests
25
25
  run: ./specs_e2e/rails_3_2/test.sh
26
+ env:
27
+ CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
26
28
 
27
29
  rails_4_2:
28
30
  runs-on: ubuntu-latest
@@ -40,6 +42,8 @@ jobs:
40
42
  - run: gem install bundler -v '< 2'
41
43
  - name: Run interaction tests
42
44
  run: ./specs_e2e/rails_4_2/test.sh
45
+ env:
46
+ CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
43
47
 
44
48
  rails_5_2:
45
49
  runs-on: ubuntu-latest
@@ -55,3 +59,5 @@ jobs:
55
59
  run: bundle exec rake
56
60
  - name: Run interaction tests
57
61
  run: ./specs_e2e/rails_5_2/test.sh
62
+ env:
63
+ CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
data/CHANGELOG.md CHANGED
@@ -1,3 +1,21 @@
1
+ ## [1.14.0]
2
+ [Compare]: https://github.com/shakacode/cypress-on-rails/compare/v1.13.1...v1.14.0
3
+
4
+ ### Changed
5
+ * Add support for proxy routes through `api_prefix` [PR 130](https://github.com/shakacode/cypress-on-rails/pull/130) by [RomainEndelin]
6
+
7
+ ### Fixed
8
+ * Properly copies the cypress_helper file when running the update generator [PR 117](https://github.com/shakacode/cypress-on-rails/pull/117) by [alvincrespo]
9
+
10
+ ### Tasks
11
+ * pass cypress record key to github action [PR 110](https://github.com/shakacode/cypress-on-rails/pull/110)
12
+
13
+ ## [1.13.1]
14
+ [Compare]: https://github.com/shakacode/cypress-on-rails/compare/v1.13.0...v1.13.1
15
+
16
+ ### Fixed
17
+ * use_vcr_middleware disabled by default [PR 109](https://github.com/shakacode/cypress-on-rails/pull/109)
18
+
1
19
  ## [1.13.0]
2
20
  [Compare]: https://github.com/shakacode/cypress-on-rails/compare/v1.12.1...v1.13.0
3
21
 
@@ -28,7 +46,7 @@
28
46
  [Compare]: https://github.com/shakacode/cypress-on-rails/compare/v1.10.1...v1.11.0
29
47
 
30
48
  ### Changed
31
- * improve app command logging on cypress
49
+ * improve app command logging on cypress
32
50
  * Allow build and build_list commands to be executed against factory bot [PR 87](https://github.com/shakacode/cypress-on-rails/pull/87) by [Alexander-Blair]
33
51
 
34
52
  ## [1.10.1]
data/README.md CHANGED
@@ -1,11 +1,12 @@
1
1
  # CypressOnRails
2
2
 
3
3
  ![Build Status](https://github.com/shakacode/cypress-on-rails/actions/workflows/ruby.yml/badge.svg)
4
+ [![cypress-on-rails](https://img.shields.io/endpoint?url=https://dashboard.cypress.io/badge/simple/2b6cjr/master&style=plastic&logo=cypress)](https://dashboard.cypress.io/projects/2b6cjr/runs)
4
5
  [![Gem Version](https://badge.fury.io/rb/cypress-on-rails.svg)](https://badge.fury.io/rb/cypress-on-rails)
5
6
 
6
7
  ----
7
8
 
8
- This project is sponsored by the software consulting firm [ShakaCode](https://www.shakacode.com), creator of the [React on Rails Gem](https://github.com/shakacode/react_on_rails). We focus on React (with TS or ReScript) front-ends, often with Ruby on Rails or Gatsby. See [our recent work](https://www.shakacode.com/recent-work) and [client engagement model](https://www.shakacode.com/blog/client-engagement-model/). Feel free to engage in discussions around this gem at our [Slack Channel](https://join.slack.com/t/reactrails/shared_invite/enQtNjY3NTczMjczNzYxLTlmYjdiZmY3MTVlMzU2YWE0OWM0MzNiZDI0MzdkZGFiZTFkYTFkOGVjODBmOWEyYWQ3MzA2NGE1YWJjNmVlMGE) or our [forum category for Cypress](https://forum.shakacode.com/c/cypress-on-rails/55).
9
+ This project is sponsored by the software consulting firm [ShakaCode](https://www.shakacode.com), creator of the [React on Rails Gem](https://github.com/shakacode/react_on_rails). We focus on React (with TS or ReScript) front-ends, often with Ruby on Rails or Gatsby. See [our recent work](https://www.shakacode.com/recent-work) and [client engagement model](https://www.shakacode.com/blog/client-engagement-model/). Feel free to engage in discussions around this gem at our [Slack Channel](https://join.slack.com/t/reactrails/shared_invite/enQtNjY3NTczMjczNzYxLTlmYjdiZmY3MTVlMzU2YWE0OWM0MzNiZDI0MzdkZGFiZTFkYTFkOGVjODBmOWEyYWQ3MzA2NGE1YWJjNmVlMGE) or our [forum category for Cypress](https://forum.shakacode.com/c/cypress-on-rails/55).
9
10
 
10
11
  Interested in joining a small team that loves open source? Check our [careers page](https://www.shakacode.com/career/).
11
12
 
@@ -13,6 +14,9 @@ Need help with cypress-on-rails? Contact [ShakaCode](mailto:justin@shakacode.com
13
14
 
14
15
  ----
15
16
 
17
+ # Playwright.dev support
18
+ We're working on full support for [Playwright.dev](https://playwright.dev/). See [issue #116](https://github.com/shakacode/cypress-on-rails/issues/116#issuecomment-1523946478) for details.
19
+
16
20
  # Totally new to Cypress?
17
21
  Suggest you first learn the basics of Cypress before attempting to integrate with Ruby on Rails
18
22
 
@@ -20,10 +24,10 @@ Suggest you first learn the basics of Cypress before attempting to integrate wit
20
24
 
21
25
  ## Overview
22
26
 
23
- Gem for using [cypress.io](http://github.com/cypress-io/) in Rails and ruby rack applications
24
- with the goal of controlling State as mentioned in [Cypress Best Practices](https://docs.cypress.io/guides/references/best-practices.html#Organizing-Tests-Logging-In-Controlling-State)
27
+ Gem for using [cypress.io](http://github.com/cypress-io/) in Rails and Ruby Rack applications
28
+ with the goal of controlling state as mentioned in [Cypress Best Practices](https://docs.cypress.io/guides/references/best-practices.html#Organizing-Tests-Logging-In-Controlling-State)
25
29
 
26
- It allows to run code in the application context when executing cypress tests.
30
+ It allows you to run code in the application context when executing cypress tests.
27
31
  Do things like:
28
32
  * use database_cleaner before each test
29
33
  * seed the database with default data for each test
@@ -42,7 +46,7 @@ Has examples of setting up state with:
42
46
 
43
47
  ## Installation
44
48
 
45
- Add this to your Gemfile:
49
+ Add this to your `Gemfile`:
46
50
 
47
51
  ```ruby
48
52
  group :test, :development do
@@ -58,6 +62,9 @@ bin/rails g cypress_on_rails:install
58
62
  # if you have/want a different cypress folder (default is cypress)
59
63
  bin/rails g cypress_on_rails:install --cypress_folder=spec/cypress
60
64
 
65
+ # if you target the Rails server with a path prefix to your URL
66
+ bin/rails g cypress_on_rails:install --api_prefix=/api
67
+
61
68
  # if you want to install cypress with npm
62
69
  bin/rails g cypress_on_rails:install --install_cypress_with=npm
63
70
 
@@ -70,26 +77,25 @@ bin/rails g cypress_on_rails:update
70
77
 
71
78
  The generator modifies/adds the following files/directory in your application:
72
79
  * `config/environments/test.rb`
73
- * `config/initializers/cypress_on_rails` used to configure CypressDev
80
+ * `config/initializers/cypress_on_rails.rb` used to configure Cypress on Rails
74
81
  * `spec/cypress/e2e/` contains your cypress tests
75
- * `spec/cypress/support/on-rails.js` contains CypressDev support code
76
- * `spec/cypress/app_commands/scenarios/` contains your CypressDev scenario definitions
77
- * `spec/cypress/cypress_helper.rb` contains helper code for CypressDev app commands
82
+ * `spec/cypress/support/on-rails.js` contains Cypress on Rails support code
83
+ * `spec/cypress/app_commands/scenarios/` contains your Cypress on Rails scenario definitions
84
+ * `spec/cypress/cypress_helper.rb` contains helper code for Cypress on Rails app commands
78
85
 
79
- if you are not using database_cleaner look at `spec/cypress/app_commands/clean.rb`.
80
- if you are not using factory_bot look at `spec/cypress/app_commands/factory_bot.rb`.
86
+ If you are not using `database_cleaner` look at `spec/cypress/app_commands/clean.rb`.
87
+ If you are not using `factory_bot` look at `spec/cypress/app_commands/factory_bot.rb`.
81
88
 
82
- Now you can create scenarios and commands that are plain ruby files that get loaded through middleware, the ruby sky is your limit.
89
+ Now you can create scenarios and commands that are plain Ruby files that get loaded through middleware, the ruby sky is your limit.
83
90
 
84
91
  ### Update your database.yml
85
92
 
86
- When writing cypress test on your local it's recommended to start your server in development mode so that changes you
87
- make are picked up without having to restart the server.
88
- It's recommend you update your database.yml to check if the CYPRESS environment variable is set and switch it to the test database
93
+ When running `cypress test` on your local computer it's recommended to start your server in development mode so that changes you
94
+ make are picked up without having to restart the server.
95
+ It's recommended you update your `database.yml` to check if the `CYPRESS` environment variable is set and switch it to the test database
89
96
  otherwise cypress will keep clearing your development database.
90
97
 
91
- for example:
92
-
98
+ For example:
93
99
  ```yaml
94
100
  development:
95
101
  <<: *default
@@ -112,9 +118,9 @@ Getting started on your local environment
112
118
  CYPRESS=1 bin/rails server -p 5017
113
119
 
114
120
  # in separate window start cypress
115
- yarn cypress open
121
+ yarn cypress open
116
122
  # or for npm
117
- node_modules/.bin/cypress open
123
+ node_modules/.bin/cypress open
118
124
  # or if you changed the cypress folder to spec/cypress
119
125
  yarn cypress open --project ./spec
120
126
  ```
@@ -127,7 +133,7 @@ How to run cypress on CI
127
133
 
128
134
  yarn run cypress run
129
135
  # or for npm
130
- node_modules/.bin/cypress run
136
+ node_modules/.bin/cypress run
131
137
  ```
132
138
 
133
139
  ### Example of using factory bot
@@ -136,8 +142,8 @@ You can run your [factory_bot](https://github.com/thoughtbot/factory_bot) direct
136
142
 
137
143
  ```js
138
144
  // spec/cypress/e2e/simple.cy.js
139
- describe('My First Test', function() {
140
- it('visit root', function() {
145
+ describe('My First Test', () => {
146
+ it('visit root', () => {
141
147
  // This calls to the backend to prepare the application state
142
148
  cy.appFactories([
143
149
  ['create_list', 'post', 10],
@@ -148,7 +154,7 @@ describe('My First Test', function() {
148
154
  // Visit the application under test
149
155
  cy.visit('/')
150
156
 
151
- cy.contains("Hello World")
157
+ cy.contains('Hello World')
152
158
 
153
159
  // Accessing result
154
160
  cy.appFactories([['create', 'invoice', { paid: false }]]).then((records) => {
@@ -157,9 +163,9 @@ describe('My First Test', function() {
157
163
  })
158
164
  })
159
165
  ```
160
- You can check the [association Docs](https://github.com/shakacode/cypress-on-rails/blob/master/docs/factory_bot_associations.md) on more ways to setup association with the correct data.
166
+ You can check the [association docs](docs/factory_bot_associations.md) on more ways to setup association with the correct data.
161
167
 
162
- In some cases, using static Cypress fixtures may not provide sufficient flexibility when mocking HTTP response bodies - it's possible to use `FactoryBot.build` to generate Ruby hashes that can then be used as mock JSON responses:
168
+ In some cases, using static Cypress fixtures may not provide sufficient flexibility when mocking HTTP response bodies. It's possible to use `FactoryBot.build` to generate Ruby hashes that can then be used as mock JSON responses:
163
169
  ```ruby
164
170
  FactoryBot.define do
165
171
  factory :some_web_response, class: Hash do
@@ -171,13 +177,13 @@ FactoryBot.define do
171
177
  end
172
178
  end
173
179
 
174
- FactoryBot.build(:some_web_response) => { 'id' => 123, 'name' => 'Mr Blobby', 'occupation' => 'Evil pink clown' }
180
+ FactoryBot.build(:some_web_response => { 'id' => 123, 'name' => 'Mr Blobby', 'occupation' => 'Evil pink clown' })
175
181
  ```
176
182
 
177
183
  This can then be combined with Cypress mocks:
178
184
  ```js
179
- describe('My First Test', function() {
180
- it('visit root', function() {
185
+ describe('My First Test', () => {
186
+ it('visit root', () => {
181
187
  // This calls to the backend to generate the mocked response
182
188
  cy.appFactories([
183
189
  ['build', 'some_web_response', { name: 'Baby Blobby' }]
@@ -190,12 +196,12 @@ describe('My First Test', function() {
190
196
  cy.visit('/')
191
197
  })
192
198
 
193
- cy.contains("Hello World")
199
+ cy.contains('Hello World')
194
200
  })
195
201
  })
196
202
  ```
197
203
 
198
- ### Example of loading rails test fixtures
204
+ ### Example of loading Rails test fixtures
199
205
  ```ruby
200
206
  # spec/cypress/app_commands/activerecord_fixtures.rb
201
207
  require "active_record/fixtures"
@@ -210,15 +216,15 @@ ActiveRecord::FixtureSet.create_fixtures(fixtures_dir, fixture_files)
210
216
 
211
217
  ```js
212
218
  // spec/cypress/e2e/simple.cy.js
213
- describe('My First Test', function() {
214
- it('visit root', function() {
219
+ describe('My First Test', () => {
220
+ it('visit root', () => {
215
221
  // This calls to the backend to prepare the application state
216
222
  cy.appFixtures()
217
223
 
218
224
  // Visit the application under test
219
225
  cy.visit('/')
220
226
 
221
- cy.contains("Hello World")
227
+ cy.contains('Hello World')
222
228
  })
223
229
  })
224
230
  ```
@@ -239,21 +245,21 @@ CypressOnRails::SmartFactoryWrapper.create(:profile, name: "Cypress Hill")
239
245
  Then reference the scenario in your test:
240
246
  ```js
241
247
  // spec/cypress/e2e/scenario_example.cy.js
242
- describe('My First Test', function() {
243
- it('visit root', function() {
248
+ describe('My First Test', () => {
249
+ it('visit root', () => {
244
250
  // This calls to the backend to prepare the application state
245
251
  cy.appScenario('basic')
246
252
 
247
253
  cy.visit('/profiles')
248
254
 
249
- cy.contains("Cypress Hill")
255
+ cy.contains('Cypress Hill')
250
256
  })
251
257
  })
252
258
  ```
253
259
 
254
260
  ### Example of using app commands
255
261
 
256
- create a ruby file in `spec/cypress/app_commands` directory:
262
+ Create a Ruby file in the `spec/cypress/app_commands` directory:
257
263
  ```ruby
258
264
  # spec/cypress/app_commands/load_seed.rb
259
265
  load "#{Rails.root}/db/seeds.rb"
@@ -262,10 +268,10 @@ load "#{Rails.root}/db/seeds.rb"
262
268
  Then reference the command in your test with `cy.app('load_seed')`:
263
269
  ```js
264
270
  // spec/cypress/e2e/simple.cy.js
265
- describe('My First Test', function() {
271
+ describe('My First Test', () => {
266
272
  beforeEach(() => { cy.app('load_seed') })
267
273
 
268
- it('visit root', function() {
274
+ it('visit root', () => {
269
275
  cy.visit('/')
270
276
 
271
277
  cy.contains("Seeds")
@@ -273,11 +279,11 @@ describe('My First Test', function() {
273
279
  })
274
280
  ```
275
281
 
276
- ## Expermintal Features (matching npm package)
282
+ ## Experimental Features (matching npm package)
277
283
 
278
- Please test and give feedback
284
+ Please test and give feedback.
279
285
 
280
- add the npm package:
286
+ Add the npm package:
281
287
 
282
288
  ```
283
289
  yarn add cypress-on-rails --dev
@@ -285,7 +291,7 @@ yarn add cypress-on-rails --dev
285
291
 
286
292
  ### for VCR
287
293
 
288
- This only works when you start the rails server with a single worker and single thread
294
+ This only works when you start the Rails server with a single worker and single thread
289
295
 
290
296
  #### setup
291
297
 
@@ -298,13 +304,13 @@ VCR.configure do |config|
298
304
  end
299
305
  ```
300
306
 
301
- Add to you `cypress/support/index.js`
307
+ Add to your `cypress/support/index.js`:
302
308
 
303
309
  ```js
304
310
  import 'cypress-on-rails/support/index'
305
311
  ```
306
312
 
307
- Add to you `clean.rb`
313
+ Add to your `cypress/app_commands/clean.rb`:
308
314
 
309
315
  ```ruby
310
316
  VCR.eject_cassette # make sure we no cassettes inserted before the next test starts
@@ -312,7 +318,7 @@ VCR.turn_off!
312
318
  WebMock.disable! if defined?(WebMock)
313
319
  ```
314
320
 
315
- Add to you `config/cypress_on_rails.rb`
321
+ Add to your `config/cypress_on_rails.rb`:
316
322
 
317
323
  ```ruby
318
324
  c.use_vcr_middleware = !Rails.env.production? && ENV['CYPRESS'].present?
@@ -324,10 +330,10 @@ You have `vcr_insert_cassette` and `vcr_eject_cassette` available. https://www.r
324
330
 
325
331
 
326
332
  ```js
327
- describe('My First Test', function() {
333
+ describe('My First Test', () => {
328
334
  beforeEach(() => { cy.app('load_seed') })
329
335
 
330
- it('visit root', function() {
336
+ it('visit root', () => {
331
337
  cy.app('clean') // have a look at cypress/app_commands/clean.rb
332
338
 
333
339
  cy.vcr_insert_cassette('cats', { record: "new_episodes" })
@@ -336,7 +342,7 @@ describe('My First Test', function() {
336
342
  cy.get('a').contains('Cats').click()
337
343
  cy.contains('Wikipedia has a recording of a cat meowing, because why not?')
338
344
 
339
- cy.vcr_eject_cassette();
345
+ cy.vcr_eject_cassette()
340
346
 
341
347
  cy.vcr_insert_cassette('cats')
342
348
  cy.visit('/using_vcr/record_cats')
@@ -362,30 +368,30 @@ use CypressOnRails::Middleware
362
368
  run MyApp
363
369
  ```
364
370
 
365
- add the following file to cypress
371
+ add the following file to Cypress
366
372
 
367
373
  ```js
368
374
  // test/cypress/support/on-rails.js
369
- // CypressOnRails: dont remove these command
370
- Cypress.Commands.add('appCommands', function (body) {
375
+ // CypressOnRails: don't remove these commands
376
+ Cypress.Commands.add('appCommands', (body) => {
371
377
  cy.request({
372
378
  method: 'POST',
373
- url: "/__cypress__/command",
379
+ url: '/__cypress__/command',
374
380
  body: JSON.stringify(body),
375
381
  log: true,
376
382
  failOnStatusCode: true
377
383
  })
378
384
  });
379
385
 
380
- Cypress.Commands.add('app', function (name, command_options) {
386
+ Cypress.Commands.add('app', (name, command_options) => {
381
387
  cy.appCommands({name: name, options: command_options})
382
388
  });
383
389
 
384
- Cypress.Commands.add('appScenario', function (name) {
390
+ Cypress.Commands.add('appScenario', (name) => {
385
391
  cy.app('scenarios/' + name)
386
392
  });
387
393
 
388
- Cypress.Commands.add('appFactories', function (options) {
394
+ Cypress.Commands.add('appFactories', (options) => {
389
395
  cy.app('factory_bot', options)
390
396
  });
391
397
  // CypressOnRails: end
@@ -396,6 +402,17 @@ beforeEach(() => {
396
402
  });
397
403
  ```
398
404
 
405
+ ## API Prefix
406
+
407
+ If your Rails server is exposed under a proxy, typically https://my-local.dev/api, you can use the `api_prefix` option.
408
+ In `config/initializers/cypress_on_rails.rb`, add this line:
409
+ ```ruby
410
+ CypressOnRails.configure do |c|
411
+ # ...
412
+ c.api_prefix = '/api'
413
+ end
414
+ ```
415
+
399
416
  ## Contributing
400
417
 
401
418
  1. Fork it ( https://github.com/shakacode/cypress-on-rails/fork )
@@ -404,14 +421,37 @@ beforeEach(() => {
404
421
  4. Push to the branch (`git push origin my-new-feature`)
405
422
  5. Create a new Pull Request
406
423
 
407
- # Supporters
408
-
409
- The following companies support this open source project, and ShakaCode uses their products! Justin writes React on Rails on [RubyMine](https://www.jetbrains.com/ruby/). We use [Scout](https://scoutapp.com/) to monitor the live performance of [HiChee.com](https://HiChee.com), [Rails AutoScale](https://railsautoscale.com) to scale the dynos of HiChee, and [HoneyBadger](https://www.honeybadger.io/) to monitor application errors. We love [BrowserStack](https://www.browserstack.com) to solve problems with oddball browsers.
410
-
411
- [![RubyMine](https://user-images.githubusercontent.com/1118459/114100597-3b0e3000-9860-11eb-9b12-73beb1a184b2.png)](https://www.jetbrains.com/ruby/)
412
- [![Scout](https://user-images.githubusercontent.com/1118459/171088197-81555b69-9ed0-4235-9acf-fcb37ecfb949.png)](https://scoutapp.com/)
413
- [![Rails AutoScale](https://user-images.githubusercontent.com/1118459/103197530-48dc0e80-488a-11eb-8b1b-a16664b30274.png)](https://railsautoscale.com/)
414
- [![BrowserStack](https://cloud.githubusercontent.com/assets/1118459/23203304/1261e468-f886-11e6-819e-93b1a3f17da4.png)](https://www.browserstack.com)
415
- [![HoneyBadger](https://user-images.githubusercontent.com/1118459/114100696-63962a00-9860-11eb-8ac1-75ca02856d8e.png)](https://www.honeybadger.io/)
416
-
417
- ShakaCode's favorite project tracking tool is [Shortcut](https://shortcut.com/). If you want to **try Shortcut and get 2 months free beyond the 14-day trial period**, click [here to use ShakaCode's referral code](http://r.clbh.se/mvfoNeH). We're participating in their awesome triple-sided referral program, which you can read about [here](https://shortcut.com/referral/). By using our [referral code](http://r.clbh.se/mvfoNeH) you'll be supporting ShakaCode and, thus, React on Rails!
424
+ ## Supporters
425
+
426
+ <a href="https://www.jetbrains.com">
427
+ <img src="https://user-images.githubusercontent.com/4244251/184881139-42e4076b-024b-4b30-8c60-c3cd0e758c0a.png" alt="JetBrains" height="120px">
428
+ </a>
429
+ <a href="https://scoutapp.com">
430
+ <picture>
431
+ <source media="(prefers-color-scheme: dark)" srcset="https://user-images.githubusercontent.com/4244251/184881147-0d077438-3978-40da-ace9-4f650d2efe2e.png">
432
+ <source media="(prefers-color-scheme: light)" srcset="https://user-images.githubusercontent.com/4244251/184881152-9f2d8fba-88ac-4ba6-873b-22387f8711c5.png">
433
+ <img alt="ScoutAPM" src="https://user-images.githubusercontent.com/4244251/184881152-9f2d8fba-88ac-4ba6-873b-22387f8711c5.png" height="120px">
434
+ </picture>
435
+ </a>
436
+ <br />
437
+ <a href="https://www.browserstack.com">
438
+ <picture>
439
+ <source media="(prefers-color-scheme: dark)" srcset="https://user-images.githubusercontent.com/4244251/184881122-407dcc29-df78-4b20-a9ad-f597b56f6cdb.png">
440
+ <source media="(prefers-color-scheme: light)" srcset="https://user-images.githubusercontent.com/4244251/184881129-e1edf4b7-3ae1-4ea8-9e6d-3595cf01609e.png">
441
+ <img alt="BrowserStack" src="https://user-images.githubusercontent.com/4244251/184881129-e1edf4b7-3ae1-4ea8-9e6d-3595cf01609e.png" height="55px">
442
+ </picture>
443
+ </a>
444
+ <a href="https://railsautoscale.com">
445
+ <img src="https://user-images.githubusercontent.com/4244251/184881144-95c2c25c-9879-4069-864d-4e67d6ed39d2.png" alt="Rails Autoscale" height="55px">
446
+ </a>
447
+ <a href="https://www.honeybadger.io">
448
+ <img src="https://user-images.githubusercontent.com/4244251/184881133-79ee9c3c-8165-4852-958e-31687b9536f4.png" alt="Honeybadger" height="55px">
449
+ </a>
450
+ <a href="https://reviewable.io">
451
+ <img src="https://user-images.githubusercontent.com/20628911/230848305-c94510a4-82d7-468f-bf9f-eeb81d3f2ce0.png" alt="Reviewable" height="55px">
452
+ </a>
453
+
454
+ <br />
455
+ <br />
456
+
457
+ The following companies support our open source projects, and ShakaCode uses their products!
@@ -1,6 +1,6 @@
1
1
  # Example for Authenticating a User
2
2
 
3
- in routes.rb
3
+ In `config/routes.rb`:
4
4
  ```rb
5
5
  Rails.application.routes.draw do
6
6
  # ...... your other routes
@@ -12,7 +12,7 @@ Rails.application.routes.draw do
12
12
  end
13
13
  ```
14
14
 
15
- app/controllers/cypress_controller.rb
15
+ `app/controllers/cypress_controller.rb`:
16
16
  ```rb
17
17
  class CypressController < ApplicationController
18
18
  skip_before_action :verify_authenticity_token
@@ -29,21 +29,23 @@ class CypressController < ApplicationController
29
29
  end
30
30
  ```
31
31
 
32
- in cypress/support/on-rails.js
32
+ In `cypress/support/on-rails.js`:
33
33
  ```js
34
- Cypress.Commands.add("forceLogin", (details) => {
35
- if(!details)
34
+ Cypress.Commands.add('forceLogin', (details) => {
35
+ if (!details) {
36
36
  details = {}
37
+ }
37
38
 
38
- if(!details.redirect_to)
39
+ if (!details.redirect_to) {
39
40
  details.redirect_to = '/'
41
+ }
40
42
 
41
- cy.visit("__cypress__/forceLogin",
42
- { method: "POST", body: { email: details.email, redirect_to: details.redirect_to } })
43
- });
43
+ cy.visit('__cypress__/forceLogin',
44
+ { method: 'POST', body: { email: details.email, redirect_to: details.redirect_to } })
45
+ })
44
46
  ```
45
47
 
46
- examples of usage in cypress specs
48
+ Examples of usage in Cypress specs:
47
49
  ```js
48
50
  cy.forceLogin()
49
51
  cy.forceLogin({redirect_to: '/profile'})
@@ -1,6 +1,6 @@
1
1
  # Setting up associations with the correct data
2
2
 
3
- You cannot access associations directly from Cypress like you can do with ruby tests.
3
+ You cannot access associations directly from Cypress like you can do with Ruby tests.
4
4
  So setting up associations has to be done differently from within Cypress.
5
5
 
6
6
  There are a few ways you can setup associations with the correct data using Cypress and FactoryBot.
@@ -27,7 +27,7 @@ You can do the following:
27
27
 
28
28
  ## 1. Setting the foreign keys
29
29
 
30
- factories.rb
30
+ `factories.rb`:
31
31
  ```rb
32
32
  FactoryBot.define do
33
33
  factory :author do
@@ -45,13 +45,13 @@ then in Cypress
45
45
  ```js
46
46
  // example with overriding the defaults
47
47
  cy.appFactories([['create', 'author', { name: 'James' }]]).then((records) => {
48
- cy.appFactories([['create', 'post', { title: 'Cypress is cool', author_id: records[0].id }]]
49
- });
48
+ cy.appFactories([['create', 'post', { title: 'Cypress is cool', author_id: records[0].id }]])
49
+ })
50
50
 
51
51
  // example without overriding anything
52
52
  cy.appFactories([['create', 'author']]).then((records) => {
53
- cy.appFactories([['create', 'post', { author_id: records[0].id }]]
54
- });
53
+ cy.appFactories([['create', 'post', { author_id: records[0].id }]])
54
+ })
55
55
  ```
56
56
 
57
57
  ## 2. Using transient attributes
@@ -75,10 +75,10 @@ end
75
75
  then in Cypress
76
76
  ```js
77
77
  // example with overriding the defaults
78
- cy.appFactories([['create', 'post', { title: 'Cypress is cool', author_name: 'James' }]]
78
+ cy.appFactories([['create', 'post', { title: 'Cypress is cool', author_name: 'James' }]])
79
79
 
80
80
  // example without overriding
81
- cy.appFactories([['create', 'post']]
81
+ cy.appFactories([['create', 'post']])
82
82
  ```
83
83
 
84
84
  ## 3. Using Nested Attributes
@@ -99,11 +99,11 @@ end
99
99
  then in Cypress
100
100
  ```js
101
101
  // example with overriding the defaults
102
- cy.appFactories([['create', 'post', { title: 'Cypress is cool', author_attributes: { name: 'James' } }]]
102
+ cy.appFactories([['create', 'post', { title: 'Cypress is cool', author_attributes: { name: 'James' } }]])
103
103
 
104
104
  // example without overriding
105
- cy.appFactories([['create', 'post']]
105
+ cy.appFactories([['create', 'post']])
106
106
 
107
107
  // example of creating author with multiple posts
108
- cy.appFactories([['create', 'author', { name: 'James', posts_attributes: [{ name: 'Cypress is cool' }, {name: 'Rails is awesome' }] ]]
108
+ cy.appFactories([['create', 'author', { name: 'James', posts_attributes: [{ name: 'Cypress is cool' }, {name: 'Rails is awesome' }] }]])
109
109
  ```
@@ -3,6 +3,7 @@ require 'logger'
3
3
  module CypressOnRails
4
4
  class Configuration
5
5
  attr_accessor :cypress_folder
6
+ attr_accessor :api_prefix
6
7
  attr_accessor :use_middleware
7
8
  attr_accessor :use_vcr_middleware
8
9
  attr_accessor :logger
@@ -16,8 +17,9 @@ module CypressOnRails
16
17
 
17
18
  def reset
18
19
  self.cypress_folder = 'spec/cypress'
20
+ self.api_prefix = ''
19
21
  self.use_middleware = true
20
- self.use_vcr_middleware = true
22
+ self.use_vcr_middleware = false
21
23
  self.logger = Logger.new(STDOUT)
22
24
  end
23
25
 
@@ -16,7 +16,7 @@ module CypressOnRails
16
16
 
17
17
  def call(env)
18
18
  request = Rack::Request.new(env)
19
- if request.path.start_with?('/__cypress__/command')
19
+ if request.path.start_with?("#{configuration.api_prefix}/__cypress__/command")
20
20
  configuration.tagged_logged { handle_command(request) }
21
21
  else
22
22
  @app.call(env)
@@ -1,3 +1,3 @@
1
1
  module CypressOnRails
2
- VERSION = '1.13.0'.freeze
2
+ VERSION = '1.14.0'.freeze
3
3
  end
@@ -1,6 +1,7 @@
1
1
  module CypressOnRails
2
2
  class InstallGenerator < Rails::Generators::Base
3
3
  class_option :cypress_folder, type: :string, default: 'cypress'
4
+ class_option :api_prefix, type: :string, default: ''
4
5
  class_option :install_cypress, type: :boolean, default: true
5
6
  class_option :install_cypress_with, type: :string, default: 'yarn'
6
7
  class_option :experimental, type: :boolean, default: false
@@ -5,6 +5,7 @@ if defined?(CypressOnRails)
5
5
  # please use with extra caution if enabling on hosted servers or starting your local server on 0.0.0.0
6
6
  c.use_middleware = !Rails.env.production?
7
7
  <% unless options.experimental %># <% end %> c.use_vcr_middleware = !Rails.env.production?
8
+ c.api_prefix = "<%= options.api_prefix %>"
8
9
  c.logger = Rails.logger
9
10
  end
10
11
 
@@ -5,7 +5,7 @@ module CypressOnRails
5
5
 
6
6
  def update_generated_files
7
7
  template "config/initializers/cypress_on_rails.rb.erb", "config/initializers/cypress_on_rails.rb"
8
- copy_file "spec/cypress/cypress_helper.rb", "#{options.cypress_folder}/cypress_helper.rb"
8
+ template "spec/cypress/cypress_helper.rb.erb", "#{options.cypress_folder}/cypress_helper.rb"
9
9
  copy_file "spec/cypress/support/on-rails.js", "#{options.cypress_folder}/support/on-rails.js"
10
10
  directory 'spec/cypress/app_commands', "#{options.cypress_folder}/app_commands"
11
11
  end
@@ -5,6 +5,7 @@ RSpec.describe CypressOnRails::Configuration do
5
5
  CypressOnRails.configure { |config| config.reset }
6
6
 
7
7
  expect(CypressOnRails.configuration.cypress_folder).to eq('spec/cypress')
8
+ expect(CypressOnRails.configuration.api_prefix).to eq('')
8
9
  expect(CypressOnRails.configuration.use_middleware?).to eq(true)
9
10
  expect(CypressOnRails.configuration.logger).to_not be_nil
10
11
  end
@@ -13,10 +14,12 @@ RSpec.describe CypressOnRails::Configuration do
13
14
  my_logger = Logger.new(STDOUT)
14
15
  CypressOnRails.configure do |config|
15
16
  config.cypress_folder = 'my/path'
17
+ config.api_prefix = '/api'
16
18
  config.use_middleware = false
17
19
  config.logger = my_logger
18
20
  end
19
21
  expect(CypressOnRails.configuration.cypress_folder).to eq('my/path')
22
+ expect(CypressOnRails.configuration.api_prefix).to eq('/api')
20
23
  expect(CypressOnRails.configuration.use_middleware?).to eq(false)
21
24
  expect(CypressOnRails.configuration.logger).to eq(my_logger)
22
25
  end
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cypress-on-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.13.0
4
+ version: 1.14.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - miceportal team
8
8
  - Grant Petersen-Speelman
9
- autorequire:
9
+ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2022-06-06 00:00:00.000000000 Z
12
+ date: 2023-05-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rack
@@ -330,8 +330,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
330
330
  - !ruby/object:Gem::Version
331
331
  version: '0'
332
332
  requirements: []
333
- rubygems_version: 3.2.22
334
- signing_key:
333
+ rubygems_version: 3.4.7
334
+ signing_key:
335
335
  specification_version: 4
336
336
  summary: Integrates cypress with rails or rack applications
337
337
  test_files: []