cypress-on-rails 1.10.1 → 1.15.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 +63 -0
- data/.gitignore +5 -1
- data/CHANGELOG.md +65 -2
- data/README.md +261 -62
- data/cypress-on-rails.gemspec +1 -0
- data/docs/authentication.md +12 -10
- data/docs/factory_bot_associations.md +109 -0
- data/lib/cypress-on-rails.rb +2 -2
- data/lib/cypress_on_rails/command_executor.rb +9 -5
- data/lib/cypress_on_rails/configuration.rb +17 -2
- data/lib/cypress_on_rails/middleware.rb +15 -16
- 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 +49 -14
- 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 +48 -30
- data/lib/generators/cypress_on_rails/templates/config/initializers/cypress_on_rails.rb.erb +3 -1
- 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} +1 -1
- data/lib/generators/cypress_on_rails/templates/spec/cypress/{integration/rails_examples/other_spec.js → e2e/rails_examples/other.cy.js} +1 -1
- 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} +1 -1
- data/lib/generators/cypress_on_rails/templates/spec/cypress/{integration/rails_examples/using_fixtures_spec.js → e2e/rails_examples/using_fixtures.cy.js} +1 -1
- data/lib/generators/cypress_on_rails/templates/spec/cypress/{integration/rails_examples/using_scenarios_spec.js → e2e/rails_examples/using_scenarios.cy.js} +1 -1
- 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 +9 -7
- data/lib/generators/cypress_on_rails/templates/spec/cypress.config.js +9 -0
- data/lib/generators/cypress_on_rails/templates/spec/{cypress → e2e}/app_commands/clean.rb +8 -0
- data/lib/generators/cypress_on_rails/templates/spec/{cypress → e2e}/app_commands/log_fail.rb +2 -0
- data/lib/generators/cypress_on_rails/templates/spec/{cypress/cypress_helper.rb → e2e/e2e_helper.rb.erb} +6 -1
- data/lib/generators/cypress_on_rails/templates/spec/playwright/e2e/rails_examples/using_scenarios.spec.js +12 -0
- data/lib/generators/cypress_on_rails/templates/spec/playwright/support/index.js.erb +21 -0
- data/lib/generators/cypress_on_rails/templates/spec/playwright/support/on-rails.js +37 -0
- data/lib/generators/cypress_on_rails/templates/spec/playwright.config.js +79 -0
- data/lib/generators/cypress_on_rails/update_generator.rb +14 -3
- 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/command_executor_spec.rb +1 -1
- data/spec/cypress_on_rails/configuration_spec.rb +6 -3
- data/spec/cypress_on_rails/middleware_spec.rb +24 -22
- data/spec/cypress_on_rails/smart_factory_wrapper_spec.rb +33 -1
- data/spec/cypress_on_rails/vcr_middleware_spec.rb +119 -0
- data/specs_e2e/cypress.config.js +10 -0
- data/specs_e2e/playwright.config.js +79 -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/test.sh +17 -11
- data/{spec/integrations → specs_e2e}/rails_4_2/.gitignore +3 -2
- data/{spec/integrations → specs_e2e}/rails_4_2/Gemfile +3 -1
- data/specs_e2e/rails_4_2/app/controllers/using_vcr_controller.rb +10 -0
- data/{spec/integrations → specs_e2e}/rails_4_2/app/models/post.rb +3 -1
- 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/config/routes.rb +5 -0
- data/specs_e2e/rails_4_2/package.json +10 -0
- data/specs_e2e/rails_4_2/test.sh +44 -0
- data/{spec/integrations → specs_e2e}/rails_5_2/.gitignore +1 -1
- data/{spec/integrations → specs_e2e}/rails_5_2/Gemfile +1 -1
- 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/specs_e2e/rails_5_2/test.sh +48 -0
- metadata +190 -177
- data/.travis.yml +0 -39
- 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_4_2/test.sh +0 -38
- data/spec/integrations/rails_5_2/test.sh +0 -41
- data/spec/integrations/rails_5_2/tmp/.keep +0 -0
- data/spec/integrations/rails_5_2/vendor/.keep +0 -0
- /data/lib/generators/cypress_on_rails/templates/spec/{cypress → e2e}/app_commands/activerecord_fixtures.rb +0 -0
- /data/lib/generators/cypress_on_rails/templates/spec/{cypress → e2e}/app_commands/eval.rb +0 -0
- /data/lib/generators/cypress_on_rails/templates/spec/{cypress → e2e}/app_commands/factory_bot.rb +0 -0
- /data/lib/generators/cypress_on_rails/templates/spec/{cypress → e2e}/app_commands/scenarios/basic.rb +0 -0
- /data/spec/cypress_on_rails/command_executor/{cypress_helper.rb → e2e_helper.rb} +0 -0
- /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/tmp/.keep +0 -0
- /data/{spec/integrations → specs_e2e}/rails_3_2/vendor/.gitkeep +0 -0
- /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/{spec/integrations → specs_e2e}/rails_4_2/app/controllers/welcome_controller.rb +0 -0
- /data/{spec/integrations → specs_e2e}/rails_4_2/app/views/layouts/application.html.erb +0 -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/secrets.yml +0 -0
- /data/{spec/integrations → specs_e2e}/rails_4_2/config.ru +0 -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/rails_4_2/spec → specs_e2e/rails_4_2/vendor}/.keep +0 -0
- /data/{spec/integrations → specs_e2e}/rails_5_2/README.md +0 -0
- /data/{spec/integrations → specs_e2e}/rails_5_2/Rakefile +0 -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/rails_4_2 → specs_e2e/rails_5_2}/vendor/.keep +0 -0
- /data/{spec/integrations/rails_5_2/log/.keep → tmp/pids/.gitkeep} +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9cb0dd8412c42d59d5c687cd911a1a41819296f0fd8c8796e58365620be94897
|
4
|
+
data.tar.gz: 0baeb4e448a0f7e069f0774caadb0829f6ecd710f38ef06942674c2114cd9244
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2836bd208f1cb49b4ad0e25c2bd20cfe6b7fcaaac97fa739e7dc10516fb291b0a220a6bab3678f05329c104bf0f596fb4ec8e9fb2f2d28fade4d59299e1c7169
|
7
|
+
data.tar.gz: 783e8a833f7dd2e386b7fa0b245c1ce9c039835a1600e511148f0cb76a584819f5a1a9af88d1681bbd86a8dfefa4a43a389ea871dce18a30224791f0b6e7cd2f
|
@@ -0,0 +1,63 @@
|
|
1
|
+
name: Ruby
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches: [ master ]
|
6
|
+
pull_request:
|
7
|
+
branches: [ master ]
|
8
|
+
|
9
|
+
jobs:
|
10
|
+
rails_3_2:
|
11
|
+
runs-on: ubuntu-latest
|
12
|
+
|
13
|
+
steps:
|
14
|
+
- uses: actions/checkout@v2
|
15
|
+
- name: Set up Ruby
|
16
|
+
uses: ruby/setup-ruby@v1
|
17
|
+
with:
|
18
|
+
ruby-version: 2.3
|
19
|
+
bundler-cache: true
|
20
|
+
- name: Run tests
|
21
|
+
run: bundle exec rake
|
22
|
+
- run: gem uninstall -v '>= 2' -ax bundler || true
|
23
|
+
- run: gem install bundler -v '< 2'
|
24
|
+
- name: Run interaction tests
|
25
|
+
run: ./specs_e2e/rails_3_2/test.sh
|
26
|
+
env:
|
27
|
+
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
|
28
|
+
|
29
|
+
rails_4_2:
|
30
|
+
runs-on: ubuntu-latest
|
31
|
+
|
32
|
+
steps:
|
33
|
+
- uses: actions/checkout@v2
|
34
|
+
- name: Set up Ruby
|
35
|
+
uses: ruby/setup-ruby@v1
|
36
|
+
with:
|
37
|
+
ruby-version: 2.5
|
38
|
+
bundler-cache: true
|
39
|
+
- name: Run tests
|
40
|
+
run: bundle exec rake
|
41
|
+
- run: gem uninstall -v '>= 2' -ax bundler || true
|
42
|
+
- run: gem install bundler -v '< 2'
|
43
|
+
- name: Run interaction tests
|
44
|
+
run: ./specs_e2e/rails_4_2/test.sh
|
45
|
+
env:
|
46
|
+
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
|
47
|
+
|
48
|
+
rails_5_2:
|
49
|
+
runs-on: ubuntu-latest
|
50
|
+
|
51
|
+
steps:
|
52
|
+
- uses: actions/checkout@v2
|
53
|
+
- name: Set up Ruby
|
54
|
+
uses: ruby/setup-ruby@v1
|
55
|
+
with:
|
56
|
+
ruby-version: 2.6
|
57
|
+
bundler-cache: true
|
58
|
+
- name: Run tests
|
59
|
+
run: bundle exec rake
|
60
|
+
- name: Run interaction tests
|
61
|
+
run: ./specs_e2e/rails_5_2/test.sh
|
62
|
+
env:
|
63
|
+
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
|
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,68 @@
|
|
1
|
-
## [1.
|
2
|
-
[Compare]: https://github.com/shakacode/cypress-on-rails/compare/v1.
|
1
|
+
## [1.15.1]
|
2
|
+
[Compare]: https://github.com/shakacode/cypress-on-rails/compare/v1.15.0...v1.15.1
|
3
|
+
|
4
|
+
### Fixed
|
5
|
+
* fix cypress_folder deprecation warning by internal code [PR 136](https://github.com/shakacode/cypress-on-rails/pull/136)
|
6
|
+
|
7
|
+
## [1.15.0]
|
8
|
+
[Compare]: https://github.com/shakacode/cypress-on-rails/compare/v1.14.0...v1.15.0
|
9
|
+
|
10
|
+
### Changed
|
11
|
+
* Add support for any e2e testing framewrok starting with Playwright [PR 131](https://github.com/shakacode/cypress-on-rails/pull/131) by [KhaledEmaraDev]
|
12
|
+
|
13
|
+
## [1.14.0]
|
14
|
+
[Compare]: https://github.com/shakacode/cypress-on-rails/compare/v1.13.1...v1.14.0
|
15
|
+
|
16
|
+
### Changed
|
17
|
+
* Add support for proxy routes through `api_prefix` [PR 130](https://github.com/shakacode/cypress-on-rails/pull/130) by [RomainEndelin]
|
18
|
+
|
19
|
+
### Fixed
|
20
|
+
* Properly copies the cypress_helper file when running the update generator [PR 117](https://github.com/shakacode/cypress-on-rails/pull/117) by [alvincrespo]
|
21
|
+
|
22
|
+
### Tasks
|
23
|
+
* pass cypress record key to github action [PR 110](https://github.com/shakacode/cypress-on-rails/pull/110)
|
24
|
+
|
25
|
+
## [1.13.1]
|
26
|
+
[Compare]: https://github.com/shakacode/cypress-on-rails/compare/v1.13.0...v1.13.1
|
27
|
+
|
28
|
+
### Fixed
|
29
|
+
* use_vcr_middleware disabled by default [PR 109](https://github.com/shakacode/cypress-on-rails/pull/109)
|
30
|
+
|
31
|
+
## [1.13.0]
|
32
|
+
[Compare]: https://github.com/shakacode/cypress-on-rails/compare/v1.12.1...v1.13.0
|
33
|
+
|
34
|
+
### Changed
|
35
|
+
* Add support for matching npm package and VCR
|
36
|
+
* generate for cypress 10 [PR 108](https://github.com/shakacode/cypress-on-rails/pull/108)
|
37
|
+
|
38
|
+
## [1.12.1]
|
39
|
+
[Compare]: https://github.com/shakacode/cypress-on-rails/compare/v1.12.0...v1.12.1
|
40
|
+
|
41
|
+
### Tasks
|
42
|
+
* Documenting how to setup Factory Associations [PR 100](https://github.com/shakacode/cypress-on-rails/pull/100)
|
43
|
+
|
44
|
+
### Fixed
|
45
|
+
* keep track of factory manual reloads to prevent auto_reload from reloading again [PR 98](https://github.com/shakacode/cypress-on-rails/pull/98)
|
46
|
+
|
47
|
+
## [1.12.0]
|
48
|
+
[Compare]: https://github.com/shakacode/cypress-on-rails/compare/v1.11.0...v1.12.0
|
49
|
+
|
50
|
+
### Changed
|
51
|
+
* only reload factories on clean instead of every factory create request [PR 95](https://github.com/shakacode/cypress-on-rails/pull/95)
|
52
|
+
* alternative command added for get tail of logs [PR 89](https://github.com/shakacode/cypress-on-rails/pull/89) by [ccrockett]
|
53
|
+
|
54
|
+
### Tasks
|
55
|
+
* switch from travis to github actions [PR 96]
|
56
|
+
|
57
|
+
## [1.11.0]
|
58
|
+
[Compare]: https://github.com/shakacode/cypress-on-rails/compare/v1.10.1...v1.11.0
|
59
|
+
|
60
|
+
### Changed
|
61
|
+
* improve app command logging on cypress
|
62
|
+
* 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]
|
63
|
+
|
64
|
+
## [1.10.1]
|
65
|
+
[Compare]: https://github.com/shakacode/cypress-on-rails/compare/v1.9.1...v1.10.1
|
3
66
|
|
4
67
|
### Changed
|
5
68
|
* improve error message received from failed command
|
data/README.md
CHANGED
@@ -1,24 +1,34 @@
|
|
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)
|
5
|
+
[![Gem Version](https://badge.fury.io/rb/cypress-on-rails.svg)](https://badge.fury.io/rb/cypress-on-rails)
|
4
6
|
|
5
7
|
----
|
6
8
|
|
7
|
-
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 front-ends, often with Ruby on Rails or Gatsby.
|
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).
|
10
|
+
|
11
|
+
Interested in joining a small team that loves open source? Check our [careers page](https://www.shakacode.com/career/).
|
12
|
+
|
13
|
+
Need help with cypress-on-rails? Contact [ShakaCode](mailto:justin@shakacode.com).
|
8
14
|
|
9
15
|
----
|
10
16
|
|
11
17
|
# Totally new to Cypress?
|
12
18
|
Suggest you first learn the basics of Cypress before attempting to integrate with Ruby on Rails
|
13
19
|
|
14
|
-
* [Good start Here](https://docs.cypress.io/examples/
|
20
|
+
* [Good start Here](https://docs.cypress.io/examples/tutorials.html#Best-Practices)
|
21
|
+
|
22
|
+
# Totally new to Playwright?
|
23
|
+
Suggest you first learn the basics of Playwright before attempting to integrate with Ruby on Rails
|
24
|
+
|
25
|
+
* [Good start Here](https://playwright.dev/docs/writing-tests)
|
15
26
|
|
16
27
|
## Overview
|
17
28
|
|
18
|
-
Gem for using [cypress.io](http://github.com/cypress-io/) in Rails and
|
19
|
-
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)
|
29
|
+
Gem for using [cypress.io](http://github.com/cypress-io/) or [playwright.dev](https://playwright.dev/) in Rails and Ruby Rack applications 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)
|
20
30
|
|
21
|
-
It allows to run code in the application context when executing cypress tests.
|
31
|
+
It allows you to run code in the application context when executing cypress or playwright tests.
|
22
32
|
Do things like:
|
23
33
|
* use database_cleaner before each test
|
24
34
|
* seed the database with default data for each test
|
@@ -37,7 +47,7 @@ Has examples of setting up state with:
|
|
37
47
|
|
38
48
|
## Installation
|
39
49
|
|
40
|
-
Add this to your Gemfile
|
50
|
+
Add this to your `Gemfile`:
|
41
51
|
|
42
52
|
```ruby
|
43
53
|
group :test, :development do
|
@@ -48,11 +58,21 @@ end
|
|
48
58
|
Generate the boilerplate code using:
|
49
59
|
|
50
60
|
```shell
|
61
|
+
# by default installs only cypress
|
51
62
|
bin/rails g cypress_on_rails:install
|
52
63
|
|
53
64
|
# if you have/want a different cypress folder (default is cypress)
|
54
65
|
bin/rails g cypress_on_rails:install --cypress_folder=spec/cypress
|
55
66
|
|
67
|
+
# to install both cypress and playwright
|
68
|
+
bin/rails g cypress_on_rails:install --install_cypress --install_playwright --playwright_folder=playwright
|
69
|
+
|
70
|
+
# to change where the Ruby files reside (default is e2e)
|
71
|
+
bin/rails g cypress_on_rails:install --install_folder=test/e2e
|
72
|
+
|
73
|
+
# if you target the Rails server with a path prefix to your URL
|
74
|
+
bin/rails g cypress_on_rails:install --api_prefix=/api
|
75
|
+
|
56
76
|
# if you want to install cypress with npm
|
57
77
|
bin/rails g cypress_on_rails:install --install_cypress_with=npm
|
58
78
|
|
@@ -64,27 +84,27 @@ bin/rails g cypress_on_rails:update
|
|
64
84
|
```
|
65
85
|
|
66
86
|
The generator modifies/adds the following files/directory in your application:
|
67
|
-
* `config/
|
68
|
-
* `
|
69
|
-
* `spec/
|
70
|
-
* `spec/cypress/support/on-rails.js` contains
|
71
|
-
* `spec/
|
72
|
-
* `spec/
|
87
|
+
* `config/initializers/cypress_on_rails.rb` used to configure Cypress on Rails
|
88
|
+
* `spec/cypress/e2e/` contains your cypress tests
|
89
|
+
* `spec/playwright/e2e/` contains your playwright tests
|
90
|
+
* `spec/cypress/support/on-rails.js` contains Cypress on Rails support code
|
91
|
+
* `spec/playwright/support/on-rails.js` contains Playwright on Rails support code
|
92
|
+
* `spec/e2e/app_commands/scenarios/` contains your Cypress on Rails scenario definitions
|
93
|
+
* `spec/e2e/cypress_helper.rb` contains helper code for Cypress on Rails app commands
|
73
94
|
|
74
|
-
|
75
|
-
|
95
|
+
If you are not using `database_cleaner` look at `spec/e2e/app_commands/clean.rb`.
|
96
|
+
If you are not using `factory_bot` look at `spec/e2e/app_commands/factory_bot.rb`.
|
76
97
|
|
77
|
-
Now you can create scenarios and commands that are plain
|
98
|
+
Now you can create scenarios and commands that are plain Ruby files that get loaded through middleware, the ruby sky is your limit.
|
78
99
|
|
79
100
|
### Update your database.yml
|
80
101
|
|
81
|
-
When
|
82
|
-
make are picked up without having to restart the server.
|
83
|
-
It's
|
102
|
+
When running `cypress test` or `playwright test` on your local computer it's recommended to start your server in development mode so that changes you
|
103
|
+
make are picked up without having to restart the server.
|
104
|
+
It's recommended you update your `database.yml` to check if the `CYPRESS` environment variable is set and switch it to the test database
|
84
105
|
otherwise cypress will keep clearing your development database.
|
85
106
|
|
86
|
-
|
87
|
-
|
107
|
+
For example:
|
88
108
|
```yaml
|
89
109
|
development:
|
90
110
|
<<: *default
|
@@ -107,11 +127,15 @@ Getting started on your local environment
|
|
107
127
|
CYPRESS=1 bin/rails server -p 5017
|
108
128
|
|
109
129
|
# in separate window start cypress
|
110
|
-
yarn cypress open
|
130
|
+
yarn cypress open
|
111
131
|
# or for npm
|
112
|
-
node_modules/.bin/cypress open
|
132
|
+
node_modules/.bin/cypress open
|
113
133
|
# or if you changed the cypress folder to spec/cypress
|
114
134
|
yarn cypress open --project ./spec
|
135
|
+
# or for playwright
|
136
|
+
yarn playwright test --ui
|
137
|
+
# or using npm
|
138
|
+
npx playwright test --ui
|
115
139
|
```
|
116
140
|
|
117
141
|
How to run cypress on CI
|
@@ -122,28 +146,17 @@ How to run cypress on CI
|
|
122
146
|
|
123
147
|
yarn run cypress run
|
124
148
|
# or for npm
|
125
|
-
|
149
|
+
npx cypress run
|
126
150
|
```
|
127
151
|
|
128
152
|
### Example of using factory bot
|
129
153
|
|
130
154
|
You can run your [factory_bot](https://github.com/thoughtbot/factory_bot) directly as well
|
131
155
|
|
132
|
-
```ruby
|
133
|
-
# spec/cypress/app_commands/factory_bot.rb
|
134
|
-
require 'cypress_on_rails/smart_factory_wrapper'
|
135
|
-
|
136
|
-
CypressOnRails::SmartFactoryWrapper.configure(
|
137
|
-
always_reload: !Rails.configuration.cache_classes,
|
138
|
-
factory: FactoryBot,
|
139
|
-
files: Dir['./spec/factories/**/*.rb']
|
140
|
-
)
|
141
|
-
```
|
142
|
-
|
143
156
|
```js
|
144
|
-
// spec/cypress/
|
145
|
-
describe('My First Test',
|
146
|
-
it('visit root',
|
157
|
+
// spec/cypress/e2e/simple.cy.js
|
158
|
+
describe('My First Test', () => {
|
159
|
+
it('visit root', () => {
|
147
160
|
// This calls to the backend to prepare the application state
|
148
161
|
cy.appFactories([
|
149
162
|
['create_list', 'post', 10],
|
@@ -154,7 +167,7 @@ describe('My First Test', function() {
|
|
154
167
|
// Visit the application under test
|
155
168
|
cy.visit('/')
|
156
169
|
|
157
|
-
cy.contains(
|
170
|
+
cy.contains('Hello World')
|
158
171
|
|
159
172
|
// Accessing result
|
160
173
|
cy.appFactories([['create', 'invoice', { paid: false }]]).then((records) => {
|
@@ -163,10 +176,47 @@ describe('My First Test', function() {
|
|
163
176
|
})
|
164
177
|
})
|
165
178
|
```
|
179
|
+
You can check the [association docs](docs/factory_bot_associations.md) on more ways to setup association with the correct data.
|
180
|
+
|
181
|
+
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:
|
182
|
+
```ruby
|
183
|
+
FactoryBot.define do
|
184
|
+
factory :some_web_response, class: Hash do
|
185
|
+
initialize_with { attributes.deep_stringify_keys }
|
186
|
+
|
187
|
+
id { 123 }
|
188
|
+
name { 'Mr Blobby' }
|
189
|
+
occupation { 'Evil pink clown' }
|
190
|
+
end
|
191
|
+
end
|
192
|
+
|
193
|
+
FactoryBot.build(:some_web_response => { 'id' => 123, 'name' => 'Mr Blobby', 'occupation' => 'Evil pink clown' })
|
194
|
+
```
|
195
|
+
|
196
|
+
This can then be combined with Cypress mocks:
|
197
|
+
```js
|
198
|
+
describe('My First Test', () => {
|
199
|
+
it('visit root', () => {
|
200
|
+
// This calls to the backend to generate the mocked response
|
201
|
+
cy.appFactories([
|
202
|
+
['build', 'some_web_response', { name: 'Baby Blobby' }]
|
203
|
+
]).then(([responseBody]) => {
|
204
|
+
cy.intercept('http://some-external-url.com/endpoint', {
|
205
|
+
body: responseBody
|
206
|
+
});
|
207
|
+
|
208
|
+
// Visit the application under test
|
209
|
+
cy.visit('/')
|
210
|
+
})
|
211
|
+
|
212
|
+
cy.contains('Hello World')
|
213
|
+
})
|
214
|
+
})
|
215
|
+
```
|
166
216
|
|
167
|
-
### Example of loading
|
217
|
+
### Example of loading Rails test fixtures
|
168
218
|
```ruby
|
169
|
-
# spec/
|
219
|
+
# spec/e2e/app_commands/activerecord_fixtures.rb
|
170
220
|
require "active_record/fixtures"
|
171
221
|
|
172
222
|
fixtures_dir = ActiveRecord::Tasks::DatabaseTasks.fixtures_path
|
@@ -178,16 +228,16 @@ ActiveRecord::FixtureSet.create_fixtures(fixtures_dir, fixture_files)
|
|
178
228
|
```
|
179
229
|
|
180
230
|
```js
|
181
|
-
// spec/cypress/
|
182
|
-
describe('My First Test',
|
183
|
-
it('visit root',
|
231
|
+
// spec/cypress/e2e/simple.cy.js
|
232
|
+
describe('My First Test', () => {
|
233
|
+
it('visit root', () => {
|
184
234
|
// This calls to the backend to prepare the application state
|
185
235
|
cy.appFixtures()
|
186
236
|
|
187
237
|
// Visit the application under test
|
188
238
|
cy.visit('/')
|
189
239
|
|
190
|
-
cy.contains(
|
240
|
+
cy.contains('Hello World')
|
191
241
|
})
|
192
242
|
})
|
193
243
|
```
|
@@ -196,7 +246,7 @@ describe('My First Test', function() {
|
|
196
246
|
|
197
247
|
Scenarios are named `before` blocks that you can reference in your test.
|
198
248
|
|
199
|
-
You define a scenario in the `spec/
|
249
|
+
You define a scenario in the `spec/e2e/app_commands/scenarios` directory:
|
200
250
|
```ruby
|
201
251
|
# spec/cypress/app_commands/scenarios/basic.rb
|
202
252
|
Profile.create name: "Cypress Hill"
|
@@ -207,34 +257,34 @@ CypressOnRails::SmartFactoryWrapper.create(:profile, name: "Cypress Hill")
|
|
207
257
|
|
208
258
|
Then reference the scenario in your test:
|
209
259
|
```js
|
210
|
-
// spec/cypress/
|
211
|
-
describe('My First Test',
|
212
|
-
it('visit root',
|
260
|
+
// spec/cypress/e2e/scenario_example.cy.js
|
261
|
+
describe('My First Test', () => {
|
262
|
+
it('visit root', () => {
|
213
263
|
// This calls to the backend to prepare the application state
|
214
264
|
cy.appScenario('basic')
|
215
265
|
|
216
266
|
cy.visit('/profiles')
|
217
267
|
|
218
|
-
cy.contains(
|
268
|
+
cy.contains('Cypress Hill')
|
219
269
|
})
|
220
270
|
})
|
221
271
|
```
|
222
272
|
|
223
273
|
### Example of using app commands
|
224
274
|
|
225
|
-
|
275
|
+
Create a Ruby file in the `spec/e2e/app_commands` directory:
|
226
276
|
```ruby
|
227
|
-
# spec/
|
277
|
+
# spec/e2e/app_commands/load_seed.rb
|
228
278
|
load "#{Rails.root}/db/seeds.rb"
|
229
279
|
```
|
230
280
|
|
231
281
|
Then reference the command in your test with `cy.app('load_seed')`:
|
232
282
|
```js
|
233
|
-
// spec/cypress/
|
234
|
-
describe('My First Test',
|
283
|
+
// spec/cypress/e2e/simple.cy.js
|
284
|
+
describe('My First Test', () => {
|
235
285
|
beforeEach(() => { cy.app('load_seed') })
|
236
286
|
|
237
|
-
it('visit root',
|
287
|
+
it('visit root', () => {
|
238
288
|
cy.visit('/')
|
239
289
|
|
240
290
|
cy.contains("Seeds")
|
@@ -242,6 +292,109 @@ describe('My First Test', function() {
|
|
242
292
|
})
|
243
293
|
```
|
244
294
|
|
295
|
+
### Example of using scenario with Playwright
|
296
|
+
|
297
|
+
Scenarios are named `before` blocks that you can reference in your test.
|
298
|
+
|
299
|
+
You define a scenario in the `spec/e2e/app_commands/scenarios` directory:
|
300
|
+
```ruby
|
301
|
+
# spec/e2e/app_commands/scenarios/basic.rb
|
302
|
+
Profile.create name: "Cypress Hill"
|
303
|
+
|
304
|
+
# or if you have factory_bot enabled in your cypress_helper
|
305
|
+
CypressOnRails::SmartFactoryWrapper.create(:profile, name: "Cypress Hill")
|
306
|
+
```
|
307
|
+
|
308
|
+
Then reference the scenario in your test:
|
309
|
+
```js
|
310
|
+
// spec/playwright/e2e/scenario_example.spec.js
|
311
|
+
import { test, expect } from "@playwright/test";
|
312
|
+
import { app, appScenario } from '../../support/on-rails';
|
313
|
+
|
314
|
+
test.describe("Rails using scenarios examples", () => {
|
315
|
+
test.beforeEach(async ({ page }) => {
|
316
|
+
await app('clean');
|
317
|
+
});
|
318
|
+
|
319
|
+
test("setup basic scenario", async ({ page }) => {
|
320
|
+
await appScenario('basic');
|
321
|
+
await page.goto("/");
|
322
|
+
});
|
323
|
+
});
|
324
|
+
```
|
325
|
+
|
326
|
+
## Experimental Features (matching npm package)
|
327
|
+
|
328
|
+
Please test and give feedback.
|
329
|
+
|
330
|
+
Add the npm package:
|
331
|
+
|
332
|
+
```
|
333
|
+
yarn add cypress-on-rails --dev
|
334
|
+
```
|
335
|
+
|
336
|
+
### for VCR
|
337
|
+
|
338
|
+
This only works when you start the Rails server with a single worker and single thread
|
339
|
+
|
340
|
+
#### setup
|
341
|
+
|
342
|
+
Add your VCR configuration to your `cypress_helper.rb`
|
343
|
+
|
344
|
+
```ruby
|
345
|
+
require 'vcr'
|
346
|
+
VCR.configure do |config|
|
347
|
+
config.hook_into :webmock
|
348
|
+
end
|
349
|
+
```
|
350
|
+
|
351
|
+
Add to your `cypress/support/index.js`:
|
352
|
+
|
353
|
+
```js
|
354
|
+
import 'cypress-on-rails/support/index'
|
355
|
+
```
|
356
|
+
|
357
|
+
Add to your `cypress/app_commands/clean.rb`:
|
358
|
+
|
359
|
+
```ruby
|
360
|
+
VCR.eject_cassette # make sure we no cassettes inserted before the next test starts
|
361
|
+
VCR.turn_off!
|
362
|
+
WebMock.disable! if defined?(WebMock)
|
363
|
+
```
|
364
|
+
|
365
|
+
Add to your `config/cypress_on_rails.rb`:
|
366
|
+
|
367
|
+
```ruby
|
368
|
+
c.use_vcr_middleware = !Rails.env.production? && ENV['CYPRESS'].present?
|
369
|
+
```
|
370
|
+
|
371
|
+
#### usage
|
372
|
+
|
373
|
+
You have `vcr_insert_cassette` and `vcr_eject_cassette` available. https://www.rubydoc.info/github/vcr/vcr/VCR:insert_cassette
|
374
|
+
|
375
|
+
|
376
|
+
```js
|
377
|
+
describe('My First Test', () => {
|
378
|
+
beforeEach(() => { cy.app('load_seed') })
|
379
|
+
|
380
|
+
it('visit root', () => {
|
381
|
+
cy.app('clean') // have a look at e2e/app_commands/clean.rb
|
382
|
+
|
383
|
+
cy.vcr_insert_cassette('cats', { record: "new_episodes" })
|
384
|
+
cy.visit('/using_vcr/index')
|
385
|
+
|
386
|
+
cy.get('a').contains('Cats').click()
|
387
|
+
cy.contains('Wikipedia has a recording of a cat meowing, because why not?')
|
388
|
+
|
389
|
+
cy.vcr_eject_cassette()
|
390
|
+
|
391
|
+
cy.vcr_insert_cassette('cats')
|
392
|
+
cy.visit('/using_vcr/record_cats')
|
393
|
+
cy.contains('Wikipedia has a recording of a cat meowing, because why not?')
|
394
|
+
})
|
395
|
+
})
|
396
|
+
```
|
397
|
+
|
245
398
|
## Usage with other rack applications
|
246
399
|
|
247
400
|
Add CypressOnRails to your config.ru
|
@@ -259,30 +412,30 @@ use CypressOnRails::Middleware
|
|
259
412
|
run MyApp
|
260
413
|
```
|
261
414
|
|
262
|
-
add the following file to
|
415
|
+
add the following file to Cypress
|
263
416
|
|
264
417
|
```js
|
265
418
|
// test/cypress/support/on-rails.js
|
266
|
-
// CypressOnRails:
|
267
|
-
Cypress.Commands.add('appCommands',
|
419
|
+
// CypressOnRails: don't remove these commands
|
420
|
+
Cypress.Commands.add('appCommands', (body) => {
|
268
421
|
cy.request({
|
269
422
|
method: 'POST',
|
270
|
-
url:
|
423
|
+
url: '/__cypress__/command',
|
271
424
|
body: JSON.stringify(body),
|
272
425
|
log: true,
|
273
426
|
failOnStatusCode: true
|
274
427
|
})
|
275
428
|
});
|
276
429
|
|
277
|
-
Cypress.Commands.add('app',
|
430
|
+
Cypress.Commands.add('app', (name, command_options) => {
|
278
431
|
cy.appCommands({name: name, options: command_options})
|
279
432
|
});
|
280
433
|
|
281
|
-
Cypress.Commands.add('appScenario',
|
434
|
+
Cypress.Commands.add('appScenario', (name) => {
|
282
435
|
cy.app('scenarios/' + name)
|
283
436
|
});
|
284
437
|
|
285
|
-
Cypress.Commands.add('appFactories',
|
438
|
+
Cypress.Commands.add('appFactories', (options) => {
|
286
439
|
cy.app('factory_bot', options)
|
287
440
|
});
|
288
441
|
// CypressOnRails: end
|
@@ -293,6 +446,17 @@ beforeEach(() => {
|
|
293
446
|
});
|
294
447
|
```
|
295
448
|
|
449
|
+
## API Prefix
|
450
|
+
|
451
|
+
If your Rails server is exposed under a proxy, typically https://my-local.dev/api, you can use the `api_prefix` option.
|
452
|
+
In `config/initializers/cypress_on_rails.rb`, add this line:
|
453
|
+
```ruby
|
454
|
+
CypressOnRails.configure do |c|
|
455
|
+
# ...
|
456
|
+
c.api_prefix = '/api'
|
457
|
+
end
|
458
|
+
```
|
459
|
+
|
296
460
|
## Contributing
|
297
461
|
|
298
462
|
1. Fork it ( https://github.com/shakacode/cypress-on-rails/fork )
|
@@ -300,3 +464,38 @@ beforeEach(() => {
|
|
300
464
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
301
465
|
4. Push to the branch (`git push origin my-new-feature`)
|
302
466
|
5. Create a new Pull Request
|
467
|
+
|
468
|
+
## Supporters
|
469
|
+
|
470
|
+
<a href="https://www.jetbrains.com">
|
471
|
+
<img src="https://user-images.githubusercontent.com/4244251/184881139-42e4076b-024b-4b30-8c60-c3cd0e758c0a.png" alt="JetBrains" height="120px">
|
472
|
+
</a>
|
473
|
+
<a href="https://scoutapp.com">
|
474
|
+
<picture>
|
475
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://user-images.githubusercontent.com/4244251/184881147-0d077438-3978-40da-ace9-4f650d2efe2e.png">
|
476
|
+
<source media="(prefers-color-scheme: light)" srcset="https://user-images.githubusercontent.com/4244251/184881152-9f2d8fba-88ac-4ba6-873b-22387f8711c5.png">
|
477
|
+
<img alt="ScoutAPM" src="https://user-images.githubusercontent.com/4244251/184881152-9f2d8fba-88ac-4ba6-873b-22387f8711c5.png" height="120px">
|
478
|
+
</picture>
|
479
|
+
</a>
|
480
|
+
<br />
|
481
|
+
<a href="https://www.browserstack.com">
|
482
|
+
<picture>
|
483
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://user-images.githubusercontent.com/4244251/184881122-407dcc29-df78-4b20-a9ad-f597b56f6cdb.png">
|
484
|
+
<source media="(prefers-color-scheme: light)" srcset="https://user-images.githubusercontent.com/4244251/184881129-e1edf4b7-3ae1-4ea8-9e6d-3595cf01609e.png">
|
485
|
+
<img alt="BrowserStack" src="https://user-images.githubusercontent.com/4244251/184881129-e1edf4b7-3ae1-4ea8-9e6d-3595cf01609e.png" height="55px">
|
486
|
+
</picture>
|
487
|
+
</a>
|
488
|
+
<a href="https://railsautoscale.com">
|
489
|
+
<img src="https://user-images.githubusercontent.com/4244251/184881144-95c2c25c-9879-4069-864d-4e67d6ed39d2.png" alt="Rails Autoscale" height="55px">
|
490
|
+
</a>
|
491
|
+
<a href="https://www.honeybadger.io">
|
492
|
+
<img src="https://user-images.githubusercontent.com/4244251/184881133-79ee9c3c-8165-4852-958e-31687b9536f4.png" alt="Honeybadger" height="55px">
|
493
|
+
</a>
|
494
|
+
<a href="https://reviewable.io">
|
495
|
+
<img src="https://user-images.githubusercontent.com/20628911/230848305-c94510a4-82d7-468f-bf9f-eeb81d3f2ce0.png" alt="Reviewable" height="55px">
|
496
|
+
</a>
|
497
|
+
|
498
|
+
<br />
|
499
|
+
<br />
|
500
|
+
|
501
|
+
The following companies support our open source projects, and ShakaCode uses their products!
|
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",
|