cypress-on-rails 1.12.0 → 1.13.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ruby.yml +3 -3
- data/.gitignore +4 -1
- data/CHANGELOG.md +22 -0
- data/README.md +92 -16
- data/cypress-on-rails.gemspec +1 -0
- data/docs/factory_bot_associations.md +109 -0
- data/lib/cypress-on-rails.rb +2 -2
- data/lib/cypress_on_rails/configuration.rb +3 -0
- data/lib/cypress_on_rails/middleware.rb +6 -10
- data/lib/cypress_on_rails/middleware_config.rb +17 -0
- data/lib/cypress_on_rails/railtie.rb +5 -1
- data/lib/cypress_on_rails/smart_factory_wrapper.rb +7 -4
- data/lib/cypress_on_rails/vcr_middleware.rb +73 -0
- data/lib/cypress_on_rails/version.rb +1 -1
- data/lib/generators/cypress_on_rails/install_generator.rb +18 -24
- data/lib/generators/cypress_on_rails/templates/config/initializers/cypress_on_rails.rb.erb +1 -0
- data/lib/generators/cypress_on_rails/templates/spec/cypress/app_commands/clean.rb +6 -0
- data/lib/generators/cypress_on_rails/templates/spec/cypress/{cypress_helper.rb → cypress_helper.rb.erb} +5 -0
- data/lib/generators/cypress_on_rails/templates/spec/cypress/{integration/rails_examples/advance_factory_bot_spec.js → e2e/rails_examples/advance_factory_bot.cy.js} +0 -0
- data/lib/generators/cypress_on_rails/templates/spec/cypress/{integration/rails_examples/other_spec.js → e2e/rails_examples/other.cy.js} +0 -0
- data/lib/generators/cypress_on_rails/templates/spec/cypress/{integration/rails_examples/using_factory_bot_spec.js → e2e/rails_examples/using_factory_bot.cy.js} +0 -0
- data/lib/generators/cypress_on_rails/templates/spec/cypress/{integration/rails_examples/using_fixtures_spec.js → e2e/rails_examples/using_fixtures.cy.js} +0 -0
- data/lib/generators/cypress_on_rails/templates/spec/cypress/{integration/rails_examples/using_scenarios_spec.js → e2e/rails_examples/using_scenarios.cy.js} +0 -0
- data/lib/generators/cypress_on_rails/templates/spec/cypress/e2e/rails_examples/using_vcr.cy.js +24 -0
- data/lib/generators/cypress_on_rails/templates/spec/cypress/support/{index.js → index.js.erb} +1 -0
- data/lib/generators/cypress_on_rails/templates/spec/cypress/support/on-rails.js +1 -1
- data/lib/generators/cypress_on_rails/templates/spec/cypress.config.js +9 -0
- data/plugin/.gitignore +1 -0
- data/plugin/cypress/plugins/index.js +4 -0
- data/plugin/package.json +31 -0
- data/plugin/support/index.js +37 -0
- data/spec/cypress_on_rails/middleware_spec.rb +3 -1
- data/spec/cypress_on_rails/vcr_middleware_spec.rb +119 -0
- data/specs_e2e/cypress.config.js +10 -0
- data/{spec/integrations → specs_e2e}/rails_3_2/.gitignore +1 -1
- data/specs_e2e/rails_3_2/.ruby_version +1 -0
- data/{spec/integrations → specs_e2e}/rails_3_2/Gemfile +1 -1
- data/{spec/integrations → specs_e2e}/rails_3_2/README.rdoc +0 -0
- data/{spec/integrations → specs_e2e}/rails_3_2/Rakefile +0 -0
- data/{spec/integrations → specs_e2e}/rails_3_2/app/assets/stylesheets/application.css +0 -0
- data/{spec/integrations → specs_e2e}/rails_3_2/app/controllers/application_controller.rb +0 -0
- data/{spec/integrations → specs_e2e}/rails_3_2/app/controllers/welcome_controller.rb +0 -0
- data/{spec/integrations → specs_e2e}/rails_3_2/app/helpers/application_helper.rb +0 -0
- data/{spec/integrations → specs_e2e}/rails_3_2/app/models/post.rb +0 -0
- data/{spec/integrations → specs_e2e}/rails_3_2/app/views/layouts/application.html.erb +0 -0
- data/{spec/integrations → specs_e2e}/rails_3_2/app/views/welcome/index.html.erb +0 -0
- data/{spec/integrations → specs_e2e}/rails_3_2/bin/rails +0 -0
- data/{spec/integrations → specs_e2e}/rails_3_2/config/application.rb +0 -0
- data/{spec/integrations → specs_e2e}/rails_3_2/config/boot.rb +0 -0
- data/{spec/integrations → specs_e2e}/rails_3_2/config/environment.rb +0 -0
- data/{spec/integrations → specs_e2e}/rails_3_2/config/environments/development.rb +0 -0
- data/{spec/integrations → specs_e2e}/rails_3_2/config/environments/production.rb +0 -0
- data/{spec/integrations → specs_e2e}/rails_3_2/config/environments/test.rb +0 -0
- data/{spec/integrations → specs_e2e}/rails_3_2/config/initializers/backtrace_silencers.rb +0 -0
- data/{spec/integrations → specs_e2e}/rails_3_2/config/initializers/inflections.rb +0 -0
- data/{spec/integrations → specs_e2e}/rails_3_2/config/initializers/mime_types.rb +0 -0
- data/{spec/integrations → specs_e2e}/rails_3_2/config/initializers/secret_token.rb +0 -0
- data/{spec/integrations → specs_e2e}/rails_3_2/config/initializers/session_store.rb +0 -0
- data/{spec/integrations → specs_e2e}/rails_3_2/config/initializers/wrap_parameters.rb +0 -0
- data/{spec/integrations → specs_e2e}/rails_3_2/config/locales/en.yml +0 -0
- data/{spec/integrations → specs_e2e}/rails_3_2/config/routes.rb +0 -0
- data/{spec/integrations → specs_e2e}/rails_3_2/config.ru +0 -0
- data/{spec/integrations → specs_e2e}/rails_3_2/log/.keep +0 -0
- data/{spec/integrations → specs_e2e}/rails_3_2/public/404.html +0 -0
- data/{spec/integrations → specs_e2e}/rails_3_2/public/422.html +0 -0
- data/{spec/integrations → specs_e2e}/rails_3_2/public/500.html +0 -0
- data/{spec/integrations → specs_e2e}/rails_3_2/public/favicon.ico +0 -0
- data/{spec/integrations → specs_e2e}/rails_3_2/public/robots.txt +0 -0
- data/{spec/integrations → specs_e2e}/rails_3_2/test.sh +8 -7
- data/{spec/integrations → specs_e2e}/rails_3_2/tmp/.keep +0 -0
- data/{spec/integrations → specs_e2e}/rails_3_2/vendor/.gitkeep +0 -0
- data/{spec/integrations → specs_e2e}/rails_4_2/.gitignore +3 -2
- data/{spec/integrations → specs_e2e}/rails_4_2/Gemfile +3 -1
- data/{spec/integrations → specs_e2e}/rails_4_2/README.rdoc +0 -0
- data/{spec/integrations → specs_e2e}/rails_4_2/Rakefile +0 -0
- data/{spec/integrations/rails_5_2/app/assets/javascripts/posts.js → specs_e2e/rails_4_2/app/assets/javascripts/using_vcr.js} +0 -0
- data/{spec/integrations/rails_5_2/app/assets/stylesheets/posts.css → specs_e2e/rails_4_2/app/assets/stylesheets/using_vcr.css} +0 -0
- data/{spec/integrations → specs_e2e}/rails_4_2/app/controllers/application_controller.rb +0 -0
- data/specs_e2e/rails_4_2/app/controllers/using_vcr_controller.rb +10 -0
- data/{spec/integrations → specs_e2e}/rails_4_2/app/controllers/welcome_controller.rb +0 -0
- data/{spec/integrations → specs_e2e}/rails_4_2/app/models/post.rb +3 -1
- data/{spec/integrations → specs_e2e}/rails_4_2/app/views/layouts/application.html.erb +0 -0
- data/specs_e2e/rails_4_2/app/views/using_vcr/index.html.erb +6 -0
- data/specs_e2e/rails_4_2/app/views/using_vcr/record_cats.html.erb +7 -0
- data/{spec/integrations → specs_e2e}/rails_4_2/app/views/welcome/index.html.erb +0 -0
- data/{spec/integrations → specs_e2e}/rails_4_2/bin/bundle +0 -0
- data/{spec/integrations → specs_e2e}/rails_4_2/bin/rails +0 -0
- data/{spec/integrations → specs_e2e}/rails_4_2/bin/rake +0 -0
- data/{spec/integrations → specs_e2e}/rails_4_2/bin/setup +0 -0
- data/{spec/integrations → specs_e2e}/rails_4_2/config/application.rb +0 -0
- data/{spec/integrations → specs_e2e}/rails_4_2/config/boot.rb +0 -0
- data/{spec/integrations → specs_e2e}/rails_4_2/config/environment.rb +0 -0
- data/{spec/integrations → specs_e2e}/rails_4_2/config/environments/development.rb +0 -0
- data/{spec/integrations → specs_e2e}/rails_4_2/config/environments/production.rb +0 -0
- data/{spec/integrations → specs_e2e}/rails_4_2/config/environments/test.rb +0 -0
- data/{spec/integrations → specs_e2e}/rails_4_2/config/initializers/backtrace_silencers.rb +0 -0
- data/{spec/integrations → specs_e2e}/rails_4_2/config/initializers/cookies_serializer.rb +0 -0
- data/{spec/integrations → specs_e2e}/rails_4_2/config/initializers/filter_parameter_logging.rb +0 -0
- data/{spec/integrations → specs_e2e}/rails_4_2/config/initializers/inflections.rb +0 -0
- data/{spec/integrations → specs_e2e}/rails_4_2/config/initializers/mime_types.rb +0 -0
- data/{spec/integrations → specs_e2e}/rails_4_2/config/initializers/session_store.rb +0 -0
- data/{spec/integrations → specs_e2e}/rails_4_2/config/initializers/to_time_preserves_timezone.rb +0 -0
- data/{spec/integrations → specs_e2e}/rails_4_2/config/initializers/wrap_parameters.rb +0 -0
- data/{spec/integrations → specs_e2e}/rails_4_2/config/locales/en.yml +0 -0
- data/{spec/integrations → specs_e2e}/rails_4_2/config/routes.rb +5 -0
- data/{spec/integrations → specs_e2e}/rails_4_2/config/secrets.yml +0 -0
- data/{spec/integrations → specs_e2e}/rails_4_2/config.ru +0 -0
- data/specs_e2e/rails_4_2/package.json +10 -0
- data/{spec/integrations → specs_e2e}/rails_4_2/public/404.html +0 -0
- data/{spec/integrations → specs_e2e}/rails_4_2/public/422.html +0 -0
- data/{spec/integrations → specs_e2e}/rails_4_2/public/500.html +0 -0
- data/{spec/integrations → specs_e2e}/rails_4_2/public/favicon.ico +0 -0
- data/{spec/integrations → specs_e2e}/rails_4_2/public/robots.txt +0 -0
- data/{spec/integrations/rails_4_2/log → specs_e2e/rails_4_2/spec}/.keep +0 -0
- data/{spec/integrations → specs_e2e}/rails_4_2/test.sh +13 -12
- data/{spec/integrations/rails_4_2/spec → specs_e2e/rails_4_2/vendor}/.keep +0 -0
- data/{spec/integrations → specs_e2e}/rails_5_2/.gitignore +1 -1
- data/{spec/integrations → specs_e2e}/rails_5_2/Gemfile +1 -1
- data/{spec/integrations → specs_e2e}/rails_5_2/README.md +0 -0
- data/{spec/integrations → specs_e2e}/rails_5_2/Rakefile +0 -0
- data/specs_e2e/rails_5_2/app/assets/javascripts/posts.js +2 -0
- data/specs_e2e/rails_5_2/app/assets/stylesheets/posts.css +4 -0
- data/{spec/integrations → specs_e2e}/rails_5_2/app/assets/stylesheets/scaffold.css +0 -0
- data/{spec/integrations → specs_e2e}/rails_5_2/app/controllers/application_controller.rb +0 -0
- data/{spec/integrations → specs_e2e}/rails_5_2/app/controllers/posts_controller.rb +0 -0
- data/{spec/integrations → specs_e2e}/rails_5_2/app/helpers/posts_helper.rb +0 -0
- data/{spec/integrations → specs_e2e}/rails_5_2/app/jobs/application_job.rb +0 -0
- data/{spec/integrations → specs_e2e}/rails_5_2/app/models/application_record.rb +0 -0
- data/{spec/integrations → specs_e2e}/rails_5_2/app/models/post.rb +0 -0
- data/{spec/integrations → specs_e2e}/rails_5_2/app/views/layouts/application.html.erb +0 -0
- data/{spec/integrations → specs_e2e}/rails_5_2/app/views/posts/_form.html.erb +0 -0
- data/{spec/integrations → specs_e2e}/rails_5_2/app/views/posts/edit.html.erb +0 -0
- data/{spec/integrations → specs_e2e}/rails_5_2/app/views/posts/index.html.erb +0 -0
- data/{spec/integrations → specs_e2e}/rails_5_2/app/views/posts/new.html.erb +0 -0
- data/{spec/integrations → specs_e2e}/rails_5_2/app/views/posts/show.html.erb +0 -0
- data/{spec/integrations → specs_e2e}/rails_5_2/app/views/welcome/index.html.erb +0 -0
- data/{spec/integrations → specs_e2e}/rails_5_2/bin/bundle +0 -0
- data/{spec/integrations → specs_e2e}/rails_5_2/bin/rails +0 -0
- data/{spec/integrations → specs_e2e}/rails_5_2/bin/rake +0 -0
- data/{spec/integrations → specs_e2e}/rails_5_2/bin/setup +0 -0
- data/{spec/integrations → specs_e2e}/rails_5_2/bin/update +0 -0
- data/{spec/integrations → specs_e2e}/rails_5_2/config/application.rb +0 -0
- data/{spec/integrations → specs_e2e}/rails_5_2/config/boot.rb +0 -0
- data/{spec/integrations → specs_e2e}/rails_5_2/config/credentials.yml.enc +0 -0
- data/{spec/integrations → specs_e2e}/rails_5_2/config/database.yml +0 -0
- data/{spec/integrations → specs_e2e}/rails_5_2/config/environment.rb +0 -0
- data/{spec/integrations → specs_e2e}/rails_5_2/config/environments/development.rb +0 -0
- data/{spec/integrations → specs_e2e}/rails_5_2/config/environments/production.rb +0 -0
- data/{spec/integrations → specs_e2e}/rails_5_2/config/environments/test.rb +0 -0
- data/{spec/integrations → specs_e2e}/rails_5_2/config/initializers/application_controller_renderer.rb +0 -0
- data/{spec/integrations → specs_e2e}/rails_5_2/config/initializers/backtrace_silencers.rb +0 -0
- data/{spec/integrations → specs_e2e}/rails_5_2/config/initializers/content_security_policy.rb +0 -0
- data/{spec/integrations → specs_e2e}/rails_5_2/config/initializers/cookies_serializer.rb +0 -0
- data/{spec/integrations → specs_e2e}/rails_5_2/config/initializers/filter_parameter_logging.rb +0 -0
- data/{spec/integrations → specs_e2e}/rails_5_2/config/initializers/inflections.rb +0 -0
- data/{spec/integrations → specs_e2e}/rails_5_2/config/initializers/mime_types.rb +0 -0
- data/{spec/integrations → specs_e2e}/rails_5_2/config/initializers/wrap_parameters.rb +0 -0
- data/{spec/integrations → specs_e2e}/rails_5_2/config/locales/en.yml +0 -0
- data/{spec/integrations → specs_e2e}/rails_5_2/config/master.key +0 -0
- data/{spec/integrations → specs_e2e}/rails_5_2/config/routes.rb +0 -0
- data/{spec/integrations → specs_e2e}/rails_5_2/config.ru +0 -0
- data/{spec/integrations → specs_e2e}/rails_5_2/db/migrate/20180621085832_create_posts.rb +0 -0
- data/{spec/integrations → specs_e2e}/rails_5_2/public/404.html +0 -0
- data/{spec/integrations → specs_e2e}/rails_5_2/public/422.html +0 -0
- data/{spec/integrations → specs_e2e}/rails_5_2/public/500.html +0 -0
- data/{spec/integrations → specs_e2e}/rails_5_2/public/apple-touch-icon-precomposed.png +0 -0
- data/{spec/integrations → specs_e2e}/rails_5_2/public/apple-touch-icon.png +0 -0
- data/{spec/integrations → specs_e2e}/rails_5_2/public/favicon.ico +0 -0
- data/{spec/integrations → specs_e2e}/rails_5_2/public/robots.txt +0 -0
- data/{spec/integrations → specs_e2e}/rails_5_2/test/controllers/posts_controller_test.rb +0 -0
- data/{spec/integrations → specs_e2e}/rails_5_2/test/cypress_fixtures/posts.yml +0 -0
- data/{spec/integrations → specs_e2e}/rails_5_2/test/fixtures/posts.yml +0 -0
- data/{spec/integrations → specs_e2e}/rails_5_2/test/models/post_test.rb +0 -0
- data/{spec/integrations → specs_e2e}/rails_5_2/test.sh +8 -7
- data/{spec/integrations/rails_4_2 → specs_e2e/rails_5_2}/vendor/.keep +0 -0
- metadata +178 -171
- data/lib/generators/cypress_on_rails/templates/spec/cypress/fixtures/example.json +0 -5
- data/lib/generators/cypress_on_rails/templates/spec/cypress/integration/examples/actions.spec.js +0 -272
- data/lib/generators/cypress_on_rails/templates/spec/cypress/integration/examples/aliasing.spec.js +0 -42
- data/lib/generators/cypress_on_rails/templates/spec/cypress/integration/examples/assertions.spec.js +0 -63
- data/lib/generators/cypress_on_rails/templates/spec/cypress/integration/examples/connectors.spec.js +0 -55
- data/lib/generators/cypress_on_rails/templates/spec/cypress/integration/examples/cookies.spec.js +0 -78
- data/lib/generators/cypress_on_rails/templates/spec/cypress/integration/examples/cypress_api.spec.js +0 -211
- data/lib/generators/cypress_on_rails/templates/spec/cypress/integration/examples/files.spec.js +0 -86
- data/lib/generators/cypress_on_rails/templates/spec/cypress/integration/examples/local_storage.spec.js +0 -52
- data/lib/generators/cypress_on_rails/templates/spec/cypress/integration/examples/location.spec.js +0 -32
- data/lib/generators/cypress_on_rails/templates/spec/cypress/integration/examples/misc.spec.js +0 -68
- data/lib/generators/cypress_on_rails/templates/spec/cypress/integration/examples/navigation.spec.js +0 -54
- data/lib/generators/cypress_on_rails/templates/spec/cypress/integration/examples/network_requests.spec.js +0 -108
- data/lib/generators/cypress_on_rails/templates/spec/cypress/integration/examples/querying.spec.js +0 -65
- data/lib/generators/cypress_on_rails/templates/spec/cypress/integration/examples/spies_stubs_clocks.spec.js +0 -62
- data/lib/generators/cypress_on_rails/templates/spec/cypress/integration/examples/traversal.spec.js +0 -121
- data/lib/generators/cypress_on_rails/templates/spec/cypress/integration/examples/utilities.spec.js +0 -89
- data/lib/generators/cypress_on_rails/templates/spec/cypress/integration/examples/viewport.spec.js +0 -59
- data/lib/generators/cypress_on_rails/templates/spec/cypress/integration/examples/waiting.spec.js +0 -34
- data/lib/generators/cypress_on_rails/templates/spec/cypress/integration/examples/window.spec.js +0 -22
- data/lib/generators/cypress_on_rails/templates/spec/cypress.json +0 -4
- data/spec/integrations/cypress.json +0 -5
- data/spec/integrations/rails_5_2/log/.keep +0 -0
- data/spec/integrations/rails_5_2/tmp/.keep +0 -0
- data/spec/integrations/rails_5_2/vendor/.keep +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f65fc72c40d5d7016113ff6af471a1557de37b794a6812d8a03bcd9f16d78917
|
4
|
+
data.tar.gz: 14fc7d218866e99cd51970b587782d9a66eca9dc7face4b497f3035c3e17a587
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ac7fd90c3ba3748bb4a4aaae00615abfad1f2046fd8358f1d674e3e9086abd34489fd1b07fec4c043fd9e588600aaf9f6bc3c0328c7cdf99b598d221d710a7f6
|
7
|
+
data.tar.gz: 7b7d371e24aea239174384b9f5fddfa218739e15f5f01256f42821f6ebfbaf42e914404b8dfeab68e77444792ca79226c6f756cbc23e1833dc6d47db2935c215
|
data/.github/workflows/ruby.yml
CHANGED
@@ -22,7 +22,7 @@ jobs:
|
|
22
22
|
- run: gem uninstall -v '>= 2' -ax bundler || true
|
23
23
|
- run: gem install bundler -v '< 2'
|
24
24
|
- name: Run interaction tests
|
25
|
-
run: ./
|
25
|
+
run: ./specs_e2e/rails_3_2/test.sh
|
26
26
|
|
27
27
|
rails_4_2:
|
28
28
|
runs-on: ubuntu-latest
|
@@ -39,7 +39,7 @@ jobs:
|
|
39
39
|
- run: gem uninstall -v '>= 2' -ax bundler || true
|
40
40
|
- run: gem install bundler -v '< 2'
|
41
41
|
- name: Run interaction tests
|
42
|
-
run: ./
|
42
|
+
run: ./specs_e2e/rails_4_2/test.sh
|
43
43
|
|
44
44
|
rails_5_2:
|
45
45
|
runs-on: ubuntu-latest
|
@@ -54,4 +54,4 @@ jobs:
|
|
54
54
|
- name: Run tests
|
55
55
|
run: bundle exec rake
|
56
56
|
- name: Run interaction tests
|
57
|
-
run: ./
|
57
|
+
run: ./specs_e2e/rails_5_2/test.sh
|
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,25 @@
|
|
1
|
+
## [1.13.1]
|
2
|
+
[Compare]: https://github.com/shakacode/cypress-on-rails/compare/v1.13.0...v1.13.1
|
3
|
+
|
4
|
+
### Fixed
|
5
|
+
* use_vcr_middleware disabled by default [PR 109](https://github.com/shakacode/cypress-on-rails/pull/109)
|
6
|
+
|
7
|
+
## [1.13.0]
|
8
|
+
[Compare]: https://github.com/shakacode/cypress-on-rails/compare/v1.12.1...v1.13.0
|
9
|
+
|
10
|
+
### Changed
|
11
|
+
* Add support for matching npm package and VCR
|
12
|
+
* generate for cypress 10 [PR 108](https://github.com/shakacode/cypress-on-rails/pull/108)
|
13
|
+
|
14
|
+
## [1.12.1]
|
15
|
+
[Compare]: https://github.com/shakacode/cypress-on-rails/compare/v1.12.0...v1.12.1
|
16
|
+
|
17
|
+
### Tasks
|
18
|
+
* Documenting how to setup Factory Associations [PR 100](https://github.com/shakacode/cypress-on-rails/pull/100)
|
19
|
+
|
20
|
+
### Fixed
|
21
|
+
* keep track of factory manual reloads to prevent auto_reload from reloading again [PR 98](https://github.com/shakacode/cypress-on-rails/pull/98)
|
22
|
+
|
1
23
|
## [1.12.0]
|
2
24
|
[Compare]: https://github.com/shakacode/cypress-on-rails/compare/v1.11.0...v1.12.0
|
3
25
|
|
data/README.md
CHANGED
@@ -9,6 +9,8 @@ This project is sponsored by the software consulting firm [ShakaCode](https://ww
|
|
9
9
|
|
10
10
|
Interested in joining a small team that loves open source? Check our [careers page](https://www.shakacode.com/career/).
|
11
11
|
|
12
|
+
Need help with cypress-on-rails? Contact [ShakaCode](mailto:justin@shakacode.com).
|
13
|
+
|
12
14
|
----
|
13
15
|
|
14
16
|
# Totally new to Cypress?
|
@@ -69,7 +71,7 @@ bin/rails g cypress_on_rails:update
|
|
69
71
|
The generator modifies/adds the following files/directory in your application:
|
70
72
|
* `config/environments/test.rb`
|
71
73
|
* `config/initializers/cypress_on_rails` used to configure CypressDev
|
72
|
-
* `spec/cypress/
|
74
|
+
* `spec/cypress/e2e/` contains your cypress tests
|
73
75
|
* `spec/cypress/support/on-rails.js` contains CypressDev support code
|
74
76
|
* `spec/cypress/app_commands/scenarios/` contains your CypressDev scenario definitions
|
75
77
|
* `spec/cypress/cypress_helper.rb` contains helper code for CypressDev app commands
|
@@ -132,19 +134,8 @@ node_modules/.bin/cypress run
|
|
132
134
|
|
133
135
|
You can run your [factory_bot](https://github.com/thoughtbot/factory_bot) directly as well
|
134
136
|
|
135
|
-
```ruby
|
136
|
-
# spec/cypress/app_commands/factory_bot.rb
|
137
|
-
require 'cypress_on_rails/smart_factory_wrapper'
|
138
|
-
|
139
|
-
CypressOnRails::SmartFactoryWrapper.configure(
|
140
|
-
always_reload: !Rails.configuration.cache_classes,
|
141
|
-
factory: FactoryBot,
|
142
|
-
files: Dir['./spec/factories/**/*.rb']
|
143
|
-
)
|
144
|
-
```
|
145
|
-
|
146
137
|
```js
|
147
|
-
// spec/cypress/
|
138
|
+
// spec/cypress/e2e/simple.cy.js
|
148
139
|
describe('My First Test', function() {
|
149
140
|
it('visit root', function() {
|
150
141
|
// This calls to the backend to prepare the application state
|
@@ -166,6 +157,7 @@ describe('My First Test', function() {
|
|
166
157
|
})
|
167
158
|
})
|
168
159
|
```
|
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.
|
169
161
|
|
170
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:
|
171
163
|
```ruby
|
@@ -217,7 +209,7 @@ ActiveRecord::FixtureSet.create_fixtures(fixtures_dir, fixture_files)
|
|
217
209
|
```
|
218
210
|
|
219
211
|
```js
|
220
|
-
// spec/cypress/
|
212
|
+
// spec/cypress/e2e/simple.cy.js
|
221
213
|
describe('My First Test', function() {
|
222
214
|
it('visit root', function() {
|
223
215
|
// This calls to the backend to prepare the application state
|
@@ -246,7 +238,7 @@ CypressOnRails::SmartFactoryWrapper.create(:profile, name: "Cypress Hill")
|
|
246
238
|
|
247
239
|
Then reference the scenario in your test:
|
248
240
|
```js
|
249
|
-
// spec/cypress/
|
241
|
+
// spec/cypress/e2e/scenario_example.cy.js
|
250
242
|
describe('My First Test', function() {
|
251
243
|
it('visit root', function() {
|
252
244
|
// This calls to the backend to prepare the application state
|
@@ -269,7 +261,7 @@ load "#{Rails.root}/db/seeds.rb"
|
|
269
261
|
|
270
262
|
Then reference the command in your test with `cy.app('load_seed')`:
|
271
263
|
```js
|
272
|
-
// spec/cypress/
|
264
|
+
// spec/cypress/e2e/simple.cy.js
|
273
265
|
describe('My First Test', function() {
|
274
266
|
beforeEach(() => { cy.app('load_seed') })
|
275
267
|
|
@@ -281,6 +273,78 @@ describe('My First Test', function() {
|
|
281
273
|
})
|
282
274
|
```
|
283
275
|
|
276
|
+
## Expermintal Features (matching npm package)
|
277
|
+
|
278
|
+
Please test and give feedback
|
279
|
+
|
280
|
+
add the npm package:
|
281
|
+
|
282
|
+
```
|
283
|
+
yarn add cypress-on-rails --dev
|
284
|
+
```
|
285
|
+
|
286
|
+
### for VCR
|
287
|
+
|
288
|
+
This only works when you start the rails server with a single worker and single thread
|
289
|
+
|
290
|
+
#### setup
|
291
|
+
|
292
|
+
Add your VCR configuration to your `cypress_helper.rb`
|
293
|
+
|
294
|
+
```ruby
|
295
|
+
require 'vcr'
|
296
|
+
VCR.configure do |config|
|
297
|
+
config.hook_into :webmock
|
298
|
+
end
|
299
|
+
```
|
300
|
+
|
301
|
+
Add to you `cypress/support/index.js`
|
302
|
+
|
303
|
+
```js
|
304
|
+
import 'cypress-on-rails/support/index'
|
305
|
+
```
|
306
|
+
|
307
|
+
Add to you `clean.rb`
|
308
|
+
|
309
|
+
```ruby
|
310
|
+
VCR.eject_cassette # make sure we no cassettes inserted before the next test starts
|
311
|
+
VCR.turn_off!
|
312
|
+
WebMock.disable! if defined?(WebMock)
|
313
|
+
```
|
314
|
+
|
315
|
+
Add to you `config/cypress_on_rails.rb`
|
316
|
+
|
317
|
+
```ruby
|
318
|
+
c.use_vcr_middleware = !Rails.env.production? && ENV['CYPRESS'].present?
|
319
|
+
```
|
320
|
+
|
321
|
+
#### usage
|
322
|
+
|
323
|
+
You have `vcr_insert_cassette` and `vcr_eject_cassette` available. https://www.rubydoc.info/github/vcr/vcr/VCR:insert_cassette
|
324
|
+
|
325
|
+
|
326
|
+
```js
|
327
|
+
describe('My First Test', function() {
|
328
|
+
beforeEach(() => { cy.app('load_seed') })
|
329
|
+
|
330
|
+
it('visit root', function() {
|
331
|
+
cy.app('clean') // have a look at cypress/app_commands/clean.rb
|
332
|
+
|
333
|
+
cy.vcr_insert_cassette('cats', { record: "new_episodes" })
|
334
|
+
cy.visit('/using_vcr/index')
|
335
|
+
|
336
|
+
cy.get('a').contains('Cats').click()
|
337
|
+
cy.contains('Wikipedia has a recording of a cat meowing, because why not?')
|
338
|
+
|
339
|
+
cy.vcr_eject_cassette();
|
340
|
+
|
341
|
+
cy.vcr_insert_cassette('cats')
|
342
|
+
cy.visit('/using_vcr/record_cats')
|
343
|
+
cy.contains('Wikipedia has a recording of a cat meowing, because why not?')
|
344
|
+
})
|
345
|
+
})
|
346
|
+
```
|
347
|
+
|
284
348
|
## Usage with other rack applications
|
285
349
|
|
286
350
|
Add CypressOnRails to your config.ru
|
@@ -339,3 +403,15 @@ beforeEach(() => {
|
|
339
403
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
340
404
|
4. Push to the branch (`git push origin my-new-feature`)
|
341
405
|
5. Create a new Pull Request
|
406
|
+
|
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!
|
data/cypress-on-rails.gemspec
CHANGED
@@ -20,6 +20,7 @@ Gem::Specification.new do |s|
|
|
20
20
|
s.add_development_dependency 'rspec'
|
21
21
|
s.add_development_dependency 'railties', '>= 3.2'
|
22
22
|
s.add_development_dependency 'factory_bot'
|
23
|
+
s.add_development_dependency 'vcr'
|
23
24
|
s.metadata = {
|
24
25
|
"bug_tracker_uri" => "https://github.com/shakacode/cypress-on-rails/issues",
|
25
26
|
"changelog_uri" => "https://github.com/shakacode/cypress-on-rails/blob/master/CHANGELOG.md",
|
@@ -0,0 +1,109 @@
|
|
1
|
+
# Setting up associations with the correct data
|
2
|
+
|
3
|
+
You cannot access associations directly from Cypress like you can do with ruby tests.
|
4
|
+
So setting up associations has to be done differently from within Cypress.
|
5
|
+
|
6
|
+
There are a few ways you can setup associations with the correct data using Cypress and FactoryBot.
|
7
|
+
1. Setting the foreign keys
|
8
|
+
2. Using transient attributes
|
9
|
+
3. Using Nested Attributes
|
10
|
+
4. Combination of the above depending on your situation
|
11
|
+
|
12
|
+
Assuming you have the following models
|
13
|
+
|
14
|
+
```rb
|
15
|
+
class Post < ApplicationRecord
|
16
|
+
belongs_to :author
|
17
|
+
accepts_nested_attributes_for :author
|
18
|
+
end
|
19
|
+
|
20
|
+
class Author < ApplicationRecord
|
21
|
+
has_many :posts
|
22
|
+
accepts_nested_attributes_for :posts
|
23
|
+
end
|
24
|
+
```
|
25
|
+
|
26
|
+
You can do the following:
|
27
|
+
|
28
|
+
## 1. Setting the foreign keys
|
29
|
+
|
30
|
+
factories.rb
|
31
|
+
```rb
|
32
|
+
FactoryBot.define do
|
33
|
+
factory :author do
|
34
|
+
name { 'Taylor' }
|
35
|
+
end
|
36
|
+
|
37
|
+
factory :post do
|
38
|
+
title { 'Cypress on Rails is Awesome' }
|
39
|
+
author_id { create(:author).id }
|
40
|
+
end
|
41
|
+
end
|
42
|
+
```
|
43
|
+
|
44
|
+
then in Cypress
|
45
|
+
```js
|
46
|
+
// example with overriding the defaults
|
47
|
+
cy.appFactories([['create', 'author', { name: 'James' }]]).then((records) => {
|
48
|
+
cy.appFactories([['create', 'post', { title: 'Cypress is cool', author_id: records[0].id }]]
|
49
|
+
});
|
50
|
+
|
51
|
+
// example without overriding anything
|
52
|
+
cy.appFactories([['create', 'author']]).then((records) => {
|
53
|
+
cy.appFactories([['create', 'post', { author_id: records[0].id }]]
|
54
|
+
});
|
55
|
+
```
|
56
|
+
|
57
|
+
## 2. Using transient attributes
|
58
|
+
|
59
|
+
```rb
|
60
|
+
FactoryBot.define do
|
61
|
+
factory :author do
|
62
|
+
name { 'Taylor' }
|
63
|
+
end
|
64
|
+
|
65
|
+
factory :post do
|
66
|
+
transient do
|
67
|
+
author_name { 'Taylor' }
|
68
|
+
end
|
69
|
+
title { 'Cypress on Rails is Awesome' }
|
70
|
+
author { create(:author, name: author_name ) }
|
71
|
+
end
|
72
|
+
end
|
73
|
+
```
|
74
|
+
|
75
|
+
then in Cypress
|
76
|
+
```js
|
77
|
+
// example with overriding the defaults
|
78
|
+
cy.appFactories([['create', 'post', { title: 'Cypress is cool', author_name: 'James' }]]
|
79
|
+
|
80
|
+
// example without overriding
|
81
|
+
cy.appFactories([['create', 'post']]
|
82
|
+
```
|
83
|
+
|
84
|
+
## 3. Using Nested Attributes
|
85
|
+
|
86
|
+
```rb
|
87
|
+
FactoryBot.define do
|
88
|
+
factory :author do
|
89
|
+
name { 'Taylor' }
|
90
|
+
end
|
91
|
+
|
92
|
+
factory :post do
|
93
|
+
title { 'Cypress on Rails is Awesome' }
|
94
|
+
author_attributes { { name: 'Taylor' } }
|
95
|
+
end
|
96
|
+
end
|
97
|
+
```
|
98
|
+
|
99
|
+
then in Cypress
|
100
|
+
```js
|
101
|
+
// example with overriding the defaults
|
102
|
+
cy.appFactories([['create', 'post', { title: 'Cypress is cool', author_attributes: { name: 'James' } }]]
|
103
|
+
|
104
|
+
// example without overriding
|
105
|
+
cy.appFactories([['create', 'post']]
|
106
|
+
|
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' }] ]]
|
109
|
+
```
|
data/lib/cypress-on-rails.rb
CHANGED
@@ -3,5 +3,5 @@ require 'cypress_on_rails/configuration'
|
|
3
3
|
require_relative './cypress_on_rails/railtie' if defined?(Rails)
|
4
4
|
|
5
5
|
# maintain backward compatibility
|
6
|
-
CypressDev = CypressOnRails
|
7
|
-
Cypress = CypressDev
|
6
|
+
CypressDev = CypressOnRails unless defined?(CypressDev)
|
7
|
+
Cypress = CypressDev unless defined?(Cypress)
|
@@ -4,6 +4,7 @@ module CypressOnRails
|
|
4
4
|
class Configuration
|
5
5
|
attr_accessor :cypress_folder
|
6
6
|
attr_accessor :use_middleware
|
7
|
+
attr_accessor :use_vcr_middleware
|
7
8
|
attr_accessor :logger
|
8
9
|
|
9
10
|
def initialize
|
@@ -11,10 +12,12 @@ module CypressOnRails
|
|
11
12
|
end
|
12
13
|
|
13
14
|
alias :use_middleware? :use_middleware
|
15
|
+
alias :use_vcr_middleware? :use_vcr_middleware
|
14
16
|
|
15
17
|
def reset
|
16
18
|
self.cypress_folder = 'spec/cypress'
|
17
19
|
self.use_middleware = true
|
20
|
+
self.use_vcr_middleware = false
|
18
21
|
self.logger = Logger.new(STDOUT)
|
19
22
|
end
|
20
23
|
|
@@ -1,11 +1,13 @@
|
|
1
1
|
require 'json'
|
2
2
|
require 'rack'
|
3
|
-
require 'cypress_on_rails/
|
3
|
+
require 'cypress_on_rails/middleware_config'
|
4
4
|
require 'cypress_on_rails/command_executor'
|
5
5
|
|
6
6
|
module CypressOnRails
|
7
7
|
# Middleware to handle cypress commands and eval
|
8
8
|
class Middleware
|
9
|
+
include MiddlewareConfig
|
10
|
+
|
9
11
|
def initialize(app, command_executor = CommandExecutor, file = ::File)
|
10
12
|
@app = app
|
11
13
|
@command_executor = command_executor
|
@@ -23,14 +25,6 @@ module CypressOnRails
|
|
23
25
|
|
24
26
|
private
|
25
27
|
|
26
|
-
def configuration
|
27
|
-
CypressOnRails.configuration
|
28
|
-
end
|
29
|
-
|
30
|
-
def logger
|
31
|
-
configuration.logger
|
32
|
-
end
|
33
|
-
|
34
28
|
Command = Struct.new(:name, :options, :cypress_folder) do
|
35
29
|
# @return [Array<Cypress::Middleware::Command>]
|
36
30
|
def self.from_body(body, configuration)
|
@@ -65,13 +59,15 @@ module CypressOnRails
|
|
65
59
|
output = {"message" => "Cannot convert to json"}.to_json
|
66
60
|
end
|
67
61
|
|
62
|
+
logger.debug "output: #{output}"
|
68
63
|
[201, {'Content-Type' => 'application/json'}, [output]]
|
69
64
|
rescue => e
|
70
65
|
output = {"message" => e.message, "class" => e.class.to_s}.to_json
|
71
66
|
[500, {'Content-Type' => 'application/json'}, [output]]
|
72
67
|
end
|
73
68
|
else
|
74
|
-
|
69
|
+
output = {"message" => "could not find command file: #{missing_command.file_path}"}.to_json
|
70
|
+
[404, {'Content-Type' => 'application/json'}, [output]]
|
75
71
|
end
|
76
72
|
end
|
77
73
|
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'json'
|
2
|
+
require 'rack'
|
3
|
+
require 'cypress_on_rails/configuration'
|
4
|
+
|
5
|
+
module CypressOnRails
|
6
|
+
module MiddlewareConfig
|
7
|
+
protected
|
8
|
+
|
9
|
+
def configuration
|
10
|
+
CypressOnRails.configuration
|
11
|
+
end
|
12
|
+
|
13
|
+
def logger
|
14
|
+
configuration.logger
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -1,13 +1,17 @@
|
|
1
1
|
require 'rails/railtie'
|
2
2
|
require 'cypress_on_rails/configuration'
|
3
|
-
require 'cypress_on_rails/middleware'
|
4
3
|
|
5
4
|
module CypressOnRails
|
6
5
|
class Railtie < Rails::Railtie
|
7
6
|
initializer :setup_cypress_middleware, after: :load_config_initializers do |app|
|
8
7
|
if CypressOnRails.configuration.use_middleware?
|
8
|
+
require 'cypress_on_rails/middleware'
|
9
9
|
app.middleware.use Middleware
|
10
10
|
end
|
11
|
+
if CypressOnRails.configuration.use_vcr_middleware?
|
12
|
+
require 'cypress_on_rails/vcr_middleware'
|
13
|
+
app.middleware.use VCRMiddleware
|
14
|
+
end
|
11
15
|
end
|
12
16
|
end
|
13
17
|
end
|
@@ -80,6 +80,7 @@ module CypressOnRails
|
|
80
80
|
end
|
81
81
|
|
82
82
|
def reload
|
83
|
+
@latest_mtime = current_latest_mtime
|
83
84
|
logger.info 'Loading Factories'
|
84
85
|
factory.reload
|
85
86
|
files.each do |file|
|
@@ -105,14 +106,16 @@ module CypressOnRails
|
|
105
106
|
CypressOnRails.configuration.logger
|
106
107
|
end
|
107
108
|
|
109
|
+
def current_latest_mtime
|
110
|
+
files.map{|file| @file_system.mtime(file) }.max
|
111
|
+
end
|
112
|
+
|
108
113
|
def auto_reload
|
109
|
-
|
110
|
-
return unless should_reload?(current_latest_mtime)
|
111
|
-
@latest_mtime = current_latest_mtime
|
114
|
+
return unless should_reload?
|
112
115
|
reload
|
113
116
|
end
|
114
117
|
|
115
|
-
def should_reload?
|
118
|
+
def should_reload?
|
116
119
|
@always_reload || @latest_mtime.nil? || @latest_mtime < current_latest_mtime
|
117
120
|
end
|
118
121
|
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
require 'json'
|
2
|
+
require 'rack'
|
3
|
+
require 'cypress_on_rails/middleware_config'
|
4
|
+
|
5
|
+
module CypressOnRails
|
6
|
+
# Middleware to handle vcr
|
7
|
+
class VCRMiddleware
|
8
|
+
include MiddlewareConfig
|
9
|
+
|
10
|
+
def initialize(app, vcr = nil)
|
11
|
+
@app = app
|
12
|
+
@vcr = vcr
|
13
|
+
@first_call = false
|
14
|
+
end
|
15
|
+
|
16
|
+
def call(env)
|
17
|
+
request = Rack::Request.new(env)
|
18
|
+
if request.path.start_with?('/__cypress__/vcr/insert')
|
19
|
+
configuration.tagged_logged { handle_insert(request) }
|
20
|
+
elsif request.path.start_with?('/__cypress__/vcr/eject')
|
21
|
+
configuration.tagged_logged { handle_eject }
|
22
|
+
else
|
23
|
+
do_first_call unless @first_call
|
24
|
+
@app.call(env)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
def handle_insert(req)
|
31
|
+
WebMock.enable! if defined?(WebMock)
|
32
|
+
vcr.turn_on!
|
33
|
+
body = JSON.parse(req.body.read)
|
34
|
+
logger.info "vcr insert cassette: #{body}"
|
35
|
+
cassette_name = body[0]
|
36
|
+
options = (body[1] || {}).symbolize_keys
|
37
|
+
options[:record] = options[:record].to_sym if options[:record]
|
38
|
+
options[:match_requests_on] = options[:match_requests_on].map(&:to_sym) if options[:match_requests_on]
|
39
|
+
options[:serialize_with] = options[:serialize_with].to_sym if options[:serialize_with]
|
40
|
+
options[:persist_with] = options[:persist_with].to_sym if options[:persist_with]
|
41
|
+
vcr.insert_cassette(cassette_name, options)
|
42
|
+
[201, {'Content-Type' => 'application/json'}, [{'message': 'OK'}.to_json]]
|
43
|
+
rescue LoadError, ArgumentError => e
|
44
|
+
[501, {'Content-Type' => 'application/json'}, [{'message': e.message}.to_json]]
|
45
|
+
end
|
46
|
+
|
47
|
+
def handle_eject
|
48
|
+
logger.info "vcr eject cassette"
|
49
|
+
vcr.eject_cassette
|
50
|
+
do_first_call
|
51
|
+
[201, {'Content-Type' => 'application/json'}, [{'message': 'OK'}.to_json]]
|
52
|
+
rescue LoadError, ArgumentError => e
|
53
|
+
[501, {'Content-Type' => 'application/json'}, [{'message': e.message}.to_json]]
|
54
|
+
end
|
55
|
+
|
56
|
+
def vcr
|
57
|
+
return @vcr if @vcr
|
58
|
+
require 'vcr'
|
59
|
+
VCR.configure do |config|
|
60
|
+
config.cassette_library_dir = "#{configuration.cypress_folder}/fixtures/vcr_cassettes"
|
61
|
+
end
|
62
|
+
@vcr = VCR
|
63
|
+
end
|
64
|
+
|
65
|
+
def do_first_call
|
66
|
+
@first_call = true
|
67
|
+
vcr.turn_off!
|
68
|
+
WebMock.disable! if defined?(WebMock)
|
69
|
+
rescue LoadError
|
70
|
+
# nop
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
@@ -3,42 +3,36 @@ module CypressOnRails
|
|
3
3
|
class_option :cypress_folder, type: :string, default: 'cypress'
|
4
4
|
class_option :install_cypress, type: :boolean, default: true
|
5
5
|
class_option :install_cypress_with, type: :string, default: 'yarn'
|
6
|
-
class_option :
|
6
|
+
class_option :experimental, type: :boolean, default: false
|
7
7
|
source_root File.expand_path('../templates', __FILE__)
|
8
8
|
|
9
9
|
def install_cypress
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
if options.
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
command = "cd #{install_dir}; npm install cypress --save-dev"
|
20
|
-
end
|
21
|
-
if command
|
22
|
-
say command
|
23
|
-
fail 'failed to install cypress' unless system(command)
|
24
|
-
end
|
10
|
+
directories = options.cypress_folder.split('/')
|
11
|
+
directories.pop
|
12
|
+
install_dir = "#{Dir.pwd}/#{directories.join('/')}"
|
13
|
+
command = nil
|
14
|
+
if options.install_cypress
|
15
|
+
if options.install_cypress_with == 'yarn'
|
16
|
+
command = "yarn --cwd=#{install_dir} add cypress --dev"
|
17
|
+
elsif options.install_cypress_with == 'npm'
|
18
|
+
command = "cd #{install_dir}; npm install cypress --save-dev"
|
25
19
|
end
|
26
|
-
if
|
27
|
-
|
28
|
-
|
20
|
+
if command
|
21
|
+
say command
|
22
|
+
fail 'failed to install cypress' unless system(command)
|
29
23
|
end
|
30
|
-
copy_file "spec/cypress/support/index.js", "#{options.cypress_folder}/support/index.js"
|
31
|
-
copy_file "spec/cypress/support/commands.js", "#{options.cypress_folder}/support/commands.js"
|
32
|
-
copy_file "spec/cypress.json", "#{options.cypress_folder}/../cypress.json"
|
33
24
|
end
|
25
|
+
template "spec/cypress/support/index.js.erb", "#{options.cypress_folder}/support/index.js"
|
26
|
+
copy_file "spec/cypress/support/commands.js", "#{options.cypress_folder}/support/commands.js"
|
27
|
+
copy_file "spec/cypress.config.js", "#{options.cypress_folder}/../cypress.config.js"
|
34
28
|
end
|
35
29
|
|
36
30
|
def add_initial_files
|
37
31
|
template "config/initializers/cypress_on_rails.rb.erb", "config/initializers/cypress_on_rails.rb"
|
38
|
-
|
32
|
+
template "spec/cypress/cypress_helper.rb.erb", "#{options.cypress_folder}/cypress_helper.rb"
|
39
33
|
copy_file "spec/cypress/support/on-rails.js", "#{options.cypress_folder}/support/on-rails.js"
|
40
34
|
directory 'spec/cypress/app_commands', "#{options.cypress_folder}/app_commands"
|
41
|
-
directory 'spec/cypress/
|
35
|
+
directory 'spec/cypress/e2e/rails_examples', "#{options.cypress_folder}/e2e/rails_examples"
|
42
36
|
end
|
43
37
|
|
44
38
|
def update_files
|
@@ -4,6 +4,7 @@ if defined?(CypressOnRails)
|
|
4
4
|
# WARNING!! CypressOnRails can execute arbitrary ruby code
|
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
|
+
<% unless options.experimental %># <% end %> c.use_vcr_middleware = !Rails.env.production?
|
7
8
|
c.logger = Rails.logger
|
8
9
|
end
|
9
10
|
|
@@ -9,4 +9,10 @@ end
|
|
9
9
|
|
10
10
|
CypressOnRails::SmartFactoryWrapper.reload
|
11
11
|
|
12
|
+
if defined?(VCR)
|
13
|
+
VCR.eject_cassette # make sure we no cassette inserted before the next test starts
|
14
|
+
VCR.turn_off!
|
15
|
+
WebMock.disable! if defined?(WebMock)
|
16
|
+
end
|
17
|
+
|
12
18
|
Rails.logger.info "APPCLEANED" # used by log_fail.rb
|